TeamDebugger: Implement post syscall event handling.

We now watch for file write syscalls in the target team. If they
constitute a write to either stdout or stderr, we attempt to capture the
output, and notify interested listeners accordingly.
This commit is contained in:
Rene Gollent
2013-06-28 18:49:32 -04:00
parent d692e338d4
commit fe448830c9
3 changed files with 52 additions and 1 deletions
+41 -1
View File
@@ -18,6 +18,7 @@
#include <AutoLocker.h>
#include "debug_utils.h"
#include "syscall_numbers.h"
#include "BreakpointManager.h"
#include "BreakpointSetting.h"
@@ -1261,8 +1262,16 @@ TeamDebugger::_HandleDebuggerMessage(DebugEvent* event)
handled = _HandleImageDeleted(imageEvent);
break;
}
case B_DEBUGGER_MESSAGE_PRE_SYSCALL:
case B_DEBUGGER_MESSAGE_POST_SYSCALL:
{
PostSyscallEvent* postSyscallEvent
= dynamic_cast<PostSyscallEvent*>(event);
TRACE_EVENTS("B_DEBUGGER_MESSAGE_POST_SYSCALL: syscall: %"
B_PRIu32 "\n", postSyscallEvent->GetSyscallInfo().Syscall());
handled = _HandlePostSyscall(postSyscallEvent);
break;
}
case B_DEBUGGER_MESSAGE_PRE_SYSCALL:
case B_DEBUGGER_MESSAGE_SIGNAL_RECEIVED:
case B_DEBUGGER_MESSAGE_PROFILER_UPDATE:
case B_DEBUGGER_MESSAGE_HANDED_OVER:
@@ -1402,6 +1411,37 @@ TeamDebugger::_HandleImageDeleted(ImageDeletedEvent* event)
}
bool
TeamDebugger::_HandlePostSyscall(PostSyscallEvent* event)
{
const SyscallInfo& info = event->GetSyscallInfo();
const uint32* args = info.Arguments();
switch (info.Syscall()) {
case SYSCALL_WRITE:
{
int32 fd = (int32)args[0];
if (fd == 1 || fd == 2) {
BString data;
ssize_t result = fDebuggerInterface->ReadMemoryString(
(target_addr_t)args[3], (size_t)args[4], data);
if (result >= 0)
fTeam->NotifyConsoleOutputReceived(fd, data);
}
break;
}
case SYSCALL_WRITEV:
{
// TODO: handle
}
default:
break;
}
return false;
}
void
TeamDebugger::_HandleImageDebugInfoChanged(image_id imageID)
{