mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 19:18:12 +00:00
Kernel: Add a systrace() syscall and implement /bin/strace using it.
Calling systrace(pid) gives you a file descriptor with a stream of the syscalls made by a peer process. The process must be owned by the same UID who calls systrace(). :^)
This commit is contained in:
parent
6693cfb26a
commit
5c68929aa1
12 changed files with 188 additions and 1 deletions
|
@ -3,6 +3,7 @@
|
|||
#include "Syscall.h"
|
||||
#include "Console.h"
|
||||
#include "Scheduler.h"
|
||||
#include <Kernel/ProcessTracer.h>
|
||||
|
||||
extern "C" void syscall_trap_entry(RegisterDump&);
|
||||
extern "C" void syscall_trap_handler();
|
||||
|
@ -251,6 +252,8 @@ static dword handle(RegisterDump& regs, dword function, dword arg1, dword arg2,
|
|||
return current->process().sys$shm_unlink((const char*)arg1);
|
||||
case Syscall::SC_ftruncate:
|
||||
return current->process().sys$ftruncate((int)arg1, (off_t)arg2);
|
||||
case Syscall::SC_systrace:
|
||||
return current->process().sys$systrace((pid_t)arg1);
|
||||
default:
|
||||
kprintf("<%u> int0x82: Unknown function %u requested {%x, %x, %x}\n", current->process().pid(), function, arg1, arg2, arg3);
|
||||
break;
|
||||
|
@ -268,6 +271,8 @@ void syscall_trap_entry(RegisterDump& regs)
|
|||
dword arg2 = regs.ecx;
|
||||
dword arg3 = regs.ebx;
|
||||
regs.eax = Syscall::handle(regs, function, arg1, arg2, arg3);
|
||||
if (auto* tracer = current->process().tracer())
|
||||
tracer->did_syscall(function, arg1, arg2, arg3, regs.eax);
|
||||
current->process().big_lock().unlock();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue