Kernel: Add macro to dump all syscalls and their return values
This commit is contained in:
parent
4599e1dec5
commit
da3b30cd94
|
@ -7,6 +7,8 @@
|
|||
|
||||
#include <termios.h>
|
||||
|
||||
#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());
|
||||
|
|
Loading…
Reference in New Issue