LLVM Compiler Infrastructure and GDB debugger

Hallo, LLVMdev!

I have found you in LLVM Developers page (http://llvm.org/developers.cgi).

First thank you for all of your work with LLVM.


I work with the LLVM Compiler Infrastructure to implement a backend for specific processor xPEC of chip NetX (http://hilscher.com/netx…html).

So C-code already possible compile to the native xPEC assembly code (works perfect! LLWM a big power!).

Now I need to debug the source C-code, that I compile for xPEC-processor. I have read the article “Source Level Debugging with LLVM” (http://llvm.org/docs/SourceLevelDebugging.html), where were described that is possible to use debugger GDB. Wonderful! I have found much information about GDB (of course http://sourceware.org/gdb/ ) and it has a debugging of remote programs.


I don’t understand how must be compiled the C-code with “llvm-gcc”. Wenn I use option “-emit-llvm” [backend needs it] of course with “-g” and “-O0”, then GDB can’t find a symbol table in bc-file. Where will place “llvm-gcc” the symbol table for DGB? Perhaps, must GDB knows the architecture of processor? If yes, so where it must be written? I have many questions and need some help.

Do you can help me what must I read and search ore recommend somebody to can?

Best regards,

Artem Rudskyy



Where will place “llvm-gcc” the symbol table for GDB?

The relevant information is all available in the .bc file, but not in
any directly usable format; the LLVM code generator (in lib/CodeGen)
writes the appropriate assembly so that the assembler writes the
appropriate symbol table and debug info in the assembled .o file.

Symbols fall out naturally from having a native .o file, since the
linker needs to be able to read them. Detailed source-level debug
info gets written out by include/CodeGen/DwarfWriter.h and related
code; if you're not using a LLVM-style backend, you'll need to call
into it yourself. You should be able to do some limited amount of
debugging without debug information, though, so I'd suggest
concentrating on getting everything else working first.

Perhaps, must GDB knows the architecture of
processor? If yes, so where it must be written?

Yes, gdb must be aware of the target; if it's a target gdb knows
about, it should be enough to pass an appropriate "--target" to
configure, but otherwise you'll have to write some code. See
http://sourceware.org/gdb/download/onlinedocs/gdbint_9.html#SEC83 and
http://sourceware.org/gdb/download/onlinedocs/gdbint_15.html, I guess,
but I don't know very much about it.