From 2c307616d809feaaf7fe1181fa753a9865dfe40f Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Tue, 31 Dec 2024 00:44:38 +1100 Subject: [PATCH] fix(tests/ptrace.c): persistent logs Even though it might seem like it, it is not necessary that write(2) is the only system call performed. It could be that the libc has to allocate memory (via MMAP) or makes use of a futex. To produce consistant results, only log on SYS_write and when the syscall number has been patched. Signed-off-by: Anhad Singh --- tests/ptrace.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tests/ptrace.c b/tests/ptrace.c index ef01252b45..40123f47b1 100644 --- a/tests/ptrace.c +++ b/tests/ptrace.c @@ -48,17 +48,18 @@ int main() { int status; while (true) { - puts("----- Pre-syscall -----"); + // puts("----- Pre-syscall -----"); result = ptrace(PTRACE_SYSCALL, pid, NULL, NULL); ERROR_IF(ptrace, result, == -1); UNEXP_IF(ptrace, result, != 0); - puts("Wait..."); + // puts("Wait..."); result = waitpid(pid, &status, 0); ERROR_IF(waitpid, result, == -1); - if (WIFEXITED(status)) { break; } + if (WIFEXITED(status)) + break; struct user_regs_struct regs; - puts("Get regs"); + // puts("Get regs"); result = ptrace(PTRACE_GETREGS, pid, NULL, ®s); ERROR_IF(ptrace, result, == -1); @@ -69,14 +70,15 @@ int main() { ERROR_IF(ptrace, result, == -1); } - puts("Post-syscall"); + // puts("Post-syscall"); result = ptrace(PTRACE_SYSCALL, pid, NULL, NULL); ERROR_IF(ptrace, result, == -1); UNEXP_IF(ptrace, result, != 0); - puts("Wait..."); + // puts("Wait..."); result = waitpid(pid, &status, 0); ERROR_IF(waitpid, result, == -1); - if (WIFEXITED(status)) { break; } + if (WIFEXITED(status)) + break; } printf("Child exited with status %d\n", WEXITSTATUS(status)); }