<div dir="ltr">Thanks a lot Greg for your input. I have tried the 2nd option  to parse the out of image lookup command and it works perfectly fine for me.<div><br></div><div>Regards,</div><div>Kamenee</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jun 21, 2016 at 2:21 PM, Greg Clayton <span dir="ltr"><<a href="mailto:gclayton@apple.com" target="_blank">gclayton@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">We currently don't expose this information through the API, though we could. You could add a new method to SBValue:<br>
<br>
namespace lldb<br>
{<br>
  class SBValue<br>
  {<br>
    SBData GetDWARFLocation();<br>
  }<br>
};<br>
<br>
This could return the DWARF location as a SBData object. Then you could consume the data by parsing the DWARF DW_OP enumerations. Otherwise you can parse the textual output of the "image lookup -va 0x123" command:<br>
<br>
result = lldb.SBCommandReturnObject()<br>
ci = debugger.GetCommandInterpreter()<br>
ci.HandleCommand("image lookup -va %#x" % (frame.GetPC()), result, False)<br>
<br>
# Now all output from the above command is in "result"<br>
output = result.GetOutput()<br>
<br>
# Parse "output" for variable locations<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
<br>
> On Jun 21, 2016, at 9:07 AM, Kamenee Arumugam <<a href="mailto:kamenee@seas.upenn.edu">kamenee@seas.upenn.edu</a>> wrote:<br>
><br>
> Hi Greg,<br>
><br>
> Thanks for your reply. I did try the method you mention above but variable.GetLocation() only provide me the memory address of the variable. What exactly I am looking for was  the register offset that stores variable i here. Example, I am looking for method able to output the one highlighted in yellow:<br>
><br>
> Variable: id = {0x000000a2}, name = "i", type= "int", location = DW_OP_fbreg(-564), decl = ivm_demo.c:6<br>
><br>
><br>
> Basically, I am working on  a binary instrumentation research tool, that will inject code to check changes on selected variable. Therefore, using register offset, I am able to inject check for instruction using this register with this offset.<br>
> Please let me know if you have any better method to grab register offset for particular variable.<br>
><br>
> Thanks,<br>
> Kamenee<br>
><br>
> On Mon, Jun 20, 2016 at 7:15 PM, Greg Clayton <<a href="mailto:gclayton@apple.com">gclayton@apple.com</a>> wrote:<br>
> The variables are available through the frame in your symbol context. You have a line of code commented out in your script:<br>
><br>
>                     #variable = frame.GetVariables(target,True,True,True)<br>
><br>
> Change it to:<br>
><br>
> get_arguments = True # Get argument variables<br>
> get_locals = True # Get local variables<br>
> get_statics = True # Get globals and static variables<br>
> get_in_scope_only = True # only get variables that are in scope<br>
> use_dynamic = lldb.eDynamicDontRunTarget # Get dynamic types for variables<br>
> variables = frame.GetVariables (get_arguments, get_locals, get_statics, get_in_scope_only, use_dynamic)<br>
> print variables<br>
><br>
> This output will look different from the output in "image lookup --address 0x... --verbose" because we have an actual frame here so we can dump the variable value itself because we have a stack frame that allows us to have variable values. If you want the location of the variable you can also print that in a for loop using "variables" from above:<br>
><br>
> for variable in variables:<br>
>     print str(variable)<br>
>     print "Location = %s" % (variable.GetLocation())<br>
><br>
><br>
> Each "variable" object is a lldb.SBValue type. There are many API calls on these that you can call manually depending on what you want. Let me know if you have any questions.<br>
><br>
> Greg Clayton<br>
><br>
><br>
><br>
><br>
> > On Jun 17, 2016, at 11:34 AM, Kamenee Arumugam via lldb-dev <<a href="mailto:lldb-dev@lists.llvm.org">lldb-dev@lists.llvm.org</a>> wrote:<br>
> ><br>
> > Hi,<br>
> ><br>
> > I am trying program using Lldb Python API to get an output exactly same when I run this command "image lookup --address 0x0000000405a6 --verbose". But when I print return value of GetSymbolContext(lldb.eSymbolContextEverything), it doesnt contain the decoding of local variables which the above commands can print out local variables.<br>
> ><br>
> > I have attached a simple script.py that I have developed. It is not possible to print out local variables using the APIs or I am missing something out?<br>
> ><br>
> > I am looking forward to hear from you soon.<br>
> ><br>
> > Thanks,<br>
> > kmn<br>
> > <script.txt>_______________________________________________<br>
> > lldb-dev mailing list<br>
> > <a href="mailto:lldb-dev@lists.llvm.org">lldb-dev@lists.llvm.org</a><br>
> > <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev</a><br>
><br>
><br>
<br>
</div></div></blockquote></div><br></div>