From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17523 invoked by alias); 22 Sep 2005 03:38:39 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 17465 invoked by uid 22791); 22 Sep 2005 03:38:26 -0000 Received: from fb1.its.utexas.edu (HELO fb1.its.utexas.edu) (128.83.126.200) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Thu, 22 Sep 2005 03:38:26 +0000 Received: from fb1.its.utexas.edu (localhost.localdomain [127.0.0.1]) by fb1.its.utexas.edu (8.12.11/8.12.11/cc-webmail.mc-1.13) with ESMTP id j8M3cLTf023699; Wed, 21 Sep 2005 22:38:21 -0500 Received: (from www@localhost) by fb1.its.utexas.edu (8.12.11/8.12.11/Submit) id j8M3cLOi023697; Wed, 21 Sep 2005 22:38:21 -0500 Received: from nmd.hcc.dca.wayport.net (nmd.hcc.dca.wayport.net [64.134.3.58]) by webmailapp1.cc.utexas.edu (IMP) with HTTP for ; Wed, 21 Sep 2005 22:38:21 -0500 Message-ID: <1127360301.4332272d2fd9a@webmailapp1.cc.utexas.edu> Date: Thu, 22 Sep 2005 03:38:00 -0000 From: jimparker@mail.utexas.edu To: gdb@sources.redhat.com Cc: gilad@science.uva.nl Subject: Searching STL containers MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.2.2 X-SW-Source: 2005-09/txt/msg00167.txt.bz2 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') For reference, I'm using gcc 3.3.1 -gdwarf-2 gdb 6.3.50 Cheers, Jim