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 "ArchitectureX86.h"
|
||||||
#include "ArchitectureX8664.h"
|
#include "ArchitectureX8664.h"
|
||||||
#include "AreaInfo.h"
|
#include "AreaInfo.h"
|
||||||
|
#include "AutoDeleter.h"
|
||||||
#include "CpuState.h"
|
#include "CpuState.h"
|
||||||
#include "DebugEvent.h"
|
#include "DebugEvent.h"
|
||||||
#include "ImageInfo.h"
|
#include "ImageInfo.h"
|
||||||
@@ -663,24 +664,37 @@ DebuggerInterface::GetThreadInfo(thread_id thread, ThreadInfo& info)
|
|||||||
status_t
|
status_t
|
||||||
DebuggerInterface::GetCpuState(thread_id thread, CpuState*& _state)
|
DebuggerInterface::GetCpuState(thread_id thread, CpuState*& _state)
|
||||||
{
|
{
|
||||||
DebugContextGetter contextGetter(fDebugContextPool);
|
debug_cpu_state debugState;
|
||||||
|
status_t error = _GetDebugCpuState(thread, debugState);
|
||||||
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)
|
if (error != B_OK)
|
||||||
return error;
|
return error;
|
||||||
if (reply.error != B_OK)
|
return fArchitecture->CreateCpuState(&debugState, sizeof(debug_cpu_state),
|
||||||
return reply.error;
|
_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;
|
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,
|
virtual status_t GetCpuState(thread_id thread,
|
||||||
CpuState*& _state);
|
CpuState*& _state);
|
||||||
// returns a reference to the caller
|
// returns a reference to the caller
|
||||||
|
virtual status_t SetCpuState(thread_id thread,
|
||||||
|
const CpuState* state);
|
||||||
|
|
||||||
// TeamMemory
|
// TeamMemory
|
||||||
virtual ssize_t ReadMemory(target_addr_t address, void* buffer,
|
virtual ssize_t ReadMemory(target_addr_t address, void* buffer,
|
||||||
@@ -94,6 +96,9 @@ private:
|
|||||||
status_t _GetNextSystemWatchEvent(DebugEvent*& _event,
|
status_t _GetNextSystemWatchEvent(DebugEvent*& _event,
|
||||||
BPrivate::KMessage& message);
|
BPrivate::KMessage& message);
|
||||||
|
|
||||||
|
status_t _GetDebugCpuState(thread_id thread,
|
||||||
|
debug_cpu_state& _state);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
team_id fTeamID;
|
team_id fTeamID;
|
||||||
port_id fDebuggerPort;
|
port_id fDebuggerPort;
|
||||||
|
|||||||
Reference in New Issue
Block a user