summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/target/armv4_5.c3
-rw-r--r--src/target/armv7m.c3
-rw-r--r--src/target/mips32.c2
-rw-r--r--src/target/target.c15
-rw-r--r--src/target/target.h4
5 files changed, 19 insertions, 8 deletions
diff --git a/src/target/armv4_5.c b/src/target/armv4_5.c
index dce6d6a6..1c4923b9 100644
--- a/src/target/armv4_5.c
+++ b/src/target/armv4_5.c
@@ -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"
"cpsr: 0x%8.8" PRIx32 " pc: 0x%8.8" PRIx32 "%s",
arm_state_strings[armv4_5->core_state],
- Jim_Nvp_value2name_simple(nvp_target_debug_reason,
- target->debug_reason)->name,
+ debug_reason_name(target),
arm_mode_name(armv4_5->core_mode),
buf_get_u32(armv4_5->cpsr->value, 0, 32),
buf_get_u32(armv4_5->core_cache->reg_list[15].value,
diff --git a/src/target/armv7m.c b/src/target/armv7m.c
index fc3f47cc..d4f6309f 100644
--- a/src/target/armv7m.c
+++ b/src/target/armv7m.c
@@ -480,8 +480,7 @@ int armv7m_arch_state(struct target *target)
LOG_USER("target halted due to %s, current mode: %s %s\n"
"xPSR: %#8.8" PRIx32 " pc: %#8.8" PRIx32 " %csp: %#8.8" PRIx32,
- Jim_Nvp_value2name_simple(nvp_target_debug_reason,
- target->debug_reason)->name,
+ debug_reason_name(target),
armv7m_mode_strings[armv7m->core_mode],
armv7m_exception_string(armv7m->exception_number),
buf_get_u32(armv7m->core_cache->reg_list[ARMV7M_xPSR].value, 0, 32),
diff --git a/src/target/mips32.c b/src/target/mips32.c
index 48d07202..e8ea541a 100644
--- a/src/target/mips32.c
+++ b/src/target/mips32.c
@@ -254,7 +254,7 @@ int mips32_arch_state(struct target *target)
}
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));
return ERROR_OK;
diff --git a/src/target/target.c b/src/target/target.c
index 597046fa..f249d380 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -187,7 +187,7 @@ const Jim_Nvp nvp_target_state[] = {
{ .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 = "breakpoint" , .value = DBG_REASON_BREAKPOINT },
{ .name = "watchpoint" , .value = DBG_REASON_WATCHPOINT },
@@ -214,6 +214,19 @@ const Jim_Nvp nvp_reset_modes[] = {
{ .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 *
target_state_name( struct target *t )
{
diff --git a/src/target/target.h b/src/target/target.h
index 73190695..dd3d4f7f 100644
--- a/src/target/target.h
+++ b/src/target/target.h
@@ -91,8 +91,6 @@ enum target_debug_reason
DBG_REASON_UNDEFINED = 6
};
-extern const Jim_Nvp nvp_target_debug_reason[];
-
enum target_endianess
{
TARGET_ENDIAN_UNKNOWN = 0,
@@ -165,6 +163,8 @@ static inline const char *target_name(struct target *target)
return target->cmd_name;
}
+const char *debug_reason_name(struct target *t);
+
enum target_event
{
/* LD historical names