1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:47:34 +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:
Andreas Kling 2019-04-22 18:44:45 +02:00
parent 6693cfb26a
commit 5c68929aa1
12 changed files with 188 additions and 1 deletions

View file

@ -18,6 +18,7 @@ class FileDescriptor;
class PageDirectory;
class Region;
class VMObject;
class ProcessTracer;
void kgettimeofday(timeval&);
@ -175,6 +176,7 @@ public:
int sys$restore_signal_mask(dword mask);
int sys$create_thread(int(*)(void*), void*);
int sys$rename(const char* oldpath, const char* newpath);
int sys$systrace(pid_t);
int sys$create_shared_buffer(pid_t peer_pid, int, void** buffer);
void* sys$get_shared_buffer(int shared_buffer_id);
@ -194,6 +196,9 @@ public:
const Vector<Retained<Region>>& regions() const { return m_regions; }
void dump_regions();
ProcessTracer* tracer() { return m_tracer.ptr(); }
ProcessTracer& ensure_tracer();
dword m_ticks_in_user { 0 };
dword m_ticks_in_kernel { 0 };
@ -318,6 +323,8 @@ private:
unsigned m_syscall_count { 0 };
RetainPtr<ProcessTracer> m_tracer;
Lock m_big_lock;
};