This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: -g1 is broken
On Thu, Feb 14, 2002 at 03:03:52PM -0800, Richard Henderson wrote:
> On Wed, Feb 13, 2002 at 04:51:26PM -0800, H . J . Lu wrote:
> > When I tried to debug libgcc_so.so, which is compiled with -g1, I
> > couldn't get anything debug info on Linux/x86 with DWARF2. On Linux/mips
> > with stabs, the function line numbers are all wrong.
>
> Err, -g1 doesn't emit line numbers.
That is true for gcc 2.96.
>
> What were you expecting, exactly?
>
>
# /usr/gcc-3.1/bin/gcc -g1 -gstabs+ -S unwind-dw2-fde-glibc.c -O2
I got
.stabs "_Unwind_Find_FDE:F(1,1)=*(1,2)=(1,2)",36,0,23,_Unwind_Find_FDE
.stabs "pc:p(1,1)",160,0,22,8
.globl _Unwind_Find_FDE
.type _Unwind_Find_FDE,@function
_Unwind_Find_FDE:
.stabn 68,0,16,.LM6-_Unwind_Find_FDE
^^^
.LM6:
The number 16 is bogus.
# /usr/gcc-3.1/bin/gcc -gstabs+ -S unwind-dw2-fde-glibc.c -O2
gave me
.stabs "_Unwind_Find_FDE:F(1,1)=*(1,2)=(1,2)",36,0,23,_Unwind_Find_FDE
.stabs "pc:p(1,1)",160,0,22,8
.globl _Unwind_Find_FDE
.type _Unwind_Find_FDE,@function
_Unwind_Find_FDE:
.stabn 68,0,23,.LM10-_Unwind_Find_FDE
^^
.LM10:
Line 23 is correct.
As for DWARF-2, it is even worse:
(gdb) set env LD_LIBRARY_PATH .:../i686-pc-linux-gnu/libstdc++-v3/src/.libs/
(gdb) r
Starting program: /export/build/gnu/gcc/build-i686-linux/gcc/a.out
Program exited with code 0143.
Current language: auto; currently c
(gdb) b main
Breakpoint 1 at 0x80486a0: file /home/hjl/tmp/foo.cc, line 4.
(gdb) r
Starting program: /export/build/gnu/gcc/build-i686-linux/gcc/a.out
Breakpoint 1, main () at /home/hjl/tmp/foo.cc:4
4 int n = 0;
Current language: auto; currently c++
(gdb) b _Unwind_Find_FDE
Breakpoint 2 at 0x400ffe96
(gdb) c
Continuing.
Breakpoint 2, 0x400ffe96 in _Unwind_Find_FDE () from ./libgcc_s.so.1
Current language: auto; currently c
(gdb) bt
#0 0x400ffe96 in _Unwind_Find_FDE () from ./libgcc_s.so.1
#1 0x400fdc15 in uw_frame_state_for () from ./libgcc_s.so.1
#2 0x400fe180 in uw_init_context_1 () from ./libgcc_s.so.1
#3 0x400fe3f8 in _Unwind_RaiseException () from ./libgcc_s.so.1
#4 0x400a57b9 in __cxa_throw (obj=0x804a908, tinfo=0xbffff664,
dest=0xbffff664)
at
/home/hjl/work/gnu/src/gcc-mips/gcc/libstdc++-v3/libsupc++/eh_throw.cc:72
#5 0x080486d1 in main () at /home/hjl/tmp/foo.cc:8
#6 0x4011b3e7 in __libc_start_main (main=0x8048690 <main>, argc=1,
ubp_av=0xbffff754, init=0x8048530 <_init>, fini=0x8048740 <_fini>,
rtld_fini=0x4000d5f4 <_dl_fini>, stack_end=0xbffff74c)
at ../sysdeps/generic/libc-start.c:129
I didn't even get function prototype.
H.J.
--unwind-dw2-fde-glibc.c---
static unsigned int
size_of_encoded_value (unsigned char encoding)
{
if (encoding == 0xff)
return 0;
switch (encoding & 0x07)
{
case 0x00:
return sizeof (void *);
case 0x02:
return 2;
case 0x03:
return 4;
case 0x04:
return 8;
}
abort ();
}
void *
_Unwind_Find_FDE (void *pc)
{
return 0;
}