pardo@JUNE.CS.WASHINGTON.EDU (04/05/89)
The following code shows gdb giving the wrong name to a
function that contains a static const char. The names and
types of parameters (and hence their values) are hidden.
I suspect that this is a gdb problem, since `dbx' gets it
right. When the program is compiled with `cc', the same
thing happens. When compiled without `-g' the correct thing
happens (with either compiler).
Machine: VAX 8550, Ultrix 2.3. Gcc 1.34 (config.gcc),
gdb 2.8
gcc -g -Wall -ansi -v -c a.c
gcc version 1.34
/uns/usr/local/lib/gcc-cpp -v -undef -D__GNUC__ -T -$ -D__STRICT_ANSI__ -D__vax__ -D__unix__ -Wall a.c /tmp/cc000602.cpp
GNU CPP version 1.34
/uns/usr/local/lib/gcc-cc1 /tmp/cc000602.cpp -quiet -dumpbase a.c -g -Wall -ansi -version -o /tmp/cc000602.s
GNU C version 1.34 (vax) compiled by GNU C version 1.34.
a.c: In function zurk:
a.c:6: warning: implicit declaration of function `printf'
a.c: In function main:
a.c:15: warning: implicit declaration of function `exit'
as /tmp/cc000602.s -o a.o
Loading run ... done
a.c:
- --------
void
zurk (char const *s)
{
static char const * const wrong_name = "wrong!!!";
printf ("%s=%s\n", s, wrong_name);
}
int
main (int argc, char const * const * argv)
{
zurk ("ha!");
exit (0);
return (0);
}
- --------
a.s:
- --------
#NO_APP
gcc_compiled.:
.stabs "a.c",100,0,0,Ltext
Ltext:
.stabs "int:t1=r1;-2147483648;2147483647;",128,0,0,0
.stabs "char:t2=r2;0;127;",128,0,0,0
.stabs "long int:t3=r1;-2147483648;2147483647;",128,0,0,0
.stabs "unsigned int:t4=r1;0;-1;",128,0,0,0
.stabs "long unsigned int:t5=r1;0;-1;",128,0,0,0
.stabs "short int:t6=r1;-32768;32767;",128,0,0,0
.stabs "long long int:t7=r1;0;-1;",128,0,0,0
.stabs "short unsigned int:t8=r1;0;65535;",128,0,0,0
.stabs "long long unsigned int:t9=r1;0;-1;",128,0,0,0
.stabs "signed char:t10=r1;-128;127;",128,0,0,0
.stabs "unsigned char:t11=r1;0;255;",128,0,0,0
.stabs "float:t12=r1;4;0;",128,0,0,0
.stabs "double:t13=r1;8;0;",128,0,0,0
.stabs "long double:t14=r1;8;0;",128,0,0,0
.stabs "void:t15=15",128,0,0,0
.text
.align 0
LC0:
.ascii "wrong!!!\0"
.align 2
_wrong_name.0:
.long LC0
.align 0
LC1:
.ascii "%s=%s\12\0"
.align 1
.globl _zurk
_zurk:
.stabd 68,0,3
.word 0x0
LBB2:
.stabd 68,0,6
pushl _wrong_name.0
pushl 4(ap)
pushab LC1
calls $3,_printf
LBE2:
.stabd 68,0,7
ret
.stabs "zurk:F15",36,0,0,_zurk
.stabs "s:p16=*2",160,0,0,4
.stabs "wrong_name:V16",36,0,0,_wrong_name.0
.stabn 192,0,0,LBB2
.stabn 224,0,0,LBE2
.align 0
LC2:
.ascii "ha!\0"
.align 1
.globl _main
_main:
.stabd 68,0,13
.word 0x0
.stabd 68,0,14
pushab LC2
calls $1,_zurk
.stabd 68,0,15
clrl -(sp)
calls $1,_exit
.stabd 68,0,16
clrl r0
ret
.stabd 68,0,17
ret
.stabs "main:F1",36,0,0,_main
.stabs "argc:p1",160,0,0,4
.stabs "argv:p17=*16",160,0,0,8
GDB 2.8, Copyright (C) 1988 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 /u1/pardo/tmp/bug4/run...done.
Type "help" for a list of commands.
(gdb) break printf
Breakpoint 1 at 0xa2
(gdb) run
Starting program: /u1/pardo/tmp/bug4/run
Bpt 1, 0xa2 in printf (92, 125, 76)
(gdb) where
#0 0xa2 in printf (92, 125, 76)
#1 0x7c in wrong_name (125) (a.c line 6)
#2 0x91 in main (argc=1, argv=(char **) 0x7fffe078, 2147475584) (a.c line 14)
(gdb) up
#1 0x7c in wrong_name (125) (a.c line 6)
(gdb) list
1 void
2 zurk (char const *s)
3 {
4 static char const * const wrong_name = "wrong!!!";
5
6 printf ("%s=%s\n", s, wrong_name);
7 }
8
9
10
(gdb) print s
No symbol "s" in current context.
(gdb)
(Note: the function has the wrong name, the parameter is `125' instead
of something like `char *s=0d125 "ha!". Finally, the symbol is not
found by `print s'.)