Skip to content

Commit

Permalink
✨ log syscall num if unknown
Browse files Browse the repository at this point in the history
  • Loading branch information
froz42 committed Oct 11, 2023
1 parent abcbd03 commit 9ccb472
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions srcs/syscall/syscall_get_description.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "syscall_32.h"
#include "syscall_64.h"
#include <ft_printf.h>
#include <syscall_strace.h>

/**
Expand All @@ -10,11 +11,15 @@
*/
const syscall_description_t *syscall_get_description(uint64_t syscall_no, register_type_t type)
{
static const syscall_description_t default_syscall = {
"unknown", INT, {NONE, NONE, NONE, NONE, NONE, NONE}};
static char default_syscall_name[32] = {0};
static syscall_description_t default_syscall = {
default_syscall_name, INT, {NONE, NONE, NONE, NONE, NONE, NONE}};
// check if in bounds
if (syscall_no >= ELEM_COUNT(x86_64_syscalls))
{
ft_snprintf(default_syscall_name, sizeof(default_syscall_name), "unknown_%llu", syscall_no);
return &default_syscall;
}
if (type == X86_64)
return &x86_64_syscalls[syscall_no];
return &x86_32_syscalls[syscall_no];
Expand Down

0 comments on commit 9ccb472

Please sign in to comment.