Implement tricore_trap_name() and register it as the CPUClass::exception_name() handler, so the common exception logging can resolve TriCore trop numbers to names.
Signed-off-by: Philippe Mathieu-Daudé <[email protected]> --- target/tricore/cpu.h | 2 ++ target/tricore/cpu.c | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/target/tricore/cpu.h b/target/tricore/cpu.h index 12e497d2a7a..fb8d2fd1011 100644 --- a/target/tricore/cpu.h +++ b/target/tricore/cpu.h @@ -178,6 +178,8 @@ enum { TRAPC_IRQ = 8 }; +const char *tricore_trap_name(int trap); + /* Class 0 TIN */ enum { TIN0_VAF = 0, diff --git a/target/tricore/cpu.c b/target/tricore/cpu.c index 84a05e3d363..d550b8b0b8e 100644 --- a/target/tricore/cpu.c +++ b/target/tricore/cpu.c @@ -36,6 +36,26 @@ static const gchar *tricore_gdb_arch_name(CPUState *cs) return "tricore"; } +const char *tricore_trap_name(int trap) +{ + static const char * const trap_names[] = { + [TRAPC_MMU] = "mmu", + [TRAPC_PROT] = "prot", + [TRAPC_INSN_ERR] = "insn err", + [TRAPC_CTX_MNG] = "ctx mng", + [TRAPC_SYSBUS] = "sysbus", + [TRAPC_ASSERT] = "assert", + [TRAPC_SYSCALL] = "syscall", + [TRAPC_NMI] = "NMI", + [TRAPC_IRQ] = "IRQ", + }; + + if (trap < 0 || trap >= ARRAY_SIZE(trap_names) || !trap_names[trap]) { + return "unknown"; + } + return trap_names[trap]; +} + static void tricore_disas_set_info(const CPUState *cpu, disassemble_info *info) { CPUTriCoreState *env = cpu_env((CPUState *)cpu); @@ -240,6 +260,7 @@ static void tricore_cpu_class_init(ObjectClass *c, const void *data) resettable_class_set_parent_phases(rc, NULL, tricore_cpu_reset_hold, NULL, &mcc->parent_phases); cc->class_by_name = tricore_cpu_class_by_name; + cc->exception_name = tricore_trap_name; cc->gdb_read_register = tricore_cpu_gdb_read_register; cc->gdb_write_register = tricore_cpu_gdb_write_register; -- 2.55.0
