[LLVMdev] Using debug info in static analysis
edwintorok at gmail.com
Tue Dec 25 05:56:52 PST 2007
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)
Or is it just easier to iterate on the Function's BasicBlocks, and look
for llvm.dbg.* instrinsics?
As you might have guessed from the subject, I want to use this in a
static analysis tool (that works on llvm bitcode),
and it would be useful if it could provide the user with nice messages,
that include references to the original source file:line, possibly with
original types and variable names.
All this seems to be available in the debug info (as generated by
llvm-gcc -O0 -g), but I couldn't find functions to query for it.
I plan on implementing some utility classes for my project, to make it
easier to query for such information, and I'd like it to design it in a
way that could be useful for LLVM too. Suggestions?
More information about the llvm-dev