| 1 | /* |
| 2 | * Target-specific parts of the CPU object |
| 3 | * |
| 4 | * Copyright (c) 2003 Fabrice Bellard |
| 5 | * |
| 6 | * This library is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU Lesser General Public |
| 8 | * License as published by the Free Software Foundation; either |
| 9 | * version 2 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * This library is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * Lesser General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Lesser General Public |
| 17 | * License along with this library; if not, see <http://www.gnu.org/licenses/>. |
| 18 | */ |
| 19 | |
| 20 | #include "qemu/osdep.h" |
| 21 | #include "accel/accel-cpu-ops.h" |
| 22 | #include "system/cpus.h" |
| 23 | #include "exec/cpu-common.h" |
| 24 | #include "exec/replay-core.h" |
| 25 | #include "exec/log.h" |
| 26 | #include "hw/core/cpu.h" |
| 27 | #include "trace/trace-root.h" |
| 28 | |
| 29 | /* enable or disable single step mode. EXCP_DEBUG is returned by the |
| 30 | CPU loop after each instruction */ |
| 31 | void cpu_single_step(CPUState *cpu, unsigned flags) |
| 32 | { |
| 33 | if (cpu->singlestep_flags != flags) { |
| 34 | trace_cpu_change_singlestep_flags(cpu->cpu_index, |
| 35 | cpu->singlestep_flags, flags); |
| 36 | cpu->singlestep_flags = flags; |
| 37 | |
| 38 | #if !defined(CONFIG_USER_ONLY) |
| 39 | const AccelOpsClass *ops = cpus_get_accel(); |
| 40 | if (ops->update_guest_debug) { |
| 41 | ops->update_guest_debug(cpu); |
| 42 | } |
| 43 | #endif |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | void cpu_abort(CPUState *cpu, const char *fmt, ...) |
| 48 | { |
| 49 | va_list ap; |
| 50 | va_list ap2; |
| 51 | |
| 52 | va_start(ap, fmt); |
| 53 | va_copy(ap2, ap); |
| 54 | fprintf(stderr, "qemu: fatal: "); |
| 55 | vfprintf(stderr, fmt, ap); |
| 56 | fprintf(stderr, "\n"); |
| 57 | cpu_dump_state(cpu, stderr, CPU_DUMP_FPU | CPU_DUMP_CCOP); |
| 58 | if (qemu_log_separate()) { |
| 59 | FILE *logfile = qemu_log_trylock(); |
| 60 | if (logfile) { |
| 61 | fprintf(logfile, "qemu: fatal: "); |
| 62 | vfprintf(logfile, fmt, ap2); |
| 63 | fprintf(logfile, "\n"); |
| 64 | cpu_dump_state(cpu, logfile, CPU_DUMP_FPU | CPU_DUMP_CCOP); |
| 65 | qemu_log_unlock(logfile); |
| 66 | } |
| 67 | } |
| 68 | va_end(ap2); |
| 69 | va_end(ap); |
| 70 | replay_finish(); |
| 71 | #if defined(CONFIG_USER_ONLY) |
| 72 | { |
| 73 | struct sigaction act; |
| 74 | sigfillset(&act.sa_mask); |
| 75 | act.sa_handler = SIG_DFL; |
| 76 | act.sa_flags = 0; |
| 77 | sigaction(SIGABRT, &act, NULL); |
| 78 | } |
| 79 | #endif |
| 80 | abort(); |
| 81 | } |