target: add debug_reason_name()
Provide and use debug_reason_name() instead of expecting targets to call Jim_Nvp_value2name_simple(). Less dependency on Jim, and the code becomes more clear too. Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
This commit is contained in:
parent
19ad7f828b
commit
bbb754aa39
|
@ -595,8 +595,7 @@ int arm_arch_state(struct target *target)
|
||||||
LOG_USER("target halted in %s state due to %s, current mode: %s\n"
|
LOG_USER("target halted in %s state due to %s, current mode: %s\n"
|
||||||
"cpsr: 0x%8.8" PRIx32 " pc: 0x%8.8" PRIx32 "%s",
|
"cpsr: 0x%8.8" PRIx32 " pc: 0x%8.8" PRIx32 "%s",
|
||||||
arm_state_strings[armv4_5->core_state],
|
arm_state_strings[armv4_5->core_state],
|
||||||
Jim_Nvp_value2name_simple(nvp_target_debug_reason,
|
debug_reason_name(target),
|
||||||
target->debug_reason)->name,
|
|
||||||
arm_mode_name(armv4_5->core_mode),
|
arm_mode_name(armv4_5->core_mode),
|
||||||
buf_get_u32(armv4_5->cpsr->value, 0, 32),
|
buf_get_u32(armv4_5->cpsr->value, 0, 32),
|
||||||
buf_get_u32(armv4_5->core_cache->reg_list[15].value,
|
buf_get_u32(armv4_5->core_cache->reg_list[15].value,
|
||||||
|
|
|
@ -480,8 +480,7 @@ int armv7m_arch_state(struct target *target)
|
||||||
|
|
||||||
LOG_USER("target halted due to %s, current mode: %s %s\n"
|
LOG_USER("target halted due to %s, current mode: %s %s\n"
|
||||||
"xPSR: %#8.8" PRIx32 " pc: %#8.8" PRIx32 " %csp: %#8.8" PRIx32,
|
"xPSR: %#8.8" PRIx32 " pc: %#8.8" PRIx32 " %csp: %#8.8" PRIx32,
|
||||||
Jim_Nvp_value2name_simple(nvp_target_debug_reason,
|
debug_reason_name(target),
|
||||||
target->debug_reason)->name,
|
|
||||||
armv7m_mode_strings[armv7m->core_mode],
|
armv7m_mode_strings[armv7m->core_mode],
|
||||||
armv7m_exception_string(armv7m->exception_number),
|
armv7m_exception_string(armv7m->exception_number),
|
||||||
buf_get_u32(armv7m->core_cache->reg_list[ARMV7M_xPSR].value, 0, 32),
|
buf_get_u32(armv7m->core_cache->reg_list[ARMV7M_xPSR].value, 0, 32),
|
||||||
|
|
|
@ -254,7 +254,7 @@ int mips32_arch_state(struct target *target)
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_USER("target halted due to %s, pc: 0x%8.8" PRIx32 "",
|
LOG_USER("target halted due to %s, pc: 0x%8.8" PRIx32 "",
|
||||||
Jim_Nvp_value2name_simple(nvp_target_debug_reason, target->debug_reason)->name ,
|
debug_reason_name(target),
|
||||||
buf_get_u32(mips32->core_cache->reg_list[MIPS32_PC].value, 0, 32));
|
buf_get_u32(mips32->core_cache->reg_list[MIPS32_PC].value, 0, 32));
|
||||||
|
|
||||||
return ERROR_OK;
|
return ERROR_OK;
|
||||||
|
|
|
@ -187,7 +187,7 @@ const Jim_Nvp nvp_target_state[] = {
|
||||||
{ .name = NULL, .value = -1 },
|
{ .name = NULL, .value = -1 },
|
||||||
};
|
};
|
||||||
|
|
||||||
const Jim_Nvp nvp_target_debug_reason [] = {
|
static const Jim_Nvp nvp_target_debug_reason [] = {
|
||||||
{ .name = "debug-request" , .value = DBG_REASON_DBGRQ },
|
{ .name = "debug-request" , .value = DBG_REASON_DBGRQ },
|
||||||
{ .name = "breakpoint" , .value = DBG_REASON_BREAKPOINT },
|
{ .name = "breakpoint" , .value = DBG_REASON_BREAKPOINT },
|
||||||
{ .name = "watchpoint" , .value = DBG_REASON_WATCHPOINT },
|
{ .name = "watchpoint" , .value = DBG_REASON_WATCHPOINT },
|
||||||
|
@ -214,6 +214,19 @@ const Jim_Nvp nvp_reset_modes[] = {
|
||||||
{ .name = NULL , .value = -1 },
|
{ .name = NULL , .value = -1 },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const char *debug_reason_name(struct target *t)
|
||||||
|
{
|
||||||
|
const char *cp;
|
||||||
|
|
||||||
|
cp = Jim_Nvp_value2name_simple(nvp_target_debug_reason,
|
||||||
|
t->debug_reason)->name;
|
||||||
|
if (!cp) {
|
||||||
|
LOG_ERROR("Invalid debug reason: %d", (int)(t->debug_reason));
|
||||||
|
cp = "(*BUG*unknown*BUG*)";
|
||||||
|
}
|
||||||
|
return cp;
|
||||||
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
target_state_name( struct target *t )
|
target_state_name( struct target *t )
|
||||||
{
|
{
|
||||||
|
|
|
@ -91,8 +91,6 @@ enum target_debug_reason
|
||||||
DBG_REASON_UNDEFINED = 6
|
DBG_REASON_UNDEFINED = 6
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const Jim_Nvp nvp_target_debug_reason[];
|
|
||||||
|
|
||||||
enum target_endianess
|
enum target_endianess
|
||||||
{
|
{
|
||||||
TARGET_ENDIAN_UNKNOWN = 0,
|
TARGET_ENDIAN_UNKNOWN = 0,
|
||||||
|
@ -165,6 +163,8 @@ static inline const char *target_name(struct target *target)
|
||||||
return target->cmd_name;
|
return target->cmd_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *debug_reason_name(struct target *t);
|
||||||
|
|
||||||
enum target_event
|
enum target_event
|
||||||
{
|
{
|
||||||
/* LD historical names
|
/* LD historical names
|
||||||
|
|
Loading…
Reference in New Issue