<p dir="ltr">+llvmdev because I accidentally dropped it</p>
<div class="gmail_quote">On Nov 3, 2013 6:57 AM, "David Blaikie" <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<p dir="ltr">You're welcome to provide a patch or I might get to it myself. Also this should be described in <a href="http://llvm.org/docs/SourceLevelDebugging.html" target="_blank">http://llvm.org/docs/SourceLevelDebugging.html</a> if it isn't already</p>


<div class="gmail_quote">On Nov 3, 2013 12:11 AM, "lu zhao" <<a href="mailto:luzhao@cs.utah.edu" target="_blank">luzhao@cs.utah.edu</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


  
    
  
  <div text="#000000" bgcolor="#FFFFFF">
    Hi David,<br>
    <br>
    Thank you! Your suggested method works.<br>
    <br>
    I think that you or someone should write what you said in the
    comments for the getVariable() function. :)<br>
    <br>
    Best,<br>
    Lu<br>
    <br>
    <div>On 11/03/2013 06:30 AM, David Blaikie
      wrote:<br>
    </div>
    <blockquote type="cite">
      <div dir="ltr"><br>
        <div class="gmail_extra"><br>
          <br>
          <div class="gmail_quote">On Sat, Nov 2, 2013 at 4:17 PM, lu
            zhao <span dir="ltr"><<a href="mailto:luzhao@cs.utah.edu" target="_blank">luzhao@cs.utah.edu</a>></span>
            wrote:<br>
            <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div text="#000000" bgcolor="#FFFFFF"> <font face="Courier New, Courier, monospace">Hi,<br>
                  <br>
                  If I have an instance of DISubprogram, can I get the
                  debug info of local variables of the function,
                  including parameters?<br>
                  <br>
                  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?<br>
                  <br>
                  My related snippet of code is like the following:<br>
                  <br>
                      NamedMDNode *M_Nodes = M.getNamedMetadata("<a href="http://llvm.dbg.cu" target="_blank">llvm.dbg.cu</a>");<br>
                      for (unsigned i = 0, e =
                  M_Nodes->getNumOperands(); i != e; ++i) {<br>
                        DIArray SPs = CU.getSubprograms();<br>
                        for (unsigned i = 0, e = SPs.getNumElements(); i
                  != e; ++ i) {<br>
                          DISubprogram SP(SPs.getElement(i));<br>
                          DIArray Vars = SP.getVariables();<br>
                          for (unsigned i2 = 0, e2 =
                  Vars.getNumElements(); i2 != e2; ++i2) {<br>
                            DIVariable DV(Vars.getElement(i));<br>
                            DV.print(errs()); errs() << " : ";
                  DV.getType().dump();<br>
                          }<br>
                        }<br>
                      }<br>
                  <br>
                  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?<br>
                </font></div>
            </blockquote>
            <div><br>
            </div>
            <div>Basically this /\. We use the variables list (the
              getVariables function you mentioned) to persist the
              variables in optimized (above -O0) builds, but at -O0 we
              save metadata space by not emitting the list and relying
              on the dbg_value/declare intrinsics to keep the variable
              metadata alive and the variables to refer to their scope
              (lexical blocks (that refer to subprograms) or
              subprograms).<br>
              <br>
              So you'd have to walk all the instructions looking for
              dbg_declare/value (I forget which, perhaps both) and trace
              those back to the DIVariables, etc... </div>
            <div> </div>
            <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div text="#000000" bgcolor="#FFFFFF"><font face="Courier
                  New, Courier, monospace"> <br>
                  Thanks,<br>
                  Lu<br>
                  <br>
                </font> </div>
              <br>
              _______________________________________________<br>
              LLVM Developers mailing list<br>
              <a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>
                      <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
              <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
              <br>
            </blockquote>
          </div>
          <br>
        </div>
      </div>
    </blockquote>
    <br>
  </div>

</blockquote></div>
</blockquote></div>