Debugging LLVM IR with LLDB

I have developed an LLVM front-end that generates LLVM IR as target code from some X source language. If I extend this interface to embed debug information into the generated IR, can LLDB be used to debug my source language? I mean, does lldb support any source language targeting LLVM IR?

+3


source to share


1 answer


You will need to get the DWARF language code and get lldb to recognize it. If we get some DWARF for an unknown language, we just ignore it ...

Then, without any support, some things will work, others will not.

If you are emitting the correct row table information, you should be able to display the backlink to your source, and that should make the steps work as well. Other things start to get complicated.



The next tricky part is how you are going to tell lldb about your type information. lldb uses the Clang AST as internal storage for type information in the debugger. lldb translates DWARF information into the Clang AST for both printing local variables (using a command frame variable

) and for use with an expression parser.

If your language has a type system that looks like C lldb, it should parse DWARF for your types. You will get this correct variable information, which should work frame variable

.

An expression parser (i.e. commands expression

, print

or po

) requires lldb to have a parser for your language. This can be a pretty big piece of work.

+2


source







All Articles