[Lldb-commits] [lldb] r163421 - /lldb/trunk/examples/python/gdb_disassemble.py

Greg Clayton gclayton at apple.com
Fri Sep 7 14:18:45 PDT 2012


Author: gclayton
Date: Fri Sep  7 16:18:45 2012
New Revision: 163421

URL: http://llvm.org/viewvc/llvm-project?rev=163421&view=rev
Log:
Added a quick example to show how disasembly output can be customized.


Added:
    lldb/trunk/examples/python/gdb_disassemble.py   (with props)

Added: lldb/trunk/examples/python/gdb_disassemble.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/python/gdb_disassemble.py?rev=163421&view=auto
==============================================================================
--- lldb/trunk/examples/python/gdb_disassemble.py (added)
+++ lldb/trunk/examples/python/gdb_disassemble.py Fri Sep  7 16:18:45 2012
@@ -0,0 +1,24 @@
+import lldb
+
+def disassemble(debugger, command, result, dict):
+    if lldb.frame.function:
+        instructions = lldb.frame.function.instructions
+        start_addr = lldb.frame.function.addr.load_addr
+        name = lldb.frame.function.name
+    elif lldb.frame.symbol:
+        instructions = lldb.frame.symbol.instructions
+        start_addr = lldb.frame.symbol.addr.load_addr
+        name = lldb.frame.symbol.name
+    
+    for inst in instructions:
+        inst_addr = inst.addr.load_addr
+        inst_offset = inst_addr - start_addr
+        comment = inst.comment
+        if comment:
+            print "<%s + %-4u> 0x%x %8s  %s ; %s" % (name, inst_offset, inst_addr, inst.mnemonic, inst.operands, comment)
+        else:
+            print "<%s + %-4u> 0x%x %8s  %s" % (name, inst_offset, inst_addr, inst.mnemonic, inst.operands)
+            
+# Install the command when the module gets imported
+lldb.debugger.HandleCommand('command script add -f gdb_disassemble.disassemble gdb-disassemble')
+print 'Installed "gdb-disassemble" command for disassembly'
\ No newline at end of file

Propchange: lldb/trunk/examples/python/gdb_disassemble.py
------------------------------------------------------------------------------
    svn:executable = *





More information about the lldb-commits mailing list