Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Paul Dubuc <pdubuc@cas.org>
To: Daniel Jacobowitz <drow@false.org>
Cc: Andrew Cagney <cagney@gnu.org>, Bob Rossi <bob@brasko.net>,
	GDB Mailing List <gdb@sources.redhat.com>
Subject: Re: Taking the address of a convenience variable value
Date: Wed, 26 May 2004 18:11:00 -0000	[thread overview]
Message-ID: <40B4DD9B.30701@cas.org> (raw)
In-Reply-To: <20040526173100.GA18211@nevyn.them.org>



Daniel Jacobowitz wrote:
> On Wed, May 26, 2004 at 01:24:34PM -0400, Andrew Cagney wrote:
> 
>>>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 :-/
> 
> 
> Or that it never worked in the FSF tree at all.  There's a reference
> below to HP-UX - could this be HP's hacked GDB sources?
> 
> 
>>What does:
>>
>>  (gdb) paddr &$arg0._M_t._M_header->_M_value_field
>>
>>display?
> 
> 
> I don't think GDB has a paddr command?
> 

Herman Pijl, the author of the article, passed this on to me from someone who 
e-mailed him about the same problem.  This works:

set $maptype = &$arg0._M_t._M_header->_M_value_field
set $maptypep = {&$arg0._M_t._M_header->_M_value_field}

I don't know why.

-- 
Paul M. Dubuc


      reply	other threads:[~2004-05-26 18:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-25 16:55 Paul Dubuc
2004-05-26  0:00 ` Bob Rossi
2004-05-26 17:24   ` Andrew Cagney
2004-05-26 17:31     ` Daniel Jacobowitz
2004-05-26 18:11       ` Paul Dubuc [this message]

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=40B4DD9B.30701@cas.org \
    --to=pdubuc@cas.org \
    --cc=bob@brasko.net \
    --cc=cagney@gnu.org \
    --cc=drow@false.org \
    --cc=gdb@sources.redhat.com \
    /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