Bug 19251 - gstabs emits wrong entry for "unsigned int/long" types on powerpc
Summary: gstabs emits wrong entry for "unsigned int/long" types on powerpc
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 3.4.3
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-debug
Depends on:
Blocks:
 
Reported: 2005-01-04 08:41 UTC by Gleb Natapov
Modified: 2012-01-11 12:45 UTC (History)
1 user (show)

See Also:
Host: i686-linux-gnu
Target: powerpc-linux-gnu
Build: i686-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gleb Natapov 2005-01-04 08:41:24 UTC
Hello,

I have problem with gcc3.x and stabs debugging format on powerpc (ppc32 603e).
gdb doesn't recognize builtin unsigned int/long formats.

I compile the following program with: powerpc-gcc -gstabs a.c
int main()
{       
        unsigned int a;
        int b;
        
        return 0;
}
and try to debug it:
> gdb a.out
(gdb) b main
Breakpoint 1 at 0x100003bc: file a.c, line 6.
(gdb) r
Starting program: a.out

Breakpoint 1, main () at a.c:6
6               return 0;
(gdb) info locals
a = <error type>
b = -1
(gdb)  q
The program is running.  Exit anyway? (y or n) y
>

After little investigation I discovered that gcc emits wrong stabs entry for
unsigned int format.
.stabs  "unsigned int:t(0,4)=r(0,4);0;4294967295;",128,0,0,0
The problem is with the max value. According to gdb source code if the value
too big for int it should be emitted in octal. Here is what gcc for intel emits
in this case by the way:
.stabs  "unsigned int:t(0,4)=r(0,4);0;-1;",128,0,0,0

After further investigation I saw that HOST_BITS_PER_WIDE_INT for powerpc is
defined to 64 and gdb rightfully things that widest int is 32 bit long on my 32
bit powerpc CPU and bails out since constant from stabs entry is to big. The
definition of HOST_BITS_PER_WIDE_INT depends on need_64bit_hwint from config.gcc
and it's set to "yes" for all powerpc CPUs there.

I've removed definition of need_64bit_hwint for powerpc and the result compiler
emits right stab entry now, but it can't compile glibc. The error is in file
glibc-2.3.2/sysdeps/unix/sysv/linux/powerpc/sys/procfs.h. It uses __uint128_t
and gcc provides it only if HOST_BITS_PER_WIDE_INT is at least 64 bits.
Comment 1 Andrew Pinski 2005-01-04 08:49:00 UTC
Hmm, what version of gdb is this, since I tried on ppc-darwin and it produces what you consided back 
stabs and it worked (this is gdb 5.3).

Also why use stabs when dwarf-2 works better and most of the time produces small debugging info 
and still provides more information?
Comment 2 Gleb Natapov 2005-01-04 09:02:34 UTC
I forgot to mension the gdb I've tried are 6.0 and 6.3.
The problem is in the stabsread.c file in function read_huge_number.

The stabs produce much smaller output for me. The result file using stabs is
23M and with dwarf-2 70M. I can debug it no my embeded system.
Comment 3 Gleb Natapov 2005-01-04 11:01:26 UTC
(In reply to comment #1)
> Hmm, what version of gdb is this, since I tried on ppc-darwin and it produces
what you consided back 
> stabs and it worked (this is gdb 5.3).
> 
gdb 5.3 doesn't work for me. Do you use vanilla gdb?
Comment 4 Richard Biener 2012-01-11 12:45:01 UTC
Seems to be about a gdb bug.