Hi guys, I have been searching the internet for a fix to my problem.
I regularly use vectors (who doesn't) and I was surprised to find that I couldn't directly view them in the debugger. Initially I wasn't too bothered and continued, using various workarounds. I also found a few scripts and homemade addons hanging around the internet which could have potentially helped, and if worst came to the worst I'd reboot and use MSVS to view the vectors, etc.
Out of all the "pretty" things you've made Code::Blocks do (all of which I really like), I'm somewhat surprised that this isn't a stock feature...
If this was a feature I could effectively abandon MSVS and Code::Blocks would cover all my needs.
Any chance this is becoming a feature, or is in the pipeline already and I've managed to not find it? I currently get the nightly builds (I did this in the hope that these would have the feature and the stable release was just lacking it..).
Any information on this would be great as I much prefer your IDE over many of the others! This is the only barrier :P
Cheers!
If you gdb is build with python enabled, you have no problem shown vectors.
See:
http://sourceware.org/gdb/wiki/STLSupport
http://forums.next.codeblocks.org/index.php/topic,11301.msg77000.html#msg77000
as references.
Okay, I probably should have mentioned I'm a Linux/Ubuntu user. I tried for a couple of hours and using my google-foo and still couldn't get it working.
I ran this:
svn co svn://gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/python
Created a file in /home called: .gdbinit
Put this in the file:
python
import sys
sys.path.insert(0, '/home/python')
from libstdcxx.v6.printers import register_libstdcxx_printers
register_libstdcxx_printers (None)
end
Still no joy :( I'm assuming that the Code::Blocks 8059 SVN nightly build and GDB 7.4-2012.04-0ubuntu2 combo is python enabled. The GDB change log seems to suggest that it is python enabled, but I just skimmed it for the word python...
Also, still waiting to find out why this isn't all standard.
More help please!
First you need the latest build, because there are some improvements to the way C::B parses the output of GDB.
Then you should disable the "Watch scripts" in the settings of the debugger.
Instead of .gdbinit you can use another file and then you can put "source path_to_file" in the initial commands of the debugger. This works 100%.
Also gcc>=4.5 include the pretty printers in their installation by default, so no additional setup is needed.
Okay, I've disabled Watch scripts.
gcc version: 4:4.6.3-1ubuntu5 | So it doesn't look like it's there by default, I'm assuming there is a tickbox that needs to be ticked.
Quoteyou can put "source path_to_file" in the initial commands of the debugger. This works 100%.
No idea what you mean by this, I looked though all the options in c::b and couldn't find where I could put this, or what "source path_to_file" should be, is it to the python scripts gained from the SVN checkout? That's what I assumed, still no luck...
Note: just thought I'd point out I'm trying to look at a vector<> of strings.
Also just updated to Code::Blocks SVN 813. Still no joy.
Any more help would be appreciated. :P
813 is not a recent revision...
And here for me it works, by only disabling the watch scripts in the options.
This is on gentoo running gcc-4.7.0, my project doesn't build with 4.6, so I can't test, but I'm sure it will work, too.
Can you paste the full log from the debugger?
Yeah! Sure:
Building to ensure sources are up-to-date
Selecting target:
Debug
Adding source dir: /host/James/Ubuntu/C-C++/ParseWords/
Adding source dir: /host/James/Ubuntu/C-C++/ParseWords/
Adding file: /host/James/Ubuntu/C-C++/ParseWords/bin/Debug/ParseWords
Changing directory to: /host/James/Ubuntu/C-C++/ParseWords/.
Starting debugger: /usr/bin/gdb -nx -fullname -quiet -args /host/James/Ubuntu/C-C++/ParseWords/bin/Debug/ParseWords
done
Setting breakpoints
Debugger name and version: GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2) 7.4-2012.04
At /host/James/Ubuntu/C-C++/ParseWords/main.cpp:220
Try again, but first enable the full logging in the options.
Quote from: oBFusCATed on July 20, 2012, 07:55:21 AM
Try again, but first enable the full logging in the options.
Opps, yeah, my bad, here's take two :P
Building to ensure sources are up-to-date
Selecting target:
Debug
Adding source dir: /host/James/Ubuntu/C-C++/ParseWords/
Adding source dir: /host/James/Ubuntu/C-C++/ParseWords/
Adding file: /host/James/Ubuntu/C-C++/ParseWords/bin/Debug/ParseWords
Changing directory to: /host/James/Ubuntu/C-C++/ParseWords/.
[debug]LD_LIBRARY_PATH=.:
[debug]Command-line: /usr/bin/gdb -nx -fullname -quiet -args /host/James/Ubuntu/C-C++/ParseWords/bin/Debug/ParseWords
[debug]Working dir : /host/James/Ubuntu/C-C++/ParseWords
Starting debugger: /usr/bin/gdb -nx -fullname -quiet -args /host/James/Ubuntu/C-C++/ParseWords/bin/Debug/ParseWords
done
[debug]> set prompt >>>>>>cb_gdb:
[debug]Skip initializing the scripting!
Setting breakpoints
[debug]Queued:[tty /dev/?]
[debug]Reading symbols from /host/James/Ubuntu/C-C++/ParseWords/bin/Debug/ParseWords...
[debug]done.
[debug](gdb) >>>>>>cb_gdb:
[debug]> show version
[debug]GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2) 7.4-2012.04
[debug]Copyright (C) 2012 Free Software Foundation, Inc.
[debug]License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
[debug]This is free software: you are free to change and redistribute it.
[debug]There is NO WARRANTY, to the extent permitted by law. Type "show copying"
[debug]and "show warranty" for details.
[debug]This GDB was configured as "x86_64-linux-gnu".
[debug]For bug reporting instructions, please see:
[debug]<http://bugs.launchpad.net/gdb-linaro/>.
[debug]>>>>>>cb_gdb:
[debug]> set confirm off
Debugger name and version: GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2) 7.4-2012.04
[debug]>>>>>>cb_gdb:
[debug]> set width 0
[debug]>>>>>>cb_gdb:
[debug]> set height 0
[debug]>>>>>>cb_gdb:
[debug]> set breakpoint pending on
[debug]>>>>>>cb_gdb:
[debug]> set print asm-demangle on
[debug]>>>>>>cb_gdb:
[debug]> set unwindonsignal on
[debug]>>>>>>cb_gdb:
[debug]> set print elements 0
[debug]>>>>>>cb_gdb:
[debug]> set disassembly-flavor intel
[debug]>>>>>>cb_gdb:
[debug]> catch throw
[debug]Function "__cxa_throw" not defined.
[debug]Catchpoint 1 (throw)
[debug]>>>>>>cb_gdb:
[debug]> directory /host/James/Ubuntu/C-C++/ParseWords/
[debug]>>>>>>cb_gdb:
[debug]> break "/host/James/Ubuntu/C-C++/ParseWords/main.cpp:220"
[debug]Breakpoint 2 at 0x401fcd: file /host/James/Ubuntu/C-C++/ParseWords/main.cpp, line 220.
[debug]>>>>>>cb_gdb:
[debug]> tty /dev/?
[debug]>>>>>>cb_gdb:
[debug]> run
[debug]/dev/?: No such file or directory.
[debug]During startup program exited with code 1.
[debug]>>>>>>cb_gdb:
I see nothing related to watches here.
Please post a log from a debug session, where a breakpoint is hit and you add a watch to a vector.
Quote from: oBFusCATed on July 20, 2012, 11:35:22 AM
I see nothing related to watches here.
Please post a log from a debug session, where a breakpoint is hit and you add a watch to a vector.
Terribly sorry, here's the stuff you were looking for:
Building to ensure sources are up-to-date
Selecting target:
Debug
Adding source dir: /host/James/Ubuntu/C-C++/ParseWords/
Adding source dir: /host/James/Ubuntu/C-C++/ParseWords/
Adding file: /host/James/Ubuntu/C-C++/ParseWords/bin/Debug/ParseWords
Changing directory to: /host/James/Ubuntu/C-C++/ParseWords/.
[debug]LD_LIBRARY_PATH=.:
[debug]Command-line: /usr/bin/gdb -nx -fullname -quiet -args /host/James/Ubuntu/C-C++/ParseWords/bin/Debug/ParseWords
[debug]Working dir : /host/James/Ubuntu/C-C++/ParseWords
Starting debugger: /usr/bin/gdb -nx -fullname -quiet -args /host/James/Ubuntu/C-C++/ParseWords/bin/Debug/ParseWords
done
[debug]> set prompt >>>>>>cb_gdb:
[debug]Skip initializing the scripting!
Setting breakpoints
[debug]Reading symbols from /host/James/Ubuntu/C-C++/ParseWords/bin/Debug/ParseWords...done.
[debug](gdb) >>>>>>cb_gdb:
[debug]> show version
[debug]GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2) 7.4-2012.04
[debug]Copyright (C) 2012 Free Software Foundation, Inc.
[debug]License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
[debug]This is free software: you are free to change and redistribute it.
[debug]There is NO WARRANTY, to the extent permitted by law. Type "show copying"
[debug]and "show warranty" for details.
[debug]This GDB was configured as "x86_64-linux-gnu".
[debug]For bug reporting instructions, please see:
[debug]<http://bugs.launchpad.net/gdb-linaro/>.
[debug]>>>>>>cb_gdb:
[debug]> set confirm off
Debugger name and version: GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2) 7.4-2012.04
[debug]>>>>>>cb_gdb:
[debug]> set width 0
[debug]>>>>>>cb_gdb:
[debug]> set height 0
[debug]>>>>>>cb_gdb:
[debug]> set breakpoint pending on
[debug]>>>>>>cb_gdb:
[debug]> set print asm-demangle on
[debug]>>>>>>cb_gdb:
[debug]> set unwindonsignal on
[debug]>>>>>>cb_gdb:
[debug]> set print elements 0
[debug]>>>>>>cb_gdb:
[debug]> set disassembly-flavor intel
[debug]>>>>>>cb_gdb:
[debug]> catch throw
[debug]Function "__cxa_throw" not defined.
[debug]Catchpoint 1 (throw)
[debug]>>>>>>cb_gdb:
[debug]> directory /host/James/Ubuntu/C-C++/ParseWords/
[debug]>>>>>>cb_gdb:
[debug]> break "/host/James/Ubuntu/C-C++/ParseWords/main.cpp:220"
[debug]Queued:[tty /dev/pts/1]
[debug]Breakpoint 2 at 0x401fcd: file /host/James/Ubuntu/C-C++/ParseWords/main.cpp, line 220.
[debug]>>>>>>cb_gdb:
[debug]> tty /dev/pts/1
[debug]>>>>>>cb_gdb:
[debug]> run
[debug]Breakpoint 2, ParseThesaurus (inFilename=..., inWordPackageArray=...) at /host/James/Ubuntu/C-C++/ParseWords/main.cpp:220
[debug]/host/James/Ubuntu/C-C++/ParseWords/main.cpp:220:5438:beg:0x401fcd
[debug]>>>>>>cb_gdb:
At /host/James/Ubuntu/C-C++/ParseWords/main.cpp:220
[debug]> whatis ParsedStringArray
[debug]type = std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >
[debug]>>>>>>cb_gdb:
[debug]> output ParsedStringArray
[debug]{<std::_Vector_base<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >> = {_M_impl = {<std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >> = {<__gnu_cxx::new_allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >> = {<No data fields>}, <No data fields>}, _M_start = 0xa3daf0, _M_finish = 0xa55af0, _M_end_of_storage = 0xa5daf0}}, <No data fields>}>>>>>>cb_gdb:
Quote from: PureBlackSin on July 20, 2012, 12:33:19 PM
Building to ensure sources are up-to-date
...
At /host/James/Ubuntu/C-C++/ParseWords/main.cpp:220
[debug]> whatis ParsedStringArray
[debug]type = std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >
[debug]>>>>>>cb_gdb:
[debug]> output ParsedStringArray
[debug]{<std::_Vector_base<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >> = {_M_impl = {<std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >> = {<__gnu_cxx::new_allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >> = {<No data fields>}, <No data fields>}, _M_start = 0xa3daf0, _M_finish = 0xa55af0, _M_end_of_storage = 0xa5daf0}}, <No data fields>}>>>>>>cb_gdb:
From the above log message, I believe that either you use a gdb which does
not have python enabled or you stl pretty printer does
not load correctly.
Another thing you could try is to stop on a breakpoint and then to execute the following command:
info pretty-printer
This will list all available printers.
If the list is empty, the printers have not been installed correctly.
If the command is not supported your gdb doesn't support python.
Building to ensure sources are up-to-date
Selecting target:
Debug
Adding source dir: /host/James/Ubuntu/C-C++/ParseWords/
Adding source dir: /host/James/Ubuntu/C-C++/ParseWords/
Adding file: /host/James/Ubuntu/C-C++/ParseWords/bin/Debug/ParseWords
Changing directory to: /host/James/Ubuntu/C-C++/ParseWords/.
[debug]LD_LIBRARY_PATH=.:
[debug]Command-line: /usr/bin/gdb -nx -fullname -quiet -args /host/James/Ubuntu/C-C++/ParseWords/bin/Debug/ParseWords
[debug]Working dir : /host/James/Ubuntu/C-C++/ParseWords
Starting debugger: /usr/bin/gdb -nx -fullname -quiet -args /host/James/Ubuntu/C-C++/ParseWords/bin/Debug/ParseWords
done
[debug]> set prompt >>>>>>cb_gdb:
[debug]Skip initializing the scripting!
Setting breakpoints
[debug]Reading symbols from /host/James/Ubuntu/C-C++/ParseWords/bin/Debug/ParseWords...done.
[debug](gdb) >>>>>>cb_gdb:
[debug]> show version
[debug]GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2) 7.4-2012.04
[debug]Copyright (C) 2012 Free Software Foundation, Inc.
[debug]License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
[debug]This is free software: you are free to change and redistribute it.
[debug]There is NO WARRANTY, to the extent permitted by law. Type "show copying"
[debug]and "show warranty" for details.
[debug]This GDB was configured as "x86_64-linux-gnu".
[debug]For bug reporting instructions, please see:
[debug]<http://bugs.launchpad.net/gdb-linaro/>.
[debug]>>>>>>cb_gdb:
[debug]> set confirm off
Debugger name and version: GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2) 7.4-2012.04
[debug]>>>>>>cb_gdb:
[debug]> set width 0
[debug]>>>>>>cb_gdb:
[debug]> set height 0
[debug]>>>>>>cb_gdb:
[debug]> set breakpoint pending on
[debug]>>>>>>cb_gdb:
[debug]> set print asm-demangle on
[debug]>>>>>>cb_gdb:
[debug]> set unwindonsignal on
[debug]>>>>>>cb_gdb:
[debug]> set print elements 0
[debug]>>>>>>cb_gdb:
[debug]> set disassembly-flavor intel
[debug]>>>>>>cb_gdb:
[debug]> catch throw
[debug]Function "__cxa_throw" not defined.
[debug]Catchpoint 1 (throw)
[debug]>>>>>>cb_gdb:
[debug]> directory /host/James/Ubuntu/C-C++/ParseWords/
[debug]>>>>>>cb_gdb:
[debug]> break "/host/James/Ubuntu/C-C++/ParseWords/main.cpp:220"
[debug]Breakpoint 2 at 0x401fcd: file /host/James/Ubuntu/C-C++/ParseWords/main.cpp, line 220.
[debug]>>>>>>cb_gdb:
[debug]> tty /dev/pts/1
[debug]Queued:[tty /dev/pts/1]
[debug]>>>>>>cb_gdb:
[debug]> run
[debug]Breakpoint 2, ParseThesaurus (inFilename=..., inWordPackageArray=...) at /host/James/Ubuntu/C-C++/ParseWords/main.cpp:220
[debug]/host/James/Ubuntu/C-C++/ParseWords/main.cpp:220:5418:beg:0x401fcd
[debug]>>>>>>cb_gdb:
At /host/James/Ubuntu/C-C++/ParseWords/main.cpp:220
[debug]> whatis ParsedStringArray
[debug]type = std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >
[debug]>>>>>>cb_gdb:
[debug]> output ParsedStringArray
[debug]{<std::_Vector_base<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >> = {_M_impl = {<std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >> = {<__gnu_cxx::new_allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >> = {<No data fields>}, <No data fields>}, _M_start = 0xa3daf0, _M_finish = 0xa55af0, _M_end_of_storage = 0xa5daf0}}, <No data fields>}>>>>>>cb_gdb:
> info pretty-printer
[debug]> info pretty-printer
[debug]>>>>>>cb_gdb:
Looks like they are not installed properly...... I'll have a crack and report back, I still can't work out why all this isn't default in the setup...
For me it works by default (gentoo+gcc-4.7+gdb-7.4)
Okay, I'm really struggling to get these scripts to be found and run by gdb. I really have tried to follow the instructions. Can someone give me an idiots guide to getting this set up. Commands to type, config files to make and menu settings to select. I've honestly tried and need help... Can someone give me a step by step here?
Quote from: PureBlackSin on July 21, 2012, 12:56:21 AM
Okay, I'm really struggling to get these scripts to be found and run by gdb. I really have tried to follow the instructions. Can someone give me an idiots guide to getting this set up. Commands to type, config files to make and menu settings to select. I've honestly tried and need help... Can someone give me a step by step here?
I re-read the log message here:
http://forums.next.codeblocks.org/index.php/topic,16607.msg112768.html#msg112768
It seems that I can see any command to load the pretty printer for std c++.
You need to add a command: (There is an option in Codeblocks' debugger setting dialog)
source /path/to/some.gdb
Note:
The file "/path/to/some.gdb" should contains the script mentioned here:
http://sourceware.org/gdb/wiki/STLSupport
ollydbg: this is not needed, becase gdb supports auto loading them...
pureblacksin: try this command in a terminal
$ ldd /usr/bin/gdb | grep pyt
It will tell you if gdb is compiled with python support, if the output is empty, then you have no luck.
But I'm pretty sure it will be non-empty.
Also you can search for the printer files, they are python scripts.
See what do I have on my system:
/usr/share/gcc-data/x86_64-pc-linux-gnu/4.7.0/python/libstdcxx/__init__.py
/usr/share/gcc-data/x86_64-pc-linux-gnu/4.7.0/python/libstdcxx/v6/__init__.py
/usr/share/gcc-data/x86_64-pc-linux-gnu/4.7.0/python/libstdcxx/v6/printers.py
/usr/share/gdb/auto-load/usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.0/32/libstdc++.so.6.0.17-gdb.py
/usr/share/gdb/auto-load/usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.0/libstdc++.so.6.0.17-gdb.py
I have these for all three supported compiles I have (4.5, 4.6 and 4.7).
Right first bit had an output of:
james@ubuntu:~/python$ ldd /usr/bin/gdb | grep pyt
libpython2.7.so.1.0 => /usr/lib/libpython2.7.so.1.0 (0x00007fd03bcfc000)
I have the first three files in a couple of folders which I downloaded, they are not in those directories, I don't have those directories.
The last two, the closest I can get to that path is:
/usr/share/gdb/gdb/auto-load
This directory terminates, has two .gdb files in it neither of which look like yours.
I tried to run make in the checked out folder where the first three files were, make didn't work. I did this to see if it would generate any files...
Then you should manually download the stl python printer files and to put the loading code in the .gdbinit or another file which you have to source in the initial commands.
Quote from: oBFusCATed on July 22, 2012, 11:03:01 AM
Then you should manually download the stl python printer files and to put the loading code in the .gdbinit or another file which you have to source in the initial commands.
Right, I have re-done that. I now have the python files checked out to the home directory, in the home directory I made a file called .gdbinit like I was told and have pointed the file at the python folder, i.e. the one that was checked out.
Now how to I tell the debugger to read the .gdbinit from the home directory... This could be the bit that is going wrong. Also, what file is the .gdbinit file looking for? I might need to let it look deeper into the python, checked out folder.
Try to put "source ~/.gdbinit" in the initial commands in the settings.
C::B uses the -nx command line flag to tell gdb to not read the ~/.gdbinit file by default.
Quote from: oBFusCATed on July 22, 2012, 05:57:55 PM
Try to put "source ~/.gdbinit" in the initial commands in the settings.
C::B uses the -nx command line flag to tell gdb to not read the ~/.gdbinit file by default.
Right, well I got it in:
Starting debugger: /usr/bin/gdb -nx -fullname -quiet source ~/.gdbinit -args /host/James/Ubuntu/C-C++/ParseWords/bin/Debug/ParseWords
donehowever -nx is still there, and still no joy, although this looks like an improvement :)
Put the source command in the initial commands field, not the args field...
If it doesn't work, put the initialization code in another file and source it.
You have to see "source my_file.source" command in the log, not in the gdb command line.
Perfect! Yep, sorted Cheers, you've just made my day!!!