diff options
author | dzwdz | 2022-07-01 20:36:59 +0200 |
---|---|---|
committer | dzwdz | 2022-07-01 20:36:59 +0200 |
commit | 58c44c9a8feb8c258dcd85209149c16342995ec7 (patch) | |
tree | f3a3d61291beada2c3f9e7c773d42c202054263c /src/kernel/syscalls.c | |
parent | 5b9f1ea3911a6e972263d00ea2ec04a56f56166d (diff) |
kernel: add the debug_klog syscall for tracking down process ids
Diffstat (limited to 'src/kernel/syscalls.c')
-rw-r--r-- | src/kernel/syscalls.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/kernel/syscalls.c b/src/kernel/syscalls.c index 7040f6b..3cfc0ef 100644 --- a/src/kernel/syscalls.c +++ b/src/kernel/syscalls.c @@ -289,6 +289,14 @@ ret: // the macro is too stupid to handle returning pointers return addr; } +void _syscall_debug_klog(const void __user *buf, size_t len) { + static char kbuf[256]; + if (len >= sizeof(kbuf)) len = sizeof(kbuf) - 1; + virt_cpy_from(process_current->pages, kbuf, buf, len); + kbuf[len] = '\0'; + kprintf("[klog] %x\t%s\n", process_current->id, kbuf); +} + int _syscall(int num, int a, int b, int c, int d) { switch (num) { case _SYSCALL_EXIT: @@ -324,6 +332,9 @@ int _syscall(int num, int a, int b, int c, int d) { case _SYSCALL_MEMFLAG: _syscall_memflag((userptr_t)a, b, c); break; + case _SYSCALL_DEBUG_KLOG: + _syscall_debug_klog((userptr_t)a, b); + break; default: kprintf("unknown syscall "); panic_unimplemented(); // TODO fail gracefully |