macOS 10.15 Catalina gdb problem for C++ Debugging in Eclipse - c++

I am using macOS 10.15.2 Catalina and am trying to debug a Hello World C++ program in Eclipse.
I have set up gdb debugger by installing it from Homebrew and signing the certificate by following the procedure in the below link.
https://www.thomasvitale.com/how-to-setup-gdb-and-eclipse-to-debug-c-files-on-macos-sierra/
The debugger does not get starts.
I have set gdb settings in the Eclipse as mentioned in the below screenshot.
When I debug the project, I am getting error: Configuring GDB Aborting configuring GDB (its screenshot is also provided below).

Which versions of gdb and Eclipse are you using?
I'll try to mention some aspects with which I had problems in the past.
In case you installed gdb with Homebrew, try setting the "GDB debugger" field to the actual path, something like /usr/local/Cellar/gdb/8.3/bin/gdb instead of the link /usr/local/bin/gdb.
Where is your .gdbinit file located? In the tutorial, it is located in the user home folder, so in the Eclipse debug configuration the GDB command file is set to ~/.gdbinit. The value in your screenshot doesn't specify an absolute path, it might be looking for it in the wrong place.
Is your gdb certificate part of the System Keychain (rather than the login Keychain)? During the signing have you passed the entitlements file as argument?

I faced a similar problem, and I had to do two steps to fix it. I'm not sure if they are both needed or not:
Make sure your debug configuration has an absolute path to .gdbinit. You need to have a .gdbinit file in your user folder with the following content:
set startup-with-shell off
My debug configuration in eclipse pointed to this file, but it wasn't reading it until I changed the path to be absolute.
Set up the permissions with extra entitlements like the ones from this guide: https://www.thomasvitale.com/how-to-setup-gdb-and-eclipse-to-debug-c-files-on-macos-sierra/
Create a gdb-entitlement.xml file with the following content:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
<true/>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
<key>com.apple.security.cs.disable-executable-page-protection</key>
<true/>
<key>com.apple.security.cs.debugger</key>
<true/>
<key>com.apple.security.get-task-allow</key>
<true/>
</dict>
</plist>
Then, open your Terminal prompt, go to the directory where you saved the xml file and run:
codesign --entitlements gdb-entitlement.xml -fs gdb-cert $(which gdb)
Where "gdb-cert" is the certificated you created before for code signing.
After those steps and setting the GDB path correctly on Eclipse, debugging worked again.

Related

ERROR: PC register is not available when starts debugging C/C++ programs on Visual Studio Code MinGw

I followed these instructions:
https://code.visualstudio.com/docs/cpp/config-mingw
But, when I try debugging (F5), it shows this kind of error on the bottom of the Debug Console and never starts to debug.
I searched on Google, but I can't find the solution.
The previous steps worked out.
How can I solve this problem?
Thanks.
Screenshot attached:
ERROR: PC register is not available
The MinGW tools are in my PATH:
My PATH
I tested the g++ and the gdb with --version on the console:
The MinGW tools are correctly installed and available
I share my configuration .json files:
Configuration files

Configure manifest tool options using cmake

Is it possible to configure DPI Awareness value using cmake or some script?
Create a manifest file (.manifest is important) with the following content:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<asmv3:application>
<asmv3:windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
</asmv3:windowsSettings>
</asmv3:application>
</assembly>
see https://learn.microsoft.com/en-us/windows/win32/hidpi/setting-the-default-dpi-awareness-for-a-process
Then add it to your binary target in CMake using:
target_sources(your-binary PRIVATE path-to-the-file-above.manifest)
You'll need CMake 3.4 or newer, see https://cmake.org/cmake/help/v3.4/release/3.4.html#other
There is no internal manifest support in CMake, but you can use it, there are couple of hints on this site (e.g. people using manifest e.g. because of UAC etc.).
About DPI, search other topic on SO e.g. here
I found this helpful. Applying manifest using cmake.
https://gist.github.com/bjornblissing/6fc452fe7ec1fdfe3419

Eclipse CDT cannot debug using gdb on Mac

I have a C++ project imported to Eclipse CDT. I can build and run the project using Makefile and argument settings. However, when I tried to add a debug point and run "debug as local c/c++ application", it throws me an error of "Launching projectName" has encountered a problem. Error with command gdb --version
By expanding the Details, it gives: Error with command: gdb --version
Cannot run program "gdb": Unknown reason
I installed the gdb by Macports before. If I enter command ggdb it returns the version info. If I type which ggdb, it gives /opt/local/bin/ggdb. I tried to add "PATH" to debug configuration -> environment variables and give the path value to it, but it did not work. How should I set the path and link the path please? And what should the variable name be.
The gdb version on my machine is GNU gdb (GDB) 7.7.1
Added: I looked up which ggdb and used the link James provided to change gdb debugger to browse to that path. But it did not work still.
Thanks.
It looks like Eclipse is using the default gdb that was on the system before you installed ggdb from macports. This link shows how to change the debugger settings, change it to ggdb which is the name Macport uses.
After installing ggdb from Macports you will have to sign it with a certificate so it will be allowed to control other processes, take a look at "Certifying GDB" here. After creating the certificate, make sure you select the correct name when signing:
$ codesign -s gdb-cert $(which ggdb) /// 'ggdb'

Mac C++/eclipse cannot debug: Error while launching command: gdb --version

I am using c++/eclipse kepler on mac, and I cannot debug any project. The error is "Error while launching command: gdb --version" Besides that, I can build and run my code using other libraries.
I searched a site that is similar to my problem: Debugger for C++ eclipse gives the following error. 'Launching program name' has encountered a ... Error while launching command: gdb --version
But what should I change if I am using a mac?
You can fix this by specifying the full path to gdb. You can do this separately for each debug configuration, and you can also set the default gdb location in the preferences under C/C++ > GDB. For example, if you installed gdb via Homebrew, then it's probably located under /usr/local/bin:
And here's a screenshot of the Preferences:
I still don't know why Eclipse can't find GDB even though it is on my path. I guess it doesn't use my .bash_profile or my .bashrc? You could try symlinking gdb into /usr/bin. Maybe Eclipse will look there.
Edit: I tried the symbolic link idea and now Eclipse can debug, but it crashes inexplicably while doing so! So, I guess... don't do that?
This guide from a UC Irvine Computer Science professor's page is a very well-written, detailed, and Mac-specfic description of all the steps involved in installing GDB, creating a certificate, signing GDB using that certificate, and finally configuring Eclipse. I was found this very helpful as someone unfamiliar with each of these steps.
GDB Installation on Mac OS X
I had the same problem. I solved it by:
Install a gdb - ( I used 7.8.1) - compile and install it. It got installed in usr/local/bin
Codesigning certificate
Open eclipse executable using sudo. Otherwise I still get the error.
I am on OS X.
Hope this helps.
I had this error too now, and spent more than an hour looking for it.
In my case, the path was correct, and eclipse seemed to fail to start "any" executable as debugger. (I tested with gksudo cat, but it clearly never got to effectively running it).
The final reason was that I had put in my eclipse.ini -Xms1G and -Xmx1G. It seemed to already use the full memory for the indexer, and trying to allocate some more memory to start the debugger failed with an "unkown" error. Removing the memory limitations fixed the issue.
Hope this helps someone
I had many difficulties making GDB to work on Eclipse. I tried LLDB instead and it worked like a charm:
https://wiki.eclipse.org/CDT/User/FAQ#How_do_I_get_the_LLDB_debugger.3F
This can be a more convenient alternative for Mac users.
Mac OS Sierra 10.13.6 gdb 8.0.1
had the same error as topic-starter.
first, I set the path as Neil Traft (here in the answers) explains to usr/local/bin/gdb;
But it didn't work.
I found these instructions:
https://gist.github.com/gravitylow/fb595186ce6068537a6e9da6d8b5b96d
and I discovered that I already had gdbcert1 in my System. So I followed everything from 7. Works!

Static build in Qt on Windows Vista

I am currently running Windows Vista Home Premium, and I have developed an application with my friend using Qt Creator. We are now trying to deploy our application as just one executable, so we are trying to do a static build. We have added CONFIG += static in our .pro file.
We are using this documentation to help us:
http://doc.trolltech.com/4.1/deployment-windows.html
When I try to build QT, I use this command:
configure -static -platform win32-msvc
Then I get this error:
Creating qmake...
execute: File or path is not found (nmake)
execute: File or path is not found (nmake)
Cleaning qmake failed, return code -1
I think I have to add nmake to my PATH, but I can't find it on my computer. Any help would be greatly appreciated. Thank you.
You will find a batch file under the bin directory of your visual studio install called "vcvars32.bat". Run that from the command line before you try building QT. That should solve your problems.
Open Visual Studo 20xx Command Prompt and compile Qt inside it!
For instance, on VS2008 I also need to set QMAKESPEC before trying to configure Qt:
set QMAKESPEC=<QT_DIR>\mkspecs\win32-msvc2008