summaryrefslogtreecommitdiff
path: root/src/target/breakpoints.c
diff options
context:
space:
mode:
authorDavid Brownell <dbrownell@users.sourceforge.net>2009-11-28 10:40:26 -0800
committerDavid Brownell <dbrownell@users.sourceforge.net>2009-11-28 10:40:26 -0800
commitacbe054a38a45432f5948026e1e9258b4e2910c2 (patch)
tree126e4c5fbe6d3d8261e994171f7f45855bf59a16 /src/target/breakpoints.c
parent68889ea02f28bfd61f0b4b85aad4b0bf8826a947 (diff)
downloadopenocd+libswd-acbe054a38a45432f5948026e1e9258b4e2910c2.tar.gz
openocd+libswd-acbe054a38a45432f5948026e1e9258b4e2910c2.tar.bz2
openocd+libswd-acbe054a38a45432f5948026e1e9258b4e2910c2.tar.xz
openocd+libswd-acbe054a38a45432f5948026e1e9258b4e2910c2.zip
target: uplevel add_{break,watch}point() error checks
In target_type.h it's documented that the target must be halted for add_breakpoint() ... and with slight ambiguity, also for its add_watchpoint() sibling. So rather than verifying that constraint in the CPU drivers, do it in the target_add_{break,watch}point() routines. Add minor paranoia on the remove_*point() paths too: save the return value, and print it out in in the LOG_DEBUG message in case it's nonzero. Note that with some current cores, like all ARMv7 ones I've looked at, there's no technical issue preventing watchpoint or breakpoint add/remove operations on active cores. This model seems deeply wired into OpenOCD though. ALSO: the ARM targets were fairly "good" about enforcing that constraint themselves. The MIPS ones were relied on other code to catch such stuff, but it's not clear such code existed ... keep an eye out for new issues on MIPS. Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Diffstat (limited to 'src/target/breakpoints.c')
-rw-r--r--src/target/breakpoints.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/target/breakpoints.c b/src/target/breakpoints.c
index 16ab7e0c..2542c41a 100644
--- a/src/target/breakpoints.c
+++ b/src/target/breakpoints.c
@@ -109,6 +109,7 @@ static void breakpoint_free(struct target *target, struct breakpoint *breakpoint
{
struct breakpoint *breakpoint = target->breakpoints;
struct breakpoint **breakpoint_p = &target->breakpoints;
+ int retval;
while (breakpoint)
{
@@ -121,9 +122,9 @@ static void breakpoint_free(struct target *target, struct breakpoint *breakpoint
if (breakpoint == NULL)
return;
- target_remove_breakpoint(target, breakpoint);
+ retval = target_remove_breakpoint(target, breakpoint);
- LOG_DEBUG("BPID: %d", breakpoint->unique_id );
+ LOG_DEBUG("free BPID: %d --> %d", breakpoint->unique_id, retval);
(*breakpoint_p) = breakpoint->next;
free(breakpoint->orig_instr);
free(breakpoint);
@@ -249,6 +250,7 @@ static void watchpoint_free(struct target *target, struct watchpoint *watchpoint
{
struct watchpoint *watchpoint = target->watchpoints;
struct watchpoint **watchpoint_p = &target->watchpoints;
+ int retval;
while (watchpoint)
{
@@ -260,8 +262,8 @@ static void watchpoint_free(struct target *target, struct watchpoint *watchpoint
if (watchpoint == NULL)
return;
- target_remove_watchpoint(target, watchpoint);
- LOG_DEBUG("WPID: %d", watchpoint->unique_id );
+ retval = target_remove_watchpoint(target, watchpoint);
+ LOG_DEBUG("free WPID: %d --> %d", watchpoint->unique_id, retval);
(*watchpoint_p) = watchpoint->next;
free(watchpoint);
}