gdb has lost its mind
Or more accurately its view of the address space/symbol mapping. Would anyone care to expalin the folliwing and suggest what I can do to fix it? np.c is just a simple program that only calls getopt so far, yet gdb can not seem to output the correct value for the extern int optind. Obviously this is rather unwelcome behavior for a debugger. gdb is still from rh9, gcc and its core libs have been updated from fc2 (rpm did not complain about a gdb dependency on the old versions). Np is built simply with gcc -g -o np np.c
[jrg@PC-linux src]$ gdb np
GNU gdb Red Hat Linux (5.3post-0.20021129.18rh)
Copyright 2003 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-redhat-linux-gnu"...
(gdb) b 56
Breakpoint 1 at 0x804888f: file np.c, line 56.
(gdb) run -o -l 4003 hello
Starting program: /home/jrg/src/np -o -l 4003 hello
# note gdb has a different view of optind than the program
Breakpoint 1, main (argc=5, argv=0xbffff964) at np.c:56
56 printf("optind %d\n",optind);
(gdb) p optind
$1 = 1
(gdb) n
optind 3
57 if ( !in && !out )
(gdb) q
The program is running. Exit anyway? (y or n) y
[jrg@PC-linux src]$ ldd np
libc.so.6 => /lib/tls/libc.so.6 (0x42000000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
[jrg@PC-linux src]$ gcc --version
gcc (GCC) 3.3.3 20040412 (Red Hat Linux 3.3.3-7)
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|