Daniel Jacobowitz wrote:
On Mon, Jul 06, 2009 at 10:59:56PM +0200, John Hughes wrote:
debugging a program that uses the glibc getopt function shows the wrong
address and value for the "optind" variable.
(gdb) info var optind
All variables matching regular expression "optind":
File /usr/include/getopt.h:
static int optind;
File getopt.c:
int optind;
Non-debugging symbols:
0x0000000000600a00 optind@@GLIBC_2.2.5
GDB thinks there are two copies. One is in getopt.c in libc.so.
That's the one that GDB is printing. The other is in the executable,
target of an R_<arch>_COPY relocation. GDB prints the one that has
debug info.
(I do not know why there is also a static copy attributed to getopt.h;
I can not find it in GDB's symbol dumps...)
I don't get the static version with gcc 4.3 and gdb 6.8 on lenny (x86-64):
(gdb) info var optind
All variables matching regular expression "optind":
File /usr/include/getopt.h:
int optind;
Non-debugging symbols:
0x0000000000600a00 optind@@GLIBC_2.2.5
Unfortunately, this bug is quite hard to fix. It applies to any
variable defined in a shared library and used in the executable.
Eew. How horrid.
--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org