From 21437e91f6d73c58f7980a12f1bc381be4f9471b Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Mon, 1 Sep 2014 02:23:31 -0700 Subject: [PATCH] Implement watchpoint removing --- src/debugger/debugger.c | 14 ++++++++++++++ src/debugger/debugger.h | 1 + src/debugger/memory-debugger.c | 13 +++++++++++++ src/debugger/memory-debugger.h | 1 + 4 files changed, 29 insertions(+) diff --git a/src/debugger/debugger.c b/src/debugger/debugger.c index 5cbb902fe..7ac5bdd8e 100644 --- a/src/debugger/debugger.c +++ b/src/debugger/debugger.c @@ -115,3 +115,17 @@ void ARMDebuggerSetWatchpoint(struct ARMDebugger* debugger, uint32_t address) { watchpoint->next = debugger->watchpoints; debugger->watchpoints = watchpoint; } + +void ARMDebuggerClearWatchpoint(struct ARMDebugger* debugger, uint32_t address) { + struct DebugBreakpoint** previous = &debugger->watchpoints; + struct DebugBreakpoint* breakpoint; + for (; (breakpoint = *previous); previous = &breakpoint->next) { + if (breakpoint->address == address) { + *previous = breakpoint->next; + free(breakpoint); + } + } + if (!debugger->watchpoints) { + ARMDebuggerRemoveMemoryShim(debugger); + } +} diff --git a/src/debugger/debugger.h b/src/debugger/debugger.h index eed03e8c5..e5ccba0c4 100644 --- a/src/debugger/debugger.h +++ b/src/debugger/debugger.h @@ -58,5 +58,6 @@ void ARMDebuggerEnter(struct ARMDebugger*, enum DebuggerEntryReason); void ARMDebuggerSetBreakpoint(struct ARMDebugger* debugger, uint32_t address); void ARMDebuggerClearBreakpoint(struct ARMDebugger* debugger, uint32_t address); void ARMDebuggerSetWatchpoint(struct ARMDebugger* debugger, uint32_t address); +void ARMDebuggerClearWatchpoint(struct ARMDebugger* debugger, uint32_t address); #endif diff --git a/src/debugger/memory-debugger.c b/src/debugger/memory-debugger.c index b5dd10bc9..adcc3313a 100644 --- a/src/debugger/memory-debugger.c +++ b/src/debugger/memory-debugger.c @@ -69,3 +69,16 @@ void ARMDebuggerInstallMemoryShim(struct ARMDebugger* debugger) { debugger->cpu->memory.setActiveRegion = ARMDebuggerShim_setActiveRegion; debugger->cpu->memory.waitMultiple = ARMDebuggerShim_waitMultiple; } + +void ARMDebuggerRemoveMemoryShim(struct ARMDebugger* debugger) { + debugger->cpu->memory.store32 = debugger->originalMemory.store32; + debugger->cpu->memory.store16 = debugger->originalMemory.store16; + debugger->cpu->memory.store8 = debugger->originalMemory.store8; + debugger->cpu->memory.load32 = debugger->originalMemory.load32; + debugger->cpu->memory.load16 = debugger->originalMemory.load16; + debugger->cpu->memory.loadU16 = debugger->originalMemory.loadU16; + debugger->cpu->memory.load8 = debugger->originalMemory.load8; + debugger->cpu->memory.loadU8 = debugger->originalMemory.loadU8; + debugger->cpu->memory.setActiveRegion = debugger->originalMemory.setActiveRegion; + debugger->cpu->memory.waitMultiple = debugger->originalMemory.waitMultiple; +} diff --git a/src/debugger/memory-debugger.h b/src/debugger/memory-debugger.h index a1a007803..f23d90765 100644 --- a/src/debugger/memory-debugger.h +++ b/src/debugger/memory-debugger.h @@ -8,5 +8,6 @@ struct ARMDebugger; void ARMDebuggerInstallMemoryShim(struct ARMDebugger* debugger); +void ARMDebuggerRemoveMemoryShim(struct ARMDebugger* debugger); #endif