Netbeans "Resolve missing debugger command" C++ - c++

Whenever I try to debug any program (i.e. a welcome message), I get this prompt. Any ideas how to run the debugger for C++ program?
I am using Macbook Pro OS X El Capitan (10.11.3)

For Mac OSX 10.5 and above,
Install Homebrew (if you don't have it already)
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Install GDB
brew install gdb
Go to https://sourceware.org/gdb/wiki/BuildingOnDarwin and follow the instructions to code sign the gdb binary.
If you're on Sierra, run the following command in your terminal
echo "set startup-with-shell off" >> ~/.gdbinit
Finally, run the following comamnd in your terminal
which gdb
Copy the output path from that command, (mine was /usr/local/bin/gdb) into the Debugger Command box in Netbeans and start debugging!

On Linux systems derived from debian, you have to install gdb
sudo apt-get install gdb
Then in debbuger command type
/usr/bin/gdb
More information of gdb can be found in GDB: The GNU Project Debugger

Make sure gdb is installed in your machine. you can do this by following
C:\cygwin64>setup-x86_64.exe -q -P gdb
after this, select gdb as a debugger in netbeans
gdb location

Use Synaptic to install gdb. This debugger is required for Netbeans.

On a Mac, I installed HomeBrew first, then followed this exactly on the Sierra OS. Worked perfectly. After Homebrew is installed, you have to create then sign your gdb certificate. Then select it in your IDE debugger section.
The instructions show how to select gdb in Eclipse, but I got it working in NetBeans by pushing the debugger button and typing in the file path in the popup (as mentioned in this document).
https://www.ics.uci.edu/~pattis/common/handouts/macmingweclipse/allexperimental/mac-gdb-install.html

Related

C++ Why is MSYS2 MINGW UCRT x64 gdb command not found

So I tried to check Mingw-w64 tools are correctly installed and gcc, g++ were correctly installed but gdb wasn't. I'm planning to usE Visual studio code in windows 10.
In the https://code.visualstudio.com/docs/cpp/config-mingw#_run-helloworldcpp, it said to match PATH entry but when I went to C:\msys64\mingw64\bin directory, the file was empty. Did I miss something or how do I know the correct path to put in the environment variable?
I tried C:\msys64\mingw64\bin as both user variable & system variable path but it won't work. and it said command not found.
This is what it said.
$ gdb --version
bash: gdb: command not found
Try installing GDB by running this in your Bash shell:
pacman -S $MINGW_PACKAGE_PREFIX-gdb

Using GDB on qtcreator-not supporting python scripting

I try to debug a trivial helloworld cpp project with qtcreator.
When I start debugging the project, I obtain an error saying:
The selected build of GDB does not support Python scripting.
It cannot be used in Qt Creator.
My system is debian9
My QT version is 5.14.2Here is my .pro file:
QT += widgets
TEMPLATE = app
SOURCES = main.cpp
Can anyone show me how I should configure GDB with QT to avoid this error?
As #Mark Plotnik (Thank you Mark) suggested, you have a gdb-minimal installed.
Running dpkg --get-selections | grep gdb, you should have an ouput like the following:
gdb-minimal install
gdbm-l10n install
libgdbm-compat4:amd64 install
libgdbm6:amd64 install
wireless-regdb install
Only gdb-minimal, there is no gdb.
Here is what I did to solve this problem on my debian 9 system:
sudo apt install gdb
to get the full gdb.
If you rerun the command after the installation dpkg --get-selections | grep gdb, you should have :
gdb install
gdb-minimal deinstall
gdbm-l10n install
libgdbm-compat4:amd64 install
libgdbm6:amd64 install
wireless-regdb install
You should have gdb installed and gdb-minimal uninstalled.
After this, I retested debugging on qtCreator and it works now.

How to fix hang in gdb in ld-linux.so.2 when running a 32-bit executable on a 64-bit Ubuntu (18.04) system?

I'm trying to debug a 32-bit executable on a 64-bit Ubuntu system. It runs just fine by itself from the command line, but when I try to use gdb, it hangs in ld-linux.so.2. Also, gdb works for the 64-bit version of the executable. Does anyone have a clue as to what I should try?
I just re-imaged a machine to Ubuntu 18.04.3, and I installed the multilib versions of gcc and g++.
Thanks in advance.
gdb <executable>
GNU gdb ...
This GDB was configured as "x86_64-linux-gnu"
...
Reading symbols from <executable>...done.
(gdb) show archi
The target architecture is set automatically (currently i386)
(gdb) break main
Breakpoint 1 at ...
(gdb) run
Starting program...
warning: Breakpoint address adjusted from 0xf7fd9be0 to 0xfffffffff7fd9be0.
...
(7 of these)
[hangs...]
[In another terminal, ran 'kill -CONT <pid>']
Program received signal SIGCONT, Continued.
0xf7fd9be0 in ?? () from /lib/ld-linux.so.2
(gdb) cont
[hangs again...]
UPDATE: This problem has been fixed for Ubuntu in the gdb package version 8.1-0ubuntu3.2, so just upgrading your packages (sudo apt update && sudo apt upgrade) should help currently.
ORIGINAL ANSWER:
#EmployedRussian suggested in his edit to the question:
By downgrading from gdb=8.1-0ubuntu3.1 to gdb=8.1-0ubuntu3 the debugger started working again for me.
This also worked for me on Ubuntu 18.04.3. You should issue these commands:
sudo apt install gdb=8.1-0ubuntu3 # downgrade GDB to the working version
sudo apt-mark hold gdb # prevent upgrading (until the repository version is fixed)
I created a bug report for Ubuntu: https://bugs.launchpad.net/ubuntu/+source/gdb/+bug/1848200
You can click Does this bug affect you? if you have an Ubuntu account to get it fixed sooner.
Probably this gdb bug:
https://sourceware.org/bugzilla/show_bug.cgi?id=23210
Try upgrading to the current GDB version (8.3.1). If Ubuntu doesn't offer a package for that, you can try compiling it yourself.
This is now fixed in 8.1-0ubuntu3.2 in bionic-updates: https://launchpad.net/ubuntu/+source/gdb/8.1-0ubuntu3.2

Visual Studio 2017 Linux remote debugging (gdbserver)

After I installed gdbserver on my remote machine (Ubuntu 16.04.4 LTS), I tested the following c++ code by making a "cross-platform console application (linux)" project in Visual Studio 2017:
#include <cstdio>
int main()
{
printf("hello from testLinuxDebug!\n");
return 0;
}
I added the connection information (ip address, id, password) of my Ubuntu machine to connection manager and selected "gdbserver" for debugging mode.
Then I started debugging and got the following message:
Unable to start debugging. Unexpected GDB output from command
"-interpreter-exec console "target remote localhost63361"". Remote
connection closed.
Message after starting to debugging (Image captured from VS2017)
By the way, I got the following message from the Linux Console Window of debug menu of Visual Studio 2017:
Process /home/.../projects/testLinuxDebug/bin/x64/Debug/testLinuxDebug.out
created; pid = 29277 Listening on port 4444 Remote debugging from host
127.0.0.1 /build/gdb-9un5Xp/gdb-7.11.1/gdb/gdbserver/regcache.c:264: A problem > internal to GDBserver has been detected. Unknown register ymm0h requested
Message from Linux Console Window (Image captured from VS2017)
Could anybody help me with this problem?
I was having this exact same problem on my Ubuntu 16.04 machine.
I went through the source code on gdbserver, and it appears to be a problem with a processor register (ymm0h) which is only available to i386 processors.
The thing is, I don't know how to fix gdbserver to not use this register in particular, but you can solve the error by upgrading your gdb & gdbserver to version 8.3 on the Ubuntu machine. If my guess is correct, version 8.1 was the one that fixed this issue, but by default, Ubuntu 16.04 has version 7.11.1 for both gdb & gdbserver.
You can run these commands on the linux machine to do that:
wget "http://ftp.gnu.org/gnu/gdb/gdb-8.3.tar.gz"
tar xzf gdb-8.3.tar.gz
cd gdb-8.3
./configure --prefix=/usr --with-system-readline
make
sudo make install
You may need to install some extra packages in order to compile the gdb:
sudo apt-get install libreadline6-dev texinfo
If you still have problems trying to install gdb, try this example from Linux from Scratch.
Good luck!
I encountered the same problem as you, although for me the issue was on Microsoft's Visual Studio Online platform - I couldn't use pwntools' gdb.debug/gdb.attach functionality (that relies on gdbserver) due to this very same error in VSOnline's docker environment.
Leaving this answer here for people who might encounter the same issues that I have.
The issue and the steps are pretty similar to what Canella described - the root of the problem is indeed the old GDB version in the environment (7.12 at the time of writing).
I've compiled my GDB with python3 bindings, and you might want to do that too if you're planning to use GEF or similar GDB extensions.
Here's how to do that in your VSOnline environment's terminal:
# I needed to get rid of the apt-provided gdb for it to work properly
sudo apt remove gdb
# VSOnline has a weird way of handling python versions
# you're better off installing python3 from apt, if it's not installed yet
sudo apt update
sudo apt install libreadline6-dev texinfo python3 python3-dev
wget "http://ftp.gnu.org/gnu/gdb/gdb-8.3.tar.gz"
tar xzf gdb-8.3.tar.gz
cd gdb-8.3
mkdir build && cd build
../configure --prefix=/usr --with-system-readline --with-python=/usr/bin/python3
make
sudo make install

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'