diff options
author | Greg Clayton <gclayton@apple.com> | 2010-10-07 04:19:01 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2010-10-07 04:19:01 +0000 |
commit | 05faeb71350f65bbe8e41b68b22345e992e9a497 (patch) | |
tree | e01f0087d0afd0f1050c255be597fcbdcbfe7c49 /lldb/examples/python | |
parent | 1b468683c273ca438345381fa89d52355bb04a80 (diff) | |
download | bcm5719-llvm-05faeb71350f65bbe8e41b68b22345e992e9a497.tar.gz bcm5719-llvm-05faeb71350f65bbe8e41b68b22345e992e9a497.zip |
Cleaned up the SWIG stuff so all includes happen as they should, no pulling
tricks to get types to resolve. I did this by correctly including the correct
files: stdint.h and all lldb-*.h files first before including the API files.
This allowed me to remove all of the hacks that were in the lldb.swig file
and it also allows all of the #defines in lldb-defines.h and enumerations
in lldb-enumerations.h to appear in the lldb.py module. This will make the
python script code a lot more readable.
Cleaned up the "process launch" command to not execute a "process continue"
command, it now just does what it should have with the internal API calls
instead of executing another command line command.
Made the lldb_private::Process set the state to launching and attaching if
WillLaunch/WillAttach return no error respectively.
llvm-svn: 115902
Diffstat (limited to 'lldb/examples/python')
-rwxr-xr-x | lldb/examples/python/disasm.py | 83 |
1 files changed, 48 insertions, 35 deletions
diff --git a/lldb/examples/python/disasm.py b/lldb/examples/python/disasm.py index 8239cf337f9..3de3730c422 100755 --- a/lldb/examples/python/disasm.py +++ b/lldb/examples/python/disasm.py @@ -28,52 +28,65 @@ debugger = lldb.SBDebugger.Create() debugger.SetAsync (False) # Create a target from a file and arch -target = debugger.CreateTargetWithFileAndArch (sys.argv[1], "x86_64") +print "Creating a target for '%s'" % sys.argv[1] + +target = debugger.CreateTargetWithFileAndArch (sys.argv[1], lldb.LLDB_ARCH_DEFAULT) if target.IsValid(): # If the target is valid set a breakpoint at main main_bp = target.BreakpointCreateByName ("main", sys.argv[1]); - + + 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.LaunchProcess (sys.argv[2:], [''], "/dev/stdout", 0, False) + process = target.LaunchProcess ([''], [''], "/dev/stdout", 0, False) # Make sure the launch went ok if process.IsValid(): # Print some simple process info - print "process:", process, "\n" - # Get the first thread - thread = process.GetThreadAtIndex (0) - if thread.IsValid(): - # Print some simple thread info - print "thread: ", thread - # Get the first frame - frame = thread.GetFrameAtIndex (0) - if frame.IsValid(): - # Print some simple frame info - print "frame: ", frame - function = frame.GetFunction() - # See if we have debug info (a function) - if function.IsValid(): - # We do have a function, print some info for the function - print "function: ", function, "\n" - # Now get all instructions for this function and print them - insts = function.GetInstructions(target) - disassemble_instructions (insts) - else: - # See if we have a symbol in the symbol table for where we stopped - symbol = frame.GetSymbol(); - if symbol.IsValid(): - # We do have a symbol, print some info for the symbol - print "symbol: ", symbol, "\n" - # Now get all instructions for this symbol and print them - insts = symbol.GetInstructions(target) + state = process.GetState () + print process + if state == lldb.eStateStopped: + # Get the first thread + thread = process.GetThreadAtIndex (0) + if thread.IsValid(): + # Print some simple thread info + print thread + # Get the first frame + frame = thread.GetFrameAtIndex (0) + if frame.IsValid(): + # Print some simple frame info + print frame + function = frame.GetFunction() + # See if we have debug info (a function) + if function.IsValid(): + # We do have a function, print some info for the function + print function + # Now get all instructions for this function and print them + insts = function.GetInstructions(target) disassemble_instructions (insts) - # Now continue to the program exit - process.Continue() - # When we return from the above function we will hopefully be at the - # program exit. Print out some process info - print "process:", process, "\n" + else: + # See if we have a symbol in the symbol table for where we stopped + symbol = frame.GetSymbol(); + if symbol.IsValid(): + # We do have a symbol, print some info for the symbol + print symbol + # Now get all instructions for this symbol and print them + insts = symbol.GetInstructions(target) + disassemble_instructions (insts) + print "Hit the breakpoint at main, continue and wait for program to exit..." + # Now continue to the program exit + process.Continue() + # When we return from the above function we will hopefully be at the + # program exit. Print out some process info + print process + elif state == lldb.eStateExited: + print "Didn't hit the breakpoint at main, program has exited..." + else: + print "Unexpected process state: %s, killing process..." % debugger.StateAsCString (state) + process.Kill() + lldb.SBDebugger.Terminate() |