> > i have some weird problem.
> Well, it would have been nice if you had told what you deemed to
> be the problem. ;-) I can't find any problem at all...
> > Breakpoint 1, main () at prog1.c:8
> > 8 return (foo(1, 2, '3', "test"));
> > (gdb) s
> > foo (i=1, s=10244, c=-54 'Ê', str=0x804855b "test") at prog1.c:13
> If you mean it should look like:
> foo (i=1, s=2, c=51 '3', str=0x804855b "test") at prog1.c:13
> here, erm, no. Your breakpoint simply hit before the function stack
> frame initialization was complete, so gdb displays the wrong values at
> that point. Just type a single `s', followed by a `where', and you'll
> see it will eventually get the argument list right then.
first of all i want to apoligize. i sent the wrong output. yes, it
does the right thing if you use "-g" switch, however it does not
work for me if i use "-ggdb" switch.
Script started on Wed Oct 31 13:46:09 2001
beetle% uname -a
FreeBSD beetle 5.0-CURRENT FreeBSD 5.0-CURRENT #0: Tue Oct 30 13:23:19 PST 2001
beetle% cat c1.sh
gcc -Wall -ggdb prog1.c
+ gcc -v
Using builtin specs.
gcc version 2.95.3 20010315 (release)
+ ld -v
GNU ld version 2.11.2 20010719 [FreeBSD] (with BFD 2.11.2 20010719 [FreeBSD])
+ rm a.out
+ cat prog1.c
int foo (int, short, char, char *);
return (foo(1, 2, '3', "test"));
foo(int i, short s, char c, char *str)
printf("%d, %d, %d, %s\n", i, s, c, str);
+ gcc -Wall -ggdb prog1.c
1, 2, 51, test
+ gdb a.out
GNU gdb 4.18
Copyright 1998 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-unknown-freebsd"...
(gdb) b main
Breakpoint 1 at 0x80484c6: file prog1.c, line 8.
Starting program: /usr/home/max/test/a.out
Breakpoint 1, main () at prog1.c:8
8 return (foo(1, 2, '3', "test"));
foo (i=671494208, s=10246, c=16 '\020', str=0x2804ca2b "\203~T") at prog1.c:13
14 printf("%d, %d, %d, %s\n", i, s, c, str);
#0 foo (i=671494208, s=10246, c=16 '\020',
str=0x2332b <Error reading address 0x2332b: Bad address>) at prog1.c:14
#1 0x80484d6 in main () at prog1.c:8
(gdb) p i
$1 = 671494208
(gdb) p s
$2 = 10246
(gdb) p c
$3 = 16 '\020'
(gdb) p str
$4 = 0x2332b <Error reading address 0x2332b: Bad address>
The program is running. Exit anyway? (y or n) y
Script done on Wed Oct 31 13:46:46 2001