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

@ -846,8 +846,10 @@ static int aarch64_resume(struct target *target, int current,
struct armv8_common *armv8 = target_to_armv8(target);
armv8->last_run_control_op = ARMV8_RUNCONTROL_RESUME;
if (target->state != TARGET_HALTED)
if (target->state != TARGET_HALTED) {
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
/*
* If this target is part of a SMP group, prepare the others
@ -1095,7 +1097,7 @@ static int aarch64_step(struct target *target, int current, target_addr_t addres
armv8->last_run_control_op = ARMV8_RUNCONTROL_STEP;
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@ -2135,7 +2137,7 @@ static int aarch64_write_cpu_memory(struct target *target,
uint32_t dscr;
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@ -2353,7 +2355,7 @@ static int aarch64_read_cpu_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;
}
@ -2790,8 +2792,8 @@ static int aarch64_mmu(struct target *target, int *enabled)
struct aarch64_common *aarch64 = target_to_aarch64(target);
struct armv8_common *armv8 = &aarch64->armv8_common;
if (target->state != TARGET_HALTED) {
LOG_ERROR("%s: target %s not halted", __func__, target_name(target));
return ERROR_TARGET_INVALID;
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
if (armv8->is_armv8r)
*enabled = 0;
@ -3010,8 +3012,10 @@ COMMAND_HANDLER(aarch64_mcrmrc_command)
return ERROR_FAIL;
}
if (target->state != TARGET_HALTED)
if (target->state != TARGET_HALTED) {
command_print(CMD, "Error: [%s] not halted", target_name(target));
return ERROR_TARGET_NOT_HALTED;
}
if (arm->core_state == ARM_STATE_AARCH64) {
command_print(CMD, "%s: not 32-bit arm target", target_name(target));

View File

@ -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;
}

View File

@ -162,7 +162,7 @@ int arc_mem_write(struct target *target, target_addr_t address, uint32_t size,
address, size, count);
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}

View File

@ -449,7 +449,7 @@ static int arm11_resume(struct target *target, int current,
if (target->state != TARGET_HALTED) {
LOG_ERROR("Target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@ -551,7 +551,7 @@ static int arm11_step(struct target *target, int current,
target_state_name(target));
if (target->state != TARGET_HALTED) {
LOG_WARNING("target was not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@ -798,7 +798,7 @@ static int arm11_read_memory_inner(struct target *target,
int retval;
if (target->state != TARGET_HALTED) {
LOG_WARNING("target was not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@ -896,7 +896,7 @@ static int arm11_write_memory_inner(struct target *target,
int retval;
if (target->state != TARGET_HALTED) {
LOG_WARNING("target was not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}

View File

@ -241,8 +241,8 @@ static int arm720t_arch_state(struct target *target)
static int arm720_mmu(struct target *target, int *enabled)
{
if (target->state != TARGET_HALTED) {
LOG_ERROR("%s: target not halted", __func__);
return ERROR_TARGET_INVALID;
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
*enabled = target_to_arm720(target)->armv4_5_mmu.mmu_enabled;

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;
}

View File

@ -533,8 +533,8 @@ int arm920t_arch_state(struct target *target)
static int arm920_mmu(struct target *target, int *enabled)
{
if (target->state != TARGET_HALTED) {
LOG_ERROR("%s: target not halted", __func__);
return ERROR_TARGET_INVALID;
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
*enabled = target_to_arm920(target)->armv4_5_mmu.mmu_enabled;
@ -1455,9 +1455,9 @@ COMMAND_HANDLER(arm920t_handle_cp15_command)
return retval;
if (target->state != TARGET_HALTED) {
command_print(CMD, "target must be stopped for "
command_print(CMD, "Error: target must be stopped for "
"\"%s\" command", CMD_NAME);
return ERROR_OK;
return ERROR_TARGET_NOT_HALTED;
}
/* one argument, read a register.

View File

@ -754,8 +754,8 @@ static int arm926ejs_mmu(struct target *target, int *enabled)
struct arm926ejs_common *arm926ejs = target_to_arm926(target);
if (target->state != TARGET_HALTED) {
LOG_ERROR("Target not halted");
return ERROR_TARGET_INVALID;
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
*enabled = arm926ejs->armv4_5_mmu.mmu_enabled;
return ERROR_OK;

View File

@ -574,7 +574,7 @@ COMMAND_HANDLER(arm946e_handle_cp15)
return retval;
if (target->state != TARGET_HALTED) {
command_print(CMD, "target must be stopped for \"%s\" command", CMD_NAME);
command_print(CMD, "Error: target must be stopped for \"%s\" command", CMD_NAME);
return ERROR_TARGET_NOT_HALTED;
}
@ -624,7 +624,7 @@ COMMAND_HANDLER(arm946e_handle_idcache)
return retval;
if (target->state != TARGET_HALTED) {
command_print(CMD, "target must be stopped for \"%s\" command", CMD_NAME);
command_print(CMD, "Error: target must be stopped for \"%s\" command", CMD_NAME);
return ERROR_TARGET_NOT_HALTED;
}

View File

@ -174,8 +174,8 @@ COMMAND_HANDLER(arm966e_handle_cp15_command)
return retval;
if (target->state != TARGET_HALTED) {
command_print(CMD, "target must be stopped for \"%s\" command", CMD_NAME);
return ERROR_OK;
command_print(CMD, "Error: target must be stopped for \"%s\" command", CMD_NAME);
return ERROR_TARGET_NOT_HALTED;
}
/* one or more argument, access a single register (write if second argument is given */

View File

@ -578,7 +578,7 @@ static int armv4_5_get_core_reg(struct reg *reg)
struct target *target = reg_arch_info->target;
if (target->state != TARGET_HALTED) {
LOG_ERROR("Target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@ -600,7 +600,7 @@ static int armv4_5_set_core_reg(struct reg *reg, uint8_t *buf)
uint32_t value = buf_get_u32(buf, 0, 32);
if (target->state != TARGET_HALTED) {
LOG_ERROR("Target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@ -817,8 +817,8 @@ COMMAND_HANDLER(handle_armv4_5_reg_command)
}
if (target->state != TARGET_HALTED) {
command_print(CMD, "error: target must be halted for register accesses");
return ERROR_FAIL;
command_print(CMD, "Error: target must be halted for register accesses");
return ERROR_TARGET_NOT_HALTED;
}
if (arm->core_type != ARM_CORE_TYPE_STD) {
@ -833,7 +833,7 @@ COMMAND_HANDLER(handle_armv4_5_reg_command)
}
if (!arm->full_context) {
command_print(CMD, "error: target doesn't support %s",
command_print(CMD, "Error: target doesn't support %s",
CMD_NAME);
return ERROR_FAIL;
}
@ -1018,8 +1018,10 @@ COMMAND_HANDLER(handle_armv4_5_mcrmrc)
return ERROR_FAIL;
}
if (target->state != TARGET_HALTED)
if (target->state != TARGET_HALTED) {
command_print(CMD, "Error: [%s] not halted", target_name(target));
return ERROR_TARGET_NOT_HALTED;
}
int cpnum;
uint32_t op1;
@ -1307,7 +1309,7 @@ int armv4_5_run_algorithm_inner(struct target *target,
}
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted");
LOG_TARGET_ERROR(target, "not halted (run target algo)");
return ERROR_TARGET_NOT_HALTED;
}

View File

@ -107,8 +107,10 @@ int armv4_5_mmu_read_physical(struct target *target,
{
int retval;
if (target->state != TARGET_HALTED)
if (target->state != TARGET_HALTED) {
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
/* disable MMU and data (or unified) cache */
retval = armv4_5_mmu->disable_mmu_caches(target, 1, 1, 0);
@ -135,8 +137,10 @@ int armv4_5_mmu_write_physical(struct target *target,
{
int retval;
if (target->state != TARGET_HALTED)
if (target->state != TARGET_HALTED) {
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
/* disable MMU and data (or unified) cache */
retval = armv4_5_mmu->disable_mmu_caches(target, 1, 1, 0);

View File

@ -22,7 +22,7 @@ static int armv7a_l1_d_cache_sanity_check(struct target *target)
struct armv7a_common *armv7a = target_to_armv7a(target);
if (target->state != TARGET_HALTED) {
LOG_ERROR("%s: target not halted", __func__);
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@ -40,7 +40,7 @@ static int armv7a_l1_i_cache_sanity_check(struct target *target)
struct armv7a_common *armv7a = target_to_armv7a(target);
if (target->state != TARGET_HALTED) {
LOG_ERROR("%s: target not halted", __func__);
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}

View File

@ -525,7 +525,7 @@ int armv7m_start_algorithm(struct target *target,
}
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted");
LOG_TARGET_ERROR(target, "not halted (start target algo)");
return ERROR_TARGET_NOT_HALTED;
}

View File

@ -964,7 +964,7 @@ int armv8_mmu_translate_va_pa(struct target *target, target_addr_t va,
};
if (target->state != TARGET_HALTED) {
LOG_WARNING("target %s not halted", target_name(target));
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}

View File

@ -309,7 +309,7 @@ static int avr32_ap7k_resume(struct target *target, int current,
int retval;
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@ -431,7 +431,7 @@ static int avr32_ap7k_read_memory(struct target *target, target_addr_t address,
count);
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@ -471,7 +471,7 @@ static int avr32_ap7k_write_memory(struct target *target, target_addr_t address,
count);
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}

View File

@ -1147,7 +1147,7 @@ static int cortex_a_step(struct target *target, int current, target_addr_t addre
int retval;
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@ -2225,7 +2225,7 @@ static int cortex_a_write_cpu_memory(struct target *target,
LOG_DEBUG("Writing CPU memory address 0x%" PRIx32 " size %" PRIu32 " count %" PRIu32,
address, size, count);
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@ -2542,7 +2542,7 @@ static int cortex_a_read_cpu_memory(struct target *target,
LOG_DEBUG("Reading CPU memory address 0x%" PRIx32 " size %" PRIu32 " count %" PRIu32,
address, size, count);
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@ -3183,8 +3183,8 @@ static int cortex_a_mmu(struct target *target, int *enabled)
struct armv7a_common *armv7a = target_to_armv7a(target);
if (target->state != TARGET_HALTED) {
LOG_ERROR("%s: target not halted", __func__);
return ERROR_TARGET_INVALID;
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
if (armv7a->is_armv7r)

View File

@ -1214,7 +1214,7 @@ static int cortex_m_restore_one(struct target *target, bool current,
struct reg *r;
if (target->state != TARGET_HALTED) {
LOG_TARGET_ERROR(target, "target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@ -1391,7 +1391,7 @@ static int cortex_m_step(struct target *target, int current,
bool isr_timed_out = false;
if (target->state != TARGET_HALTED) {
LOG_TARGET_WARNING(target, "target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@ -2092,7 +2092,7 @@ int cortex_m_remove_watchpoint(struct target *target, struct watchpoint *watchpo
/* REVISIT why check? DWT can be updated with core running ... */
if (target->state != TARGET_HALTED) {
LOG_TARGET_WARNING(target, "target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@ -2948,8 +2948,8 @@ COMMAND_HANDLER(handle_cortex_m_mask_interrupts_command)
return retval;
if (target->state != TARGET_HALTED) {
command_print(CMD, "target must be stopped for \"%s\" command", CMD_NAME);
return ERROR_OK;
command_print(CMD, "Error: target must be stopped for \"%s\" command", CMD_NAME);
return ERROR_TARGET_NOT_HALTED;
}
if (CMD_ARGC > 0) {

View File

@ -1296,7 +1296,7 @@ static int dsp563xx_step(struct target *target,
struct dsp563xx_common *dsp563xx = target_to_dsp563xx(target);
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@ -1381,7 +1381,7 @@ static int dsp563xx_run_algorithm(struct target *target,
struct dsp563xx_common *dsp563xx = target_to_dsp563xx(target);
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted");
LOG_TARGET_ERROR(target, "not halted (run target algo)");
return ERROR_TARGET_NOT_HALTED;
}
@ -1705,7 +1705,7 @@ static int dsp563xx_write_memory_core(struct target *target,
count);
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}

View File

@ -318,8 +318,10 @@ static int esirisc_flush_caches(struct target *target)
LOG_DEBUG("-");
if (target->state != TARGET_HALTED)
if (target->state != TARGET_HALTED) {
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
int retval = esirisc_jtag_flush_caches(jtag_info);
if (retval != ERROR_OK) {
@ -855,8 +857,10 @@ static int esirisc_resume_or_step(struct target *target, int current, target_add
LOG_DEBUG("-");
if (target->state != TARGET_HALTED)
if (target->state != TARGET_HALTED) {
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
if (!debug_execution) {
target_free_all_working_areas(target);

View File

@ -449,7 +449,7 @@ static int adapter_resume(struct target *target, int current,
address, handle_breakpoints, debug_execution);
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@ -538,7 +538,7 @@ static int adapter_step(struct target *target, int current,
LOG_DEBUG("%s", __func__);
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}

View File

@ -438,7 +438,7 @@ int mips32_run_algorithm(struct target *target, int num_mem_params,
}
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted");
LOG_TARGET_ERROR(target, "not halted (run target algo)");
return ERROR_TARGET_NOT_HALTED;
}
@ -921,8 +921,8 @@ COMMAND_HANDLER(mips32_handle_cp0_command)
return retval;
if (target->state != TARGET_HALTED) {
command_print(CMD, "target must be stopped for \"%s\" command", CMD_NAME);
return ERROR_OK;
command_print(CMD, "Error: target must be stopped for \"%s\" command", CMD_NAME);
return ERROR_TARGET_NOT_HALTED;
}
/* two or more argument, access a single register/select (write if third argument is given) */

View File

@ -606,7 +606,7 @@ static int mips_mips64_resume(struct target *target, int current,
address = mips64_extend_sign(address);
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted %d", target->state);
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@ -706,7 +706,7 @@ static int mips_mips64_step(struct target *target, int current,
int retval = ERROR_OK;
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@ -804,7 +804,7 @@ static int mips_mips64_remove_breakpoint(struct target *target,
int retval = ERROR_OK;
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@ -865,7 +865,7 @@ static int mips_mips64_remove_watchpoint(struct target *target,
int retval = ERROR_OK;
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@ -886,7 +886,7 @@ static int mips_mips64_read_memory(struct target *target, uint64_t address,
void *t;
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted %d", target->state);
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@ -1014,7 +1014,7 @@ static int mips_mips64_write_memory(struct target *target, uint64_t address,
int retval;
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}

View File

@ -789,7 +789,7 @@ static int or1k_resume_or_step(struct target *target, int current,
address, step ? "yes" : "no", handle_breakpoints ? "yes" : "no");
if (target->state != TARGET_HALTED) {
LOG_ERROR("Target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@ -1026,7 +1026,7 @@ static int or1k_read_memory(struct target *target, target_addr_t address,
LOG_DEBUG("Read memory at 0x%08" TARGET_PRIxADDR ", size: %" PRIu32 ", count: 0x%08" PRIx32, address, size, count);
if (target->state != TARGET_HALTED) {
LOG_ERROR("Target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@ -1053,7 +1053,7 @@ static int or1k_write_memory(struct target *target, target_addr_t address,
LOG_DEBUG("Write memory at 0x%08" TARGET_PRIxADDR ", size: %" PRIu32 ", count: 0x%08" PRIx32, address, size, count);
if (target->state != TARGET_HALTED) {
LOG_WARNING("Target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}

View File

@ -1840,7 +1840,7 @@ static int riscv_run_algorithm(struct target *target, int num_mem_params,
}
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted");
LOG_TARGET_ERROR(target, "not halted (run target algo)");
return ERROR_TARGET_NOT_HALTED;
}

View File

@ -994,7 +994,7 @@ static int stm8_resume(struct target *target, int current,
handle_breakpoints, debug_execution);
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@ -1303,7 +1303,7 @@ static int stm8_step(struct target *target, int current,
struct breakpoint *breakpoint = NULL;
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@ -1518,7 +1518,7 @@ static int stm8_remove_breakpoint(struct target *target,
struct stm8_common *stm8 = target_to_stm8(target);
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@ -1654,7 +1654,7 @@ static int stm8_remove_watchpoint(struct target *target,
struct stm8_common *stm8 = target_to_stm8(target);
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}

View File

@ -1325,7 +1325,7 @@ int target_add_breakpoint(struct target *target,
struct breakpoint *breakpoint)
{
if ((target->state != TARGET_HALTED) && (breakpoint->type != BKPT_HARD)) {
LOG_WARNING("target %s is not halted (add breakpoint)", target_name(target));
LOG_TARGET_ERROR(target, "not halted (add breakpoint)");
return ERROR_TARGET_NOT_HALTED;
}
return target->type->add_breakpoint(target, breakpoint);
@ -1335,7 +1335,7 @@ int target_add_context_breakpoint(struct target *target,
struct breakpoint *breakpoint)
{
if (target->state != TARGET_HALTED) {
LOG_WARNING("target %s is not halted (add context breakpoint)", target_name(target));
LOG_TARGET_ERROR(target, "not halted (add context breakpoint)");
return ERROR_TARGET_NOT_HALTED;
}
return target->type->add_context_breakpoint(target, breakpoint);
@ -1345,7 +1345,7 @@ int target_add_hybrid_breakpoint(struct target *target,
struct breakpoint *breakpoint)
{
if (target->state != TARGET_HALTED) {
LOG_WARNING("target %s is not halted (add hybrid breakpoint)", target_name(target));
LOG_TARGET_ERROR(target, "not halted (add hybrid breakpoint)");
return ERROR_TARGET_NOT_HALTED;
}
return target->type->add_hybrid_breakpoint(target, breakpoint);
@ -1361,7 +1361,7 @@ int target_add_watchpoint(struct target *target,
struct watchpoint *watchpoint)
{
if (target->state != TARGET_HALTED) {
LOG_WARNING("target %s is not halted (add watchpoint)", target_name(target));
LOG_TARGET_ERROR(target, "not halted (add watchpoint)");
return ERROR_TARGET_NOT_HALTED;
}
return target->type->add_watchpoint(target, watchpoint);
@ -1375,7 +1375,7 @@ int target_hit_watchpoint(struct target *target,
struct watchpoint **hit_watchpoint)
{
if (target->state != TARGET_HALTED) {
LOG_WARNING("target %s is not halted (hit watchpoint)", target->cmd_name);
LOG_TARGET_ERROR(target, "not halted (hit watchpoint)");
return ERROR_TARGET_NOT_HALTED;
}
@ -1457,7 +1457,7 @@ int target_step(struct target *target,
int target_get_gdb_fileio_info(struct target *target, struct gdb_fileio_info *fileio_info)
{
if (target->state != TARGET_HALTED) {
LOG_WARNING("target %s is not halted (gdb fileio)", target->cmd_name);
LOG_TARGET_ERROR(target, "not halted (gdb fileio)");
return ERROR_TARGET_NOT_HALTED;
}
return target->type->get_gdb_fileio_info(target, fileio_info);
@ -1466,7 +1466,7 @@ int target_get_gdb_fileio_info(struct target *target, struct gdb_fileio_info *fi
int target_gdb_fileio_end(struct target *target, int retcode, int fileio_errno, bool ctrl_c)
{
if (target->state != TARGET_HALTED) {
LOG_WARNING("target %s is not halted (gdb fileio end)", target->cmd_name);
LOG_TARGET_ERROR(target, "not halted (gdb fileio end)");
return ERROR_TARGET_NOT_HALTED;
}
return target->type->gdb_fileio_end(target, retcode, fileio_errno, ctrl_c);
@ -6666,8 +6666,8 @@ COMMAND_HANDLER(handle_ps_command)
struct target *target = get_current_target(CMD_CTX);
char *display;
if (target->state != TARGET_HALTED) {
LOG_INFO("target not halted !!");
return ERROR_OK;
command_print(CMD, "Error: [%s] not halted", target_name(target));
return ERROR_TARGET_NOT_HALTED;
}
if ((target->rtos) && (target->rtos->type)
@ -6698,8 +6698,8 @@ COMMAND_HANDLER(handle_test_mem_access_command)
int retval = ERROR_OK;
if (target->state != TARGET_HALTED) {
LOG_INFO("target not halted !!");
return ERROR_FAIL;
command_print(CMD, "Error: [%s] not halted", target_name(target));
return ERROR_TARGET_NOT_HALTED;
}
if (CMD_ARGC != 1)

View File

@ -1118,7 +1118,7 @@ static int xscale_resume(struct target *target, int current,
LOG_DEBUG("-");
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@ -1382,7 +1382,7 @@ static int xscale_step(struct target *target, int current,
int retval;
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@ -1632,7 +1632,7 @@ static int xscale_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;
}
@ -1705,7 +1705,7 @@ static int xscale_restore_banked(struct target *target)
int i, j;
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@ -1781,7 +1781,7 @@ static int xscale_read_memory(struct target *target, target_addr_t address,
count);
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@ -1880,7 +1880,7 @@ static int xscale_write_memory(struct target *target, target_addr_t address,
count);
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@ -2073,7 +2073,7 @@ static int xscale_set_breakpoint(struct target *target,
struct xscale_common *xscale = target_to_xscale(target);
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@ -2163,7 +2163,7 @@ static int xscale_unset_breakpoint(struct target *target,
struct xscale_common *xscale = target_to_xscale(target);
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@ -2210,7 +2210,7 @@ static int xscale_remove_breakpoint(struct target *target, struct breakpoint *br
struct xscale_common *xscale = target_to_xscale(target);
if (target->state != TARGET_HALTED) {
LOG_ERROR("target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@ -2232,7 +2232,7 @@ static int xscale_set_watchpoint(struct target *target,
uint32_t dbcon_value = buf_get_u32(dbcon->value, 0, 32);
if (target->state != TARGET_HALTED) {
LOG_ERROR("target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@ -2336,7 +2336,7 @@ static int xscale_unset_watchpoint(struct target *target,
uint32_t dbcon_value = buf_get_u32(dbcon->value, 0, 32);
if (target->state != TARGET_HALTED) {
LOG_WARNING("target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@ -2369,7 +2369,7 @@ static int xscale_remove_watchpoint(struct target *target, struct watchpoint *wa
struct xscale_common *xscale = target_to_xscale(target);
if (target->state != TARGET_HALTED) {
LOG_ERROR("target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@ -2490,7 +2490,7 @@ static int xscale_read_trace(struct target *target)
unsigned int num_checkpoints = 0;
if (target->state != TARGET_HALTED) {
LOG_WARNING("target must be stopped to read trace data");
LOG_TARGET_ERROR(target, "must be stopped to read trace data");
return ERROR_TARGET_NOT_HALTED;
}
@ -3131,8 +3131,8 @@ static int xscale_mmu(struct target *target, int *enabled)
struct xscale_common *xscale = target_to_xscale(target);
if (target->state != TARGET_HALTED) {
LOG_ERROR("Target not halted");
return ERROR_TARGET_INVALID;
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
*enabled = xscale->armv4_5_mmu.mmu_enabled;
return ERROR_OK;
@ -3149,8 +3149,8 @@ COMMAND_HANDLER(xscale_handle_mmu_command)
return retval;
if (target->state != TARGET_HALTED) {
command_print(CMD, "target must be stopped for \"%s\" command", CMD_NAME);
return ERROR_OK;
command_print(CMD, "Error: target must be stopped for \"%s\" command", CMD_NAME);
return ERROR_TARGET_NOT_HALTED;
}
if (CMD_ARGC >= 1) {
@ -3179,8 +3179,8 @@ COMMAND_HANDLER(xscale_handle_idcache_command)
return retval;
if (target->state != TARGET_HALTED) {
command_print(CMD, "target must be stopped for \"%s\" command", CMD_NAME);
return ERROR_OK;
command_print(CMD, "Error: target must be stopped for \"%s\" command", CMD_NAME);
return ERROR_TARGET_NOT_HALTED;
}
bool icache = false;
@ -3347,8 +3347,8 @@ COMMAND_HANDLER(xscale_handle_trace_buffer_command)
return retval;
if (target->state != TARGET_HALTED) {
command_print(CMD, "target must be stopped for \"%s\" command", CMD_NAME);
return ERROR_OK;
command_print(CMD, "Error: target must be stopped for \"%s\" command", CMD_NAME);
return ERROR_TARGET_NOT_HALTED;
}
if (CMD_ARGC >= 1) {
@ -3451,8 +3451,8 @@ COMMAND_HANDLER(xscale_handle_dump_trace_command)
return retval;
if (target->state != TARGET_HALTED) {
command_print(CMD, "target must be stopped for \"%s\" command", CMD_NAME);
return ERROR_OK;
command_print(CMD, "Error: target must be stopped for \"%s\" command", CMD_NAME);
return ERROR_TARGET_NOT_HALTED;
}
if (CMD_ARGC < 1)
@ -3514,8 +3514,8 @@ COMMAND_HANDLER(xscale_handle_cp15)
return retval;
if (target->state != TARGET_HALTED) {
command_print(CMD, "target must be stopped for \"%s\" command", CMD_NAME);
return ERROR_OK;
command_print(CMD, "Error: target must be stopped for \"%s\" command", CMD_NAME);
return ERROR_TARGET_NOT_HALTED;
}
uint32_t reg_no = 0;
struct reg *reg = NULL;

View File

@ -1541,7 +1541,7 @@ int xtensa_prepare_resume(struct target *target,
debug_execution);
if (target->state != TARGET_HALTED) {
LOG_TARGET_WARNING(target, "target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
xtensa->halt_request = false;
@ -1667,7 +1667,7 @@ int xtensa_do_step(struct target *target, int current, target_addr_t address, in
current, address, handle_breakpoints);
if (target->state != TARGET_HALTED) {
LOG_TARGET_WARNING(target, "target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@ -1941,7 +1941,7 @@ int xtensa_read_memory(struct target *target, target_addr_t address, uint32_t si
bool bswap = xtensa->target->endianness == TARGET_BIG_ENDIAN;
if (target->state != TARGET_HALTED) {
LOG_TARGET_WARNING(target, "target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@ -2037,7 +2037,7 @@ int xtensa_write_memory(struct target *target,
bool fill_head_tail = false;
if (target->state != TARGET_HALTED) {
LOG_TARGET_WARNING(target, "target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}
@ -2566,7 +2566,7 @@ int xtensa_watchpoint_add(struct target *target, struct watchpoint *watchpoint)
xtensa_reg_val_t dbreakcval;
if (target->state != TARGET_HALTED) {
LOG_TARGET_WARNING(target, "target not halted");
LOG_TARGET_ERROR(target, "not halted");
return ERROR_TARGET_NOT_HALTED;
}