[LLVMdev] Source file information.

Jeffrey Yasskin jyasskin at google.com
Thu Jul 9 09:34:02 PDT 2009


On Thu, Jul 9, 2009 at 8:40 AM, Aaron
Gray<aaronngray.lists at googlemail.com> wrote:
>>Aaron Gray wrote:
>>> What I am after is to be able to emit line number information for COFF
>>> (Common Object File Format) object module files, basically it comes down
>>> to
>>> paired line numbers and virtual address offsets.
>>>
>>> I have not really set out to look at this yet, just feeling ahead, and
>>> was
>>> prompted by Saman's question to have a look.
>>>
>>> So any pointers or help are most welcome,
>>>
>>So you are digging into the code generator issues.  That's beyond my ken.
>>
>>The original question seemed to be interested in getting debug
>>information corresponding to an LLVM instruction at the LLVM IR level.
>>That's what the code above does.  In your case, you need additional
>>information about what the code generator is doing.  Unfortunately, I
>>can't help you with that, but hopefully someone else can.
>>
>>Sorry.
>
> Okay :)
>
> What I need to find or write is somethng that maps MachineBasicBlocks to
> line numbers.

Every MachineInstruction holds a DebugLoc accessible through
MachineInstr::getDebugLoc().
http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineInstr.h?view=markup

Then MachineFunction::getDebugLocTuple(DebugLoc)
(http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineFunction.h?view=markup)
will transform that into a DebugLocTuple
(http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/DebugLoc.h?view=markup)
which gives you the CompileUnit, line number, and column number. Use
DebugInfo.h:DICompileUnit to interpret the CompileUnit.

I've been looking at the AsmPrinter to figure out how debug info works
so I can implement it in the JITEmitter (for oprofile). The AsmPrinter
inserts a label anywhere the DebugLoc changes
(AsmPrinter::processDebugLoc). The JITEmitter has the option of using
getCurrentPCValue() to record line boundaries, so I don't know whether
recording addresses directly or also using labels for the JIT will be
better.




More information about the llvm-dev mailing list