summaryrefslogtreecommitdiff
path: root/src/target/target.c
diff options
context:
space:
mode:
authorDavid Brownell <dbrownell@users.sourceforge.net>2009-12-07 14:55:08 -0800
committerDavid Brownell <dbrownell@users.sourceforge.net>2009-12-07 14:57:44 -0800
commitbbb754aa395be74ceac0c01640fb33c0fae52c20 (patch)
tree54c581f26df52ec5b0f7fe3efe73b406d3acdb88 /src/target/target.c
parent19ad7f828ba36f398f52749c2f33e25a3ea78ac2 (diff)
downloadopenocd+libswd-bbb754aa395be74ceac0c01640fb33c0fae52c20.tar.gz
openocd+libswd-bbb754aa395be74ceac0c01640fb33c0fae52c20.tar.bz2
openocd+libswd-bbb754aa395be74ceac0c01640fb33c0fae52c20.tar.xz
openocd+libswd-bbb754aa395be74ceac0c01640fb33c0fae52c20.zip
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>
Diffstat (limited to 'src/target/target.c')
-rw-r--r--src/target/target.c15
1 files changed, 14 insertions, 1 deletions
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 )
{