7 #include "qemu/compiler.h"
9 /* Private global variables, don't use */
10 extern FILE *qemu_logfile
;
11 extern int qemu_loglevel
;
18 /* Log settings checking macros: */
20 /* Returns true if qemu_log() will really write somewhere
22 static inline bool qemu_log_enabled(void)
24 return qemu_logfile
!= NULL
;
27 /* Returns true if qemu_log() will write somewhere else than stderr
29 static inline bool qemu_log_separate(void)
31 return qemu_logfile
!= NULL
&& qemu_logfile
!= stderr
;
34 #define CPU_LOG_TB_OUT_ASM (1 << 0)
35 #define CPU_LOG_TB_IN_ASM (1 << 1)
36 #define CPU_LOG_TB_OP (1 << 2)
37 #define CPU_LOG_TB_OP_OPT (1 << 3)
38 #define CPU_LOG_INT (1 << 4)
39 #define CPU_LOG_EXEC (1 << 5)
40 #define CPU_LOG_PCALL (1 << 6)
41 #define CPU_LOG_TB_CPU (1 << 8)
42 #define CPU_LOG_RESET (1 << 9)
43 #define LOG_UNIMP (1 << 10)
44 #define LOG_GUEST_ERROR (1 << 11)
45 #define CPU_LOG_MMU (1 << 12)
46 #define CPU_LOG_TB_NOCHAIN (1 << 13)
47 #define CPU_LOG_PAGE (1 << 14)
48 #define LOG_TRACE (1 << 15)
50 /* Returns true if a bit is set in the current loglevel mask
52 static inline bool qemu_loglevel_mask(int mask
)
54 return (qemu_loglevel
& mask
) != 0;
57 /* Logging functions: */
59 /* main logging function
61 void GCC_FMT_ATTR(1, 2) qemu_log(const char *fmt
, ...);
63 /* vfprintf-like logging function
65 static inline void GCC_FMT_ATTR(1, 0)
66 qemu_log_vprintf(const char *fmt
, va_list va
)
69 vfprintf(qemu_logfile
, fmt
, va
);
73 /* log only if a bit is set on the current loglevel mask
75 void GCC_FMT_ATTR(2, 3) qemu_log_mask(int mask
, const char *fmt
, ...);
80 /* fflush() the log file */
81 static inline void qemu_log_flush(void)
86 /* Close the log file */
87 static inline void qemu_log_close(void)
90 if (qemu_logfile
!= stderr
) {
97 /* Set up a new log file */
98 static inline void qemu_log_set_file(FILE *f
)
103 /* define log items */
104 typedef struct QEMULogItem
{
110 extern const QEMULogItem qemu_log_items
[];
112 /* This is the function that actually does the work of
113 * changing the log level; it should only be accessed via
114 * the qemu_set_log() wrapper.
116 void do_qemu_set_log(int log_flags
, bool use_own_buffers
);
118 static inline void qemu_set_log(int log_flags
)
120 #ifdef CONFIG_USER_ONLY
121 do_qemu_set_log(log_flags
, true);
123 do_qemu_set_log(log_flags
, false);
127 void qemu_set_log_filename(const char *filename
);
128 int qemu_str_to_log_mask(const char *str
);
130 /* Print a usage message listing all the valid logging categories
131 * to the specified FILE*.
133 void qemu_print_log_usage(FILE *f
);