From 2c10e3e2577604f5ec75b7f688f53fa2b3cbb0e7 Mon Sep 17 00:00:00 2001 From: Evgeniy Didin Date: Fri, 31 Jul 2020 00:13:12 +0300 Subject: [PATCH] target/arc: restore breakpoints in arc_resume() Presently, we rely on gdb to restore break/watchpoints upon resuming execution in arc_resume(). To match this behavior in absence of gdb (more specifically, when handle_breakpoints is true), this patch explicitly re-enables all breakpoints and watchpoints in arc_resume(). This has previously been committed to the Zephyr project's openocd repo (see https://github.com/zephyrproject-rtos/openocd/pull/31). Change-Id: I59e9c91270ef0b5fd19cfc570663dc67a6022dbd Signed-off-by: Evgeniy Didin Signed-off-by: Stephanos Ioannidis Signed-off-by: Artemiy Volkov Reviewed-on: https://review.openocd.org/c/openocd/+/7816 Tested-by: jenkins Reviewed-by: Antonio Borneo Reviewed-by: Oleksij Rempel --- src/target/arc.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/target/arc.c b/src/target/arc.c index 0f7b11025d..f3449aada9 100644 --- a/src/target/arc.c +++ b/src/target/arc.c @@ -50,6 +50,8 @@ static int arc_remove_watchpoint(struct target *target, struct watchpoint *watchpoint); +static int arc_enable_watchpoints(struct target *target); +static int arc_enable_breakpoints(struct target *target); void arc_reg_data_type_add(struct target *target, struct arc_reg_data_type *data_type) @@ -1262,6 +1264,13 @@ static int arc_resume(struct target *target, int current, target_addr_t address, return ERROR_TARGET_NOT_HALTED; } + if (!debug_execution) { + /* (gdb) continue = execute until we hit break/watch-point */ + target_free_all_working_areas(target); + CHECK_RETVAL(arc_enable_breakpoints(target)); + CHECK_RETVAL(arc_enable_watchpoints(target)); + } + /* current = 1: continue on current PC, otherwise continue at
*/ if (!current) { target_buffer_set_u32(target, pc->value, address); @@ -1658,6 +1667,19 @@ static int arc_unset_breakpoint(struct target *target, return retval; } +static int arc_enable_breakpoints(struct target *target) +{ + struct breakpoint *breakpoint = target->breakpoints; + + /* set any pending breakpoints */ + while (breakpoint) { + if (!breakpoint->is_set) + CHECK_RETVAL(arc_set_breakpoint(target, breakpoint)); + breakpoint = breakpoint->next; + } + + return ERROR_OK; +} static int arc_add_breakpoint(struct target *target, struct breakpoint *breakpoint) { @@ -1895,6 +1917,20 @@ static int arc_unset_watchpoint(struct target *target, return retval; } +static int arc_enable_watchpoints(struct target *target) +{ + struct watchpoint *watchpoint = target->watchpoints; + + /* set any pending watchpoints */ + while (watchpoint) { + if (!watchpoint->is_set) + CHECK_RETVAL(arc_set_watchpoint(target, watchpoint)); + watchpoint = watchpoint->next; + } + + return ERROR_OK; +} + static int arc_add_watchpoint(struct target *target, struct watchpoint *watchpoint) {