target: Rework 'set' variable of break-/watchpoints
[openocd.git] / src / target / stm8.c
index 21fc8c54f819e8067b542399bf6ba8797a1e784b..4102082ffca9bd2c7a287f7338fafbe89c81694d 100644 (file)
@@ -1370,7 +1370,7 @@ static void stm8_enable_breakpoints(struct target *target)
 
        /* set any pending breakpoints */
        while (breakpoint) {
-               if (breakpoint->set == 0)
+               if (!breakpoint->is_set)
                        stm8_set_breakpoint(target, breakpoint);
                breakpoint = breakpoint->next;
        }
@@ -1383,7 +1383,7 @@ static int stm8_set_breakpoint(struct target *target,
        struct stm8_comparator *comparator_list = stm8->hw_break_list;
        int retval;
 
-       if (breakpoint->set) {
+       if (breakpoint->is_set) {
                LOG_WARNING("breakpoint already set");
                return ERROR_OK;
        }
@@ -1398,7 +1398,7 @@ static int stm8_set_breakpoint(struct target *target,
                                        breakpoint->unique_id);
                        return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
                }
-               breakpoint->set = bp_num + 1;
+               breakpoint_hw_set(breakpoint, bp_num);
                comparator_list[bp_num].used = true;
                comparator_list[bp_num].bp_value = breakpoint->address;
                comparator_list[bp_num].type = HWBRK_EXEC;
@@ -1435,7 +1435,7 @@ static int stm8_set_breakpoint(struct target *target,
                } else {
                        return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
                }
-               breakpoint->set = 1; /* Any nice value but 0 */
+               breakpoint->is_set = true;
        }
 
        return ERROR_OK;
@@ -1476,14 +1476,14 @@ static int stm8_unset_breakpoint(struct target *target,
        struct stm8_comparator *comparator_list = stm8->hw_break_list;
        int retval;
 
-       if (!breakpoint->set) {
+       if (!breakpoint->is_set) {
                LOG_WARNING("breakpoint not set");
                return ERROR_OK;
        }
 
        if (breakpoint->type == BKPT_HARD) {
-               int bp_num = breakpoint->set - 1;
-               if ((bp_num < 0) || (bp_num >= stm8->num_hw_bpoints)) {
+               int bp_num = breakpoint->number;
+               if (bp_num >= stm8->num_hw_bpoints) {
                        LOG_DEBUG("Invalid comparator number in breakpoint (bpid: %" PRIu32 ")",
                                          breakpoint->unique_id);
                        return ERROR_OK;
@@ -1517,7 +1517,7 @@ static int stm8_unset_breakpoint(struct target *target,
                } else
                        return ERROR_FAIL;
        }
-       breakpoint->set = 0;
+       breakpoint->is_set = false;
 
        return ERROR_OK;
 }
@@ -1533,7 +1533,7 @@ static int stm8_remove_breakpoint(struct target *target,
                return ERROR_TARGET_NOT_HALTED;
        }
 
-       if (breakpoint->set)
+       if (breakpoint->is_set)
                stm8_unset_breakpoint(target, breakpoint);
 
        if (breakpoint->type == BKPT_HARD)
@@ -1550,7 +1550,7 @@ static int stm8_set_watchpoint(struct target *target,
        int wp_num = 0;
        int ret;
 
-       if (watchpoint->set) {
+       if (watchpoint->is_set) {
                LOG_WARNING("watchpoint already set");
                return ERROR_OK;
        }
@@ -1593,7 +1593,7 @@ static int stm8_set_watchpoint(struct target *target,
                return ret;
        }
 
-       watchpoint->set = wp_num + 1;
+       watchpoint_set(watchpoint, wp_num);
 
        LOG_DEBUG("wp_num %i bp_value 0x%" PRIx32 "",
                        wp_num,
@@ -1627,7 +1627,7 @@ static void stm8_enable_watchpoints(struct target *target)
 
        /* set any pending watchpoints */
        while (watchpoint) {
-               if (watchpoint->set == 0)
+               if (!watchpoint->is_set)
                        stm8_set_watchpoint(target, watchpoint);
                watchpoint = watchpoint->next;
        }
@@ -1640,18 +1640,18 @@ static int stm8_unset_watchpoint(struct target *target,
        struct stm8_common *stm8 = target_to_stm8(target);
        struct stm8_comparator *comparator_list = stm8->hw_break_list;
 
-       if (!watchpoint->set) {
+       if (!watchpoint->is_set) {
                LOG_WARNING("watchpoint not set");
                return ERROR_OK;
        }
 
-       int wp_num = watchpoint->set - 1;
-       if ((wp_num < 0) || (wp_num >= stm8->num_hw_bpoints)) {
+       int wp_num = watchpoint->number;
+       if (wp_num >= stm8->num_hw_bpoints) {
                LOG_DEBUG("Invalid hw comparator number in watchpoint");
                return ERROR_OK;
        }
        comparator_list[wp_num].used = false;
-       watchpoint->set = 0;
+       watchpoint->is_set = false;
 
        stm8_set_hwbreak(target, comparator_list);
 
@@ -1669,7 +1669,7 @@ static int stm8_remove_watchpoint(struct target *target,
                return ERROR_TARGET_NOT_HALTED;
        }
 
-       if (watchpoint->set)
+       if (watchpoint->is_set)
                stm8_unset_watchpoint(target, watchpoint);
 
        stm8->num_hw_bpoints_avail++;

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)