Browse Source

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>
tags/v0.4.0-rc1
David Brownell 14 years ago
parent
commit
bbb754aa39
5 changed files with 19 additions and 8 deletions
  1. +1
    -2
      src/target/armv4_5.c
  2. +1
    -2
      src/target/armv7m.c
  3. +1
    -1
      src/target/mips32.c
  4. +14
    -1
      src/target/target.c
  5. +2
    -2
      src/target/target.h

+ 1
- 2
src/target/armv4_5.c View File

@@ -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,


+ 1
- 2
src/target/armv7m.c View File

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


+ 1
- 1
src/target/mips32.c View File

@@ -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;


+ 14
- 1
src/target/target.c 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 )
{


+ 2
- 2
src/target/target.h View File

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


Loading…
Cancel
Save