propagate return status of set_breakpoint() up call chain
authorMike Dunn <mikedunn@newsguy.com>
Sun, 12 Sep 2010 19:05:07 +0000 (12:05 -0700)
committerØyvind Harboe <oyvind.harboe@zylin.com>
Mon, 13 Sep 2010 17:45:42 +0000 (19:45 +0200)
Hi everyone,

I figured since I was poking around in the breakpoint code on other arches, I'd
add this change to those arches that don't do it already.  This patch propagates
the return code of <arch>_set_breakpoint() up the call stack.  This ensures that
the higher layer breakpoint infrastructure is aware that an error ocurred, in
which case the breakpoint is not recorded.

Normally I wouldn't touch code that I can't test, but the code is very
uniform across architectures, and the change is rather benign, so I figured
after careful inspection that it is safe.  If the maintainers or others think
this is imprudent, the patch can be dropped.

Also changed the error code to something more appropriate in two cases where
hardware resources are unavailable.

Comments and criticisms of course gratefully received.

Mike

Signed-off-by: Mike Dunn <mikedunn@newsguy.com>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
src/target/cortex_a8.c
src/target/cortex_m3.c
src/target/mips_m4k.c

index 9b3521ac5115f7dad9977886551e1834b84c4172..8b4ced59c0df17e84a4eb0c5533897b07f8a2213 100644 (file)
@@ -1230,7 +1230,7 @@ static int cortex_a8_set_breakpoint(struct target *target,
                if (brp_i >= cortex_a8->brp_num)
                {
                        LOG_ERROR("ERROR Can not find free Breakpoint Register Pair");
-                       return ERROR_FAIL;
+                       return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
                }
                breakpoint->set = brp_i + 1;
                if (breakpoint->length == 2)
@@ -1360,9 +1360,8 @@ static int cortex_a8_add_breakpoint(struct target *target,
 
        if (breakpoint->type == BKPT_HARD)
                cortex_a8->brp_num_available--;
-       cortex_a8_set_breakpoint(target, breakpoint, 0x00); /* Exact match */
 
-       return ERROR_OK;
+       return cortex_a8_set_breakpoint(target, breakpoint, 0x00); /* Exact match */
 }
 
 static int cortex_a8_remove_breakpoint(struct target *target, struct breakpoint *breakpoint)
index f87c3e0b80634d4b8ab6e8008abfc14869ba4377..3011b59771652a061b1c58666628c569c6f72e80 100644 (file)
@@ -1221,9 +1221,8 @@ cortex_m3_add_breakpoint(struct target *target, struct breakpoint *breakpoint)
 
        if (breakpoint->type == BKPT_HARD)
                cortex_m3->fp_code_available--;
-       cortex_m3_set_breakpoint(target, breakpoint);
 
-       return ERROR_OK;
+       return cortex_m3_set_breakpoint(target, breakpoint);
 }
 
 static int
index 21ff0ba94da1f1b569c86adcdf4c4bad8c2b21a8..62c484a98af2467d9db4107c067bb1911df3382d 100644 (file)
@@ -497,7 +497,7 @@ static int mips_m4k_set_breakpoint(struct target *target,
                {
                        LOG_ERROR("Can not find free FP Comparator(bpid: %d)",
                                          breakpoint->unique_id );
-                       return ERROR_FAIL;
+                       return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
                }
                breakpoint->set = bp_num + 1;
                comparator_list[bp_num].used = 1;
@@ -662,9 +662,7 @@ static int mips_m4k_add_breakpoint(struct target *target, struct breakpoint *bre
                mips32->num_inst_bpoints_avail--;
        }
 
-       mips_m4k_set_breakpoint(target, breakpoint);
-
-       return ERROR_OK;
+       return mips_m4k_set_breakpoint(target, breakpoint);
 }
 
 static int mips_m4k_remove_breakpoint(struct target *target,

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)