[LLVMdev] Debugging LLVM IR

Eli Bendersky eliben at gmail.com
Mon Jan 30 09:29:37 PST 2012


<snip>
> Anyway, I've looked at the IR generated by clang for a roughly
> equivalent C program and have a hard time figuring out when I'm going
> wrong. Another problem here is that I'm not aware of any good ways to
> debug IR. I tried gdb a little bit, but it doesn't seem to understand
> IR. And I ran my program under valgrind, but nothing useful showed up
> there, either. I tried to figure out someways of printf'ing pointers
> and values straight from the IR, but that doesn't work. Perhaps it
> would be useful to add an instruction for that? It also seems like lli
> should be fertile ground for better debugging tools; I imagine it
> should technically not be too hard to print out a blow-by-blow of the
> evolution of my program's state...
>
> Anyway, if anyone has some hints to help me debug this stuff, that
> would be most welcome.
>

Hi Dirkjan,

Unfortunately it won't be immediately helpful, but we're currently in
the middle of pushing a functional MC-JIT implementation for Linux
(and hopefully Windows as well) which will enable debugging out of the
box. Once the set of patches gets committed, it will be possible to
debug JITted code with GDB, if this code was compiled from C/C++ with
Clang. The debugging should work like any C code debugging.

However, as I said this is a work in progress and it may take some
time until its fully functional in LLVM trunk.

Eli



More information about the llvm-dev mailing list