diff --git a/event.c b/event.c index d909c75..d93ed61 100644 --- a/event.c +++ b/event.c @@ -285,20 +285,21 @@ static void handle_breakpoint(struct task *task) if (unlikely(options.verbose)) ++bp->count; - if (unlikely(bp->deleted)) { - struct breakpoint *nbp = breakpoint_find(task, bp->addr); + if (unlikely(task->skip_bp)) { + struct breakpoint *skip_bp = task->skip_bp; - if (!nbp) - nbp = bp; + task->skip_bp = NULL; - skip_breakpoint(task, nbp); - goto end; + breakpoint_put(skip_bp); + + if (likely(skip_bp == bp)) { + skip_breakpoint(task, bp); + goto end; + } } - if (unlikely(task->skip_bp == bp)) { - breakpoint_put(task->skip_bp); - task->skip_bp = NULL; - skip_breakpoint(task, bp); + if (unlikely(bp->deleted)) { + continue_task(task, 0); goto end; } diff --git a/task.c b/task.c index 63d6a0c..8b6b242 100644 --- a/task.c +++ b/task.c @@ -399,7 +399,7 @@ int task_fork(struct task *task, struct task *newtask) else newtask->breakpoint = NULL; - if (task->skip_bp) + if (task->skip_bp && !task->skip_bp->deleted) newtask->skip_bp = breakpoint_get(breakpoint_find(newtask, newtask->skip_bp->addr)); else newtask->skip_bp = NULL; @@ -420,10 +420,12 @@ fail: void task_reset_bp(struct task *task) { - breakpoint_put(task->skip_bp); + if (task->skip_bp) { + breakpoint_put(task->skip_bp); + task->skip_bp = NULL; + } task->breakpoint = NULL; - task->skip_bp = NULL; } static struct task *open_one_pid(pid_t pid) diff --git a/trace.c b/trace.c index afcd9ef..4f0da0e 100644 --- a/trace.c +++ b/trace.c @@ -64,10 +64,8 @@ int skip_breakpoint(struct task *task, struct breakpoint *bp) set_timer(&start, &skip_bp_time); if (unlikely(ret)) { - if (unlikely(ret == 1)) { - breakpoint_put(task->skip_bp); + if (unlikely(ret == 1)) task->skip_bp = breakpoint_get(bp); - } return ret; } }