* Searching STL containers
@ 2005-09-22 3:38 jimparker
0 siblings, 0 replies; only message in thread
From: jimparker @ 2005-09-22 3:38 UTC (permalink / raw)
To: gdb; +Cc: gilad
I am looking for a method to examine the contents of STL containers using gdb.
and I hit upon a site hosted by Gilad Mishne
http://staff.science.uva.nl/~gilad/stl/stl_gdb.html
and found a related thread on this forum
http://sourceware.org/ml/gdb/2004-05/msg00179.html
Adapting from these two posts I generated the following definition
define plist
set $next = $arg0->_M_node._M_next
#This is stupid _prev._next... but I can't get it to find the
# end otherwise...
set $end = $arg0->_M_node._M_prev._M_next
set $listp = {&$arg0._M_node}
while ($next != $end)
# the assignment to ._M_prev is a hack that works...
# otherwise, I am one node off
set (void*)*$listp = $next._M_prev
p (*$listp)._M_data
set $next = $next->_M_next
end
end
that is a quick hack. I would appreciate if someone would explain/correct the
above pointer references to make it cleaner. But I present it as is, since it
works for my purposes, and perhaps will be useful to others. This is very
similar to the
C++ journal article mentioned, but I explicitly defined setbegin, setend,
and the pointer assignment.
Gilad,
On your site you type cast the $listp as (_List_node*) which doesn't seem to
work for me. In my STL library (g++) the typename _List_node is templated and
therefore requires the node class name and the std:: scope. i.e.
('std::_List_node<int>')
For reference, I'm using
gcc 3.3.1 -gdwarf-2
gdb 6.3.50
Cheers,
Jim
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-09-22 3:38 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-22 3:38 Searching STL containers jimparker
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).