Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Extend DebuggerInterface.

- Factor out an _GetDebugCpuState() call to share between
{Get,Set}CpuState().

- Add SetCpuState() which allows to update the state of a given thread.
  • Loading branch information...
commit c21b8ec70330b207dac1d4e7041a0ed0b0b6f2c7 1 parent 93b54e5
@anevilyak anevilyak authored
View
63 src/apps/debugger/debugger_interface/DebuggerInterface.cpp
@@ -23,6 +23,7 @@
#include "ArchitectureX86.h"
#include "ArchitectureX8664.h"
#include "AreaInfo.h"
+#include "AutoDeleter.h"
#include "CpuState.h"
#include "DebugEvent.h"
#include "ImageInfo.h"
@@ -663,24 +664,37 @@ DebuggerInterface::GetThreadInfo(thread_id thread, ThreadInfo& info)
status_t
DebuggerInterface::GetCpuState(thread_id thread, CpuState*& _state)
{
- DebugContextGetter contextGetter(fDebugContextPool);
+ debug_cpu_state debugState;
+ status_t error = _GetDebugCpuState(thread, debugState);
+ if (error != B_OK)
+ return error;
+ return fArchitecture->CreateCpuState(&debugState, sizeof(debug_cpu_state),
+ _state);
+}
- debug_nub_get_cpu_state message;
- message.reply_port = contextGetter.Context()->reply_port;
- message.thread = thread;
- debug_nub_get_cpu_state_reply reply;
+status_t
+DebuggerInterface::SetCpuState(thread_id thread, const CpuState* state)
+{
+ debug_cpu_state debugState;
+ status_t error = _GetDebugCpuState(thread, debugState);
+ if (error != B_OK)
+ return error;
- status_t error = send_debug_message(contextGetter.Context(),
- B_DEBUG_MESSAGE_GET_CPU_STATE, &message, sizeof(message), &reply,
- sizeof(reply));
+ DebugContextGetter contextGetter(fDebugContextPool);
+
+ error = state->UpdateDebugState(&debugState, sizeof(debugState));
if (error != B_OK)
return error;
- if (reply.error != B_OK)
- return reply.error;
- return fArchitecture->CreateCpuState(&reply.cpu_state,
- sizeof(debug_cpu_state), _state);
+ debug_nub_set_cpu_state message;
+ message.thread = thread;
+
+ memcpy(&message.cpu_state, &debugState, sizeof(debugState));
+
+ return send_debug_message(contextGetter.Context(),
+ B_DEBUG_MESSAGE_SET_CPU_STATE, &message, sizeof(message), NULL,
+ 0);
}
@@ -883,3 +897,28 @@ DebuggerInterface::_GetNextSystemWatchEvent(DebugEvent*& _event,
return error;
}
+
+
+status_t
+DebuggerInterface::_GetDebugCpuState(thread_id thread, debug_cpu_state& _state)
+{
+ DebugContextGetter contextGetter(fDebugContextPool);
+
+ debug_nub_get_cpu_state message;
+ message.reply_port = contextGetter.Context()->reply_port;
+ message.thread = thread;
+
+ debug_nub_get_cpu_state_reply reply;
+
+ status_t error = send_debug_message(contextGetter.Context(),
+ B_DEBUG_MESSAGE_GET_CPU_STATE, &message, sizeof(message), &reply,
+ sizeof(reply));
+ if (error != B_OK)
+ return error;
+ if (reply.error != B_OK)
+ return reply.error;
+
+ memcpy(&_state, &reply.cpu_state, sizeof(debug_cpu_state));
+
+ return B_OK;
+}
View
5 src/apps/debugger/debugger_interface/DebuggerInterface.h
@@ -74,6 +74,8 @@ class DebuggerInterface : public TeamMemory {
virtual status_t GetCpuState(thread_id thread,
CpuState*& _state);
// returns a reference to the caller
+ virtual status_t SetCpuState(thread_id thread,
+ const CpuState* state);
// TeamMemory
virtual ssize_t ReadMemory(target_addr_t address, void* buffer,
@@ -94,6 +96,9 @@ class DebuggerInterface : public TeamMemory {
status_t _GetNextSystemWatchEvent(DebugEvent*& _event,
BPrivate::KMessage& message);
+ status_t _GetDebugCpuState(thread_id thread,
+ debug_cpu_state& _state);
+
private:
team_id fTeamID;
port_id fDebuggerPort;
Please sign in to comment.
Something went wrong with that request. Please try again.