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...) Unfortunately, this bug is quite hard to fix. It applies to any variable defined in a shared library and used in the executable. Here's a little more about the issue: http://sourceware.org/ml/gdb/2005-08/msg00031.html -- Daniel Jacobowitz CodeSourcery -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org