Debugger: Cleanups.

ResolvePICFunctionAddress() needs to restore the CPUState object back
to how it was when it was originally passed in. Fixes various issues
that would occur as a result.
This commit is contained in:
Rene Gollent
2013-07-28 18:59:36 -04:00
parent aef9e4fce2
commit f270c76a2e
2 changed files with 5 additions and 5 deletions
@@ -605,7 +605,6 @@ ArchitectureX86::ResolvePICFunctionAddress(target_addr_t instructionAddress,
// will actually have taken us to its corresponding PLT slot.
// in such a case, look at the disassembled jump to determine
// where to find the actual function address.
state->SetInstructionPointer(instructionAddress);
InstructionInfo info;
if (GetInstructionInfo(instructionAddress, info, state) != B_OK) {
return B_BAD_VALUE;
@@ -625,6 +625,7 @@ status_t
ArchitectureX8664::ResolvePICFunctionAddress(target_addr_t instructionAddress,
CpuState* state, target_addr_t& _targetAddress)
{
target_addr_t previousIP = state->InstructionPointer();
// if the function in question is position-independent, the call
// will actually have taken us to its corresponding PLT slot.
// in such a case, look at the disassembled jump to determine
@@ -638,8 +639,10 @@ ArchitectureX8664::ResolvePICFunctionAddress(target_addr_t instructionAddress,
// after this instruction (where it would be during actual
// execution), and recalculate the target address of the jump
state->SetInstructionPointer(info.Address() + info.Size());
if (GetInstructionInfo(info.Address(), info, state) != B_OK)
return B_BAD_VALUE;
status_t result = GetInstructionInfo(info.Address(), info, state);
state->SetInstructionPointer(previousIP);
if (result != B_OK)
return result;
target_addr_t subroutineAddress;
ssize_t bytesRead = fTeamMemory->ReadMemory(info.TargetAddress(),
@@ -650,8 +653,6 @@ ArchitectureX8664::ResolvePICFunctionAddress(target_addr_t instructionAddress,
_targetAddress = subroutineAddress;
return B_OK;
return B_BAD_VALUE;
}