[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 61/74] target/mips: Use error_report for UHI_assert
From: |
Richard Henderson |
Subject: |
[PATCH v2 61/74] target/mips: Use error_report for UHI_assert |
Date: |
Tue, 3 May 2022 12:48:30 -0700 |
Always log the assert locally. Do not report_fault, but
instead include the fact of the fault in the assertion.
Don't bother freeing allocated strings before the abort().
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/mips/tcg/sysemu/mips-semi.c | 39 ++++++++++++++----------------
1 file changed, 18 insertions(+), 21 deletions(-)
diff --git a/target/mips/tcg/sysemu/mips-semi.c
b/target/mips/tcg/sysemu/mips-semi.c
index d8c9be5e9f..df1747aafe 100644
--- a/target/mips/tcg/sysemu/mips-semi.c
+++ b/target/mips/tcg/sysemu/mips-semi.c
@@ -221,18 +221,6 @@ static int copy_argn_to_target(CPUMIPSState *env, int
arg_num,
} \
} while (0)
-#define GET_TARGET_STRINGS_2(p, addr, p2, addr2) \
- do { \
- p = lock_user_string(addr); \
- if (!p) { \
- report_fault(env); \
- } \
- p2 = lock_user_string(addr2); \
- if (!p2) { \
- report_fault(env); \
- } \
- } while (0)
-
#define FREE_TARGET_STRING(p, gpr) \
do { \
unlock_user(p, gpr, 0); \
@@ -243,7 +231,7 @@ void mips_semihosting(CPUMIPSState *env)
CPUState *cs = env_cpu(env);
target_ulong *gpr = env->active_tc.gpr;
const UHIOp op = gpr[25];
- char *p, *p2;
+ char *p;
switch (op) {
case UHI_exit:
@@ -355,14 +343,23 @@ void mips_semihosting(CPUMIPSState *env)
break;
case UHI_assert:
- GET_TARGET_STRINGS_2(p, gpr[4], p2, gpr[5]);
- printf("assertion '");
- printf("\"%s\"", p);
- printf("': file \"%s\", line %d\n", p2, (int)gpr[6]);
- FREE_TARGET_STRING(p2, gpr[5]);
- FREE_TARGET_STRING(p, gpr[4]);
- abort();
- break;
+ {
+ const char *msg, *file;
+
+ msg = lock_user_string(gpr[4]);
+ if (!msg) {
+ msg = "<EFAULT>";
+ }
+ file = lock_user_string(gpr[5]);
+ if (!file) {
+ file = "<EFAULT>";
+ }
+
+ error_report("UHI assertion \"%s\": file \"%s\", line %d",
+ msg, file, (int)gpr[6]);
+ abort();
+ }
+
default:
error_report("Unknown UHI operation %d", op);
abort();
--
2.34.1
- [PATCH v2 51/74] target/nios2: Eliminate nios2_semi_is_lseek, (continued)
- [PATCH v2 51/74] target/nios2: Eliminate nios2_semi_is_lseek, Richard Henderson, 2022/05/03
- [PATCH v2 57/74] target/mips: Drop link syscall from semihosting, Richard Henderson, 2022/05/03
- [PATCH v2 53/74] target/nios2: Use semihosting/syscalls.h, Richard Henderson, 2022/05/03
- [PATCH v2 54/74] target/mips: Use an exception for semihosting, Richard Henderson, 2022/05/03
- [PATCH v2 60/74] target/mips: Avoid qemu_semihosting_log_out for UHI_plog, Richard Henderson, 2022/05/03
- [PATCH v2 56/74] target/mips: Create report_fault for semihosting, Richard Henderson, 2022/05/03
- [PATCH v2 58/74] target/mips: Drop pread and pwrite syscalls from semihosting, Richard Henderson, 2022/05/03
- [PATCH v2 59/74] target/mips: Use semihosting/syscalls.h, Richard Henderson, 2022/05/03
- [PATCH v2 63/74] target/mips: Simplify UHI_argnlen and UHI_argn, Richard Henderson, 2022/05/03
- [PATCH v2 65/74] target/xtensa: Use an exception for semihosting, Richard Henderson, 2022/05/03
- [PATCH v2 61/74] target/mips: Use error_report for UHI_assert,
Richard Henderson <=
- [PATCH v2 67/74] tests/docker: Add debian-rx-cross image, Richard Henderson, 2022/05/03
- [PATCH v2 64/74] target/mips: Remove GET_TARGET_STRING and FREE_TARGET_STRING, Richard Henderson, 2022/05/03
- [PATCH v2 69/74] target/rx: Fix the base of the fixed vector table, Richard Henderson, 2022/05/03
- [PATCH v2 73/74] target/rx: Implement libgloss semihosting, Richard Henderson, 2022/05/03
- [PATCH v2 71/74] target/rx: Consolidate exception helpers, Richard Henderson, 2022/05/03
- [PATCH v2 74/74] tests/tcg/rx: Enable semihosting multiarch tests, Richard Henderson, 2022/05/03
- [PATCH v2 62/74] semihosting: Remove qemu_semihosting_log_out, Richard Henderson, 2022/05/03
- [PATCH v2 66/74] target/xtensa: Use semihosting/syscalls.h, Richard Henderson, 2022/05/03
- [PATCH v2 68/74] hw/rx: Handle a kernel file that is ELF, Richard Henderson, 2022/05/03