[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 16/16] target/sparc/int32_helper: Extract and use excp_name_str()
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 16/16] target/sparc/int32_helper: Extract and use excp_name_str() |
Date: |
Tue, 9 Jun 2020 09:32:14 +0200 |
Improve exception error report:
Before:
qemu: fatal: Trap 0x06 while interrupts disabled, Error state
After:
qemu: fatal: Trap 0x06 (Window Underflow) while interrupts disabled, Error
state
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: KONRAD Frederic <frederic.konrad@adacore.com>
Message-Id: <20200331105048.27989-8-f4bug@amsat.org>
---
target/sparc/int32_helper.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/target/sparc/int32_helper.c b/target/sparc/int32_helper.c
index c56dd3df18..9a71e1abd8 100644
--- a/target/sparc/int32_helper.c
+++ b/target/sparc/int32_helper.c
@@ -57,6 +57,14 @@ static const char * const excp_names[0x80] = {
[TT_NCP_INSN] = "Coprocessor Disabled",
};
+static const char *excp_name_str(int32_t exception_index)
+{
+ if (exception_index < 0 || exception_index >= ARRAY_SIZE(excp_names)) {
+ return "Unknown";
+ }
+ return excp_names[exception_index];
+}
+
void sparc_cpu_do_interrupt(CPUState *cs)
{
SPARCCPU *cpu = SPARC_CPU(cs);
@@ -77,10 +85,7 @@ void sparc_cpu_do_interrupt(CPUState *cs)
} else if (intno >= 0x80) {
name = "Trap Instruction";
} else {
- name = excp_names[intno];
- if (!name) {
- name = "Unknown";
- }
+ name = excp_name_str(intno);
}
qemu_log("%6d: %s (v=%02x)\n", count, name, intno);
@@ -106,8 +111,9 @@ void sparc_cpu_do_interrupt(CPUState *cs)
env->def.features & CPU_FEATURE_TA0_SHUTDOWN) {
qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
} else {
- cpu_abort(cs, "Trap 0x%02x while interrupts disabled, Error state",
- cs->exception_index);
+ cpu_abort(cs, "Trap 0x%02x (%s) while interrupts disabled, "
+ "Error state",
+ cs->exception_index, excp_name_str(cs->exception_index));
}
return;
}
--
2.21.3
- [PULL 09/16] hw/sparc64/niagara: Map the UART device unconditionally, (continued)
- [PULL 09/16] hw/sparc64/niagara: Map the UART device unconditionally, Philippe Mathieu-Daudé, 2020/06/09
- [PULL 07/16] hw/misc/empty_slot: Name the slots when created, Philippe Mathieu-Daudé, 2020/06/09
- [PULL 12/16] hw/misc/grlib_ahb_apb_pnp: Fix AHB PnP 8-bit accesses, Philippe Mathieu-Daudé, 2020/06/09
- [PULL 05/16] hw/misc/empty_slot: Convert debug printf() to trace event, Philippe Mathieu-Daudé, 2020/06/09
- [PULL 13/16] hw/misc/grlib_ahb_apb_pnp: Add trace events on read accesses, Philippe Mathieu-Daudé, 2020/06/09
- [PULL 14/16] hw/timer/grlib_gptimer: Display frequency in decimal, Philippe Mathieu-Daudé, 2020/06/09
- [PULL 11/16] hw/misc/grlib_ahb_apb_pnp: Avoid crash when writing to AHB PnP registers, Philippe Mathieu-Daudé, 2020/06/09
- [PULL 15/16] target/sparc/int32_helper: Remove DEBUG_PCALL definition, Philippe Mathieu-Daudé, 2020/06/09
- [PULL 08/16] hw/sparc/leon3: Map the UART device unconditionally, Philippe Mathieu-Daudé, 2020/06/09
- [PULL 10/16] hw/sparc64/niagara: Remove duplicated NIAGARA_UART_BASE definition, Philippe Mathieu-Daudé, 2020/06/09
- [PULL 16/16] target/sparc/int32_helper: Extract and use excp_name_str(),
Philippe Mathieu-Daudé <=
- Re: [PULL 00/16] SPARC patches for 2020-06-09, Peter Maydell, 2020/06/09
- Re: [PULL 00/16] SPARC patches for 2020-06-09, Mark Cave-Ayland, 2020/06/09