linux-headers: Update to 3.7-rc5
[qemu/ar7.git] / qemu-log.h
blob344eca3f1b0df889c99c116dd908711c53c9b65e
1 #ifndef QEMU_LOG_H
2 #define QEMU_LOG_H
4 #include <stdarg.h>
5 #ifdef NEED_CPU_H
6 #include "disas.h"
7 #endif
9 /* Private global variables, don't use */
10 extern FILE *qemu_logfile;
11 extern int qemu_loglevel;
13 /*
14 * The new API:
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 #define CPU_LOG_TB_OUT_ASM (1 << 0)
28 #define CPU_LOG_TB_IN_ASM (1 << 1)
29 #define CPU_LOG_TB_OP (1 << 2)
30 #define CPU_LOG_TB_OP_OPT (1 << 3)
31 #define CPU_LOG_INT (1 << 4)
32 #define CPU_LOG_EXEC (1 << 5)
33 #define CPU_LOG_PCALL (1 << 6)
34 #define CPU_LOG_IOPORT (1 << 7)
35 #define CPU_LOG_TB_CPU (1 << 8)
36 #define CPU_LOG_RESET (1 << 9)
37 #define LOG_UNIMP (1 << 10)
38 #define LOG_GUEST_ERROR (1 << 11)
40 /* Returns true if a bit is set in the current loglevel mask
42 static inline bool qemu_loglevel_mask(int mask)
44 return (qemu_loglevel & mask) != 0;
47 /* Logging functions: */
49 /* main logging function
51 void GCC_FMT_ATTR(1, 2) qemu_log(const char *fmt, ...);
53 /* vfprintf-like logging function
55 static inline void GCC_FMT_ATTR(1, 0)
56 qemu_log_vprintf(const char *fmt, va_list va)
58 if (qemu_logfile) {
59 vfprintf(qemu_logfile, fmt, va);
63 /* log only if a bit is set on the current loglevel mask
65 void GCC_FMT_ATTR(2, 3) qemu_log_mask(int mask, const char *fmt, ...);
68 /* Special cases: */
70 #ifdef NEED_CPU_H
71 /* cpu_dump_state() logging functions: */
72 static inline void log_cpu_state(CPUArchState *env1, int flags)
74 if (qemu_log_enabled()) {
75 cpu_dump_state(env1, qemu_logfile, fprintf, flags);
79 static inline void log_cpu_state_mask(int mask, CPUArchState *env1, int flags)
81 if (qemu_loglevel & mask) {
82 log_cpu_state(env1, flags);
86 /* disas() and target_disas() to qemu_logfile: */
87 static inline void log_target_disas(CPUArchState *env, target_ulong start,
88 target_ulong len, int flags)
90 target_disas(qemu_logfile, env, start, len, flags);
93 static inline void log_disas(void *code, unsigned long size)
95 disas(qemu_logfile, code, size);
98 #if defined(CONFIG_USER_ONLY)
99 /* page_dump() output to the log file: */
100 static inline void log_page_dump(void)
102 page_dump(qemu_logfile);
104 #endif
105 #endif
108 /* Maintenance: */
110 /* fflush() the log file */
111 static inline void qemu_log_flush(void)
113 fflush(qemu_logfile);
116 /* Close the log file */
117 static inline void qemu_log_close(void)
119 fclose(qemu_logfile);
120 qemu_logfile = NULL;
123 /* Set up a new log file */
124 static inline void qemu_log_set_file(FILE *f)
126 qemu_logfile = f;
129 /* Set up a new log file, only if none is set */
130 static inline void qemu_log_try_set_file(FILE *f)
132 if (!qemu_logfile) {
133 qemu_logfile = f;
137 /* define log items */
138 typedef struct CPULogItem {
139 int mask;
140 const char *name;
141 const char *help;
142 } CPULogItem;
144 extern const CPULogItem cpu_log_items[];
146 void qemu_set_log(int log_flags, bool use_own_buffers);
148 static inline void cpu_set_log(int log_flags)
150 #ifdef CONFIG_USER_ONLY
151 qemu_set_log(log_flags, true);
152 #else
153 qemu_set_log(log_flags, false);
154 #endif
157 void cpu_set_log_filename(const char *filename);
158 int cpu_str_to_log_mask(const char *str);
160 #endif