diff options
author | Greg Clayton <gclayton@apple.com> | 2012-09-07 21:18:45 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2012-09-07 21:18:45 +0000 |
commit | ba1fad84205732c96476d994000784dafd1fd1e7 (patch) | |
tree | 0a8f442f0c18b4350f40cca8e28d4a9d9839f6d3 /lldb/examples/python/gdb_disassemble.py | |
parent | 68b9f0583f6af28c4912367899e4156edee3c3d0 (diff) | |
download | bcm5719-llvm-ba1fad84205732c96476d994000784dafd1fd1e7.tar.gz bcm5719-llvm-ba1fad84205732c96476d994000784dafd1fd1e7.zip |
Added a quick example to show how disasembly output can be customized.
llvm-svn: 163421
Diffstat (limited to 'lldb/examples/python/gdb_disassemble.py')
-rwxr-xr-x | lldb/examples/python/gdb_disassemble.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lldb/examples/python/gdb_disassemble.py b/lldb/examples/python/gdb_disassemble.py new file mode 100755 index 00000000000..d9a2f212fc9 --- /dev/null +++ b/lldb/examples/python/gdb_disassemble.py @@ -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 |