diff options
-rw-r--r-- | debugger.c | 19 | ||||
-rw-r--r-- | debugger.h | 1 |
2 files changed, 11 insertions, 9 deletions
@@ -79,6 +79,7 @@ static void install_breakpoints(struct thread *th) { word = (word & ~0xff) | BREAKPOINT_INSN; ptrace(PTRACE_POKETEXT, th->id, b->address, word); b->installed = 1; + b->previously_installed = 1; } } } @@ -89,16 +90,15 @@ static void uninstall_breakpoints(struct thread *th) { if (b->installed) { ptrace(PTRACE_POKETEXT, th->id, b->address, b->text); b->installed = 0; + } - if (b->enabled < 0) { - struct thread *t; - if (b->tid == 0 || - ((t = thread_by_id(th->proc, b->tid)) && !t->doing)) { - struct breakpoint *del = b; - b = b->next; - list_remove(del); - free(del); - } + if (b->previously_installed && b->enabled < 0) { + struct thread *t = NULL; + if (b->tid == 0 || ((t = thread_by_id(th->proc, b->tid)) && !t->doing)) { + struct breakpoint *del = b; + b = b->next; + list_remove(del); + free(del); } } } @@ -434,6 +434,7 @@ struct breakpoint *add_breakpoint(struct process *proc, unsigned long address) { b->address = address; b->text = 0; b->installed = 0; + b->previously_installed = 0; b->hits = 0; b->user = 1; b->stack = 0; @@ -11,6 +11,7 @@ struct breakpoint { unsigned long address; unsigned long text; int installed; + int previously_installed; int hits; int user; |