i want to debug something in glibc, so i want to use a debug version of glibc to build the program. if i just use "gcc -o test test.c" to build the program,
apt-get install libc6-dbg
apt-get source libc6-dev
when i was debugging the programs,some val is told that it is optimized. and EIP is always jump back.
how can i debug the debug version of glibc.
Caveat: I use fedora but it has a similar mechanism.
The debug package downloads an additional file that has the debug information you would get if you compiled with -g for glibc.
But, this package matches the standard build which is built with optimization (e.g. -O2).
It's the optimization that is causing the behavior you're seeing. So, the gdb "coverage" will be spotty.
What you want is a glibc version that is built with -gdwarf-2 and -O0. AFAIK, you'll have to get that by building glibc yourself from the source.
You'll probably have to run the configure script and select the -g and -O options for the build. Then, run make. The exact details should be in the source documentation [or online] somewhere.
Then, you'll have to [forcibly] link your program against the built-from-source version.