target/xtensa: Implement and register CPUClass::exception_name()
Implement xtensa_exception_name() and register it as the CPUClass::exception_name() handler, so the common exception logging can resolve Xtensa exception codes to names. Use the new helper in xtensa_cpu_do_interrupt(). With '-d int', xtensa_cpu_do_interrupt() now logs the exception name after its number. Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com> Message-ID: <20261022215115.19680-34-philmd@oss.qualcomm.com>
This commit is contained in:
1 parent
1647c22d64
commit
07a10df87d
3 files changed
+28
-1
No files matched your search
@@ -29,6 +29,7 @@
|
||||
*/
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "qemu/cutils.h"
|
||||
#include "qapi/error.h"
|
||||
#include "exec/cpu-defs.h"
|
||||
#include "cpu.h"
|
||||
@@ -239,6 +240,28 @@ static void xtensa_cpu_disas_set_info(const CPUState *cs,
|
||||
: BFD_ENDIAN_LITTLE;
|
||||
}
|
||||
|
||||
const char *xtensa_exception_name(int excp)
|
||||
{
|
||||
static const char * const excp_names[] = {
|
||||
[EXC_RESET0] = "reset",
|
||||
[EXC_RESET1] = "reset",
|
||||
[EXC_MEMORY_ERROR] = "memory error",
|
||||
[EXC_WINDOW_OVERFLOW4] = "window overflow",
|
||||
[EXC_WINDOW_UNDERFLOW4] = "window underflow",
|
||||
[EXC_WINDOW_OVERFLOW8] = "window overflow",
|
||||
[EXC_WINDOW_UNDERFLOW8] = "window underflow",
|
||||
[EXC_WINDOW_OVERFLOW12] = "window overflow",
|
||||
[EXC_WINDOW_UNDERFLOW12] = "window underflow",
|
||||
[EXC_IRQ] = "interrupt",
|
||||
[EXC_KERNEL] = "kernel",
|
||||
[EXC_USER] = "user",
|
||||
[EXC_DOUBLE] = "double",
|
||||
[EXC_DEBUG] = "debug",
|
||||
};
|
||||
|
||||
return STR_ARRAY_ELEM_OR_NULL(excp_names, excp) ?: "unknown";
|
||||
}
|
||||
|
||||
static void xtensa_cpu_realizefn(DeviceState *dev, Error **errp)
|
||||
{
|
||||
CPUState *cs = CPU(dev);
|
||||
@@ -347,6 +370,7 @@ static void xtensa_cpu_class_init(ObjectClass *oc, const void *data)
|
||||
&xcc->parent_phases);
|
||||
|
||||
cc->class_by_name = xtensa_cpu_class_by_name;
|
||||
cc->exception_name = xtensa_exception_name;
|
||||
cc->dump_state = xtensa_cpu_dump_state;
|
||||
cc->set_pc = xtensa_cpu_set_pc;
|
||||
cc->get_pc = xtensa_cpu_get_pc;
|
||||
|
||||
@@ -262,6 +262,8 @@ enum {
|
||||
EXC_MAX
|
||||
};
|
||||
|
||||
const char *xtensa_exception_name(int excp);
|
||||
|
||||
enum {
|
||||
ILLEGAL_INSTRUCTION_CAUSE = 0,
|
||||
SYSCALL_CAUSE,
|
||||
|
||||
@@ -236,9 +236,10 @@ void xtensa_cpu_do_interrupt(CPUState *cs)
|
||||
case EXC_USER:
|
||||
case EXC_DOUBLE:
|
||||
case EXC_DEBUG:
|
||||
qemu_log_mask(CPU_LOG_INT, "%s(%d) "
|
||||
qemu_log_mask(CPU_LOG_INT, "%s(%d:%s) "
|
||||
"pc = %08x, a0 = %08x, ps = %08x, ccount = %08x\n",
|
||||
__func__, cs->exception_index,
|
||||
xtensa_exception_name(cs->exception_index),
|
||||
env->pc, env->regs[0], env->sregs[PS],
|
||||
env->sregs[CCOUNT]);
|
||||
if (env->config->exception_vector[cs->exception_index]) {
|
||||
|
||||
Reference in new issue
Block a user