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:
Tomas Vanek
2023-07-20 14:52:54 +02:00
parent 7023deb06a
commit a5108240f9
29 changed files with 145 additions and 131 deletions

View File

@@ -184,7 +184,7 @@ static int arm7_9_set_breakpoint(struct target *target, struct breakpoint *break
breakpoint->type);
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@@ -455,7 +455,7 @@ static int arm7_9_set_watchpoint(struct target *target, struct watchpoint *watch
mask = watchpoint->length - 1;
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@@ -524,7 +524,7 @@ static int arm7_9_unset_watchpoint(struct target *target, struct watchpoint *wat
struct arm7_9_common *arm7_9 = target_to_arm7_9(target);
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@@ -1259,7 +1259,7 @@ static int arm7_9_debug_entry(struct target *target)
return retval;
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@@ -1390,7 +1390,7 @@ static int arm7_9_full_context(struct target *target)
LOG_DEBUG("-");
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@@ -1506,7 +1506,7 @@ static int arm7_9_restore_context(struct target *target)
LOG_DEBUG("-");
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@@ -1709,7 +1709,7 @@ int arm7_9_resume(struct target *target,
LOG_DEBUG("-");
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@@ -1907,7 +1907,7 @@ int arm7_9_step(struct target *target, int current, target_addr_t address, int h
int err, retval;
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@@ -2118,7 +2118,7 @@ int arm7_9_read_memory(struct target *target,
address, size, count);
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@@ -2291,7 +2291,7 @@ int arm7_9_write_memory(struct target *target,
#endif
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}