From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1240 invoked by alias); 26 May 2004 17:24:43 -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 1189 invoked from network); 26 May 2004 17:24:42 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org with SMTP; 26 May 2004 17:24:42 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.10/8.12.10) with ESMTP id i4QHOgi7008689 for ; Wed, 26 May 2004 13:24:42 -0400 Received: from localhost.redhat.com (dhcp64-184.boston.redhat.com [172.16.64.184]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i4QHOf002866; Wed, 26 May 2004 13:24:41 -0400 Received: from gnu.org (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id E85532B9D; Wed, 26 May 2004 13:24:34 -0400 (EDT) Message-ID: <40B4D2D2.3000700@gnu.org> Date: Wed, 26 May 2004 17:24:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-GB; rv:1.4.1) Gecko/20040217 MIME-Version: 1.0 To: Bob Rossi , Paul Dubuc Cc: GDB Mailing List Subject: Re: Taking the address of a convenience variable value References: <40B37A92.6020106@cas.org> <20040525235958.GA30063@white> In-Reply-To: <20040525235958.GA30063@white> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2004-05/txt/msg00179.txt.bz2 > On Tue, May 25, 2004 at 12:55:46PM -0400, Paul Dubuc wrote: > >>> In the June 2004 issue of the C/C++ User's Journal (p. 24) there is an >>> article on how to write user-defined commands for gdb to examine the >>> contents of STL vectors, sets and maps. It looks extremely useful, so I >>> decided to try it modifying the commands for use with the GCC STL, but I >>> can't get some of the commands for sets and maps to work. It relies on a >>> tecnique that involves being able to take the address of a convenience >>> variable value, for example: >>> >>> set $maptype = &$arg0._M_t._M_header->_M_value_field >>> set $maptypep = &$maptype >>> >>> When I try this the 2nd statement gives me the error message >>> >>> Attempt to take address of value not located in memory. As you note, its trying to take the address of a convenience variable - since convenience variables do not live in the inferior they don't have an address. Does: set $maptype = &$arg0._M_t._M_header->_M_value_field set $maptypep = &&$arg0._M_t._M_header->_M_value_field or: set $maptype = $arg0._M_t._M_header->_M_value_field set $maptypep = &$arg0._M_t._M_header->_M_value_field make sense? The other, sigh, possability is that this was a ``feature'' and there's been a regression :-/ Andrew >>> It doesn't work with gdb 5.3 or 6.1 on Solaris. The author claims that it >>> works on HP-UX, but I don't know why it would be any different. >>> >>> Is there a way around this? Or is there another source of user-defined >>> commands that can be used to print the contents of STL containers in gdb? >>> Any help would be very much appreciated. > > > I read that article and was wondering if it was necessary to compile the > STL with -g and not with -O2. I don't think the author mentioned it, but > how else could all of the symbols in the STL work properly with GDB? What does: (gdb) paddr &$arg0._M_t._M_header->_M_value_field display?