Debugger: Add memory write support.

- Implements various support classes and functions that will be
  needed in order to marshal requests to write to memory in the
  target team.
This commit is contained in:
Rene Gollent
2015-05-23 16:54:16 -04:00
parent 5474c67270
commit 68e78ff841
10 changed files with 196 additions and 7 deletions
+51 -1
View File
@@ -1,6 +1,6 @@
/*
* Copyright 2009-2012, Ingo Weinhold, [email protected].
* Copyright 2010-2014, Rene Gollent, [email protected].
* Copyright 2010-2015, Rene Gollent, [email protected].
* Distributed under the terms of the MIT License.
*/
@@ -743,6 +743,24 @@ TeamDebugger::MessageReceived(BMessage* message)
break;
}
case MSG_WRITE_TARGET_MEMORY:
{
target_addr_t address;
if (message->FindUInt64("address", &address) != B_OK)
break;
void* data;
if (message->FindPointer("data", &data) != B_OK)
break;
target_size_t size;
if (message->FindUInt64("size", &size) != B_OK)
break;
_HandleWriteMemory(address, data, size);
break;
}
case MSG_EVALUATE_EXPRESSION:
{
SourceLanguage* language;
@@ -1158,6 +1176,18 @@ TeamDebugger::InspectRequested(target_addr_t address,
}
void
TeamDebugger::MemoryWriteRequested(target_addr_t address, const void* data,
target_size_t size)
{
BMessage message(MSG_WRITE_TARGET_MEMORY);
message.AddUInt64("address", address);
message.AddPointer("data", data);
message.AddUInt64("size", size);
PostMessage(&message);
}
void
TeamDebugger::ExpressionEvaluationRequested(SourceLanguage* language,
ExpressionInfo* info, StackFrame* frame, ::Thread* thread)
@@ -2057,6 +2087,26 @@ TeamDebugger::_HandleInspectAddress(target_addr_t address,
}
void
TeamDebugger::_HandleWriteMemory(target_addr_t address, void* data,
target_size_t size)
{
TRACE_CONTROL("TeamDebugger::_HandleWriteTargetMemory(%" B_PRIx64 ", %p, "
"%" B_PRIu64 ")\n", address, data, size);
AutoLocker< ::Team> teamLocker(fTeam);
TeamMemory* memory = fTeam->GetTeamMemory();
// schedule the job
status_t result;
if ((result = fWorker->ScheduleJob(
new(std::nothrow) WriteMemoryJob(fTeam, memory, address, data, size),
this)) != B_OK) {
_NotifyUser("Write Memory", "Failed to write memory data: %s",
strerror(result));
}
}
void
TeamDebugger::_HandleEvaluateExpression(SourceLanguage* language,
ExpressionInfo* info, StackFrame* frame, ::Thread* thread)