public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Struct fields printed in a strange way
@ 2004-11-24 17:47 Grumble
  2004-11-24 17:53 ` Ramana Radhakrishnan
  0 siblings, 1 reply; 4+ messages in thread
From: Grumble @ 2004-11-24 17:47 UTC (permalink / raw)
  To: gdb

Hello all,

[ Apologies: I forgot to set the Reply-To field the first time.
Please re-send your reply if it was lost inside the bit bucket. ]

gdb seems slightly confused when the name of a struct field is
suffixed with "__0".

$ cat foo.c
struct foo { double x__0, y__0, z__1; } bar;

int main(void) { return 0; }

$ gcc-3.3.2 -Wall -ansi -pedantic -g3 foo.c

$ gdb a.out
GNU gdb 6.0-2mdk (Mandrake Linux)
Copyright 2003 Free Software Foundation, Inc.
[...]
This GDB was configured as "i586-mandrake-linux-gnu"...Using host
libthread_db library "/lib/tls/libthread_db.so.1".

(gdb) print bar
$1 = {::x(void) = 0, ::y(void) = 0, z__1 = 0}

(gdb) show language
The current source language is "auto; currently c".

Why is x__0 changed to ::x(void)? Is the "__0" suffix reserved in gdb?

-- 
Regards, Grumble

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Struct fields printed in a strange way
  2004-11-24 17:47 Struct fields printed in a strange way Grumble
@ 2004-11-24 17:53 ` Ramana Radhakrishnan
  2004-11-26 17:26   ` Dave Korn
  0 siblings, 1 reply; 4+ messages in thread
From: Ramana Radhakrishnan @ 2004-11-24 17:53 UTC (permalink / raw)
  To: devnull; +Cc: gdb


Hi,

> Hello all,
>
> [ Apologies: I forgot to set the Reply-To field the first time.
> Please re-send your reply if it was lost inside the bit bucket. ]
Its still lost ! :-)

>
> gdb seems slightly confused when the name of a struct field is
> suffixed with "__0".
>
> $ cat foo.c
> struct foo { double x__0, y__0, z__1; } bar;
>
> int main(void) { return 0; }
>
> $ gcc-3.3.2 -Wall -ansi -pedantic -g3 foo.c

I was able to repeat this with

[ramana@numenor gdb]$ gcc -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.3.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit
--host=i386-redhat-linux
Thread model: posix
gcc version 3.3.2 20031022 (Red Hat Linux 3.3.2-1)

and


GNU gdb 6.3.50_2004-11-23-cvs

>
> $ gdb a.out
> GNU gdb 6.0-2mdk (Mandrake Linux)
> Copyright 2003 Free Software Foundation, Inc.
> [...]
> This GDB was configured as "i586-mandrake-linux-gnu"...Using host
> libthread_db library "/lib/tls/libthread_db.so.1".
>
> (gdb) print bar
> $1 = {::x(void) = 0, ::y(void) = 0, z__1 = 0}
>
> (gdb) show language
> The current source language is "auto; currently c".
>
> Why is x__0 changed to ::x(void)? Is the "__0" suffix reserved in gdb?


This appears to be due to the way in which the structs are handled in
c-valprint.c . The demangler gets called here because the function
c_val_print prints the structure fields using the printer from the c++
language implementation. Should there not be a C equivalent for this ?
This btw is from yesterday's CVS sources.



cheers
Ramana





>
> --
> Regards, Grumble
>


----
Ramana Radhakrishnan
GNU Tools.
Codito Technologies

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: Struct fields printed in a strange way
  2004-11-24 17:53 ` Ramana Radhakrishnan
@ 2004-11-26 17:26   ` Dave Korn
  0 siblings, 0 replies; 4+ messages in thread
From: Dave Korn @ 2004-11-26 17:26 UTC (permalink / raw)
  To: ramana.radhakrishnan, devnull; +Cc: gdb

> -----Original Message-----
> From: gdb-owner On Behalf Of Ramana Radhakrishnan
> Sent: 24 November 2004 18:05

> > gdb seems slightly confused when the name of a struct field is
> > suffixed with "__0".
> >
> > $ cat foo.c
> > struct foo { double x__0, y__0, z__1; } bar;
> >
> > int main(void) { return 0; }
> >
> > $ gcc-3.3.2 -Wall -ansi -pedantic -g3 foo.c
> 
> I was able to repeat this with
> 
> [ramana@numenor gdb]$ gcc -v

> gcc version 3.3.2 20031022 (Red Hat Linux 3.3.2-1)
> 
> and
> 
> 
> GNU gdb 6.3.50_2004-11-23-cvs


  Also confirmed on cygwin with "gcc (GCC) 3.3.3 (cygwin special)" and 
"GNU gdb 2003-09-20-cvs (cygwin-special)"

  So it's a fairly longstanding bug.

> > (gdb) show language
> > The current source language is "auto; currently c".
> >
> > Why is x__0 changed to ::x(void)? Is the "__0" suffix 
> reserved in gdb?
> 
> 
> This appears to be due to the way in which the structs are handled in
> c-valprint.c . The demangler gets called here because the function
> c_val_print prints the structure fields using the printer from the c++
> language implementation. Should there not be a C equivalent for this ?
> This btw is from yesterday's CVS sources.

  That's definitely bad logic.  I had noticed that even if you explicitly
say "set lang c", it _still_ tries to demangle the name.  Anyone going to
file a bugzilla then?

    cheers, 
      DaveK
-- 
Can't think of a witty .sigline today....

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Struct fields printed in a strange way
@ 2004-11-18 21:22 Grumble
  0 siblings, 0 replies; 4+ messages in thread
From: Grumble @ 2004-11-18 21:22 UTC (permalink / raw)
  To: gdb

Hello all,

gdb seems slightly confused when the name of a struct field is
suffixed with "__0".

$ cat foo.c
struct foo { double x__0, y__0, z__1; } bar;

int main(void)
{
   return 0;
}

$ gcc-3.3.2 -Wall -ansi -pedantic -g3 foo.c

$ gdb a.out
GNU gdb 6.0-2mdk (Mandrake Linux)
Copyright 2003 Free Software Foundation, Inc.
[...]
This GDB was configured as "i586-mandrake-linux-gnu"...Using host 
libthread_db library "/lib/tls/libthread_db.so.1".

(gdb) print bar
$1 = {::x(void) = 0, ::y(void) = 0, z__1 = 0}

(gdb) show language
The current source language is "auto; currently c".

Why is x__0 changed to ::x(void)? Is the "__0" suffix reserved in gdb?

-- 
Regards, Grumble

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-11-24 18:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-24 17:47 Struct fields printed in a strange way Grumble
2004-11-24 17:53 ` Ramana Radhakrishnan
2004-11-26 17:26   ` Dave Korn
  -- strict thread matches above, loose matches on Subject: below --
2004-11-18 21:22 Grumble

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).