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>
This commit is contained in:
parent
2eacb8fdfb
commit
1d37b37dc7
|
@ -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)
|
uint32_t addr, uint32_t asid, uint32_t length, int hw)
|
||||||
{
|
{
|
||||||
struct target *target = get_current_target(cmd_ctx);
|
struct target *target = get_current_target(cmd_ctx);
|
||||||
|
int retval;
|
||||||
|
|
||||||
if (asid == 0) {
|
if (asid == 0) {
|
||||||
int retval = breakpoint_add(target, addr, length, hw);
|
retval = breakpoint_add(target, addr, length, hw);
|
||||||
if (ERROR_OK == retval)
|
if (ERROR_OK == retval)
|
||||||
command_print(cmd_ctx, "breakpoint set at 0x%8.8" PRIx32 "", addr);
|
command_print(cmd_ctx, "breakpoint set at 0x%8.8" PRIx32 "", addr);
|
||||||
else {
|
else {
|
||||||
|
@ -3320,7 +3321,11 @@ static int handle_bp_command_set(struct command_context *cmd_ctx,
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
} else if (addr == 0) {
|
} 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)
|
if (ERROR_OK == retval)
|
||||||
command_print(cmd_ctx, "Context breakpoint set at 0x%8.8" PRIx32 "", asid);
|
command_print(cmd_ctx, "Context breakpoint set at 0x%8.8" PRIx32 "", asid);
|
||||||
else {
|
else {
|
||||||
|
@ -3328,7 +3333,11 @@ static int handle_bp_command_set(struct command_context *cmd_ctx,
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
} else {
|
} 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)
|
if (ERROR_OK == retval)
|
||||||
command_print(cmd_ctx, "Hybrid breakpoint set at 0x%8.8" PRIx32 "", asid);
|
command_print(cmd_ctx, "Hybrid breakpoint set at 0x%8.8" PRIx32 "", asid);
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Reference in New Issue