Skip to content

Commit

Permalink
target/arc: restore breakpoints in arc_resume()
Browse files Browse the repository at this point in the history
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 zephyrproject-rtos/openocd#31).

Change-Id: I59e9c91270ef0b5fd19cfc570663dc67a6022dbd
Signed-off-by: Evgeniy Didin <[email protected]>
Signed-off-by: Stephanos Ioannidis <[email protected]>
Signed-off-by: Artemiy Volkov <[email protected]>
Reviewed-on: https://review.openocd.org/c/openocd/+/7816
Tested-by: jenkins
Reviewed-by: Antonio Borneo <[email protected]>
Reviewed-by: Oleksij Rempel <[email protected]>
  • Loading branch information
EvgeniiDidin authored and borneoa committed Jan 13, 2024
1 parent 04eda37 commit 2c10e3e
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/target/arc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 <address> */
if (!current) {
target_buffer_set_u32(target, pc->value, address);
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit 2c10e3e

Please sign in to comment.