Disassemble with colors! Terminal only
(debugger, command, exe_ctx, result, internal_dict)
| 12 | 'command script add -f disassemble.handle_command dd -h "Alternative to LLDB\'s disassemble cmd"') |
| 13 | |
| 14 | def handle_command(debugger, command, exe_ctx, result, internal_dict): |
| 15 | ''' |
| 16 | Disassemble with colors! Terminal only |
| 17 | ''' |
| 18 | |
| 19 | command_args = shlex.split(command, posix=False) |
| 20 | target = exe_ctx.target |
| 21 | parser = generate_option_parser() |
| 22 | try: |
| 23 | (options, args) = parser.parse_args(command_args) |
| 24 | except: |
| 25 | result.SetError(parser.usage) |
| 26 | return |
| 27 | |
| 28 | output = '' |
| 29 | |
| 30 | |
| 31 | |
| 32 | if options.search_functions: |
| 33 | query = options.search_functions |
| 34 | symbol_context_list = target.FindGlobalFunctions(query, 0, lldb.eMatchTypeRegex) |
| 35 | for symContext in symbol_context_list: |
| 36 | output += generateAssemblyFromSymbol(symContext.symbol, options, exe_ctx) |
| 37 | elif len(args) == 0: |
| 38 | sym = exe_ctx.frame.symbol |
| 39 | output += generateAssemblyFromSymbol(sym, options, exe_ctx) |
| 40 | elif args[0].startswith('0x'): |
| 41 | sym = target.ResolveLoadAddress(long(args[0], 16)).GetSymbol() |
| 42 | output += generateAssemblyFromSymbol(sym, options, exe_ctx) |
| 43 | elif args[0].isdigit(): |
| 44 | sym = target.ResolveLoadAddress(long(args[0])).GetSymbol() |
| 45 | output += generateAssemblyFromSymbol(sym, options, exe_ctx) |
| 46 | else: |
| 47 | cleanCommand = ' '.join(args) |
| 48 | symList = target.FindGlobalFunctions(cleanCommand, 0, lldb.eMatchTypeNormal) |
| 49 | if symList.GetSize() == 0: |
| 50 | result.SetError(ds.attrStr("Couldn't find any matches for \"{}\"".format(cleanCommand), 'red')) |
| 51 | return |
| 52 | sym = symList |
| 53 | output += generateAssemblyFromSymbol(symList.GetContextAtIndex(0).symbol, options, exe_ctx) |
| 54 | |
| 55 | result.AppendMessage(output) |
| 56 | |
| 57 | def generateAssemblyFromSymbol(sym, options, exe_ctx): |
| 58 | target = exe_ctx.target |
nothing calls this directly
no test coverage detected
searching dependent graphs…