Merge branch 'target-arm.for-upstream' of git://git.linaro.org/people/pmaydell/qemu-arm
[qemu/opensuse.git] / qemu-log.h
blob40f8b7b0c8b56002215001abec5aeec00bf329bb
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)
39 /* Returns true if a bit is set in the current loglevel mask
41 static inline bool qemu_loglevel_mask(int mask)
43 return (qemu_loglevel & mask) != 0;
46 /* Logging functions: */
48 /* main logging function
50 void GCC_FMT_ATTR(1, 2) qemu_log(const char *fmt, ...);
52 /* vfprintf-like logging function
54 static inline void qemu_log_vprintf(const char *fmt, va_list va)
56 if (qemu_logfile) {
57 vfprintf(qemu_logfile, fmt, va);
61 /* log only if a bit is set on the current loglevel mask
63 void GCC_FMT_ATTR(2, 3) qemu_log_mask(int mask, const char *fmt, ...);
66 /* Special cases: */
68 #ifdef NEED_CPU_H
69 /* cpu_dump_state() logging functions: */
70 static inline void log_cpu_state(CPUArchState *env1, int flags)
72 cpu_dump_state(env1, qemu_logfile, fprintf, flags);
75 static inline void log_cpu_state_mask(int mask, CPUArchState *env1, int flags)
77 if (qemu_loglevel & mask) {
78 log_cpu_state(env1, flags);
82 /* disas() and target_disas() to qemu_logfile: */
83 static inline void log_target_disas(target_ulong start, target_ulong len,
84 int flags)
86 target_disas(qemu_logfile, start, len, flags);
89 static inline void log_disas(void *code, unsigned long size)
91 disas(qemu_logfile, code, size);
94 #if defined(CONFIG_USER_ONLY)
95 /* page_dump() output to the log file: */
96 static inline void log_page_dump(void)
98 page_dump(qemu_logfile);
100 #endif
101 #endif
104 /* Maintenance: */
106 /* fflush() the log file */
107 static inline void qemu_log_flush(void)
109 fflush(qemu_logfile);
112 /* Close the log file */
113 static inline void qemu_log_close(void)
115 fclose(qemu_logfile);
116 qemu_logfile = NULL;
119 /* Set up a new log file */
120 static inline void qemu_log_set_file(FILE *f)
122 qemu_logfile = f;
125 /* Set up a new log file, only if none is set */
126 static inline void qemu_log_try_set_file(FILE *f)
128 if (!qemu_logfile) {
129 qemu_logfile = f;
133 /* define log items */
134 typedef struct CPULogItem {
135 int mask;
136 const char *name;
137 const char *help;
138 } CPULogItem;
140 extern const CPULogItem cpu_log_items[];
142 void cpu_set_log(int log_flags);
143 void cpu_set_log_filename(const char *filename);
144 int cpu_str_to_log_mask(const char *str);
146 #endif