The variables are available through the frame in your symbol context. You have 
a line of code commented out in your script:

                    #variable = frame.GetVariables(target,True,True,True)

Change it to:

get_arguments = True # Get argument variables
get_locals = True # Get local variables
get_statics = True # Get globals and static variables
get_in_scope_only = True # only get variables that are in scope
use_dynamic = lldb.eDynamicDontRunTarget # Get dynamic types for variables
variables = frame.GetVariables (get_arguments, get_locals, get_statics, 
get_in_scope_only, use_dynamic)
print variables

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:

for variable in variables:
    print str(variable)
    print "Location = %s" % (variable.GetLocation())


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.

Greg Clayton


   

> On Jun 17, 2016, at 11:34 AM, Kamenee Arumugam via lldb-dev 
> <lldb-dev@lists.llvm.org> wrote:
> 
> Hi,
> 
> 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.
> 
> 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?
> 
> I am looking forward to hear from you soon.
> 
> Thanks,
> kmn
> <script.txt>_______________________________________________
> lldb-dev mailing list
> lldb-dev@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev

_______________________________________________
lldb-dev mailing list
lldb-dev@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev

Reply via email to