Article View: gnu.gdb.bug
Article #10162in GDB 3.5 on a sparc
From: Jay Chalmers
Date: Mon, 02 Apr 1990 07:33
Date: Mon, 02 Apr 1990 07:33
262 lines
9180 bytes
9180 bytes
I was looking at what gcc did when inlining some simple routines,
and I ran across an error in how gdb disassembles things. I believe the
culprit is the sort order of the opcode table. Any how, in collecting
the documentation, I found several such errors, that are located at
the relative offsets 24, 28, 44, 76, 84, 108, 120, 144, 192, 200, 252,
and 272 in the gdb listing.
Enclosed is a shar containing three files: my source program, the
adb disassembly, and the gdb disassembly.
While I am writing, I would like to thank you for the nice software
that you are producing, especially gcc and g++. I would like to make
a pitch for the use of #pragma. All of the -f... compiler flags,
you know the ones that make things go faster?, they tend to just
sit in some makefile somewhere, while the pieces of code they are
used on get incorporated into various other programs. I suggest that
most of the compiler flags be available from within the program text.
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create:
# grayinv.c
# adb.list
# gdb.list
# This archive created: Mon Apr 2 02:30:16 1990
export PATH; PATH=/bin:/usr/bin:$PATH
if test -f 'grayinv.c'
then
echo shar: "will not over-write existing file 'grayinv.c'"
else
cat << \SHAR_EOF > 'grayinv.c'
__inline__ int
grayinv (const int gray) {
register int i = 0;
register int g = gray;
do i ^= g;
while (g >>= 1);
return (i);
}
int inhex;
char line[18];
main (int an, char *av[]) {
if (an > 1 && *av[1] == '-') {
if (av[1][1] == 'x' || av[1][1] == 'X') inhex++;
}
while (--an) {
register int i, g = atoi (*++av);
i = grayinv (g);
if (inhex) printf ("%4.4x\n", i);
else {
register char *p = line;
register int j = 0x10000;
while (! ((j >>= 1) & i)) *p++ = ' ';
do *p++ = (j & i) ? '1' : '0';
while (j >>= 1);
*p++ = '\n';
printf (line);
}
}
exit (0);
}
SHAR_EOF
fi
if test -f 'adb.list'
then
echo shar: "will not over-write existing file 'adb.list'"
else
cat << \SHAR_EOF > 'adb.list'
_main: save %sp, -0x70, %sp
_main+4: mov %i0, %l0
_main+8: mov %i1, %l1
_main+0xc: cmp %l0, 0x1
_main+0x10: ble _main + 0x58
_main+0x14: nop
_main+0x18: ld [%l1 + 0x4], %o1
_main+0x1c: ldsb [%o1], %o0
_main+0x20: cmp %o0, 0x2d
_main+0x24: bne _main + 0x58
_main+0x28: nop
_main+0x2c: ldsb [%o1 + 0x1], %o0
_main+0x30: cmp %o0, 0x78
_main+0x34: be _main + 0x48
_main+0x38: nop
_main+0x3c: cmp %o0, 0x58
_main+0x40: bne _main + 0x58
_main+0x44: nop
_main+0x48: sethi %hi(0x8400), %g1
_main+0x4c: ld [%g1 + 0x350], %o0
_main+0x50: add %o0, 0x1, %o0
_main+0x54: st %o0, [%g1 + 0x350]
_main+0x58: addcc %l0, -0x1, %l0
_main+0x5c: be _main + 0x130
_main+0x60: nop
_main+0x64: add %l1, 0x4, %l1
_main+0x68: call _atoi
_main+0x6c: ld [%l1], %o0
_main+0x70: clr %o1
_main+0x74: xor %o1, %o0, %o1
_main+0x78: sra %o0, 0x1, %o0
_main+0x7c: orcc %g0, %o0, %g0
_main+0x80: bne _main + 0x74
_main+0x84: nop
_main+0x88: mov %o1, %o4
_main+0x8c: sethi %hi(0x8400), %g1
_main+0x90: ld [%g1 + 0x350], %o0
_main+0x94: orcc %g0, %o0, %g0
_main+0x98: be _main + 0xac
_main+0x9c: nop
_main+0xa0: sethi %hi(0x2000), %o0
_main+0xa4: ba _main + 0x11c
_main+0xa8: or %o0, 0x2b4, %o0
_main+0xac: sethi %hi(0x8400), %o2
_main+0xb0: or %o2, 0x358, %o2 ! _line
_main+0xb4: ba _main + 0xc8
_main+0xb8: sethi %hi(0x10000), %o1
_main+0xbc: mov 0x20, %o5
_main+0xc0: stb %o5, [%o2]
_main+0xc4: add %o2, 0x1, %o2
_main+0xc8: sra %o1, 0x1, %o1
_main+0xcc: andcc %o1, %o4, %g0
_main+0xd0: be _main + 0xbc
_main+0xd4: nop
_main+0xd8: mov %o2, %o3
_main+0xdc: add %o2, 0x1, %o2
_main+0xe0: andcc %o1, %o4, %g0
_main+0xe4: be _main + 0xf4
_main+0xe8: nop
_main+0xec: mov 0x31, %o0
_main+0xf0: ba,a _main + 0xf8
_main+0xf4: mov 0x30, %o0
_main+0xf8: stb %o0, [%o3]
_main+0xfc: sra %o1, 0x1, %o1
_main+0x100: orcc %g0, %o1, %g0
_main+0x104: bne _main + 0xd8
_main+0x108: nop
_main+0x10c: mov 0xa, %o5
_main+0x110: stb %o5, [%o2]
_main+0x114: sethi %hi(0x8400), %o0
_main+0x118: or %o0, 0x358, %o0 ! _line
_main+0x11c: call _printf
_main+0x120: nop
_main+0x124: addcc %l0, -0x1, %l0
_main+0x128: bne _main + 0x64
_main+0x12c: nop
_main+0x130: call _atoi + 0xd0
_main+0x134: clr %o0
_main+0x138: ret
_main+0x13c: restore
SHAR_EOF
fi
if test -f 'gdb.list'
then
echo shar: "will not over-write existing file 'gdb.list'"
else
cat << \SHAR_EOF > 'gdb.list'
Script started on Mon Apr 2 00:54:04 1990
cmsun 1% gdb a.out
GDB 3.5, Copyright (C) 1989 Free Software Foundation, Inc.
There is ABSOLUTELY NO WARRANTY for GDB; type "info warranty" for details.
GDB is free software and you are welcome to distribute copies of it
under certain conditions; type "info copying" to see the conditions.
Reading symbol data from /scr2/jwc/ccstuf/mv/junk/a.out...done.
Type "help" for a list of commands.
(gdb) disas &main
Reading in symbols for grayinv.c...done.
Dump of assembler code for function main:
0x22c8 <main>: save %sp, -112, %sp
0x22cc <main+4>: mov %i0, %l0
0x22d0 <main+8>: mov %i1, %l1
0x22d4 <main+12>: cmp %l0, 1
0x22d8 <main+16>: ble 0x2320 <main+88>
0x22dc <main+20>: nop
0x22e0 <main+24>: ld %l1+4, %o1
0x22e4 <main+28>: ldsb %o1, %o0
0x22e8 <main+32>: cmp %o0, 0x2d
0x22ec <main+36>: bne 0x2320 <main+88>
0x22f0 <main+40>: nop
0x22f4 <main+44>: ldsb %o1+1, %o0
0x22f8 <main+48>: cmp %o0, 0x78
0x22fc <main+52>: be 0x2310 <main+72>
0x2300 <main+56>: nop
0x2304 <main+60>: cmp %o0, 0x58
0x2308 <main+64>: bne 0x2320 <main+88>
0x230c <main+68>: nop
0x2310 <main+72>: sethi %hi(0x8400), %g1
0x2314 <main+76>: ld %g1+0x350, %o0 ! 0x8750 <inhex>
0x2318 <main+80>: inc %o0
0x231c <main+84>: st %o0, %g1+0x350
0x2320 <main+88>: addcc -1, %l0, %l0
0x2324 <main+92>: be 0x23f8 <main+304>
0x2328 <main+96>: nop
0x232c <main+100>: add %l1, 4, %l1
0x2330 <main+104>: call 0x2408 <atoi>
0x2334 <main+108>: ld %l1, %o0
0x2338 <main+112>: clr %o1
0x233c <main+116>: xor %o1, %o0, %o1
0x2340 <main+120>: inc %o0
0x2344 <main+124>: tst %o0
0x2348 <main+128>: bne 0x233c <main+116>
0x234c <main+132>: nop
0x2350 <main+136>: mov %o1, %o4
0x2354 <main+140>: sethi %hi(0x8400), %g1
0x2358 <main+144>: ld %g1+0x350, %o0 ! 0x8750 <inhex>
0x235c <main+148>: tst %o0
0x2360 <main+152>: be 0x2374 <main+172>
0x2364 <main+156>: nop
0x2368 <main+160>: sethi %hi(0x2000), %o0
0x236c <main+164>: b 0x23e4 <main+284>
0x2370 <main+168>: or %o0, 0x2b4, %o0 ! 0x22b4 <grayinv+44>
0x2374 <main+172>: sethi %hi(0x8400), %o2
0x2378 <main+176>: or %o2, 0x358, %o2 ! 0x8758 <line>
0x237c <main+180>: b 0x2390 <main+200>
0x2380 <main+184>: sethi %hi(0x10000), %o1
0x2384 <main+188>: mov 0x20, %o5
0x2388 <main+192>: stb %o5, %o2
0x238c <main+196>: inc %o2
0x2390 <main+200>: inc %o1
0x2394 <main+204>: andcc %o1, %o4, %g0
0x2398 <main+208>: be 0x2384 <main+188>
0x239c <main+212>: nop
0x23a0 <main+216>: mov %o2, %o3
0x23a4 <main+220>: inc %o2
0x23a8 <main+224>: andcc %o1, %o4, %g0
0x23ac <main+228>: be 0x23bc <main+244>
0x23b0 <main+232>: nop
0x23b4 <main+236>: mov 0x31, %o0
0x23b8 <main+240>: b,a 0x23c0 <main+248>
0x23bc <main+244>: mov 0x30, %o0
0x23c0 <main+248>: stb %o0, %o3
0x23c4 <main+252>: inc %o1
0x23c8 <main+256>: tst %o1
0x23cc <main+260>: bne 0x23a0 <main+216>
0x23d0 <main+264>: nop
0x23d4 <main+268>: mov 0xa, %o5
0x23d8 <main+272>: stb %o5, %o2
0x23dc <main+276>: sethi %hi(0x8400), %o0
0x23e0 <main+280>: or %o0, 0x358, %o0 ! 0x8758 <line>
0x23e4 <main+284>: call 0x2b40 <printf>
0x23e8 <main+288>: nop
0x23ec <main+292>: addcc -1, %l0, %l0
0x23f0 <main+296>: bne 0x232c <main+100>
0x23f4 <main+300>: nop
0x23f8 <main+304>: call 0x24d8 <exit>
0x23fc <main+308>: clr %o0
0x2400 <main+312>: ret
0x2404 <main+316>: restore
End of assembler dump.
(gdb) q
cmsun 2% ^D
script done on Mon Apr 2 00:54:51 1990
SHAR_EOF
fi
exit 0
# End of shell archive
Technical Details
Message-ID:
<9004020733.AA07451@cmsun.ncsa.uiuc.edu>Path:
arc1-ca.pugleaf.net!gmdzi!unido!fauern!ira.uka.de!snorkelwacker!tut.cis.ohio-state.edu!NCSA.UIUC.EDU!jwcShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f5053,6de395c8aedb51dd,start X-Google-Attributes: gidf5053,public X-Google-ArrivalTime: 1990-04-02 19:19:48 PST Path: arc1-ca.pugleaf.net!gmdzi!unido!fauern!ira.uka.de!snorkelwacker!tut.cis.ohio-state.edu!NCSA.UIUC.EDU!jwc From: jwc@NCSA.UIUC.EDU (Jay Chalmers) Newsgroups: gnu.gdb.bug Subject: in GDB 3.5 on a sparc Message-ID: <9004020733.AA07451@cmsun.ncsa.uiuc.edu> Date: 2 Apr 90 07:33:47 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 262 Posted: Mon Apr 2 08:33:47 1990