]> git.proxmox.com Git - mirror_qemu.git/blob - include/exec/log.h
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging
[mirror_qemu.git] / include / exec / log.h
1 #ifndef QEMU_EXEC_LOG_H
2 #define QEMU_EXEC_LOG_H
3
4 #include "qemu/log.h"
5 #include "hw/core/cpu.h"
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 */
16 static inline void log_cpu_state(CPUState *cpu, int flags)
17 {
18 QemuLogFile *logfile;
19
20 if (qemu_log_enabled()) {
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();
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 */
38 static 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: */
47 static inline void log_target_disas(CPUState *cpu, target_ulong start,
48 target_ulong len)
49 {
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();
57 }
58
59 static inline void log_disas(void *code, unsigned long size)
60 {
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();
68 }
69
70 #if defined(CONFIG_USER_ONLY)
71 /* page_dump() output to the log file: */
72 static inline void log_page_dump(const char *operation)
73 {
74 FILE *logfile = qemu_log_lock();
75 if (logfile) {
76 qemu_log("page layout changed following %s\n", operation);
77 page_dump(logfile);
78 }
79 qemu_log_unlock(logfile);
80 }
81 #endif
82 #endif
83
84 #endif