[LLVMdev] set line number debug info

Abhirup Ghosh abhirupju at gmail.com
Fri Mar 25 06:50:59 PDT 2011


Oh! I made a mistake by not using setDebugInfo() function present in the
Instruction class. Now it's working fully.
So, the solution is:-
To set the line number for an instruction -
1. Add a function in DebugLoc class located in llvm/Support/DebugLoc.h. Set
the line number there to the private variable called LineCol.
2. Call the added function. And then pass the modified DebugLoc object to
the seDebugInfo method for the instruction.

Abhirup Ghosh
M. Tech
Department of Computer Science & Engg.
IIT, Bombay
email - abhirupju at gmail.com , abhirup at cse.iitb.ac.in
Contact - 9920735181 / 9434362120


On Fri, Mar 25, 2011 at 5:45 PM, Abhirup Ghosh <abhirupju at gmail.com> wrote:

> Thanks for the help.
> I thought I'd solved the problem (setting the line number information in
> the instruction metadata) by inserting my own function for setting line
> number in llvm/Support/DebugLoc.h. I have added  a function
> setLine(unsigned) in DebugLoc class. The function simply sets the LineCol
> variable as needed. But there is a problem.
>
> Whenever I'm checking the line number(calling getLine()) from the function
> where I've called setLine(...) function, it returns the changed line number
> but whenever I call the getLine() function from other functions then it is
> returning the previous value not the changed. Is the change in the LineCol
> variable is not permanent or is this variable not at all linked with the
> debug information?
>
> How can I set the line number information for the instructions?
>
>
>
> Abhirup Ghosh
> M. Tech
> Department of Computer Science & Engg.
> IIT, Bombay
> email - abhirupju at gmail.com , abhirup at cse.iitb.ac.in
> Contact - 9920735181
>
>
> On Mon, Mar 14, 2011 at 1:45 PM, Frits van Bommel <fvbommel at gmail.com>wrote:
>
>> On Mon, Mar 14, 2011 at 8:56 AM, Abhirup Ghosh <abhirupju at gmail.com>
>> wrote:
>> > Hi,
>> >       I am new to LLVM infrastructure. Recently I am trying to set the
>> debug
>> > info for an instruction. The main aim is to set the source line number
>> of an
>> > instruction. Can anyone please show how to do that?
>> >       I think  that setMetadata method in Instruction class is to be
>> used.
>> > But how do I create MDNode* consisting of desired source line number.
>> Source
>> > line number can be extracted from the instruction-debug-info using
>> > getMetadata method and then using getLineNumber method from DILocation
>> > class. Unfortunately DILocation class does not have any function like
>> > setLinenumber.
>>
>> You may want to check out Instruction::setDebugLoc().
>> llvm/Support/DebugLoc.h and llvm/Analysis/DIBuilder.h will likely be
>> helpful as well.
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110325/f664d3a0/attachment.html>


More information about the llvm-dev mailing list