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 <andypython@protonmail.com>
This commit is contained in:
+9
-7
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user