diff options
author | Salvador Arroyo <sarroyofdez@yahoo.es> | 2014-10-11 23:37:08 +0200 |
---|---|---|
committer | Spencer Oliver <spen@spen-soft.co.uk> | 2015-01-09 08:46:45 +0000 |
commit | 1d37b37dc781e1aaab4feca42de12c6775b21ea2 (patch) | |
tree | 38d2d2afe21f9816d3c537daa3c5af3c01823ad8 /src/target/target.c | |
parent | 2eacb8fdfb4ea761acc3a3fbb51d048fefccd9b6 (diff) | |
download | riscv-openocd-1d37b37dc781e1aaab4feca42de12c6775b21ea2.zip riscv-openocd-1d37b37dc781e1aaab4feca42de12c6775b21ea2.tar.gz riscv-openocd-1d37b37dc781e1aaab4feca42de12c6775b21ea2.tar.bz2 |
avoid segfaulting when attempting to set an unavailable type of breackpoint
For example "bp 0x20000000 8 2" makes openocd segfaulting on a
stm32f4x Discovery board.
Change-Id: I1ddd46b1fa9ade78db2234ed975ccefb72539331
Signed-off-by: Salvador Arroyo <sarroyofdez@yahoo.es>
Reviewed-on: http://openocd.zylin.com/2342
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
Diffstat (limited to 'src/target/target.c')
-rw-r--r-- | src/target/target.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/target/target.c b/src/target/target.c index 6f458bc..af5c5b9 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -3310,9 +3310,10 @@ static int handle_bp_command_set(struct command_context *cmd_ctx, uint32_t addr, uint32_t asid, uint32_t length, int hw) { struct target *target = get_current_target(cmd_ctx); + int retval; if (asid == 0) { - int retval = breakpoint_add(target, addr, length, hw); + retval = breakpoint_add(target, addr, length, hw); if (ERROR_OK == retval) command_print(cmd_ctx, "breakpoint set at 0x%8.8" PRIx32 "", addr); else { @@ -3320,7 +3321,11 @@ static int handle_bp_command_set(struct command_context *cmd_ctx, return retval; } } else if (addr == 0) { - int retval = context_breakpoint_add(target, asid, length, hw); + if (target->type->add_context_breakpoint == NULL) { + LOG_WARNING("Context breakpoint not available"); + return ERROR_OK; + } + retval = context_breakpoint_add(target, asid, length, hw); if (ERROR_OK == retval) command_print(cmd_ctx, "Context breakpoint set at 0x%8.8" PRIx32 "", asid); else { @@ -3328,7 +3333,11 @@ static int handle_bp_command_set(struct command_context *cmd_ctx, return retval; } } else { - int retval = hybrid_breakpoint_add(target, addr, asid, length, hw); + if (target->type->add_hybrid_breakpoint == NULL) { + LOG_WARNING("Hybrid breakpoint not available"); + return ERROR_OK; + } + retval = hybrid_breakpoint_add(target, addr, asid, length, hw); if (ERROR_OK == retval) command_print(cmd_ctx, "Hybrid breakpoint set at 0x%8.8" PRIx32 "", asid); else { |