[Lldb-commits] [lldb] r132090 - /lldb/trunk/examples/python/disasm.py
Johnny Chen
johnny.chen at apple.com
Wed May 25 15:29:24 PDT 2011
Author: johnny
Date: Wed May 25 17:29:23 2011
New Revision: 132090
URL: http://llvm.org/viewvc/llvm-project?rev=132090&view=rev
Log:
Add a little spice to the script to allow us to specify a function name to break at and to disassemble.
Usage: disasm.py [-n name] executable-image
By default, it breaks at and disassembles the 'main' function.
Modified:
lldb/trunk/examples/python/disasm.py
Modified: lldb/trunk/examples/python/disasm.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/python/disasm.py?rev=132090&r1=132089&r2=132090&view=diff
==============================================================================
--- lldb/trunk/examples/python/disasm.py (original)
+++ lldb/trunk/examples/python/disasm.py Wed May 25 17:29:23 2011
@@ -17,6 +17,23 @@
for i in insts:
print i
+def usage():
+ print "Usage: disasm.py [-n name] executable-image"
+ print " By default, it breaks at and disassembles the 'main' function."
+ sys.exit(0)
+
+if len(sys.argv) == 2:
+ fname = 'main'
+ exe = sys.argv[1]
+elif len(sys.argv) == 4:
+ if sys.argv[1] != '-n':
+ usage()
+ else:
+ fname = sys.argv[2]
+ exe = sys.argv[3]
+else:
+ usage()
+
# Create a new debugger instance
debugger = lldb.SBDebugger.Create()
@@ -25,13 +42,13 @@
debugger.SetAsync (False)
# Create a target from a file and arch
-print "Creating a target for '%s'" % sys.argv[1]
+print "Creating a target for '%s'" % exe
-target = debugger.CreateTargetWithFileAndArch (sys.argv[1], lldb.LLDB_ARCH_DEFAULT)
+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());
+ main_bp = target.BreakpointCreateByName (fname, target.GetExecutable().GetFilename());
print main_bp
More information about the lldb-commits
mailing list