Minor refactoring.
- Factor out a _HasExitedFrame() function. - Reorder how/where return values are added a bit.
This commit is contained in:
@@ -52,6 +52,7 @@ ThreadHandler::ThreadHandler(Thread* thread, Worker* worker,
|
|||||||
fStepMode(STEP_NONE),
|
fStepMode(STEP_NONE),
|
||||||
fStepStatement(NULL),
|
fStepStatement(NULL),
|
||||||
fBreakpointAddress(0),
|
fBreakpointAddress(0),
|
||||||
|
fSteppedOverFunctionAddress(0),
|
||||||
fPreviousInstructionPointer(0),
|
fPreviousInstructionPointer(0),
|
||||||
fPreviousFrameAddress(0),
|
fPreviousFrameAddress(0),
|
||||||
fSingleStepping(false)
|
fSingleStepping(false)
|
||||||
@@ -487,17 +488,8 @@ ThreadHandler::_DoStepOver(CpuState* cpuState)
|
|||||||
if (_InstallTemporaryBreakpoint(info.Address() + info.Size()) != B_OK)
|
if (_InstallTemporaryBreakpoint(info.Address() + info.Size()) != B_OK)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ReturnValueInfo* returnInfo = new(std::nothrow) ReturnValueInfo(
|
fSteppedOverFunctionAddress = info.TargetAddress();
|
||||||
info.TargetAddress(), cpuState);
|
|
||||||
if (returnInfo == NULL)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
BReference<ReturnValueInfo> returnInfoReference(returnInfo, true);
|
|
||||||
|
|
||||||
if (fThread->AddReturnValueInfo(returnInfo) != B_OK)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
returnInfoReference.Detach();
|
|
||||||
_RunThread(cpuState->InstructionPointer());
|
_RunThread(cpuState->InstructionPointer());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -597,6 +589,25 @@ ThreadHandler::_HandleBreakpointHitStep(CpuState* cpuState)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fPreviousFrameAddress != 0) {
|
||||||
|
TRACE_CONTROL("STEP_OVER: called function address %#" B_PRIx64
|
||||||
|
", previous frame address: %#" B_PRIx64 ", frame address: %#"
|
||||||
|
B_PRIx64 ", adding return info\n", fSteppedOverFunctionAddress,
|
||||||
|
fPreviousFrameAddress, stackTrace->FrameAt(0)->FrameAddress());
|
||||||
|
ReturnValueInfo* returnInfo = new(std::nothrow) ReturnValueInfo(
|
||||||
|
fSteppedOverFunctionAddress, cpuState);
|
||||||
|
if (returnInfo == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
BReference<ReturnValueInfo> returnInfoReference(returnInfo, true);
|
||||||
|
|
||||||
|
if (fThread->AddReturnValueInfo(returnInfo) != B_OK)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
returnInfoReference.Detach();
|
||||||
|
fSteppedOverFunctionAddress = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// If we're still in the statement, we continue single-stepping,
|
// If we're still in the statement, we continue single-stepping,
|
||||||
// otherwise we're done.
|
// otherwise we're done.
|
||||||
if (fStepStatement->ContainsAddress(
|
if (fStepStatement->ContainsAddress(
|
||||||
@@ -618,6 +629,23 @@ ThreadHandler::_HandleBreakpointHitStep(CpuState* cpuState)
|
|||||||
// That's the return address, so we're done in theory,
|
// That's the return address, so we're done in theory,
|
||||||
// unless we're a recursive function. Check if we've actually
|
// unless we're a recursive function. Check if we've actually
|
||||||
// exited the previous stack frame or not
|
// exited the previous stack frame or not
|
||||||
|
if (!_HasExitedFrame(cpuState->StackFramePointer())) {
|
||||||
|
status_t error = _InstallTemporaryBreakpoint(
|
||||||
|
cpuState->InstructionPointer());
|
||||||
|
if (error != B_OK)
|
||||||
|
_StepFallback();
|
||||||
|
else
|
||||||
|
_RunThread(cpuState->InstructionPointer());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fPreviousFrameAddress == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
TRACE_CONTROL("ThreadHandler::_HandleBreakpointHitStep() - "
|
||||||
|
"frame pointer 0x%#" B_PRIx64 ", previous: 0x%#" B_PRIx64
|
||||||
|
" - step out adding return value\n", cpuState
|
||||||
|
->StackFramePointer(), fPreviousFrameAddress);
|
||||||
ReturnValueInfo* info = new(std::nothrow) ReturnValueInfo(
|
ReturnValueInfo* info = new(std::nothrow) ReturnValueInfo(
|
||||||
cpuState->InstructionPointer(), cpuState);
|
cpuState->InstructionPointer(), cpuState);
|
||||||
if (info == NULL)
|
if (info == NULL)
|
||||||
@@ -627,21 +655,6 @@ ThreadHandler::_HandleBreakpointHitStep(CpuState* cpuState)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
infoReference.Detach();
|
infoReference.Detach();
|
||||||
target_addr_t framePointer = cpuState->StackFramePointer();
|
|
||||||
bool hasExitedFrame = fDebuggerInterface->GetArchitecture()
|
|
||||||
->StackGrowthDirection() == STACK_GROWTH_DIRECTION_POSITIVE
|
|
||||||
? framePointer < fPreviousFrameAddress
|
|
||||||
: framePointer > fPreviousFrameAddress;
|
|
||||||
|
|
||||||
if (!hasExitedFrame) {
|
|
||||||
status_t error = _InstallTemporaryBreakpoint(
|
|
||||||
cpuState->InstructionPointer());
|
|
||||||
if (error != B_OK)
|
|
||||||
_StepFallback();
|
|
||||||
else
|
|
||||||
_RunThread(cpuState->InstructionPointer());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
fPreviousFrameAddress = 0;
|
fPreviousFrameAddress = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -709,10 +722,15 @@ ThreadHandler::_HandleSingleStepStep(CpuState* cpuState)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stackTrace != NULL && stackTrace->FrameAt(0)
|
|
||||||
->FrameAddress() != fPreviousFrameAddress) {
|
if (stackTrace != NULL) {
|
||||||
ReturnValueInfo* info = new(std::nothrow) ReturnValueInfo(
|
if (_HasExitedFrame(stackTrace->FrameAt(0)
|
||||||
cpuState->InstructionPointer(), cpuState);
|
->FrameAddress())) {
|
||||||
|
TRACE_CONTROL("ThreadHandler::_HandleSingleStepStep() "
|
||||||
|
" - adding return value for STEP_OVER\n");
|
||||||
|
ReturnValueInfo* info = new(std::nothrow)
|
||||||
|
ReturnValueInfo(cpuState->InstructionPointer(),
|
||||||
|
cpuState);
|
||||||
if (info == NULL)
|
if (info == NULL)
|
||||||
return false;
|
return false;
|
||||||
BReference<ReturnValueInfo> infoReference(info, true);
|
BReference<ReturnValueInfo> infoReference(info, true);
|
||||||
@@ -721,7 +739,7 @@ ThreadHandler::_HandleSingleStepStep(CpuState* cpuState)
|
|||||||
|
|
||||||
infoReference.Detach();
|
infoReference.Detach();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return _DoStepOver(cpuState);
|
return _DoStepOver(cpuState);
|
||||||
@@ -733,3 +751,13 @@ ThreadHandler::_HandleSingleStepStep(CpuState* cpuState)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
ThreadHandler::_HasExitedFrame(target_addr_t framePointer) const
|
||||||
|
{
|
||||||
|
return fDebuggerInterface->GetArchitecture()->StackGrowthDirection()
|
||||||
|
== STACK_GROWTH_DIRECTION_POSITIVE
|
||||||
|
? framePointer < fPreviousFrameAddress
|
||||||
|
: framePointer > fPreviousFrameAddress;
|
||||||
|
}
|
||||||
|
|||||||
@@ -91,6 +91,9 @@ private:
|
|||||||
bool _HandleBreakpointHitStep(CpuState* cpuState);
|
bool _HandleBreakpointHitStep(CpuState* cpuState);
|
||||||
bool _HandleSingleStepStep(CpuState* cpuState);
|
bool _HandleSingleStepStep(CpuState* cpuState);
|
||||||
|
|
||||||
|
bool _HasExitedFrame(target_addr_t framePointer)
|
||||||
|
const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Thread* fThread;
|
Thread* fThread;
|
||||||
Worker* fWorker;
|
Worker* fWorker;
|
||||||
@@ -99,6 +102,7 @@ private:
|
|||||||
uint32 fStepMode;
|
uint32 fStepMode;
|
||||||
Statement* fStepStatement;
|
Statement* fStepStatement;
|
||||||
target_addr_t fBreakpointAddress;
|
target_addr_t fBreakpointAddress;
|
||||||
|
target_addr_t fSteppedOverFunctionAddress;
|
||||||
target_addr_t fPreviousInstructionPointer;
|
target_addr_t fPreviousInstructionPointer;
|
||||||
target_addr_t fPreviousFrameAddress;
|
target_addr_t fPreviousFrameAddress;
|
||||||
bool fSingleStepping;
|
bool fSingleStepping;
|
||||||
|
|||||||
Reference in New Issue
Block a user