This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Re: Handling of structure dereferencing
- From: Andrew Cagney <ac131313 at cygnus dot com>
- To: Daniel Jacobowitz <drow at mvista dot com>
- Cc: Eli Zaretskii <eliz at is dot elta dot co dot il>, gdb at sources dot redhat dot com
- Date: Thu, 03 Jan 2002 13:55:44 +0930
- Subject: Re: Handling of structure dereferencing
- References: <20011206120739.A1490@nevyn.them.org> <7263-Thu06Dec2001214750+0200-eliz@is.elta.co.il> <20011206154348.D11234@nevyn.them.org>
> On Thu, Dec 06, 2001 at 09:47:50PM +0200, Eli Zaretskii wrote:
>
>> > Date: Thu, 6 Dec 2001 12:07:39 -0500
>> > From: Daniel Jacobowitz <drow@mvista.com>
>> >
>> > Right now, and historically, gdb has accepted things like:
>> > struct foo {char a} *b, **c, ***d;
>> >
>> > (gdb) print b.a
>> > (gdb) print d->a
b->a and b.a are probably commonly used - don't some languages even
accept both forms? As for ``d.a'', I don't have an opinion - hmm, now
that I know about it I might just start using it :-(
Do you know which code was involved? I can dig up a little bit more of
the history.
> Yes, exactly.
>
>
>> > So, straw poll: how would people feel about:
>> > - not letting this happen; only explicit dereferencing
>
>>
>> I don't mind in this specific case, but I wonder whether there isn't
>> some iceberg of which this is only a tip. We do want GDB to continue
>> to print a string when you say "p str", and str is a pointer to a
>> string, right? It's quite possible that the same machinery which
>> supports printing arrays also causes the above.
>
>
> I don't think that's the case; printing a char* does not involve
> implicit dereferencing (if it did, you'd only get the first character).
GDB certainly does pull some magic though - ``(gdb) print (char*)foo''
prints a string up to NUL. I know this cos I've a fuzzy memory of one
version of GDB breaking this behavour and the bug report triggering a
long argument over the advantages/disadvantages of such features.
Andrew