[LLVMdev] get function local debug info?

lu zhao luzhao at cs.utah.edu
Sat Nov 2 16:17:39 PDT 2013


Hi,

If I have an instance of DISubprogram, can I get the debug info of local 
variables of the function, including parameters?

I tried to use the getVariables() function defined in DISubprogram, but 
it seemed to return an empty DIArray node when I ran my pass alone using 
opt. Do I need to enable any other analysis passes in order to populate 
the data?

My related snippet of code is like the following:

     NamedMDNode *M_Nodes = M.getNamedMetadata("llvm.dbg.cu");
     for (unsigned i = 0, e = M_Nodes->getNumOperands(); i != e; ++i) {
       DIArray SPs = CU.getSubprograms();
       for (unsigned i = 0, e = SPs.getNumElements(); i != e; ++ i) {
         DISubprogram SP(SPs.getElement(i));
         DIArray Vars = SP.getVariables();
         for (unsigned i2 = 0, e2 = Vars.getNumElements(); i2 != e2; ++i2) {
           DIVariable DV(Vars.getElement(i));
           DV.print(errs()); errs() << " : "; DV.getType().dump();
         }
       }
     }

In addition, can I use DebegInfo to get the list of parameters (var 
names and types) of a subprogram? or I have to parse the underlying 
metadata and build the relationship?

Thanks,
Lu

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


More information about the llvm-dev mailing list