tools to debug human readable llvm assembly bc code?


I am working with a long llvm bc code in human readable form. I am wondering is there a tool like gdb to help me debug that piece of code?



It's not directly executable so no, not really. You could try debugging lli but that's probably pretty painful and is effectively debugging jitted code.

You could try to use bugpoint to reduce a test case out of what you have.


Hi Eric,

Thanks for the reply. I am very new to llvm so could you elaborate more about you meant by ‘debugging lli’?

Thanks a lot!


I'm not sure how you're running your large bc file ultimately so I don't know necessarily what you mean by "debugging" for the bc file. It's not really executable :slight_smile:

lli is a command line interface to the jit/interpreter for bc files. You could conceivably set a breakpoint in there, but I really don't suggest it. If you're ultimately creating a native executable with your bc files then you could just make sure that the front end that you have emits debug info and debug that directly or just do step by step in the assembly.


Another possibility is to generate C code from IR using the C backend,
then compile and debug that C code with gdb. The generated C
statements may be close enough to IR instructions for your purposes.
I've successfully used this method in the past, although I don't know
what the state of the C backend is these days, since I understand it
is not fully supported.