mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-01 23:18:21 +00:00
remake the syscall logger
This commit is contained in:
+39
-11
@@ -100,6 +100,30 @@ func_table:
|
|||||||
section .text
|
section .text
|
||||||
global asm_syscall_entry
|
global asm_syscall_entry
|
||||||
|
|
||||||
|
%macro abi_save 0
|
||||||
|
push rax
|
||||||
|
push rdi
|
||||||
|
push rsi
|
||||||
|
push rdx
|
||||||
|
push rcx
|
||||||
|
push r8
|
||||||
|
push r9
|
||||||
|
push r10
|
||||||
|
push r11
|
||||||
|
%endmacro
|
||||||
|
|
||||||
|
%macro abi_restore 0
|
||||||
|
pop r11
|
||||||
|
pop r10
|
||||||
|
pop r9
|
||||||
|
pop r8
|
||||||
|
pop rcx
|
||||||
|
pop rdx
|
||||||
|
pop rsi
|
||||||
|
pop rdi
|
||||||
|
pop rax
|
||||||
|
%endmacro
|
||||||
|
|
||||||
; the registers for the system call are:
|
; the registers for the system call are:
|
||||||
; RETURN:
|
; RETURN:
|
||||||
; rax -> ret value
|
; rax -> ret value
|
||||||
@@ -173,28 +197,32 @@ asm_syscall_entry:
|
|||||||
|
|
||||||
.do_syscall:
|
.do_syscall:
|
||||||
|
|
||||||
; DEBUG STUFF
|
abi_save
|
||||||
;mov r15,rax
|
|
||||||
; END DEBUG STUFF
|
push rax
|
||||||
|
|
||||||
|
extern syscalllogger
|
||||||
|
call syscalllogger
|
||||||
|
|
||||||
|
add rsp,8
|
||||||
|
|
||||||
|
abi_restore
|
||||||
|
|
||||||
call [func_table + rax * 8]
|
call [func_table + rax * 8]
|
||||||
|
|
||||||
|
|
||||||
push rax
|
push rax
|
||||||
push rdx
|
push rdx
|
||||||
|
|
||||||
; DEBUG STUFF
|
mov rdi, rax
|
||||||
|
mov rsi, rdx
|
||||||
|
|
||||||
;mov rsi,rdx
|
extern syscalllogger_return
|
||||||
;mov rdi,r15
|
call syscalllogger_return
|
||||||
;extern syscalllogger
|
|
||||||
;call syscalllogger
|
|
||||||
|
|
||||||
extern postsyscall
|
extern postsyscall
|
||||||
call postsyscall
|
call postsyscall
|
||||||
|
|
||||||
|
|
||||||
; DEBUG STUFF END
|
|
||||||
|
|
||||||
pop rdx
|
pop rdx
|
||||||
pop rax
|
pop rax
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
#include <arch/cls.h>
|
||||||
|
#include <kernel/sched.h>
|
||||||
|
|
||||||
static char* syscalls[] = {
|
static char* syscalls[] = {
|
||||||
"syscall_libc_log",
|
"syscall_libc_log",
|
||||||
@@ -53,18 +55,26 @@ static char* syscalls[] = {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void syscalllogger(uint64_t num, uint64_t error){
|
void syscalllogger(uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5, uint64_t arg6, uint64_t num){
|
||||||
|
|
||||||
e9_puts("syscall: ");
|
thread_t* thread = arch_getcls()->thread;
|
||||||
e9_puts(syscalls[num]);
|
proc_t* proc = thread->proc;
|
||||||
e9_putc(':');
|
|
||||||
char err[] = {'0', '0', '0', NULL};
|
char tmp[100];
|
||||||
err[2] += error % 10;
|
|
||||||
error /= 10;
|
sprintf(tmp, "PID %d TID %d: %s (%d): %p %p %p %p %p %p\n", proc->pid, thread->tid, syscalls[num], num, arg1, arg2, arg3, arg4, arg5, arg6);
|
||||||
err[1] += error % 10;
|
|
||||||
error /= 10;
|
e9_puts(tmp);
|
||||||
err[0] += error % 10;
|
|
||||||
e9_puts(err);
|
|
||||||
e9_putc('\n');
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void syscalllogger_return(uint64_t value, uint64_t errno){
|
||||||
|
char tmp[100];
|
||||||
|
|
||||||
|
thread_t* thread = arch_getcls()->thread;
|
||||||
|
proc_t* proc = thread->proc;
|
||||||
|
|
||||||
|
sprintf(tmp, "PID %d TID %d: returned %p %d\n", proc->pid, thread->tid, value, errno);
|
||||||
|
|
||||||
|
e9_puts(tmp);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user