diff options
author | Antonio Borneo <borneo.antonio@gmail.com> | 2021-04-29 09:22:00 +0200 |
---|---|---|
committer | Antonio Borneo <borneo.antonio@gmail.com> | 2021-06-03 23:26:56 +0100 |
commit | ffaef5809c68d81359de5573d3971a4b6bb521c3 (patch) | |
tree | 985b8a30fa5f18ef99551f3f7f437972b33886c0 | |
parent | 1fb736f6c5a69f743dd90e68045f7b4e6a0f8c78 (diff) | |
download | riscv-openocd-ffaef5809c68d81359de5573d3971a4b6bb521c3.zip riscv-openocd-ffaef5809c68d81359de5573d3971a4b6bb521c3.tar.gz riscv-openocd-ffaef5809c68d81359de5573d3971a4b6bb521c3.tar.bz2 |
target/cortex_a: fix number of watchpoints
Decrement the available watchpoints only when succeed setting it.
Initialize the available watchpoint with the correct value.
Change-Id: I0f93b347300b8ebedbcd9e718d4ba32b26cf6846
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6196
Tested-by: jenkins
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
-rw-r--r-- | src/target/cortex_a.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/target/cortex_a.c b/src/target/cortex_a.c index 9e8248a..78daed3 100644 --- a/src/target/cortex_a.c +++ b/src/target/cortex_a.c @@ -1802,8 +1802,12 @@ static int cortex_a_add_watchpoint(struct target *target, struct watchpoint *wat return ERROR_TARGET_RESOURCE_NOT_AVAILABLE; } + int retval = cortex_a_set_watchpoint(target, watchpoint); + if (retval != ERROR_OK) + return retval; + cortex_a->wrp_num_available--; - return cortex_a_set_watchpoint(target, watchpoint); + return ERROR_OK; } /** @@ -3007,7 +3011,7 @@ static int cortex_a_examine_first(struct target *target) /* Setup Watchpoint Register Pairs */ cortex_a->wrp_num = ((didr >> 28) & 0x0F) + 1; - cortex_a->wrp_num_available = cortex_a->brp_num; + cortex_a->wrp_num_available = cortex_a->wrp_num; free(cortex_a->wrp_list); cortex_a->wrp_list = calloc(cortex_a->wrp_num, sizeof(struct cortex_a_wrp)); for (i = 0; i < cortex_a->wrp_num; i++) { |