Article View: gnu.gdb.bug
Article #10229short args print wrong on Sun4
From: Stephen Gildea
Date: Wed, 01 Nov 1989 23:53
Date: Wed, 01 Nov 1989 23:53
62 lines
1982 bytes
1982 bytes
On a Sparcstation 1 running SunOS 4.0.3c, I can sometimes make
short int arguments to C functions print out incorrectly in
gdb 3.2 and 3.3. The program sees the correct values and works
fine. Gdb works fine on a Sun 3/60 also running SunOS 4.0.3.
To repeat:
Put the following C program into a file called testgdb.c:
/* test the way short args print in gdb 3.2 and 3.3 */
#include <stdio.h>
main()
{
subr(2);
exit(0);
}
subr(arg)
short arg;
{
short x1=4, j=14, x2=5;
printf("arg is %d\n", arg);
if (arg == 2)
subr(j);
buggy(121);
}
buggy(arg2)
short arg2;
{
printf(" buggy got %d\n", arg2);
}
Now compile it:
cc -g -Bstatic -o testgdb4 testgdb.c
Run the program; it does what you expect.
Now run gdb on your Sun4 and break at "buggy". Notice that the
argument to buggy doesn't have the value you would expect.
However, casting it as a short (which it should already be)
makes it print out correctly.
(gdb) break buggy
Reading in symbols for testgdb.c...done.
Breakpoint 1 at 0x2338: file testgdb.c, line 27.
(gdb) run
Starting program: /a/gildea/temp/./testgdb4
arg is 2
arg is 14
Bpt 1, buggy (arg2=4160684153) (testgdb.c line 27)
(gdb) print (short)arg2
$1 = 121
Compiling with gcc gives a different wrong value for arg2
according to gdb. The program still works.
< Stephen
Technical Details
Message-ID:
<8911012354.AA21602@life.ai.mit.edu>Path:
arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!ALEXANDER.BBN.COM!gildeaShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f5053,67e31f79371144e5,start X-Google-Attributes: gidf5053,public X-Google-ArrivalTime: 1989-11-02 05:31:25 PST Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!ALEXANDER.BBN.COM!gildea From: gildea@ALEXANDER.BBN.COM (Stephen Gildea) Newsgroups: gnu.gdb.bug Subject: short args print wrong on Sun4 Message-ID: <8911012354.AA21602@life.ai.mit.edu> Date: 1 Nov 89 23:53:44 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 62 Posted: Thu Nov 2 00:53:44 1989