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.


git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@132090 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/examples/python/disasm.py b/examples/python/disasm.py
index 4c4e2d7..59ab30c 100755
--- a/examples/python/disasm.py
+++ b/examples/python/disasm.py
@@ -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