Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 Jun 2006 20:52:40 +0200
From:      Ulrich <freebsd-alpha@infopuls.com>
To:        freebsd-alpha@freebsd.org
Subject:   4.11 gdb/gcc problem with debugging simple C programs
Message-ID:  <20060630185240.17233.qmail@igel.cyberlink.ch>
References:  <Pine.GSO.4.58a.0509070037220.11377@uhunix2> <20060227231802.8883.qmail@igel.cyberlink.ch> <20060228020917.GA2778@xiao.rsnet> <20060228074937.GB39184@freebie.xs4all.nl>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi everybody 

While running a simple C program I noticed that gdb wasn't able to print out 
the correct values of parameters. All parameter values were wrongly 
displayed whenever gdb entered or left a function and automatically showed 
the function's parameter list together with each parameter's value. Strange 
enough the program works with the correct values and runs correctly. Using 
gdb's print command also displays the wrong values. Sometimes even a pointer 
value is displayed as null although the program works with a valid pointer. 

The program was compiled without optimisation: gcc -Wall -g test1.c -o test1 

Here are two short examples of what I see. 

Starting program: ./test1 value1 value2 value3 value4 

Breakpoint 1, main (ac=536872600, av=0x0) at test1.c:3
3       int main(int ac, char *av[])    {
(gdb) print ac
$1 = 536872600 

The program can access the 4 parameter values and ac has the correct value. 

Starting program: ./test2 -v 6000 -l 112233 file1 file2 

Breakpoint 1, main (ac=536873548, av=0x7) at test2.c:75 

75      int main(int ac, char *av[])    {
(gdb) print ac
$1 = 536873548 

It seems that the addresses of parameters are shifted while accessed by gdb. 
The value of parameter "av" is displayed as "0x7" which is the correct value 
of "ac". I also don't know whether it means something that the wrong values 
of "ac" in both examples start with the same sequence of digits "53687". 

I'm reading the list since end of 2004 and I cannot remember that this 
problem came up already. I also checked with google but didn't find anything 
useful. Can someone drop me a hint where to search or what to do? I don't 
think that gdb or gcc are faulty, but that I did something without noticing 
it. 

gcc version 2.95.4 20020320 [FreeBSD]
GNU gdb 4.18 (FreeBSD) 

TIA 

Ulrich 




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060630185240.17233.qmail>