public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Handling aliases in debug information
@ 2003-09-24 18:14 Andrew Haley
  2003-09-24 19:31 ` Elena Zannoni
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Haley @ 2003-09-24 18:14 UTC (permalink / raw)
  To: gcc; +Cc: gdb

In this program, a and b are aliases for the same variable:

int
main (int argc, char *argv[])
{
  union
  {
    int a;
    int b;
  };
  a = argc;
  return b;
}

But debugging is hard:

cuddles:~ $ g++ -v
Reading specs from /usr/local/lib/gcc/i686-pc-linux-gnu/3.4/specs
Configured with: '/local/aph/gcc/gcc/configure' '--enable-threads=posix '--enable-languages=c,c++,java : (reconfigured) 
Thread model: posix
gcc version 3.4 20030915 (experimental)
cuddles:~ $ g++ union.cc -g
cuddles:~ $ gdb ./a.out
GNU gdb 5.2.1
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...
(gdb) b main
Breakpoint 1 at 0x8048434: file union.cc, line 10.
(gdb) r
Starting program: /cuddles/aph/home/a.out 

Breakpoint 1, main (argc=1, argv=0xbfffdbc4) at union.cc:10
10        a = argc;
(gdb) n
11        return b;
(gdb) p a
No symbol "a" in current context.
(gdb) info locals
No locals.

Is this because

a.  g++ is not generating good debug info for anonymous unions?
b.  gdb is not interpreting g++ debug info correctly?
c.  Some other reason?

Thanks,
Andrew.

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

* Re: Handling aliases in debug information
  2003-09-24 18:14 Handling aliases in debug information Andrew Haley
@ 2003-09-24 19:31 ` Elena Zannoni
  0 siblings, 0 replies; 3+ messages in thread
From: Elena Zannoni @ 2003-09-24 19:31 UTC (permalink / raw)
  To: Andrew Haley; +Cc: gcc, gdb

Andrew Haley writes:
 > In this program, a and b are aliases for the same variable:
 > 
 > int
 > main (int argc, char *argv[])
 > {
 >   union
 >   {
 >     int a;
 >     int b;
 >   };
 >   a = argc;
 >   return b;
 > }
 > 
 > But debugging is hard:
 > 
 > cuddles:~ $ g++ -v
 > Reading specs from /usr/local/lib/gcc/i686-pc-linux-gnu/3.4/specs
 > Configured with: '/local/aph/gcc/gcc/configure' '--enable-threads=posix '--enable-languages=c,c++,java : (reconfigured) 
 > Thread model: posix
 > gcc version 3.4 20030915 (experimental)
 > cuddles:~ $ g++ union.cc -g
 > cuddles:~ $ gdb ./a.out
 > GNU gdb 5.2.1
 > Copyright 2002 Free Software Foundation, Inc.
 > GDB is free software, covered by the GNU General Public License, and you are
 > welcome to change it and/or distribute copies of it under certain conditions.
 > Type "show copying" to see the conditions.
 > There is absolutely no warranty for GDB.  Type "show warranty" for details.
 > This GDB was configured as "i686-pc-linux-gnu"...
 > (gdb) b main
 > Breakpoint 1 at 0x8048434: file union.cc, line 10.
 > (gdb) r
 > Starting program: /cuddles/aph/home/a.out 
 > 
 > Breakpoint 1, main (argc=1, argv=0xbfffdbc4) at union.cc:10
 > 10        a = argc;
 > (gdb) n
 > 11        return b;
 > (gdb) p a
 > No symbol "a" in current context.
 > (gdb) info locals
 > No locals.
 > 
 > Is this because
 > 
 > a.  g++ is not generating good debug info for anonymous unions?
 > b.  gdb is not interpreting g++ debug info correctly?
 > c.  Some other reason?

Hmm, I do not see this:

[ezannoni@topanga ezannoni]$ gcc -g aph.cc -o aph
[ezannoni@topanga ezannoni]$ gdb ./aph
GNU gdb Red Hat Linux (5.3.90-0.20030710.39rh)
Copyright 2003 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...Using host libthread_db library "/lib/tls/libthread_db.so.1".

(gdb) b main
Breakpoint 1 at 0x8048324: file aph.cc, line 9.
(gdb) r
Starting program: /home/ezannoni/aph 

Breakpoint 1, main (argc=1, argv=0xbfffc5b4) at aph.cc:9
9	  a = argc;
(gdb) p a
$1 = 134513528
(gdb) p b
$2 = 134513528
(gdb) info locals
a = 134513528
b = 134513528
(gdb) n
10	  return b;
(gdb) info locals
a = 1
b = 1
(gdb) 

[ezannoni@topanga ezannoni]$ gcc -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/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.2.3 20030502 (Red Hat Linux 3.2.3-20)

But I see you are using an ancient gdb. So maybe try a newer one.

elena

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

* Re: Handling aliases in debug information
@ 2003-09-24 19:53 Michael Elizabeth Chastain
  0 siblings, 0 replies; 3+ messages in thread
From: Michael Elizabeth Chastain @ 2003-09-24 19:53 UTC (permalink / raw)
  To: aph, gcc; +Cc: gdb

Both (a) and (c).

I have a current problem with anonymous unions also.
The gdb test script for anon unions has more FAILs with
g++ HEAD than g++ 3.3.1.

g++ has an issue with the variable scopes of 'main' in C++.
'main' is special because the standard explicitly allows 'main'
  to return an 'int' but not have a return statement at the end
  (which returns a success value).
So g++ has a little bit of special code.

I started pursuing this a few months ago and got sidetracked
because my test program made gcc ICE, and by the time that got
fixed, I was working on something else.

Can you separate the two issues -- have your 'main' function
call a different function with the anonymous union in it.
That would help.

The gcc people can't fix PR's if I don't file them!
After gdb 6.0 ships I will get back to debug info regressions
from gcc 3.3.1 to gcc HEAD.

Michael C
GDB QA Guy

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

end of thread, other threads:[~2003-09-24 19:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-24 18:14 Handling aliases in debug information Andrew Haley
2003-09-24 19:31 ` Elena Zannoni
2003-09-24 19:53 Michael Elizabeth Chastain

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