From da3b30cd945d111e6e2adb8ce18586aefb83a74e Mon Sep 17 00:00:00 2001 From: Bananymous Date: Thu, 1 Aug 2024 17:20:20 +0300 Subject: [PATCH] Kernel: Add macro to dump all syscalls and their return values --- kernel/kernel/Syscall.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/kernel/kernel/Syscall.cpp b/kernel/kernel/Syscall.cpp index ab979b68..9ae400ce 100644 --- a/kernel/kernel/Syscall.cpp +++ b/kernel/kernel/Syscall.cpp @@ -7,6 +7,8 @@ #include +#define DUMP_ALL_SYSCALLS 0 + namespace Kernel { @@ -28,6 +30,12 @@ namespace Kernel #undef O }; + static constexpr const char* s_syscall_names[] { +#define O(enum, name) #enum, + __SYSCALL_LIST(O) +#undef O + }; + extern "C" long cpp_syscall_handler(int syscall, uintptr_t arg1, uintptr_t arg2, uintptr_t arg3, uintptr_t arg4, uintptr_t arg5, InterruptStack* interrupt_stack) { ASSERT(GDT::is_user_segment(interrupt_stack->cs)); @@ -46,7 +54,13 @@ namespace Kernel asm volatile("cli"); if (ret.is_error() && ret.error().get_error_code() == ENOTSUP) - dprintln("ENOTSUP {}", syscall); + dprintln("{}: ENOTSUP", s_syscall_names[syscall]); +#if DUMP_ALL_SYSCALLS + else if (ret.is_error()) + dprintln("{}: {}", s_syscall_names[syscall], ret.error()); + else + dprintln("{}: {}", s_syscall_names[syscall], ret.value()); +#endif if (ret.is_error() && ret.error().is_kernel_error()) Kernel::panic("Kernel error while returning to userspace {}", ret.error());