This is the mail archive of the
mailing list for the libstdc++ project.
Re: Printing STL List Entries in GDB
Although I'd like to take credit for this idea, it isn't really my
ambitious idea. Many people have already done this. Gilad Mishne
created a set of commands to print out STL container structures (for SGI
version of STL) in GDB
And Ravi Menon created print commands for some of the GNU-STL structures
(http://gcc.gnu.org/ml/libstdc++/2006-08/msg00009.html). He didn't make
commands for the list data structure though.
I'd like to make one for lists, but I don't know how the list data
members are named. I suppose I could go into the source code and find
out, but does anybody have this information handy?
Benjamin Kosnik wrote:
I tried using single quotes as well, but it still won't print the
value: p (('std::_List_node' *) $curNode)->_M_data
No symbol "std::_List_node" in current context.
Your planned usage of gdb is pretty ambitious. As far as I can tell,
it's never supported such sophistication. Any non-trivial scoping seems
If you are debugging on linux, you might try compiling with the flags
Do I need to the type of list entries I'm trying to print? I'm
trying to create a user-defined command in gdb for printing stl lists
so I'd rather keep the command general so that I could reuse this
command for any other lists I might want to print.
In a perfect world, some theoretical future gdb would allow you to use
std::list's own member functions for access.