summaryrefslogtreecommitdiffstats
path: root/debugger.c
diff options
context:
space:
mode:
authorMalfurious <m@lfurio.us>2023-10-09 16:31:56 -0400
committerMalfurious <m@lfurio.us>2024-04-24 13:31:08 -0400
commit574d5a2c4f07bed91d9682e4f48e655e88e37498 (patch)
tree0faa0f9c7d5a26b9b9d25557539c5be1abff55d9 /debugger.c
parentee936125622325a4b33bafe336b44e44a24ce1aa (diff)
downloadmisplays-574d5a2c4f07bed91d9682e4f48e655e88e37498.tar.gz
misplays-574d5a2c4f07bed91d9682e4f48e655e88e37498.zip
Implement support for PTRACE_EVENT_FORK and ui
Signed-off-by: Malfurious <m@lfurio.us>
Diffstat (limited to 'debugger.c')
-rw-r--r--debugger.c18
1 files changed, 18 insertions, 0 deletions
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) {