[LLVMdev] Debugging LLVM IR with GDB

Pablo Barrio pbarrio at die.upm.es
Fri Oct 19 04:55:00 PDT 2012


Hi Will,

On 18/10/12 16:35, Will Dietz wrote:
> For my own purposes, I wrote a pass that does exactly what you all are
> describing: add debug metadata to LLVM IR.

Your pass seems to be exactly what I'm looking for. ┬┐Could you make it 
available to me (us)?

> 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.

I'm not really an expert on debug info, so correct me if I'm wrong. The 
idea would imply some level of support from GDB itself (visualization of 
multiple file formats at the same time i.e. C and IR) which I'm not 
aware of, or perhaps generate a mixed-format file just for the purposes 
of visualization. The idea is interesting though.

> 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.
>
> In short, it seemed to work well for me and having it done properly in
> LLVM itself would be great!
It might be already in the right place. As far as I understand, we 
should be able to annotate the code after all the optimizations have 
been made, which can be done inside opt. On the other hand, I can see 
the benefits of doing it inside llc or llvm-as, as we have more 
information about the correspondence of IR and assembler code.

Anyway, as Tobias said, your pass is a step forward on its own. I'm 
willing to help here.

Thanks ahead,
Pablo

-- 
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