[LLVMdev] Replacement for findStopPoint() in LLVM 2.7

John Criswell criswell at uiuc.edu
Tue Mar 16 08:21:53 PDT 2010


Török Edwin wrote:
> On 03/16/2010 05:00 PM, John Criswell wrote:
>   
>> Dear LLVMers,
>>
>> I'm updating some code to use the new LLVM 2.7 API.  One piece of this 
>> code uses the findStopPoint() function to find the source filename and 
>> line number information of an instruction.
>>
>> What is the best way to do this under LLVM 2.7 now that the stop point 
>> intrinsic has been removed?  It appears that the debug information is 
>> attached as metadata, but what is the easiest way to extract the 
>> filename and line number information out of this metadata?
>>
>>     
>
> Something like this (you can of course cache TheMetadata and MDDbgKind)
>
> llvm::MetadataContext *TheMetadata = M->getContext().getMetadata();
> MDDbgKind = TheMetadata->getMDKind("dbg");
> if (MDDbgKind) {
>   if (MDNode *Dbg = TheMetadata->getMD(MDDbgKind, I)) {
>         DILocation Loc(Dbg);
> 	...
> 	Loc.getDirectory()
> 	Loc.getFilename()
> 	Loc.getLineNumber()
>         Loc.getColumnNumber()
> 	....
>   }
>   

A grep through my LLVM 2.7 source tree does not find MetadataContext 
anywhere.  Is this something that was added to LLVM mainline after the 
LLVM 2.7 branch was created?

I'm using the release_27 branch of LLVM, so I'm limited to facilities 
within that branch.

-- John T.

> }
>
> Best regards,
> --Edwin
>   




More information about the llvm-dev mailing list