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.
This commit is contained in:
@@ -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_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));
|
||||
debug_cpu_state debugState;
|
||||
status_t error = _GetDebugCpuState(thread, debugState);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
if (reply.error != B_OK)
|
||||
return reply.error;
|
||||
return fArchitecture->CreateCpuState(&debugState, sizeof(debug_cpu_state),
|
||||
_state);
|
||||
}
|
||||
|
||||
return fArchitecture->CreateCpuState(&reply.cpu_state,
|
||||
sizeof(debug_cpu_state), _state);
|
||||
|
||||
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;
|
||||
|
||||
DebugContextGetter contextGetter(fDebugContextPool);
|
||||
|
||||
error = state->UpdateDebugState(&debugState, sizeof(debugState));
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -74,6 +74,8 @@ public:
|
||||
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 @@ private:
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user