diff --git a/common/context_handler.py b/common/context_handler.py index f92901b..c5b6404 100644 --- a/common/context_handler.py +++ b/common/context_handler.py @@ -364,7 +364,9 @@ def display_code(self) -> None: output_line(f"{filename}'{function_name}:") - pre_instructions = extract_instructions(self.target, function_start, pc - 1, self.state.disassembly_syntax)[-3:] + pre_instructions = extract_instructions( + self.target, self.arch, function_start, pc - 1, self.state.disassembly_syntax + )[-3:] print_instructions( self.target, pre_instructions, @@ -381,7 +383,7 @@ def display_code(self) -> None: disassembly_end_address = min(frame_end_address, max_disassembly_end_address) post_instructions = extract_instructions( - self.target, pc, disassembly_end_address, self.state.disassembly_syntax + self.target, self.arch, pc, disassembly_end_address, self.state.disassembly_syntax ) if len(post_instructions) > 0: diff --git a/common/instruction_util.py b/common/instruction_util.py index 2404707..b668c66 100644 --- a/common/instruction_util.py +++ b/common/instruction_util.py @@ -3,6 +3,7 @@ from lldb import SBAddress, SBInstruction, SBTarget +from arch import I386, X86_64, BaseArch from common.color_settings import LLEFColorSettings from common.golang.analysis import go_annotate_jumps from common.golang.util import go_context_analysis @@ -11,7 +12,7 @@ def extract_instructions( - target: SBTarget, start_address: int, end_address: int, disassembly_flavour: str + target: SBTarget, arch: BaseArch, start_address: int, end_address: int, disassembly_flavour: str ) -> list[SBInstruction]: """ Returns a list of instructions between a range of memory address defined by @start_address and @end_address. @@ -25,7 +26,10 @@ def extract_instructions( current = start_address while current <= end_address: address = SBAddress(current, target) - instruction = target.ReadInstructions(address, 1, disassembly_flavour).GetInstructionAtIndex(0) + if arch is I386 or arch is X86_64: + instruction = target.ReadInstructions(address, 1, disassembly_flavour).GetInstructionAtIndex(0) + else: + instruction = target.ReadInstructions(address, 1).GetInstructionAtIndex(0) instructions.append(instruction) instruction_size = instruction.GetByteSize() if instruction_size > 0: