diff --git a/headers/os/kernel/debugger.h b/headers/os/kernel/debugger.h index c443b3977a..770d0b7c00 100644 --- a/headers/os/kernel/debugger.h +++ b/headers/os/kernel/debugger.h @@ -487,7 +487,7 @@ typedef struct { typedef struct { debug_origin origin; uint32 syscall; // the syscall number - uint32 args[16]; // syscall arguments + uint8 args[128]; // syscall arguments } debug_pre_syscall; // B_DEBUGGER_MESSAGE_POST_SYSCALL @@ -498,7 +498,7 @@ typedef struct { bigtime_t end_time; // time of syscall completion uint64 return_value; // the syscall's return value uint32 syscall; // the syscall number - uint32 args[16]; // syscall arguments + uint8 args[128]; // syscall arguments } debug_post_syscall; // B_DEBUGGER_MESSAGE_SIGNAL_RECEIVED diff --git a/src/apps/debugger/controllers/TeamDebugger.cpp b/src/apps/debugger/controllers/TeamDebugger.cpp index 8a0b42d20a..7885590568 100644 --- a/src/apps/debugger/controllers/TeamDebugger.cpp +++ b/src/apps/debugger/controllers/TeamDebugger.cpp @@ -20,6 +20,7 @@ #include "debug_utils.h" #include "syscall_numbers.h" +#include "Architecture.h" #include "BreakpointManager.h" #include "BreakpointSetting.h" #include "CpuState.h" @@ -1415,16 +1416,37 @@ 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]; + int32 fd; + target_addr_t address; + size_t size; + // TODO: decoding the syscall arguments should probably be + // factored out into an Architecture method of its own, since + // there's no guarantee the target architecture has the same + // endianness as the host. This could re-use the syscall + // argument parser that strace uses, though that would need to + // be adapted to handle the aforementioned endian differences. + // This works for x86{-64} for now though. + if (fTeam->GetArchitecture()->AddressSize() == 4) { + const uint32* args = (const uint32*)info.Arguments(); + fd = args[0]; + address = args[3]; + size = args[4]; + } else { + const uint64* args = (const uint64*)info.Arguments(); + fd = args[0]; + address = args[2]; + size = args[3]; + } + if (fd == 1 || fd == 2) { BString data; + ssize_t result = fDebuggerInterface->ReadMemoryString( - (target_addr_t)args[3], (size_t)args[4], data); + address, size, data); if (result >= 0) fTeam->NotifyConsoleOutputReceived(fd, data); } diff --git a/src/apps/debugger/model/SyscallInfo.cpp b/src/apps/debugger/model/SyscallInfo.cpp index 21b615e9e0..e6b6ea47dc 100644 --- a/src/apps/debugger/model/SyscallInfo.cpp +++ b/src/apps/debugger/model/SyscallInfo.cpp @@ -31,7 +31,7 @@ SyscallInfo::SyscallInfo(const SyscallInfo& other) SyscallInfo::SyscallInfo(bigtime_t startTime, bigtime_t endTime, - uint64 returnValue, uint32 syscall, const uint32* args) + uint64 returnValue, uint32 syscall, const uint8* args) : fStartTime(startTime), fEndTime(endTime), @@ -44,7 +44,7 @@ SyscallInfo::SyscallInfo(bigtime_t startTime, bigtime_t endTime, void SyscallInfo::SetTo(bigtime_t startTime, bigtime_t endTime, uint64 returnValue, - uint32 syscall, const uint32* args) + uint32 syscall, const uint8* args) { fStartTime = startTime; fEndTime = endTime; diff --git a/src/apps/debugger/model/SyscallInfo.h b/src/apps/debugger/model/SyscallInfo.h index c2609c84a6..4bb597f037 100644 --- a/src/apps/debugger/model/SyscallInfo.h +++ b/src/apps/debugger/model/SyscallInfo.h @@ -16,27 +16,27 @@ public: bigtime_t endTime, uint64 returnValue, uint32 syscall, - const uint32* args); + const uint8* args); void SetTo(bigtime_t startTime, bigtime_t endTime, uint64 returnValue, uint32 syscall, - const uint32* args); + const uint8* args); bigtime_t StartTime() const { return fStartTime; } bigtime_t EndTime() const { return fEndTime; } uint64 ReturnValue() const { return fReturnValue; } uint32 Syscall() const { return fSyscall; } - const uint32* Arguments() const { return fArguments; } + const uint8* Arguments() const { return fArguments; } private: bigtime_t fStartTime; bigtime_t fEndTime; uint64 fReturnValue; uint32 fSyscall; - uint32 fArguments[16]; + uint8 fArguments[128]; };