diff options
| -rw-r--r-- | debugger.c | 33 | 
1 files changed, 13 insertions, 20 deletions
| @@ -110,26 +110,19 @@ static int detect_breakpoint(struct thread *th, int *restart) {      struct iovec ivregs = { ®s, sizeof(regs) };      ptrace(PTRACE_GETREGSET, th->id, NT_PRSTATUS, &ivregs); -    /* implement with get_breakpoint? */ -    struct list *breaks = &th->proc->breakpoints; -    for (struct breakpoint *b = breaks->tail; b != breaks->end; b = b->prev) { -        if (b->installed && (regs.rip - 1 == b->address)) { -            regs.rip--; -            ptrace(PTRACE_SETREGSET, th->id, NT_PRSTATUS, &ivregs); -            b->hits++; -            ret = b->user; - -            if (b->stack != 0 && b->stack != regs.rsp) { -                *restart = 1; -            } -            if (b->tid != 0 && b->tid != th->id) { -                *restart = 1; -            } -            if (!b->enabled) { -                *restart = 1; -            } - -            break; +    struct breakpoint *b = get_breakpoint(th->proc, regs.rip - 1); +    if (b && b->installed && th->doing != PTRACE_SINGLESTEP) { +        regs.rip--; +        ptrace(PTRACE_SETREGSET, th->id, NT_PRSTATUS, &ivregs); +        b->hits++; /* todo: consider whether this is firing too much */ +        ret = b->user; + +        if (b->stack != 0 && b->stack != regs.rsp) { +            *restart = 1; +        } else if (b->tid != 0 && b->tid != th->id) { +            *restart = 1; +        } else if (!b->enabled) { +            *restart = 1;          }      } | 
