]> git.proxmox.com Git - mirror_qemu.git/blame - include/qemu/log.h
target-openrisc: Do not dump cpu state with -d in_asm
[mirror_qemu.git] / include / qemu / log.h
CommitLineData
79383c9c
BS
1#ifndef QEMU_LOG_H
2#define QEMU_LOG_H
3
eeacee4d
BS
4
5/* Private global variables, don't use */
6extern FILE *qemu_logfile;
7extern int qemu_loglevel;
79383c9c 8
6d2c5146
AL
9/*
10 * The new API:
11 *
12 */
13
14/* Log settings checking macros: */
15
16/* Returns true if qemu_log() will really write somewhere
17 */
eeacee4d
BS
18static inline bool qemu_log_enabled(void)
19{
20 return qemu_logfile != NULL;
21}
6d2c5146 22
013a2942
PB
23/* Returns true if qemu_log() will write somewhere else than stderr
24 */
25static inline bool qemu_log_separate(void)
26{
27 return qemu_logfile != NULL && qemu_logfile != stderr;
28}
29
5726c27f
BS
30#define CPU_LOG_TB_OUT_ASM (1 << 0)
31#define CPU_LOG_TB_IN_ASM (1 << 1)
32#define CPU_LOG_TB_OP (1 << 2)
33#define CPU_LOG_TB_OP_OPT (1 << 3)
34#define CPU_LOG_INT (1 << 4)
35#define CPU_LOG_EXEC (1 << 5)
36#define CPU_LOG_PCALL (1 << 6)
5726c27f
BS
37#define CPU_LOG_TB_CPU (1 << 8)
38#define CPU_LOG_RESET (1 << 9)
dafdf1ab 39#define LOG_UNIMP (1 << 10)
e54eba19 40#define LOG_GUEST_ERROR (1 << 11)
339aaf5b 41#define CPU_LOG_MMU (1 << 12)
89a82cd4 42#define CPU_LOG_TB_NOCHAIN (1 << 13)
13829020 43#define CPU_LOG_PAGE (1 << 14)
ed7f5f1d 44#define LOG_TRACE (1 << 15)
5a18407f 45#define CPU_LOG_TB_OP_IND (1 << 16)
5726c27f 46
6d2c5146
AL
47/* Returns true if a bit is set in the current loglevel mask
48 */
eeacee4d
BS
49static inline bool qemu_loglevel_mask(int mask)
50{
51 return (qemu_loglevel & mask) != 0;
52}
6d2c5146 53
6d2c5146
AL
54/* Logging functions: */
55
56/* main logging function
57 */
bdfb460e 58int GCC_FMT_ATTR(1, 2) qemu_log(const char *fmt, ...);
6d2c5146
AL
59
60/* vfprintf-like logging function
61 */
726f8cbf
SW
62static inline void GCC_FMT_ATTR(1, 0)
63qemu_log_vprintf(const char *fmt, va_list va)
eeacee4d
BS
64{
65 if (qemu_logfile) {
66 vfprintf(qemu_logfile, fmt, va);
67 }
68}
6d2c5146 69
7ee60623
PM
70/* log only if a bit is set on the current loglevel mask:
71 * @mask: bit to check in the mask
72 * @fmt: printf-style format string
73 * @args: optional arguments for format string
6d2c5146 74 */
7ee60623
PM
75#define qemu_log_mask(MASK, FMT, ...) \
76 do { \
77 if (unlikely(qemu_loglevel_mask(MASK))) { \
78 qemu_log(FMT, ## __VA_ARGS__); \
79 } \
80 } while (0)
6d2c5146 81
d977e1c2
AB
82/* log only if a bit is set on the current loglevel mask
83 * and we are in the address range we care about:
84 * @mask: bit to check in the mask
85 * @addr: address to check in dfilter
86 * @fmt: printf-style format string
87 * @args: optional arguments for format string
88 */
89#define qemu_log_mask_and_addr(MASK, ADDR, FMT, ...) \
90 do { \
91 if (unlikely(qemu_loglevel_mask(MASK)) && \
92 qemu_log_in_addr_range(ADDR)) { \
93 qemu_log(FMT, ## __VA_ARGS__); \
94 } \
95 } while (0)
96
6d2c5146
AL
97/* Maintenance: */
98
5726c27f 99/* define log items */
38dad9e5 100typedef struct QEMULogItem {
5726c27f
BS
101 int mask;
102 const char *name;
103 const char *help;
38dad9e5 104} QEMULogItem;
5726c27f 105
38dad9e5 106extern const QEMULogItem qemu_log_items[];
5726c27f 107
f2937a33
PB
108void qemu_set_log(int log_flags);
109void qemu_log_needs_buffers(void);
daa76aa4 110void qemu_set_log_filename(const char *filename, Error **errp);
bd6fee9f 111void qemu_set_dfilter_ranges(const char *ranges, Error **errp);
3514552e 112bool qemu_log_in_addr_range(uint64_t addr);
4fde1eba 113int qemu_str_to_log_mask(const char *str);
6d2c5146 114
59a6fa6e
PM
115/* Print a usage message listing all the valid logging categories
116 * to the specified FILE*.
117 */
118void qemu_print_log_usage(FILE *f);
119
99affd1d
DL
120/* fflush() the log file */
121void qemu_log_flush(void);
122/* Close the log file */
123void qemu_log_close(void);
124
79383c9c 125#endif