编译Graphviz 2.34.0后GDB调试断点失效及步进异常问题求助
Looks like your core problem is that GDB is loading the system-installed Graphviz shared libraries (/usr/lib/libgvc.so.6, /usr/lib/libcgraph.so.6) instead of the version you compiled from source. These system libraries don't include debugging symbols, which explains why GDB can't find your source files (input.c, grammar.c) and your breakpoints fail to attach. Let's walk through the fixes step by step:
1. Recompile Graphviz with Full Debug Symbols
First, you need to ensure your build generates debug information (without optimizations that strip debug data):
# Clean up previous build artifacts make clean # Configure with debug flags enabled ../graphviz-2.34.0/configure --enable-debug CFLAGS="-g -O0" CXXFLAGS="-g -O0" # Rebuild make
The -g flag adds debug symbols, and -O0 disables compiler optimizations (which can warp line numbers and make debugging harder).
2. Force GDB to Load Your Local Compiled Libraries
By default, the system's library path takes precedence. You need to tell GDB to use your local build's libraries first:
Option A: Use LD_LIBRARY_PATH When Launching GDB
Point the library path to the .libs directories where your compiled libraries live (adjust the paths to match your actual build structure):
LD_LIBRARY_PATH=./build2/lib/.libs/:./build2/lib/cgraph/.libs/:./build2/lib/common/.libs/ \ gdb -x ./gdbCommands.txt --args ./build2/cmd/dot/.libs/dot -Tjpeg -oInput.jpeg Input.txt
Option B: Set Library Search Path Inside GDB
If you prefer to configure this after launching GDB, run:
set solib-search-path ./build2/lib/.libs/:./build2/lib/cgraph/.libs/:./build2/lib/common/.libs/
This tells GDB to prioritize your local libraries over system ones.
3. Verify Correct Library Loading
After launching GDB, run info sharedlibrary to confirm:
- The paths for
libgvc.so.6andlibcgraph.so.6point to yourbuild2directory, not/usr/lib/ - The
Syms Readcolumn showsYes(notYes (*)), meaning debug symbols are loaded successfully
4. Fixing Breakpoint Issues
Once the correct libraries are loaded with debug symbols:
- Your existing breakpoints (
break input.c:570,break grammar.c:1281) should attach without the "No source file named..." error - Double-check that the
dircommands in your GDB script point to the correct source directories (confirminput.cexists in/home/oren/GIT/klee/benchmarks/graphviz/graphviz-2.34.0/lib/cgraphandgrammar.cis in the path you specified)
5. Notes on Static Compilation
Your earlier --disable-shared attempt failed because static builds require all dependencies to be available as static libraries, which can be tricky for Graphviz's complex dependencies. For debugging, dynamic libraries are generally easier to work with—stick with the dynamic build fixes above unless you have a specific need for static compilation.
内容的提问来源于stack exchange,提问作者OrenIshShalom

