Sun CC bug?
amir at taux01.nsc.com
amir at taux01.nsc.com
Thu Jun 6 00:17:00 AEST 1991
I have trouble tracing 'short' parameters passed into functions.
'dbx', 'gdb' and 'ups' all fail to show the value correctly.
If I compile it with gcc, then it works fine, but gcc introduces other
compilcations, so I'd rather stick with plain-vanilla Sun's cc.
I suspect that the debug symbols in the object file are corrupted.
Enclosed are the C file, output from 'nm -apo' and recordings of
dbx and gdb sessions:
#---------------------------------------------------------------
#A C-file example:
#---------------------------------------------------------------
$ cat test.c
shorty (a,b)
short a;
int b;
{
printf ("short=%d, int=%d\n", a, b);
}
main ()
{
short aa;
int bb;
aa = 10;
bb = 20;
shorty (aa,bb);
aa += 100;
bb += 100;
shorty (aa,bb);
}
#---------------------------------------------------------------
# dump of object file
#---------------------------------------------------------------
$ nm -apo test.o
test.o:00000034 T _main
test.o: U _printf
test.o:00000000 T _shorty
test.o:00000000 - 00 0000 SO /files/pilat/amir/c/
test.o:00000000 - 00 0000 SO test.c
test.o:00000000 - 00 0000 LSYM int:t(0,1)=r(0,1);-2147483648;2147483647;
test.o:00000000 - 00 0000 LSYM char:t(0,2)=r(0,2);0;127;
test.o:00000000 - 00 0000 LSYM long:t(0,3)=r(0,1);-2147483648;2147483647;
test.o:00000000 - 00 0000 LSYM short:t(0,4)=r(0,1);-32768;32767;
test.o:00000000 - 00 0000 LSYM unsigned char:t(0,5)=r(0,1);0;255;
test.o:00000000 - 00 0000 LSYM unsigned short:t(0,6)=r(0,1);0;65535;
test.o:00000000 - 00 0000 LSYM unsigned long:t(0,7)=r(0,1);0;-1;
test.o:00000000 - 00 0000 LSYM unsigned int:t(0,8)=r(0,1);0;-1;
test.o:00000000 - 00 0000 LSYM float:t(0,9)=r(0,1);4;0;
test.o:00000000 - 00 0000 LSYM double:t(0,10)=r(0,1);8;0;
test.o:00000000 - 00 0000 LSYM void:t(0,11)=(0,11)
test.o:00000000 - 00 0000 LSYM ???:t(0,12)=(0,1)
test.o:00000000 - 00 0004 FUN shorty:F(0,1)
test.o:00000000 - 00 0004 SLINE
test.o:00000046 - 00 0002 PSYM a:p(0,4)
test.o:00000048 - 00 0004 PSYM b:p(0,1)
test.o:00000014 - 00 0004 SLINE
test.o:00000014 - 00 0005 SLINE
test.o:0000002c - 00 0006 SLINE
test.o:00000034 - 00 0004 FUN main:F(0,1)
test.o:00000034 - 00 0009 SLINE
test.o:00000040 - 00 0009 SLINE
test.o:fffffffe - 00 0002 LSYM aa:(0,4)
test.o:fffffff8 - 00 0004 LSYM bb:(0,1)
test.o:00000040 - 00 0002 LBRAC
test.o:00000040 - 00 000e SLINE
test.o:00000048 - 00 000f SLINE
test.o:00000050 - 00 0011 SLINE
test.o:00000060 - 00 0014 SLINE
test.o:00000074 - 00 0015 SLINE
test.o:00000080 - 00 0017 SLINE
test.o:00000090 - 00 0019 SLINE
test.o:000000a0 - 00 0002 RBRAC
test.o:000000a0 - 00 001a SLINE
#---------------------------------------------------------------
#A recording of the dbx session:
#---------------------------------------------------------------
$ dbx test
Reading symbolic information...
Read 49 symbols
(dbx) stop in shorty
(2) stop in shorty
(dbx) run
Running: test
stopped in shorty at line 5 in file "test.c"
5 printf ("short%d, int=%d\n", a, b);
(dbx) where
shorty(a = 0, b = 20), line 5 in "test.c"
main(), line 17 in "test.c"
(dbx) cont
short=10, int=20
stopped in shorty at line 5 in file "test.c"
5 printf ("short=%d, int=%d\n", a, b);
(dbx) cont
short=110, int=120
execution completed, exit code is 1
program exited with 1
(dbx) quit
#---------------------------------------------------------------
#A recording of the gdb session:
#---------------------------------------------------------------
$ gdb test
(gdb) break shorty
Reading in symbols for test.c...done.
Breakpoint 1 at 0x22a4: file test.c, line 5.
(gdb) run
Starting program: c/test
Bpt 1, shorty (a=0, b=20) (test.c line 5)
5 printf ("short=%d, int=%d\n", a, b);
(gdb) bt
#0 shorty (a=0, b=20) (test.c line 5)
#1 0x22f0 in main () (test.c line 17)
(gdb) cont
Continuing.
short=10, int=20
Bpt 1, shorty (a=0, b=120) (test.c line 5)
5 printf ("short=%d, int=%d\n", a, b);
(gdb) bt
#0 shorty (a=0, b=120) (test.c line 5)
#1 0x2320 in main () (test.c line 23)
(gdb) cont
Continuing.
short=110, int=120
More information about the Comp.sys.sun
mailing list