public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: jimparker@mail.utexas.edu
To: gdb@sources.redhat.com
Cc: gilad@science.uva.nl
Subject: Searching STL containers
Date: Thu, 22 Sep 2005 03:38:00 -0000	[thread overview]
Message-ID: <1127360301.4332272d2fd9a@webmailapp1.cc.utexas.edu> (raw)

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




                 reply	other threads:[~2005-09-22  3:38 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1127360301.4332272d2fd9a@webmailapp1.cc.utexas.edu \
    --to=jimparker@mail.utexas.edu \
    --cc=gdb@sources.redhat.com \
    --cc=gilad@science.uva.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).