[LLVMdev] Debugging LLVM IR with GDB

Pablo Barrio pbarrio at die.upm.es
Wed Oct 17 06:42:56 PDT 2012

Hi all,

Has anybody debugged LLVM IR with GDB? I'm using dragonegg to transform 
C into IR, then applying my optimizations. Passing "-g" to dragonegg 
doesn't seem to work since it generates debug info for the C code, not 
the IR. I really need GDB (lli doesn't solve my problems) in order to 
debug multi-threaded and multi-process MPI code.

More clearly, if I have a file hello.ll and I execute:

$> llc hello.ll -march=x86-64 -o hello.s
$> mpicc -O0 hello.s -o hello

Can I debug "hello" with GDB at the IR level? If so, how? If not, would 
it be possible to add debug info generation at the IR level (and how 
much effort required)? I read something about DwarfDebug but it's not 
clear to me how to use it or even if it does what I need. I hope I 
didn't miss any obvious solution.

Thanks ahead,

Pablo Barrio
Dpt. Electrical Engineering - Technical University of Madrid
Office C-203
Avda. Complutense s/n, 28040 Madrid
Tel. (+34) 915495700 ext. 4234
@: pbarrio at die.upm.es

More information about the llvm-dev mailing list