jtag: linuxgpiod: drop extra parenthesis
[openocd.git] / src / target / arc.c
index 0f7b11025d09418b9744aecc0bf4f4caed2a65b7..72e4d918de9725bf0ee9d6b034f1d7588152c043 100644 (file)
 
 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);
+static int arc_unset_breakpoint(struct target *target,
+               struct breakpoint *breakpoint);
+static int arc_set_breakpoint(struct target *target,
+               struct breakpoint *breakpoint);
+static int arc_single_step_core(struct target *target);
 
 void arc_reg_data_type_add(struct target *target,
                struct arc_reg_data_type *data_type)
@@ -748,6 +755,29 @@ static int arc_examine(struct target *target)
        return ERROR_OK;
 }
 
+static int arc_exit_debug(struct target *target)
+{
+       uint32_t value;
+       struct arc_common *arc = target_to_arc(target);
+
+       /* Do read-modify-write sequence, or DEBUG.UB will be reset unintentionally. */
+       CHECK_RETVAL(arc_jtag_read_aux_reg_one(&arc->jtag_info, AUX_DEBUG_REG, &value));
+       value |= SET_CORE_FORCE_HALT; /* set the HALT bit */
+       CHECK_RETVAL(arc_jtag_write_aux_reg_one(&arc->jtag_info, AUX_DEBUG_REG, value));
+       alive_sleep(1);
+
+       target->state = TARGET_HALTED;
+       CHECK_RETVAL(target_call_event_callbacks(target, TARGET_EVENT_HALTED));
+
+       if (debug_level >= LOG_LVL_DEBUG) {
+               LOG_DEBUG("core stopped (halted) debug-reg: 0x%08" PRIx32, value);
+               CHECK_RETVAL(arc_jtag_read_aux_reg_one(&arc->jtag_info, AUX_STATUS32_REG, &value));
+               LOG_DEBUG("core STATUS32: 0x%08" PRIx32, value);
+       }
+
+       return ERROR_OK;
+}
+
 static int arc_halt(struct target *target)
 {
        uint32_t value, irq_state;
@@ -1249,7 +1279,7 @@ static int arc_resume(struct target *target, int current, target_addr_t address,
        uint32_t value;
        struct reg *pc = &arc->core_and_aux_cache->reg_list[arc->pc_index_in_cache];
 
-       LOG_DEBUG("current:%i, address:0x%08" TARGET_PRIxADDR ", handle_breakpoints(not supported yet):%i,"
+       LOG_DEBUG("current:%i, address:0x%08" TARGET_PRIxADDR ", handle_breakpoints:%i,"
                " debug_execution:%i", current, address, handle_breakpoints, debug_execution);
 
        /* We need to reset ARC cache variables so caches
@@ -1262,6 +1292,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);
@@ -1287,6 +1324,19 @@ static int arc_resume(struct target *target, int current, target_addr_t address,
                CHECK_RETVAL(arc_jtag_write_aux_reg_one(&arc->jtag_info, AUX_PC_REG, value));
        }
 
+       /* the front-end may request us not to handle breakpoints here */
+       if (handle_breakpoints) {
+               /* Single step past breakpoint at current address */
+               struct breakpoint *breakpoint = breakpoint_find(target, resume_pc);
+               if (breakpoint) {
+                       LOG_DEBUG("skipping past breakpoint at 0x%08" TARGET_PRIxADDR,
+                               breakpoint->address);
+                       CHECK_RETVAL(arc_unset_breakpoint(target, breakpoint));
+                       CHECK_RETVAL(arc_single_step_core(target));
+                       CHECK_RETVAL(arc_set_breakpoint(target, breakpoint));
+               }
+       }
+
        /* Restore IRQ state if not in debug_execution*/
        if (!debug_execution)
                CHECK_RETVAL(arc_enable_interrupts(target, arc->irq_state));
@@ -1658,6 +1708,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 +1958,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)
 {
@@ -1991,6 +2068,22 @@ static int arc_config_step(struct target *target, int enable_step)
        return ERROR_OK;
 }
 
+static int arc_single_step_core(struct target *target)
+{
+       CHECK_RETVAL(arc_debug_entry(target));
+
+       /* disable interrupts while stepping */
+       CHECK_RETVAL(arc_enable_interrupts(target, 0));
+
+       /* configure single step mode */
+       CHECK_RETVAL(arc_config_step(target, 1));
+
+       /* exit debug mode */
+       CHECK_RETVAL(arc_exit_debug(target));
+
+       return ERROR_OK;
+}
+
 static int arc_step(struct target *target, int current, target_addr_t address,
        int handle_breakpoints)
 {

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)