diff --git a/src/apps/debugger/arch/InstructionInfo.cpp b/src/apps/debugger/arch/InstructionInfo.cpp index 03afae474e..1a48c70848 100644 --- a/src/apps/debugger/arch/InstructionInfo.cpp +++ b/src/apps/debugger/arch/InstructionInfo.cpp @@ -9,6 +9,7 @@ InstructionInfo::InstructionInfo() : fAddress(0), + fTargetAddress(0), fSize(0), fType(INSTRUCTION_TYPE_OTHER), fBreakpointAllowed(false), @@ -17,11 +18,13 @@ InstructionInfo::InstructionInfo() } -InstructionInfo::InstructionInfo(target_addr_t address, target_size_t size, +InstructionInfo::InstructionInfo(target_addr_t address, + target_addr_t targetAddress, target_size_t size, instruction_type type, bool breakpointAllowed, const BString& disassembledLine) : fAddress(address), + fTargetAddress(targetAddress), fSize(size), fType(type), fBreakpointAllowed(breakpointAllowed), @@ -31,11 +34,12 @@ InstructionInfo::InstructionInfo(target_addr_t address, target_size_t size, bool -InstructionInfo::SetTo(target_addr_t address, target_size_t size, - instruction_type type, bool breakpointAllowed, +InstructionInfo::SetTo(target_addr_t address, target_addr_t targetAddress, + target_size_t size, instruction_type type, bool breakpointAllowed, const BString& disassembledLine) { fAddress = address; + fTargetAddress = targetAddress; fSize = size; fType = type; fBreakpointAllowed = breakpointAllowed; diff --git a/src/apps/debugger/arch/InstructionInfo.h b/src/apps/debugger/arch/InstructionInfo.h index 36c2fa2834..f130080fb6 100644 --- a/src/apps/debugger/arch/InstructionInfo.h +++ b/src/apps/debugger/arch/InstructionInfo.h @@ -20,16 +20,21 @@ class InstructionInfo { public: InstructionInfo(); InstructionInfo(target_addr_t address, + target_addr_t targetAddress, target_size_t size, instruction_type type, bool breakpointAllowed, const BString& disassembledLine); - bool SetTo(target_addr_t address, target_size_t size, + bool SetTo(target_addr_t address, + target_addr_t targetAddress, + target_size_t size, instruction_type type, bool breakpointAllowed, const BString& disassembledLine); target_addr_t Address() const { return fAddress; } + target_addr_t TargetAddress() const + { return fTargetAddress; } target_size_t Size() const { return fSize; } instruction_type Type() const { return fType; } bool IsBreakpointAllowed() const @@ -40,6 +45,7 @@ public: private: target_addr_t fAddress; + target_addr_t fTargetAddress; target_size_t fSize; instruction_type fType; bool fBreakpointAllowed; diff --git a/src/apps/debugger/arch/x86/ArchitectureX86.cpp b/src/apps/debugger/arch/x86/ArchitectureX86.cpp index dd19a9012d..5eccb064c8 100644 --- a/src/apps/debugger/arch/x86/ArchitectureX86.cpp +++ b/src/apps/debugger/arch/x86/ArchitectureX86.cpp @@ -596,6 +596,7 @@ ArchitectureX86::GetInstructionInfo(target_addr_t address, // disassemble the instruction BString line; target_addr_t instructionAddress; + target_addr_t targetAddress = 0; target_size_t instructionSize; bool breakpointAllowed; error = disassembler.GetNextInstruction(line, instructionAddress, @@ -607,17 +608,21 @@ ArchitectureX86::GetInstructionInfo(target_addr_t address, if (buffer[0] == 0xff && (buffer[1] & 0x34) == 0x10) { // absolute call with r/m32 instructionType = INSTRUCTION_TYPE_SUBROUTINE_CALL; + // TODO: retrieve target address (might be in a register) } else if (buffer[0] == 0xe8 && instructionSize == 5) { // relative call with rel32 -- don't categorize the call with 0 as // subroutine call, since it is only used to get the address of the GOT if (buffer[1] != 0 || buffer[2] != 0 || buffer[3] != 0 || buffer[4] != 0) { instructionType = INSTRUCTION_TYPE_SUBROUTINE_CALL; + int32 offset; + memcpy(&offset, &buffer[1], 4); + targetAddress = instructionAddress + instructionSize + offset; } } - if (!_info.SetTo(instructionAddress, instructionSize, instructionType, - breakpointAllowed, line)) { + if (!_info.SetTo(instructionAddress, targetAddress, instructionSize, + instructionType, breakpointAllowed, line)) { return B_NO_MEMORY; } diff --git a/src/apps/debugger/arch/x86_64/ArchitectureX8664.cpp b/src/apps/debugger/arch/x86_64/ArchitectureX8664.cpp index 21525627e7..f32b82055f 100644 --- a/src/apps/debugger/arch/x86_64/ArchitectureX8664.cpp +++ b/src/apps/debugger/arch/x86_64/ArchitectureX8664.cpp @@ -487,6 +487,7 @@ ArchitectureX8664::GetInstructionInfo(target_addr_t address, // disassemble the instruction BString line; target_addr_t instructionAddress; + target_addr_t targetAddress = 0; target_size_t instructionSize; bool breakpointAllowed; error = disassembler.GetNextInstruction(line, instructionAddress, @@ -508,8 +509,8 @@ ArchitectureX8664::GetInstructionInfo(target_addr_t address, } } - if (!_info.SetTo(instructionAddress, instructionSize, instructionType, - breakpointAllowed, line)) { + if (!_info.SetTo(instructionAddress, targetAddress, instructionSize, + instructionType, breakpointAllowed, line)) { return B_NO_MEMORY; }