virtio: add check for descriptor's mapped address
[qemu/ar7.git] / include / qemu / log.h
blob00bf37fc0f9a7036f5b242ac2c780178e34ef987
1 #ifndef QEMU_LOG_H
2 #define QEMU_LOG_H
5 /* Private global variables, don't use */
6 extern FILE *qemu_logfile;
7 extern int qemu_loglevel;
9 /*
10 * The new API:
14 /* Log settings checking macros: */
16 /* Returns true if qemu_log() will really write somewhere
18 static inline bool qemu_log_enabled(void)
20 return qemu_logfile != NULL;
23 /* Returns true if qemu_log() will write somewhere else than stderr
25 static inline bool qemu_log_separate(void)
27 return qemu_logfile != NULL && qemu_logfile != stderr;
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)
37 #define CPU_LOG_TB_CPU (1 << 8)
38 #define CPU_LOG_RESET (1 << 9)
39 #define LOG_UNIMP (1 << 10)
40 #define LOG_GUEST_ERROR (1 << 11)
41 #define CPU_LOG_MMU (1 << 12)
42 #define CPU_LOG_TB_NOCHAIN (1 << 13)
43 #define CPU_LOG_PAGE (1 << 14)
44 #define LOG_TRACE (1 << 15)
45 #define CPU_LOG_TB_OP_IND (1 << 16)
47 /* Returns true if a bit is set in the current loglevel mask
49 static inline bool qemu_loglevel_mask(int mask)
51 return (qemu_loglevel & mask) != 0;
54 /* Logging functions: */
56 /* main logging function
58 int GCC_FMT_ATTR(1, 2) qemu_log(const char *fmt, ...);
60 /* vfprintf-like logging function
62 static inline void GCC_FMT_ATTR(1, 0)
63 qemu_log_vprintf(const char *fmt, va_list va)
65 if (qemu_logfile) {
66 vfprintf(qemu_logfile, fmt, va);
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
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)
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
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)
97 /* Maintenance: */
99 /* define log items */
100 typedef struct QEMULogItem {
101 int mask;
102 const char *name;
103 const char *help;
104 } QEMULogItem;
106 extern const QEMULogItem qemu_log_items[];
108 void qemu_set_log(int log_flags);
109 void qemu_log_needs_buffers(void);
110 void qemu_set_log_filename(const char *filename, Error **errp);
111 void qemu_set_dfilter_ranges(const char *ranges, Error **errp);
112 bool qemu_log_in_addr_range(uint64_t addr);
113 int qemu_str_to_log_mask(const char *str);
115 /* Print a usage message listing all the valid logging categories
116 * to the specified FILE*.
118 void qemu_print_log_usage(FILE *f);
120 /* fflush() the log file */
121 void qemu_log_flush(void);
122 /* Close the log file */
123 void qemu_log_close(void);
125 #endif