strange gdb behavior

Alexey Shuvaev shuvaev at physik.uni-wuerzburg.de
Mon Nov 2 15:42:19 UTC 2009


On Mon, Nov 02, 2009 at 03:52:33PM +0200, Max Boyarov wrote:
> Hi,
> 
> Who could help understand this:
> 
> `--> cat 1.c
> int
> main(int argc, char **argv)
> {
>         return 0;
> }
> 
> [snip]
> 
> (gdb) set args test
> (gdb) b main
> Breakpoint 1 at 0x80483d0: file 1.c, line 3.
> (gdb) r
> Starting program: /tmp/1 test
> 
> Breakpoint 1, main () at 1.c:3
> 3       {
> (gdb) print argc
> Error accessing memory address 0x0: Bad address.
> (gdb) list
> 1       int
> 2       main(int argc, char **argv)
> 3       {
> 4               return 0;
> 5       }
> 
> checked on 9.0-CURRENT, 8.0-BETA3
> 
On
FreeBSD wep4035 9.0-CURRENT FreeBSD 9.0-CURRENT #0 r198671: Fri Oct 30 16:12:10 CET 2009     root at wep4035:/usr/obj/usr/src/sys/GENERIC  amd64
I have the following:

(gdb) set args test
(gdb) b main
Breakpoint 1 at 0x40052b: file 1.c, line 4.
(gdb) r
Starting program: /home/lexx/1 test

Breakpoint 1, main (argc=2, argv=0x7fffffffe790) at 1.c:4
4               return 0;
(gdb) list
1       int
2       main(int argc, char **argv)
3       {
4               return 0;
5       }
(gdb) print argc
$1 = 2
(gdb) 

Note that the breakpoint is set to line 4, not line 3 as in your case.
There was a series of changes to the linker recently. Update to the latest
CURRENT might help.

HTH,
Alexey.


More information about the freebsd-hackers mailing list