qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] target/mips/helper: Also display exception names in user-mode
@ 2020-11-19 13:18 Philippe Mathieu-Daudé
  2020-11-19 14:45 ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 2+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-11-19 13:18 UTC (permalink / raw)
  To: qemu-devel
  Cc: Aleksandar Rikalo, Richard Henderson, Philippe Mathieu-Daudé,
	Laurent Vivier, Aurelien Jarno

Currently MIPS exceptions are displayed as string in system-mode
emulation, but as number in user-mode.
Unify by extracting the current system-mode code as excp_name()
and use that in user-mode.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/mips/helper.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/target/mips/helper.c b/target/mips/helper.c
index 063b65c0528..f566bd6da50 100644
--- a/target/mips/helper.c
+++ b/target/mips/helper.c
@@ -978,6 +978,7 @@ hwaddr cpu_mips_translate_address(CPUMIPSState *env, target_ulong address,
         return physical;
     }
 }
+#endif
 
 static const char * const excp_names[EXCP_LAST + 1] = {
     [EXCP_RESET] = "reset",
@@ -1018,7 +1019,14 @@ static const char * const excp_names[EXCP_LAST + 1] = {
     [EXCP_MSADIS] = "MSA disabled",
     [EXCP_MSAFPE] = "MSA floating point",
 };
-#endif
+
+static const char *excp_name(int32_t exception)
+{
+    if (exception < 0 || exception > EXCP_LAST) {
+        return "unknown";
+    }
+    return excp_names[exception];
+}
 
 target_ulong exception_resume_pc(CPUMIPSState *env)
 {
@@ -1091,19 +1099,14 @@ void mips_cpu_do_interrupt(CPUState *cs)
     bool update_badinstr = 0;
     target_ulong offset;
     int cause = -1;
-    const char *name;
 
     if (qemu_loglevel_mask(CPU_LOG_INT)
         && cs->exception_index != EXCP_EXT_INTERRUPT) {
         if (cs->exception_index < 0 || cs->exception_index > EXCP_LAST) {
-            name = "unknown";
-        } else {
-            name = excp_names[cs->exception_index];
-        }
-
         qemu_log("%s enter: PC " TARGET_FMT_lx " EPC " TARGET_FMT_lx
                  " %s exception\n",
-                 __func__, env->active_tc.PC, env->CP0_EPC, name);
+                 __func__, env->active_tc.PC, env->CP0_EPC,
+                 excp_name(cs->exception_index));
     }
     if (cs->exception_index == EXCP_EXT_INTERRUPT &&
         (env->hflags & MIPS_HFLAG_DM)) {
@@ -1490,8 +1493,8 @@ void QEMU_NORETURN do_raise_exception_err(CPUMIPSState *env,
 {
     CPUState *cs = env_cpu(env);
 
-    qemu_log_mask(CPU_LOG_INT, "%s: %d %d\n",
-                  __func__, exception, error_code);
+    qemu_log_mask(CPU_LOG_INT, "%s: %d (%s) %d\n",
+                  __func__, exception, excp_name(exception), error_code);
     cs->exception_index = exception;
     env->error_code = error_code;
 
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] target/mips/helper: Also display exception names in user-mode
  2020-11-19 13:18 [PATCH] target/mips/helper: Also display exception names in user-mode Philippe Mathieu-Daudé
@ 2020-11-19 14:45 ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 2+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-11-19 14:45 UTC (permalink / raw)
  To: qemu-devel
  Cc: Aleksandar Rikalo, Richard Henderson, Laurent Vivier,
	Aurelien Jarno

On 11/19/20 2:18 PM, Philippe Mathieu-Daudé wrote:
> Currently MIPS exceptions are displayed as string in system-mode
> emulation, but as number in user-mode.
> Unify by extracting the current system-mode code as excp_name()
> and use that in user-mode.
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  target/mips/helper.c | 23 +++++++++++++----------
>  1 file changed, 13 insertions(+), 10 deletions(-)
> 
> diff --git a/target/mips/helper.c b/target/mips/helper.c
> index 063b65c0528..f566bd6da50 100644
> --- a/target/mips/helper.c
> +++ b/target/mips/helper.c
> @@ -978,6 +978,7 @@ hwaddr cpu_mips_translate_address(CPUMIPSState *env, target_ulong address,
>          return physical;
>      }
>  }
> +#endif
>  
>  static const char * const excp_names[EXCP_LAST + 1] = {
>      [EXCP_RESET] = "reset",
> @@ -1018,7 +1019,14 @@ static const char * const excp_names[EXCP_LAST + 1] = {
>      [EXCP_MSADIS] = "MSA disabled",
>      [EXCP_MSAFPE] = "MSA floating point",
>  };
> -#endif
> +
> +static const char *excp_name(int32_t exception)
> +{
> +    if (exception < 0 || exception > EXCP_LAST) {
> +        return "unknown";
> +    }
> +    return excp_names[exception];
> +}
>  
>  target_ulong exception_resume_pc(CPUMIPSState *env)
>  {
> @@ -1091,19 +1099,14 @@ void mips_cpu_do_interrupt(CPUState *cs)
>      bool update_badinstr = 0;
>      target_ulong offset;
>      int cause = -1;
> -    const char *name;
>  
>      if (qemu_loglevel_mask(CPU_LOG_INT)
>          && cs->exception_index != EXCP_EXT_INTERRUPT) {
>          if (cs->exception_index < 0 || cs->exception_index > EXCP_LAST) {

I clearly failed to fix the cherry-pick conflict =)

> -            name = "unknown";
> -        } else {
> -            name = excp_names[cs->exception_index];
> -        }
> -
>          qemu_log("%s enter: PC " TARGET_FMT_lx " EPC " TARGET_FMT_lx
>                   " %s exception\n",
> -                 __func__, env->active_tc.PC, env->CP0_EPC, name);
> +                 __func__, env->active_tc.PC, env->CP0_EPC,
> +                 excp_name(cs->exception_index));
>      }
>      if (cs->exception_index == EXCP_EXT_INTERRUPT &&
>          (env->hflags & MIPS_HFLAG_DM)) {
> @@ -1490,8 +1493,8 @@ void QEMU_NORETURN do_raise_exception_err(CPUMIPSState *env,
>  {
>      CPUState *cs = env_cpu(env);
>  
> -    qemu_log_mask(CPU_LOG_INT, "%s: %d %d\n",
> -                  __func__, exception, error_code);
> +    qemu_log_mask(CPU_LOG_INT, "%s: %d (%s) %d\n",
> +                  __func__, exception, excp_name(exception), error_code);
>      cs->exception_index = exception;
>      env->error_code = error_code;
>  
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-11-19 14:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-19 13:18 [PATCH] target/mips/helper: Also display exception names in user-mode Philippe Mathieu-Daudé
2020-11-19 14:45 ` Philippe Mathieu-Daudé

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).