target: fix messages and return values of failed op because not halted
Lot of messages was logged as LOG_WARNING, but the operation failed immediately. Sometimes no error message was logged at all. Add missing messages, change warnings to errors. Sometimes ERROR_TARGET_INVALID was returned. Some command handlers returned ERROR_OK! Always return ERROR_TARGET_NOT_HALTED. While on it use LOG_TARGET_ERROR() whenever possible. Prefix command_print() message with 'Error:' to get closer to LOG_TARGET_ERROR() variant. Error message was not added to get() and set() methods of struct xxx_reg_type - the return value is properly checked and a message is logged by the caller in case of ERROR_TARGET_NOT_HALTED. Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Change-Id: I2fe4187c6025f0038956ab387edbf3f461c69398 Reviewed-on: https://review.openocd.org/c/openocd/+/7819 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
This commit is contained in:
@@ -1258,7 +1258,7 @@ static int arc_resume(struct target *target, int current, target_addr_t address,
|
||||
CHECK_RETVAL(arc_reset_caches_states(target));
|
||||
|
||||
if (target->state != TARGET_HALTED) {
|
||||
LOG_WARNING("target not halted");
|
||||
LOG_TARGET_ERROR(target, "not halted");
|
||||
return ERROR_TARGET_NOT_HALTED;
|
||||
}
|
||||
|
||||
@@ -1671,7 +1671,7 @@ static int arc_add_breakpoint(struct target *target, struct breakpoint *breakpoi
|
||||
return arc_set_breakpoint(target, breakpoint);
|
||||
|
||||
} else {
|
||||
LOG_WARNING(" > core was not halted, please try again.");
|
||||
LOG_TARGET_ERROR(target, "not halted (add breakpoint)");
|
||||
return ERROR_TARGET_NOT_HALTED;
|
||||
}
|
||||
}
|
||||
@@ -1683,7 +1683,7 @@ static int arc_remove_breakpoint(struct target *target,
|
||||
if (breakpoint->is_set)
|
||||
CHECK_RETVAL(arc_unset_breakpoint(target, breakpoint));
|
||||
} else {
|
||||
LOG_WARNING("target not halted");
|
||||
LOG_TARGET_ERROR(target, "not halted (remove breakpoint)");
|
||||
return ERROR_TARGET_NOT_HALTED;
|
||||
}
|
||||
|
||||
@@ -1905,7 +1905,7 @@ static int arc_add_watchpoint(struct target *target,
|
||||
struct watchpoint *watchpoint)
|
||||
{
|
||||
if (target->state != TARGET_HALTED) {
|
||||
LOG_WARNING("target not halted");
|
||||
LOG_TARGET_ERROR(target, "not halted");
|
||||
return ERROR_TARGET_NOT_HALTED;
|
||||
}
|
||||
|
||||
@@ -1918,7 +1918,7 @@ static int arc_remove_watchpoint(struct target *target,
|
||||
struct watchpoint *watchpoint)
|
||||
{
|
||||
if (target->state != TARGET_HALTED) {
|
||||
LOG_WARNING("target not halted");
|
||||
LOG_TARGET_ERROR(target, "not halted");
|
||||
return ERROR_TARGET_NOT_HALTED;
|
||||
}
|
||||
|
||||
@@ -2006,7 +2006,7 @@ static int arc_step(struct target *target, int current, target_addr_t address,
|
||||
struct reg *pc = &(arc->core_and_aux_cache->reg_list[arc->pc_index_in_cache]);
|
||||
|
||||
if (target->state != TARGET_HALTED) {
|
||||
LOG_WARNING("target not halted");
|
||||
LOG_TARGET_ERROR(target, "not halted");
|
||||
return ERROR_TARGET_NOT_HALTED;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user