About debug in LLVM!!!

Hi all LLVMdev!

Here is a question:

I try to understand how I can realize a debugging in LLVM!?

I have written a back end for my target and now I need a debug.

I asked developers Chris Lattner and Robert L. Bocchino. They recommend me
ask the LLVMdev.

Is there a tool like "llvm-db" about Robert said?

Here a mail from Robert:

Do you want to debug the native executables generated by your back-end?
What debug info format your native executables support?
In general, this is how it works for that case.

1. clang-cc -g generates required debug info in the .bc file.
2. The backend (llc) converts that to Dwarf (or something else as desired by that back-end).
3. Native debuggers like (gdb) understands Dwarf and provide source level debugging eventually.

- Sanjiv

Rudskyy wrote:

Hello,

I’m not sure whether Bugpoint does what you are looking for but it comes with LLVM. It’s documentation is found at http://llvm.org/cmds/bugpoint.html so if you want to look into that, that may answer your question. It’s the closest thing I’ve found to an LLVM debugging tool.

Sorry I can’t help more than this.

–Sam

2. The backend (llc) converts that to Dwarf (or something else as
desired by that back-end).

How advanced is LLVM Dwarf generation compared to GCC ?

2. The backend (llc) converts that to Dwarf (or something else as
desired by that back-end).

How advanced is LLVM Dwarf generation compared to GCC ?

Devang can probably give a better answer, but my understanding is:

1. At -O0, the quality is very good, with a few exceptions (like
inlined functions). With clang I believe there are cases where we are
more accurate than gcc.

2. At -O1+ we only have line number information, which is approximate
at best. This is substantially worse than gcc (although plenty of
caveats about debugging optimized code apply).

- Daniel

llvm-gcc is not very good at keeping track of lexical scopes in debug
info. (This needs some help from someone who can grok GIMPLE trees
well). However, clang handles it well.