tags:

views:

275

answers:

1

I have been using the macro solution, as it is outlined here. However, there is a mention on how to view them without macros. I am referring to GDB version 7 and above.

Would someone illustrate how?

Thanks

+4  A: 

Get the python viewers from SVN

svn://gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/python

Add them to your .gdbinit file in ~

(0)mcbeth@williwaw:~/Source/Printers$ cat ~/.gdbinit
python
import sys
sys.path.insert(0, '/home/mcbeth/Source/Printers')
from libstdcxx.v6.printers import register_libstdcxx_printers
register_libstdcxx_printers (None)
end
McBeth
And how to actually use it in GDB to print the contents? Is anything need to be set. thx
vehomzzz
Once that load code is in .gdbinit, then print should just work, to get back to the old view, you do a print /r (/r is for raw)(formatting apparently sucks in comments, my apologies) std::map<int, std::string> the_map; the_map[23] = "hello"; the_map[1024] = "world";(gdb) print the_map$1 = std::map with 2 elements = { [23] = "hello", [1024] = "world"}
McBeth
Consider editing your answer to include this information in your comment. That way the formatting wont suck.
camh
@McBeth, please put this code sample in the answer. I can't read it in the comments.
Nathan Fellman