Have targets register a helper to resolve their exceptions.
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
---
include/hw/core/cpu.h | 2 ++
accel/tcg/cpu-exec-common.c | 8 +++++++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index 456154df6f6..9d71db16d2f 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -108,6 +108,7 @@ struct SemihostingCPUOps;
* @list_cpus: list available CPU models and flags.
* @parse_features: Callback to parse command line arguments.
* @reset_dump_flags: #CPUDumpFlags to use for reset logging.
+ * @exception_name: Callback for getting architecture exception name.
* @memory_rw_debug: Callback for GDB memory access.
* @dump_state: Callback for dumping state.
* @query_cpu_fast:
@@ -178,6 +179,7 @@ struct CPUClass {
const char * (*gdb_arch_name)(CPUState *cpu);
const char * (*gdb_get_core_xml_file)(CPUState *cpu);
+ const char *(*exception_name)(int exception);
void (*disas_set_info)(const CPUState *cpu, disassemble_info *info);
const char *deprecation_note;
diff --git a/accel/tcg/cpu-exec-common.c b/accel/tcg/cpu-exec-common.c
index 2ac8380d0bb..a347dc244d8 100644
--- a/accel/tcg/cpu-exec-common.c
+++ b/accel/tcg/cpu-exec-common.c
@@ -106,7 +106,7 @@ static const char *qemu_excp_name(int excp)
if ((excp < ARRAY_SIZE(excp_name)) && excp_name[excp]) {
return excp_name[excp];
}
- return "undocumented";
+ return "unknown";
}
static void log_raise_exception(const CPUState *cpu, int excp)
@@ -117,6 +117,12 @@ static void log_raise_exception(const CPUState *cpu, int
excp)
if (excp >= EXCP_QEMU_INTERNAL) {
qemu_log_mask(CPU_LOG_INT, "raise exception: 0x%x (internal: %s)\n",
excp, qemu_excp_name(excp));
+ } else {
+ const CPUClass *cc = cpu->cc;
+ const char *name = cc->exception_name ? cc->exception_name(excp)
+ : "unknown";
+
+ qemu_log_mask(CPU_LOG_INT, "raise exception: %d (%s)\n", excp, name);
}
}
--
2.55.0