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-27 19:40:41 -04:00
parent d692e338d4
commit fe448830c9
3 changed files with 52 additions and 1 deletions

View File

@ -4,6 +4,10 @@ CCFLAGS += -Werror ;
C++FLAGS += -Werror ;
UseHeaders [ FDirName $(HAIKU_TOP) headers compatibility bsd ] : true ;
# for syscall_numbers.h
UseHeaders [ FDirName $(HAIKU_COMMON_DEBUG_OBJECT_DIR) system kernel ] ;
UsePrivateHeaders app debug interface kernel shared libroot ;
UsePrivateSystemHeaders ;
@ -58,6 +62,11 @@ SourceHdrs
: [ FDirName $(SUBDIR) dwarf ]
;
# since syscall_numbers.h is generated on the fly, we need to explicitly
# let Jam know about the dependency.
Includes [ FGristFiles TeamDebugger.cpp ]
: <syscalls>syscall_numbers.h ;
Application Debugger :
Debugger.cpp

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)
{

View File

@ -141,6 +141,8 @@ private:
ImageCreatedEvent* event);
bool _HandleImageDeleted(
ImageDeletedEvent* event);
bool _HandlePostSyscall(
PostSyscallEvent* event);
void _HandleImageDebugInfoChanged(image_id imageID);
void _HandleImageFileChanged(image_id imageID);