qemu/cpu-target.c
<<
>>
Prefs
   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 "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/* Validate correct placement of CPUArchState. */
  31QEMU_BUILD_BUG_ON(offsetof(ArchCPU, parent_obj) != 0);
  32QEMU_BUILD_BUG_ON(offsetof(ArchCPU, env) != sizeof(CPUState));
  33
  34/* enable or disable single step mode. EXCP_DEBUG is returned by the
  35   CPU loop after each instruction */
  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