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:
@@ -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 )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user