From 93b54e54a4cf762415ff5112d84fbb580e5901bf Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Thu, 16 May 2013 21:16:45 -0400 Subject: [PATCH] Add MSG_THREAD_SET_ADDRESS and implement handling. --- src/apps/debugger/MessageCodes.h | 1 + .../debugger/controllers/TeamDebugger.cpp | 1 + .../debugger/controllers/ThreadHandler.cpp | 25 +++++++++++++++++++ src/apps/debugger/controllers/ThreadHandler.h | 3 +++ 4 files changed, 30 insertions(+) diff --git a/src/apps/debugger/MessageCodes.h b/src/apps/debugger/MessageCodes.h index f35929fde1..b5ca5e3e25 100644 --- a/src/apps/debugger/MessageCodes.h +++ b/src/apps/debugger/MessageCodes.h @@ -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', diff --git a/src/apps/debugger/controllers/TeamDebugger.cpp b/src/apps/debugger/controllers/TeamDebugger.cpp index 1f3e3c0a81..63d7ba5ee3 100644 --- a/src/apps/debugger/controllers/TeamDebugger.cpp +++ b/src/apps/debugger/controllers/TeamDebugger.cpp @@ -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: diff --git a/src/apps/debugger/controllers/ThreadHandler.cpp b/src/apps/debugger/controllers/ThreadHandler.cpp index d5fe3a9d1c..2a84a5b444 100644 --- a/src/apps/debugger/controllers/ThreadHandler.cpp +++ b/src/apps/debugger/controllers/ThreadHandler.cpp @@ -220,6 +220,11 @@ ThreadHandler::HandleThreadAction(uint32 action, target_addr_t address) BReference cpuStateReference(cpuState); BReference 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 stateReference(newState, true); + + newState->SetInstructionPointer(address); + if (fDebuggerInterface->SetCpuState(fThread->ID(), newState) != B_OK) + return false; + + AutoLocker locker(fThread->GetTeam()); + fThread->SetStackTrace(NULL); + fThread->SetCpuState(newState); + + return true; +} + + void ThreadHandler::_SetThreadState(uint32 state, CpuState* cpuState, uint32 stoppedReason, const BString& stoppedReasonInfo) diff --git a/src/apps/debugger/controllers/ThreadHandler.h b/src/apps/debugger/controllers/ThreadHandler.h index e1c6b1c322..3a79f601c5 100644 --- a/src/apps/debugger/controllers/ThreadHandler.h +++ b/src/apps/debugger/controllers/ThreadHandler.h @@ -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);