7 #include "qemu/compiler.h"
9 #include "disas/disas.h"
12 /* Private global variables, don't use */
13 extern FILE *qemu_logfile
;
14 extern int qemu_loglevel
;
21 /* Log settings checking macros: */
23 /* Returns true if qemu_log() will really write somewhere
25 static inline bool qemu_log_enabled(void)
27 return qemu_logfile
!= NULL
;
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_IOPORT (1 << 7)
38 #define CPU_LOG_TB_CPU (1 << 8)
39 #define CPU_LOG_RESET (1 << 9)
40 #define LOG_UNIMP (1 << 10)
41 #define LOG_GUEST_ERROR (1 << 11)
43 /* Returns true if a bit is set in the current loglevel mask
45 static inline bool qemu_loglevel_mask(int mask
)
47 return (qemu_loglevel
& mask
) != 0;
50 /* Logging functions: */
52 /* main logging function
54 void GCC_FMT_ATTR(1, 2) qemu_log(const char *fmt
, ...);
56 /* vfprintf-like logging function
58 static inline void GCC_FMT_ATTR(1, 0)
59 qemu_log_vprintf(const char *fmt
, va_list va
)
62 vfprintf(qemu_logfile
, fmt
, va
);
66 /* log only if a bit is set on the current loglevel mask
68 void GCC_FMT_ATTR(2, 3) qemu_log_mask(int mask
, const char *fmt
, ...);
74 /* cpu_dump_state() logging functions: */
75 static inline void log_cpu_state(CPUArchState
*env1
, int flags
)
77 if (qemu_log_enabled()) {
78 cpu_dump_state(env1
, qemu_logfile
, fprintf
, flags
);
82 static inline void log_cpu_state_mask(int mask
, CPUArchState
*env1
, int flags
)
84 if (qemu_loglevel
& mask
) {
85 log_cpu_state(env1
, flags
);
89 /* disas() and target_disas() to qemu_logfile: */
90 static inline void log_target_disas(CPUArchState
*env
, target_ulong start
,
91 target_ulong len
, int flags
)
93 target_disas(qemu_logfile
, env
, start
, len
, flags
);
96 static inline void log_disas(void *code
, unsigned long size
)
98 disas(qemu_logfile
, code
, size
);
101 #if defined(CONFIG_USER_ONLY)
102 /* page_dump() output to the log file: */
103 static inline void log_page_dump(void)
105 page_dump(qemu_logfile
);
113 /* fflush() the log file */
114 static inline void qemu_log_flush(void)
116 fflush(qemu_logfile
);
119 /* Close the log file */
120 static inline void qemu_log_close(void)
123 if (qemu_logfile
!= stderr
) {
124 fclose(qemu_logfile
);
130 /* Set up a new log file */
131 static inline void qemu_log_set_file(FILE *f
)
136 /* define log items */
137 typedef struct QEMULogItem
{
143 extern const QEMULogItem qemu_log_items
[];
145 /* This is the function that actually does the work of
146 * changing the log level; it should only be accessed via
147 * the qemu_set_log() wrapper.
149 void do_qemu_set_log(int log_flags
, bool use_own_buffers
);
151 static inline void qemu_set_log(int log_flags
)
153 #ifdef CONFIG_USER_ONLY
154 do_qemu_set_log(log_flags
, true);
156 do_qemu_set_log(log_flags
, false);
160 void qemu_set_log_filename(const char *filename
);
161 int qemu_str_to_log_mask(const char *str
);
163 /* Print a usage message listing all the valid logging categories
164 * to the specified FILE*.
166 void qemu_print_log_usage(FILE *f
);