如何获取LLVM调试符号

时间:2016-02-01 16:19:18

标签: linux debugging llvm-clang

我有一个使用Clang API的c ++项目,我希望能够在调试项目时调试到clang / llvm函数。

我使用CMake使用以下选项构建了llvm + clang v3.7.0:

 -DCMAKE_INSTALL_PREFIX=$HOME/opt/llvm -DCMAKE_BUILD_TYPE=Debug

但是GDB没有步入clang API的功能。

我做错了什么?

1 个答案:

答案 0 :(得分:0)

您可能正在做的不是在命令行上使用-cc1设置断点。 clang forks立即进行错误处理,所以如果你在main上设置一个断点,你会看到它发生。如果你想从clang开始调试那么你应该:

  • 使用调试符号构建(看起来就是这样)
  • 使用-v运行clang以获取各种命令行,例如

    dzur:〜/ TMP> 〜/ builds / build-llvm / bin / clang -v t.c -S

    “/ usr / local / google / home / echristo / builds / build-llvm / bin / clang-3.9”-cc1 -triple x86_64-unknown-linux-gnu -S -disable-free -main-file-name tc -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -v -dwarf-column-info -debugger-tuning = gdb -coverage-file / usr / local / google / home / echristo / tmp / tc -resource-dir /usr/local/google/home/echristo/builds/build-llvm/bin/../lib/clang/3.9.0 -internal-isystem / usr / local / include -internal-isystem /usr/local/google/home/echristo/builds/build-llvm/bin/../lib/clang/3.9.0/include -internal-externc-isystem / usr / include / x86_64-linux-gnu -internal-externc-isystem / include -internal-externc-isystem / usr / include -fdebug-compilation-dir / usr / local / google / home / echristo / tmp -ferror-limit 19 -fmessage-length 120 -fobjc-runtime = gcc -fdiagnostics-show-option -fcolor-diagnostics -o t.s -x c t.c

  • 在此命令行中设置您在源中所需的断点。