4 def disassemble(debugger
, command
, result
, dict):
5 if lldb
.frame
.function
:
6 instructions
= lldb
.frame
.function
.instructions
7 start_addr
= lldb
.frame
.function
.addr
.load_addr
8 name
= lldb
.frame
.function
.name
9 elif lldb
.frame
.symbol
:
10 instructions
= lldb
.frame
.symbol
.instructions
11 start_addr
= lldb
.frame
.symbol
.addr
.load_addr
12 name
= lldb
.frame
.symbol
.name
14 for inst
in instructions
:
15 inst_addr
= inst
.addr
.load_addr
16 inst_offset
= inst_addr
- start_addr
17 comment
= inst
.comment
20 "<%s + %-4u> 0x%x %8s %s ; %s"
21 % (name
, inst_offset
, inst_addr
, inst
.mnemonic
, inst
.operands
, comment
)
25 "<%s + %-4u> 0x%x %8s %s"
26 % (name
, inst_offset
, inst_addr
, inst
.mnemonic
, inst
.operands
)
30 # Install the command when the module gets imported
31 def __lldb_init_module(debugger
, internal_dict
):
32 debugger
.HandleCommand(
33 "command script add -o -f gdb_disassemble.disassemble gdb-disassemble"
35 print('Installed "gdb-disassemble" command for disassembly')