]> git.proxmox.com Git - mirror_qemu.git/blame - include/exec/log.h
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging
[mirror_qemu.git] / include / exec / log.h
CommitLineData
508127e2
PB
1#ifndef QEMU_EXEC_LOG_H
2#define QEMU_EXEC_LOG_H
3
4#include "qemu/log.h"
2e5b09fd 5#include "hw/core/cpu.h"
508127e2
PB
6#include "disas/disas.h"
7
8/* cpu_dump_state() logging functions: */
9/**
10 * log_cpu_state:
11 * @cpu: The CPU whose state is to be logged.
12 * @flags: Flags what to log.
13 *
14 * Logs the output of cpu_dump_state().
15 */
16static inline void log_cpu_state(CPUState *cpu, int flags)
17{
7606488c
RF
18 QemuLogFile *logfile;
19
508127e2 20 if (qemu_log_enabled()) {
7606488c
RF
21 rcu_read_lock();
22 logfile = atomic_rcu_read(&qemu_logfile);
23 if (logfile) {
24 cpu_dump_state(cpu, logfile->fd, flags);
25 }
26 rcu_read_unlock();
508127e2
PB
27 }
28}
29
30/**
31 * log_cpu_state_mask:
32 * @mask: Mask when to log.
33 * @cpu: The CPU whose state is to be logged.
34 * @flags: Flags what to log.
35 *
36 * Logs the output of cpu_dump_state() if loglevel includes @mask.
37 */
38static inline void log_cpu_state_mask(int mask, CPUState *cpu, int flags)
39{
40 if (qemu_loglevel & mask) {
41 log_cpu_state(cpu, flags);
42 }
43}
44
45#ifdef NEED_CPU_H
46/* disas() and target_disas() to qemu_logfile: */
47static inline void log_target_disas(CPUState *cpu, target_ulong start,
1d48474d 48 target_ulong len)
508127e2 49{
7606488c
RF
50 QemuLogFile *logfile;
51 rcu_read_lock();
52 logfile = atomic_rcu_read(&qemu_logfile);
53 if (logfile) {
54 target_disas(logfile->fd, cpu, start, len);
55 }
56 rcu_read_unlock();
508127e2
PB
57}
58
59static inline void log_disas(void *code, unsigned long size)
60{
7606488c
RF
61 QemuLogFile *logfile;
62 rcu_read_lock();
63 logfile = atomic_rcu_read(&qemu_logfile);
64 if (logfile) {
65 disas(logfile->fd, code, size);
66 }
67 rcu_read_unlock();
508127e2
PB
68}
69
70#if defined(CONFIG_USER_ONLY)
71/* page_dump() output to the log file: */
10d0d505 72static inline void log_page_dump(const char *operation)
508127e2 73{
10d0d505 74 FILE *logfile = qemu_log_lock();
7606488c 75 if (logfile) {
10d0d505
AB
76 qemu_log("page layout changed following %s\n", operation);
77 page_dump(logfile);
7606488c 78 }
10d0d505 79 qemu_log_unlock(logfile);
508127e2
PB
80}
81#endif
82#endif
83
84#endif