I am aware of this question, but it does not appear to work for me.
For the setup, take a simple C++ program, hw.cpp
, given by: int main() { }
Upon compiling with g++ -o hw hw.cpp -O0 -g
on Linux, running ldd ./hw
gives:
linux-gate.so.1 => (0x003e5000)
libstdc++.so.6 => /usr/local/lib/libstdc++.so.6 (0x007c5000)
libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0x006a4000)
libgcc_s.so.1 => /usr/local/lib/libgcc_s.so.1 (0x00a40000)
libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0x00a93000)
/lib/ld-linux.so.2 (0x00a0f000)
Now I also appear to have debug libraries in /usr/lib/debug/lib/tls/i686/cmov/
, which I imagine are the corresponding debug builds of the system libraries.
Question: How do I compile my program so that it is linked against the debug builds of the standard C and/or C++ libraries, libc
/libm
/libstdc++
, shared or static? For the shared build, I want the output of ldd ./hw
to point to the debug directory.
(Background: One of the shared libraries that's used by my project is reported as leaking ("still reachable") by Valgrind, but the origins are not in the shared library itself, but in dlopen-type code (see here). So I figured that if I can step through the _Start()
invocation in the CRT I might be able to trace the culprit.)
Update/Correction: I think I was just very, very stupid - the debug libraries have probably always been linked as desired all along. I was confused by the debugger not showing anything while stepping, which is because I don't have the source code for the libraries.
Update II: OK, belay the previous update. I have the library sources now, but while it is true that the standard library ships with debug symbols, I don't appear to have a separate debug build. Is such a build available, and how would I link against it?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…