vfio: Wrap VFIO_DEVICE_GET_REGION_INFO
[qemu/ar7.git] / include / qemu / log.h
blob40c24fda40bc1e172118f94035098829d890dbc7
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)
46 /* Returns true if a bit is set in the current loglevel mask
48 static inline bool qemu_loglevel_mask(int mask)
50 return (qemu_loglevel & mask) != 0;
53 /* Logging functions: */
55 /* main logging function
57 void GCC_FMT_ATTR(1, 2) qemu_log(const char *fmt, ...);
59 /* vfprintf-like logging function
61 static inline void GCC_FMT_ATTR(1, 0)
62 qemu_log_vprintf(const char *fmt, va_list va)
64 if (qemu_logfile) {
65 vfprintf(qemu_logfile, fmt, va);
69 /* log only if a bit is set on the current loglevel mask
71 void GCC_FMT_ATTR(2, 3) qemu_log_mask(int mask, const char *fmt, ...);
74 /* Maintenance: */
76 /* fflush() the log file */
77 static inline void qemu_log_flush(void)
79 fflush(qemu_logfile);
82 /* Close the log file */
83 static inline void qemu_log_close(void)
85 if (qemu_logfile) {
86 if (qemu_logfile != stderr) {
87 fclose(qemu_logfile);
89 qemu_logfile = NULL;
93 /* define log items */
94 typedef struct QEMULogItem {
95 int mask;
96 const char *name;
97 const char *help;
98 } QEMULogItem;
100 extern const QEMULogItem qemu_log_items[];
102 /* This is the function that actually does the work of
103 * changing the log level; it should only be accessed via
104 * the qemu_set_log() wrapper.
106 void do_qemu_set_log(int log_flags, bool use_own_buffers);
108 static inline void qemu_set_log(int log_flags)
110 #ifdef CONFIG_USER_ONLY
111 do_qemu_set_log(log_flags, true);
112 #else
113 do_qemu_set_log(log_flags, false);
114 #endif
117 void qemu_set_log_filename(const char *filename);
118 int qemu_str_to_log_mask(const char *str);
120 /* Print a usage message listing all the valid logging categories
121 * to the specified FILE*.
123 void qemu_print_log_usage(FILE *f);
125 #endif