[LLVMdev] Using debug info in static analysis

Chris Lattner sabre at nondot.org
Tue Dec 25 10:53:41 PST 2007


On Dec 25, 2007, at 5:56 AM, Török Edwin wrote:
> I was looking at how to  use debug info to find out original  
> source:line
> for a certain function/variable in the llvm bytecode.
>
> I read http://llvm.org/docs/SourceLevelDebugging.html, and then I have
> looked in lib/Debugger/ProgramInfo.cpp.
> getFunction() looks useful, however I am not sure how to call it. I  
> have
> a reference to a Function, however getFunction() takes
> a GlobalVariable. I tried creating a GlobalVariable that points to my
> Function, but that didn't work, since getFunction() is looking
> at uses of the GlobalVariable, which in my case was none.
>
> Am I missing something obvious here? How do I find out source:line for
> an LLVM Function? (assuming original file was compiled with debug  
> info,
> and bitcode has debug info)

You can only get the location from a stoppoint intrinsic.  Just walk  
the function looking for the first stoppoint in it.  From that you can  
get the descriptor containing the file/line#.  See the llvm  
programmer's manual for info on how to walk the IR.

-Chris



More information about the llvm-dev mailing list