Search code examples
gdbllvmdebug-symbols

How to debug llvm source?


I have build llvm debug version with configue --enable-debug-runtime. I want to learn the exetution process of llvm by the gdb stack trace ? But occured error when I using gdb:

llvm-3.4.2/build/Release+Asserts/bin$ gdb ./clang
(gdb) b clang::CreateLLVMCodeGen (...)
(gdb) r ./clang ~/tmp/helloworld.c -o helloworld

Can any one help me? Thanks.


Solution

  • An issue you're going to have in trying to debug clang is that the first invocation of clang spawns another clang process. What you should do is use clang -v to get the -cc1 command line and use that as your run arguments in gdb.

    As far as the Release+Asserts bit, you'll want to do this configure line:

    configure --enable-debug-symbols --disable-optimized
    

    since you appear to be using release sources of llvm. The defaults change versus the bits in svn.

    Asserts are useful anyhow, so I'd keep them in.