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
import lldb
import os
triple = "x86_64"
def disassemble_instructions(insts):
for i in insts:
print i
# Set the path to the executable to debug
exe = "buffer"
# Create a new debugger instance
debugger = lldb.SBDebugger.Create()
# When we step or continue, don't return from the function until the process
# stops. Otherwise we would have to handle the process events ourselves which,
while doable is
#a little tricky. We do this by setting the async mode to false.
debugger.SetAsync (False)
# Create a target from a file and arch
print "Creating a target for '%s'" % exe
target = debugger.CreateTargetWithFileAndArch (exe, lldb.LLDB_ARCH_DEFAULT)
if target:
# If the target is valid set a breakpoint at main
main_bp = target.BreakpointCreateByName
("main",target.GetExecutable().GetFilename());
#print main_bp
# Launch the process. Since we specified synchronous mode, we won't return
# from this function until we hit the breakpoint at main
process = target.LaunchSimple (None, None, os.getcwd())
# Make sure the launch went ok
if process:
# Print some simple process info
state = process.GetState ()
#print process
if state == lldb.eStateStopped:
# Get the first thread
thread = process.GetThreadAtIndex (0)
if thread:
# Print some simple thread info
#print thread
# Get the first frame
frame = thread.GetFrameAtIndex (0)
#if frame:
# Print some simple frame info
# Print some simple frame info
#print frame
#function = frame.GetFunction()
#variable = frame.GetVariables(target,True,True,True)
module = target.GetModuleAtIndex(0)
target.SetSectionLoadAddress(module.FindSection("__TEXT"),
0x100000000)
module = target.AddModule
("/usr/lib/system/libsystem_c.dylib", triple, None,
"/build/server/a/libsystem_c.dylib.dSYM")
target.SetSectionLoadAddress(module.FindSection("__TEXT"),
0x7fff83f32000)
module = target.AddModule
("/usr/lib/system/libsystem_dnssd.dylib", triple, None,
"/build/server/b/libsystem_dnssd.dylib.dSYM")
target.SetSectionLoadAddress(module.FindSection("__TEXT"),
0x7fff883db000)
module = target.AddModule
("/usr/lib/system/libsystem_kernel.dylib", triple, None,
"/build/server/c/libsystem_kernel.dylib.dSYM")
target.SetSectionLoadAddress(module.FindSection("__TEXT"),
0x7fff8c0dc000)
load_addr = 0x0000000004005a6
so_addr = target.ResolveLoadAddress(load_addr)
sym_ctx =
so_addr.GetSymbolContext(lldb.eSymbolContextEverything)
print sym_ctx
_______________________________________________
lldb-dev mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev