xref: /openbmc/qemu/include/exec/log.h (revision 93756fdcf6f3f6482bd9f22d8189b6c4ee09303e)
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 = qatomic_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 #endif
46