syscall log: support for selective syscall tracing

This commit is contained in:
2025-12-29 14:25:12 +01:00
committed by Matheus
parent 91e2430d91
commit 963d29fc90
9 changed files with 155 additions and 0 deletions
+8
View File
@@ -5,6 +5,9 @@
#ifdef SYSCALL_LOGGING
void arch_interrupt_disable();
void arch_interrupt_enable();
#define SYSCALL_COUNT 99
#define LOGSTR(x) arch_e9_puts(x)
@@ -225,6 +228,9 @@ __attribute__((no_caller_saved_registers)) void arch_syscall_log(int syscall, ui
thread_t *thread = current_thread();
proc_t *proc = thread->proc;
if (!(proc->flags & PROC_FLAG_SYSTRACE))
return;
snprintf(argbuff, 768, syscall < SYSCALL_COUNT ? args[syscall] : "N/A", a1, a2, a3, a4, a5, a6);
snprintf(printbuff, 1024, "\e[92msyscall: pid %d tid %d: %s: %s (%lu cached pages, %lu free pages)\n\e[0m", proc->pid, thread->tid, syscall < SYSCALL_COUNT ? name[syscall] : "invalid syscall", argbuff, vmmcache_cachedpages, freepagecount);
@@ -242,6 +248,8 @@ __attribute__((no_caller_saved_registers)) void arch_syscall_log_return(uint64_t
thread_t *thread = current_thread();
proc_t *proc = thread->proc;
if (!(proc->flags & PROC_FLAG_SYSTRACE))
return;
snprintf(printbuff, 1024, "\e[94msyscall return: pid %d tid %d: %lu %s (%lu cached pages, %lu free pages)\n\e[0m", proc->pid, thread->tid, ret, strerror(errno), vmmcache_cachedpages, freepagecount);
arch_interrupt_disable();