[LLVMdev] Questions about how to debug LLVM and CLang
David Blaikie
dblaikie at gmail.com
Thu Apr 10 09:20:20 PDT 2014
On Wed, Apr 9, 2014 at 7:11 PM, 蜡笔小新 <841224078 at qq.com> wrote:
> Hi, all.
>
> Clang is the front end of C/C++ compiler and LLVM plays the role of
> optimizer and backend. So how do these different stages are connected?
They're connected by API (ie: the clang binary links in the LLVM
libraries and calls into them to do optimization/machine code/assembly
emission).
> Is
> there any detailed document about this?
Not really
> What's more, the code of LLVM and Clang is so huge that it is hard for me to
> get started. If I want to make some modifications or just wanna to debug the
> source code, what should I do?
Depends what it is you want to change. I started by looking at Clang
diagnostic (warnings, errors, etc) issues - false positives (cases
where warnings are emitted but shouldn't be) were a good place to
start because I could find the code that emitted the warning
(ultimately breaking on textual printing code - printf/write/whatever
basic system call) and then work backwards through the stack trace in
a debugger (gdb, etc) to find out what context lead to emitting that
warning there and where the missing checks were.
One common hurdle to debugging clang is that clang executes another
process inside itself. Either use clang -### to get the underlying
command and debug that, or in gdb use "set fork-follow-mode child" to
make sure the debugger debugs the child process.
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
More information about the llvm-dev
mailing list