Ever wondered why you cannot see inside vector while debugging? It is because gdb does not support STL types and thus only thing you will see is the pointers in vector container. In order to get full support from gdb, you need to do some work.
Requirements for this task are:
MinGW. I’m sure you can do it by Cygwin as well but I don’t use it so I don’t know.
Python 2.7. You can download it from here. Remember: you should download Python 2.7.x. Important: Install 32 bit python if you have basic MinGW.
- I will tell you how to do it in Eclipse but if you are using gdb only, I’m sure you know how to trigger gdb with
Now, to install Python 2.7 properly, add the following line to your PATH. Of course, if you installed Python to another location, update accordingly. If Eclipse instance is running as you change the PATH, you should restart Eclipse!
Open your MinGW shell and type
mingw-get install gdb-python
This will install python enabled gdb binaries. If you receive errors like
probable package conflict; existing file not overwritten ignore them and continue. Now try to launch
If you receive
The application was unable to start correctly (0xc000007b) error, your path didn’t really work. It needs python libraries to run. Or you installed 64 bit python and have 32 bit gdb. Easiest way is to have 32 bit python!
If you receive
libintl-8.dll not found error, then your problem is with package conflict.
- Remove gdb by typing
mingw-get remove gdb
mingw-get install --reinstall --recursive gdb-python
- Now install gdb back,
mingw-get install gdb
Hopefully, your problem should have been solved.
Then create a new document called
.gdbinit and add this to your file. Don’t forget to change your directory if your MinGW is installed to another location. Furthermore, double check the gcc version. Mine is located at
gcc-4.7.2. Yours could be a newer or older version!
python import sys sys.path.insert(0, 'c:\MinGW\share\gcc-4.8.1\python') #Change this from libstdcxx.v6.printers import register_libstdcxx_printers register_libstdcxx_printers (None) end
After that, open Eclipse. Click to debugging symbol and select debug configuration and do the following changes:
Change your GDB debugger to
gdb-python27.exe which is located in MinGW/bin directory. And choose command file to your gdbinit file that you created earlier. I experienced some problems with stopping at main. If this configuration doesn’t work for your, uncheck Stop on startup at main.