[LLVMdev] Fwd: Accessing metadata & creating DIVariable

Devang Patel dpatel at apple.com
Tue Mar 29 16:42:59 PDT 2011


[Forgot to cc list.]

Begin forwarded message:

> From: Devang Patel <dpatel at apple.com>
> Date: March 29, 2011 4:41:30 PM PDT
> To: Vedavyas Duggirala <vduggira at gmail.com>
> Subject: Re: [LLVMdev] Accessing metadata & creating DIVariable
> 
> 
> On Mar 29, 2011, at 4:29 PM, Vedavyas Duggirala wrote:
> 
>>>> I get the filename and directory from  DISubprogram from reading
>>>> llvm.dbg.sp and use
>>>> that to DIBuiler::.createCompileUnit. This  leads to  "duplicate
>>>> symbol" error from llc.
>> 
>>> If the llvm::Module already has llvm.dbg.sp then you don't need to use DIBuilder::createCompileUnit(). The point, I am missing is how did you get llvm.dbg.sp in module ?
>>> 
>>> It seems you already have generated debug info in llvm::Module using DIBuilder. If that is true then you don't need to use createCompileUnit() for the same translation unit.
>> 
>> Yes, that was what I said in the first line of my original mail :)  I
>> am adding instrumentation code/variables to IR, and I want to add
>> debuginfo for the new variables and calls I introduced.
> 
> Sorry, I missed that.
> 
> If you already have DISubprogram then you can use DISubprogram::getCompileUnit() to find the compile unit for the subprogram. DISubprogram is one the useful MDNode wrapper. See DebugInfo.h for more info. You also may find DebugInfoFinder from DebugInfo.h useful.
> 
> In your case, you'll have to construct MDNodes for variables and types by hand. It is simple, take a look at DIBuilder.cpp. 
> 
> The documentation of the structure of these MDNodes is at http://llvm.org/docs/SourceLevelDebugging.html
> 
> -
> Devang

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110329/ca7ee5a8/attachment.html>


More information about the llvm-dev mailing list