diff mbox series

[PATCH-for-8.0,4/5] cpu: Move cpu_abort() to common code

Message ID 20221130135241.85060-5-philmd@linaro.org
State New
Headers show
Series cpu: Move target-independent code to common code | expand

Commit Message

Philippe Mathieu-Daudé Nov. 30, 2022, 1:52 p.m. UTC
This code is not target-specific.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 cpu.c         | 38 --------------------------------------
 cpus-common.c | 38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 38 deletions(-)

Comments

Richard Henderson Nov. 30, 2022, 10:20 p.m. UTC | #1
On 11/30/22 05:52, Philippe Mathieu-Daudé wrote:
> This code is not target-specific.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   cpu.c         | 38 --------------------------------------
>   cpus-common.c | 38 ++++++++++++++++++++++++++++++++++++++
>   2 files changed, 38 insertions(+), 38 deletions(-)
> 
> diff --git a/cpu.c b/cpu.c
> index 385e72e140..d6936a536b 100644
> --- a/cpu.c
> +++ b/cpu.c
> @@ -31,11 +31,9 @@
>   #endif
>   #include "sysemu/tcg.h"
>   #include "sysemu/kvm.h"
> -#include "sysemu/replay.h"
>   #include "exec/cpu-common.h"
>   #include "exec/exec-all.h"
>   #include "exec/translate-all.h"
> -#include "exec/log.h"
>   #include "hw/core/accel-cpu.h"
>   #include "trace/trace-root.h"
>   #include "qemu/accel.h"
> @@ -270,42 +268,6 @@ void cpu_single_step(CPUState *cpu, int enabled)
>       }
>   }
>   
> -void cpu_abort(CPUState *cpu, const char *fmt, ...)
> -{
> -    va_list ap;
> -    va_list ap2;
> -
> -    va_start(ap, fmt);
> -    va_copy(ap2, ap);
> -    fprintf(stderr, "qemu: fatal: ");
> -    vfprintf(stderr, fmt, ap);
> -    fprintf(stderr, "\n");
> -    cpu_dump_state(cpu, stderr, CPU_DUMP_FPU | CPU_DUMP_CCOP);
> -    if (qemu_log_separate()) {
> -        FILE *logfile = qemu_log_trylock();
> -        if (logfile) {
> -            fprintf(logfile, "qemu: fatal: ");
> -            vfprintf(logfile, fmt, ap2);
> -            fprintf(logfile, "\n");
> -            cpu_dump_state(cpu, logfile, CPU_DUMP_FPU | CPU_DUMP_CCOP);
> -            qemu_log_unlock(logfile);
> -        }
> -    }
> -    va_end(ap2);
> -    va_end(ap);
> -    replay_finish();
> -#if defined(CONFIG_USER_ONLY)
> -    {
> -        struct sigaction act;
> -        sigfillset(&act.sa_mask);
> -        act.sa_handler = SIG_DFL;
> -        act.sa_flags = 0;
> -        sigaction(SIGABRT, &act, NULL);
> -    }
> -#endif
> -    abort();
> -}
> -
>   /* physical memory access (slow version, mainly for debug) */
>   #if defined(CONFIG_USER_ONLY)
>   int cpu_memory_rw_debug(CPUState *cpu, vaddr addr,
> diff --git a/cpus-common.c b/cpus-common.c
> index 8fdb34740e..38af2ab840 100644
> --- a/cpus-common.c
> +++ b/cpus-common.c
> @@ -21,9 +21,11 @@
>   #include "qemu/main-loop.h"
>   #include "exec/cpu-common.h"
>   #include "exec/memory.h"
> +#include "exec/log.h"
>   #include "hw/qdev-properties.h"
>   #include "hw/core/cpu.h"
>   #include "sysemu/cpus.h"
> +#include "sysemu/replay.h"
>   #include "qemu/lockable.h"
>   #include "trace/trace-root.h"
>   
> @@ -485,3 +487,39 @@ void cpu_breakpoint_remove_all(CPUState *cpu, int mask)
>           }
>       }
>   }
> +
> +void cpu_abort(CPUState *cpu, const char *fmt, ...)
> +{
> +    va_list ap;
> +    va_list ap2;
> +
> +    va_start(ap, fmt);
> +    va_copy(ap2, ap);
> +    fprintf(stderr, "qemu: fatal: ");
> +    vfprintf(stderr, fmt, ap);
> +    fprintf(stderr, "\n");
> +    cpu_dump_state(cpu, stderr, CPU_DUMP_FPU | CPU_DUMP_CCOP);
> +    if (qemu_log_separate()) {
> +        FILE *logfile = qemu_log_trylock();
> +        if (logfile) {
> +            fprintf(logfile, "qemu: fatal: ");
> +            vfprintf(logfile, fmt, ap2);
> +            fprintf(logfile, "\n");
> +            cpu_dump_state(cpu, logfile, CPU_DUMP_FPU | CPU_DUMP_CCOP);
> +            qemu_log_unlock(logfile);
> +        }
> +    }
> +    va_end(ap2);
> +    va_end(ap);
> +    replay_finish();
> +#if defined(CONFIG_USER_ONLY)

CONFIG_USER_ONLY is build specific.

r~
diff mbox series

Patch

diff --git a/cpu.c b/cpu.c
index 385e72e140..d6936a536b 100644
--- a/cpu.c
+++ b/cpu.c
@@ -31,11 +31,9 @@ 
 #endif
 #include "sysemu/tcg.h"
 #include "sysemu/kvm.h"
-#include "sysemu/replay.h"
 #include "exec/cpu-common.h"
 #include "exec/exec-all.h"
 #include "exec/translate-all.h"
-#include "exec/log.h"
 #include "hw/core/accel-cpu.h"
 #include "trace/trace-root.h"
 #include "qemu/accel.h"
@@ -270,42 +268,6 @@  void cpu_single_step(CPUState *cpu, int enabled)
     }
 }
 
-void cpu_abort(CPUState *cpu, const char *fmt, ...)
-{
-    va_list ap;
-    va_list ap2;
-
-    va_start(ap, fmt);
-    va_copy(ap2, ap);
-    fprintf(stderr, "qemu: fatal: ");
-    vfprintf(stderr, fmt, ap);
-    fprintf(stderr, "\n");
-    cpu_dump_state(cpu, stderr, CPU_DUMP_FPU | CPU_DUMP_CCOP);
-    if (qemu_log_separate()) {
-        FILE *logfile = qemu_log_trylock();
-        if (logfile) {
-            fprintf(logfile, "qemu: fatal: ");
-            vfprintf(logfile, fmt, ap2);
-            fprintf(logfile, "\n");
-            cpu_dump_state(cpu, logfile, CPU_DUMP_FPU | CPU_DUMP_CCOP);
-            qemu_log_unlock(logfile);
-        }
-    }
-    va_end(ap2);
-    va_end(ap);
-    replay_finish();
-#if defined(CONFIG_USER_ONLY)
-    {
-        struct sigaction act;
-        sigfillset(&act.sa_mask);
-        act.sa_handler = SIG_DFL;
-        act.sa_flags = 0;
-        sigaction(SIGABRT, &act, NULL);
-    }
-#endif
-    abort();
-}
-
 /* physical memory access (slow version, mainly for debug) */
 #if defined(CONFIG_USER_ONLY)
 int cpu_memory_rw_debug(CPUState *cpu, vaddr addr,
diff --git a/cpus-common.c b/cpus-common.c
index 8fdb34740e..38af2ab840 100644
--- a/cpus-common.c
+++ b/cpus-common.c
@@ -21,9 +21,11 @@ 
 #include "qemu/main-loop.h"
 #include "exec/cpu-common.h"
 #include "exec/memory.h"
+#include "exec/log.h"
 #include "hw/qdev-properties.h"
 #include "hw/core/cpu.h"
 #include "sysemu/cpus.h"
+#include "sysemu/replay.h"
 #include "qemu/lockable.h"
 #include "trace/trace-root.h"
 
@@ -485,3 +487,39 @@  void cpu_breakpoint_remove_all(CPUState *cpu, int mask)
         }
     }
 }
+
+void cpu_abort(CPUState *cpu, const char *fmt, ...)
+{
+    va_list ap;
+    va_list ap2;
+
+    va_start(ap, fmt);
+    va_copy(ap2, ap);
+    fprintf(stderr, "qemu: fatal: ");
+    vfprintf(stderr, fmt, ap);
+    fprintf(stderr, "\n");
+    cpu_dump_state(cpu, stderr, CPU_DUMP_FPU | CPU_DUMP_CCOP);
+    if (qemu_log_separate()) {
+        FILE *logfile = qemu_log_trylock();
+        if (logfile) {
+            fprintf(logfile, "qemu: fatal: ");
+            vfprintf(logfile, fmt, ap2);
+            fprintf(logfile, "\n");
+            cpu_dump_state(cpu, logfile, CPU_DUMP_FPU | CPU_DUMP_CCOP);
+            qemu_log_unlock(logfile);
+        }
+    }
+    va_end(ap2);
+    va_end(ap);
+    replay_finish();
+#if defined(CONFIG_USER_ONLY)
+    {
+        struct sigaction act;
+        sigfillset(&act.sa_mask);
+        act.sa_handler = SIG_DFL;
+        act.sa_flags = 0;
+        sigaction(SIGABRT, &act, NULL);
+    }
+#endif
+    abort();
+}