Add MSG_THREAD_SET_ADDRESS and implement handling.

This commit is contained in:
Rene Gollent
2013-05-16 22:22:47 -04:00
parent fe3e87c2a8
commit 93b54e54a4
4 changed files with 30 additions and 0 deletions
+1
View File
@@ -8,6 +8,7 @@
enum {
MSG_THREAD_RUN = 'run_',
MSG_THREAD_SET_ADDRESS = 'sead',
MSG_THREAD_STOP = 'stop',
MSG_THREAD_STEP_OVER = 'stov',
MSG_THREAD_STEP_INTO = 'stin',
@@ -530,6 +530,7 @@ TeamDebugger::MessageReceived(BMessage* message)
{
switch (message->what) {
case MSG_THREAD_RUN:
case MSG_THREAD_SET_ADDRESS:
case MSG_THREAD_STOP:
case MSG_THREAD_STEP_OVER:
case MSG_THREAD_STEP_INTO:
@@ -220,6 +220,11 @@ ThreadHandler::HandleThreadAction(uint32 action, target_addr_t address)
BReference<CpuState> cpuStateReference(cpuState);
BReference<StackTrace> stackTraceReference(stackTrace);
if (action == MSG_THREAD_SET_ADDRESS) {
_HandleSetAddress(cpuState, address);
return;
}
// When continuing the thread update thread state before actually issuing
// the command, since we need to unlock.
if (action != MSG_THREAD_STOP) {
@@ -412,6 +417,26 @@ ThreadHandler::_HandleThreadStopped(CpuState* cpuState, uint32 stoppedReason,
}
bool
ThreadHandler::_HandleSetAddress(CpuState* state, target_addr_t address)
{
CpuState* newState = NULL;
if (state->Clone(newState) != B_OK)
return false;
BReference<CpuState> stateReference(newState, true);
newState->SetInstructionPointer(address);
if (fDebuggerInterface->SetCpuState(fThread->ID(), newState) != B_OK)
return false;
AutoLocker<Team> locker(fThread->GetTeam());
fThread->SetStackTrace(NULL);
fThread->SetCpuState(newState);
return true;
}
void
ThreadHandler::_SetThreadState(uint32 state, CpuState* cpuState,
uint32 stoppedReason, const BString& stoppedReasonInfo)
@@ -70,6 +70,9 @@ private:
const BString& stoppedReasonInfo
= BString());
bool _HandleSetAddress(CpuState* cpuState,
target_addr_t address);
void _SetThreadState(uint32 state,
CpuState* cpuState, uint32 stoppedReason,
const BString& stoppedReasonInfo);