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:
David Brownell
2009-12-07 14:55:08 -08:00
parent 19ad7f828b
commit bbb754aa39
5 changed files with 19 additions and 8 deletions

View File

@@ -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 )
{