[LLVMdev] Debugging LLVM IR with GDB

Tobias Grosser tobias at grosser.es
Thu Oct 18 07:59:59 PDT 2012


On 10/18/2012 04:35 PM, Will Dietz wrote:
> On Thu, Oct 18, 2012 at 8:59 AM, Eli Bendersky <eliben at gmail.com> wrote:

>
> Hi all,
>
> For my own purposes, I wrote a pass that does exactly what you all are
> describing: add debug metadata to LLVM IR.
>
> As a pass, it had to tackle the problem of "This file needs to exist
> on disk somewhere so gdb can find it", which I solved my dumping it
> onto /tmp/ somewhere.  Not a great solution (who deletes these?) but
> worked well enough.
>
> Another interesting issue is how to coexist with any existing debug
> metadata, which can be useful for simultaneously debugging an IR
> transform inline with the C source for instrumentation-style passes
> like SAFECode, ASan/TSan.
[...]

> The pass itself is rather simple--the hard problem it solves is
> emitting the IR to disk and reasoning about what Instruction* is on
> what line, which really shouldn't be a problem if done properly in
> LLVM.  If desired I can certainly make the code available on request.

I am definitely interested in such a pass. I think a pass that simply 
annotates an existing LLVM-IR file is already a big step forward. The 
stuff on top that you describe is also great, but if it complicates 
integration into LLVM, you could start with a plain LLVM-IR debug info 
annotation pass and add additional stuff later on.

Cheers
Tobi




More information about the llvm-dev mailing list