1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#include "qemu/osdep.h"
21#include "cpu.h"
22#include "accel/accel-cpu-ops.h"
23#include "system/cpus.h"
24#include "exec/cpu-common.h"
25#include "exec/replay-core.h"
26#include "exec/log.h"
27#include "hw/core/cpu.h"
28#include "trace/trace-root.h"
29
30
31QEMU_BUILD_BUG_ON(offsetof(ArchCPU, parent_obj) != 0);
32QEMU_BUILD_BUG_ON(offsetof(ArchCPU, env) != sizeof(CPUState));
33
34
35
36void cpu_single_step(CPUState *cpu, int enabled)
37{
38 if (cpu->singlestep_enabled != enabled) {
39 cpu->singlestep_enabled = enabled;
40
41#if !defined(CONFIG_USER_ONLY)
42 const AccelOpsClass *ops = cpus_get_accel();
43 if (ops->update_guest_debug) {
44 ops->update_guest_debug(cpu);
45 }
46#endif
47
48 trace_breakpoint_singlestep(cpu->cpu_index, enabled);
49 }
50}
51
52void cpu_abort(CPUState *cpu, const char *fmt, ...)
53{
54 va_list ap;
55 va_list ap2;
56
57 va_start(ap, fmt);
58 va_copy(ap2, ap);
59 fprintf(stderr, "qemu: fatal: ");
60 vfprintf(stderr, fmt, ap);
61 fprintf(stderr, "\n");
62 cpu_dump_state(cpu, stderr, CPU_DUMP_FPU | CPU_DUMP_CCOP);
63 if (qemu_log_separate()) {
64 FILE *logfile = qemu_log_trylock();
65 if (logfile) {
66 fprintf(logfile, "qemu: fatal: ");
67 vfprintf(logfile, fmt, ap2);
68 fprintf(logfile, "\n");
69 cpu_dump_state(cpu, logfile, CPU_DUMP_FPU | CPU_DUMP_CCOP);
70 qemu_log_unlock(logfile);
71 }
72 }
73 va_end(ap2);
74 va_end(ap);
75 replay_finish();
76#if defined(CONFIG_USER_ONLY)
77 {
78 struct sigaction act;
79 sigfillset(&act.sa_mask);
80 act.sa_handler = SIG_DFL;
81 act.sa_flags = 0;
82 sigaction(SIGABRT, &act, NULL);
83 }
84#endif
85 abort();
86}
87