I'm trying to use gdb to debug a shared library
when stepping into the function in the shared library I've started getting <optimized out> for all the local variables (written in C)
I've tried linking to a shared library (.so) linking to a static library (.a) making sure no optimisations are set in the Makefiles, i.e. -O0 and -g is set for both the library and the library harness
The strange thing I was able to debug it previously, <optimized out> has only appeared recently but I have no idea why, e.g. I was able to see the local variable originally
I know this is a vague question and theres all sorts of further info I may need to provide to sort it, e.g. Makefiles, source code etc. but possibly someone recognises the problem from this high level description and can offer a potential fix?
only appeared recently but I have no idea why
The <optimized out> can only appear when you debug optimized code.
Since you've verified that no -O* flags are present in your compile lines (don't just look in the Makefile, examine the actual compile log), the logical conclusion is that someone installed a different (optimized) version of your library somewhere else on the system, and that you are linking to that version.
On Linux (and many other UNIX systems) you can add -Wl,-t flag to your link line, and see which library is actually used at link time.
When using a shared library, GDB info shared command will tell you which library is picked up at runtime.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With