From 574d5a2c4f07bed91d9682e4f48e655e88e37498 Mon Sep 17 00:00:00 2001 From: Malfurious Date: Mon, 9 Oct 2023 16:31:56 -0400 Subject: Implement support for PTRACE_EVENT_FORK and ui Signed-off-by: Malfurious --- debugger.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'debugger.c') diff --git a/debugger.c b/debugger.c index 18f91e1..9a4d142 100644 --- a/debugger.c +++ b/debugger.c @@ -15,6 +15,7 @@ static const int PTRACE_OPTIONS = PTRACE_O_TRACECLONE | + PTRACE_O_TRACEFORK | PTRACE_O_TRACEEXEC | PTRACE_O_TRACEEXIT | PTRACE_O_TRACESYSGOOD; @@ -311,6 +312,7 @@ static int wait_thread(struct thread *th) { strcpy(th->status, "TERMINATED"); return 1; } else if (WIFSTOPPED(status)) { + struct process *eventproc; struct thread *eventth; unsigned long eventmsg; ptrace(PTRACE_GETEVENTMSG, th->id, NULL, &eventmsg); @@ -331,6 +333,22 @@ static int wait_thread(struct thread *th) { th->state = NULL; return 1; + case SIGTRAP | (PTRACE_EVENT_FORK << 8): + eventproc = new_process(eventmsg, th->proc->child); + eventth = new_thread(eventproc, eventmsg); + list_insert(eventproc->threads.end, eventth); + list_insert(th->proc->next, eventproc); + //while (!wait_thread(eventth)) {} + dbg_sync(eventproc); + + th->stopped = 1; + th->signal = 0; + th->doing = 0; + th->donext = 0; + strcpy(th->status, "FORK"); + th->state = NULL; + return 1; + case SIGTRAP | (PTRACE_EVENT_EXEC << 8): eventth = thread_by_id(th->proc, eventmsg); if (eventth->id != th->id) { -- cgit v1.2.3