Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Extend InstructionInfo for subroutines.

- InstructionInfo now also stores the destination address of subroutine
  call instructions.
- Adjust callers.
  • Loading branch information...
commit 84ea02a0f4e9cc454dc587d7920d18bf979c19b1 1 parent 9ede3c0
Rene Gollent anevilyak authored
10 src/apps/debugger/arch/InstructionInfo.cpp
View
@@ -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;
8 src/apps/debugger/arch/InstructionInfo.h
View
@@ -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 @@ class InstructionInfo {
private:
target_addr_t fAddress;
+ target_addr_t fTargetAddress;
target_size_t fSize;
instruction_type fType;
bool fBreakpointAllowed;
9 src/apps/debugger/arch/x86/ArchitectureX86.cpp
View
@@ -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;
}
5 src/apps/debugger/arch/x86_64/ArchitectureX8664.cpp
View
@@ -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;
}
Please sign in to comment.
Something went wrong with that request. Please try again.