diff options
-rw-r--r-- | debugger.c | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -16,6 +16,7 @@ static const int PTRACE_OPTIONS = PTRACE_O_TRACECLONE | PTRACE_O_TRACEEXEC | + PTRACE_O_TRACEEXIT | PTRACE_O_TRACESYSGOOD; static const int PTRACE_CHILD_OPTIONS = PTRACE_OPTIONS | PTRACE_O_EXITKILL; @@ -258,7 +259,7 @@ static void resume_threads(struct process *proc) { int once = 0; for (struct thread *th = threads->head; th != threads->end; th = th->next) { - if (th->doing == PTRACE_SINGLESTEP) { + if (th->stopped && th->doing == PTRACE_SINGLESTEP) { ptrace(PTRACE_SINGLESTEP, th->id, NULL, th->signal); th->stopped = 0; th->signal = 0; @@ -267,7 +268,7 @@ static void resume_threads(struct process *proc) { } for (struct thread *th = threads->head; th != threads->end; th = th->next) { - if (th->doing && th->doing != PTRACE_SINGLESTEP) { + if (th->stopped && th->doing && th->doing != PTRACE_SINGLESTEP) { if (!once) { usleep(SCHEDULER_DELAY); once = 1; @@ -349,6 +350,15 @@ static int wait_thread(struct thread *th) { th->state = NULL; return 1; + case SIGTRAP | (PTRACE_EVENT_EXIT << 8): + th->stopped = 1; + th->signal = 0; + th->doing = PTRACE_CONT; + th->donext = 0; + strcpy(th->status, "EXITING"); + th->state = NULL; + return 1; + case SIGTRAP | (PTRACE_EVENT_STOP << 8): th->stopped = 1; th->signal = 0; |