wangbo15
wangbo15

Reputation: 221

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.

Upvotes: 0

Views: 2174

Answers (2)

chenwj
chenwj

Reputation: 2069

set follow-fork-mode child would work, too. That way, you don't bother to figure out what follows -cc1.

Upvotes: 2

echristo
echristo

Reputation: 1727

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.

Upvotes: 2

Related Questions