]> Git Repo - qemu.git/blob - qemu-log.h
dt: Add -machine dumpdtb option to dump the current dtb
[qemu.git] / qemu-log.h
1 #ifndef QEMU_LOG_H
2 #define QEMU_LOG_H
3
4 #include <stdarg.h>
5 #ifdef NEED_CPU_H
6 #include "disas.h"
7 #endif
8
9 /* Private global variables, don't use */
10 extern FILE *qemu_logfile;
11 extern int qemu_loglevel;
12
13 /* 
14  * The new API:
15  *
16  */
17
18 /* Log settings checking macros: */
19
20 /* Returns true if qemu_log() will really write somewhere
21  */
22 static inline bool qemu_log_enabled(void)
23 {
24     return qemu_logfile != NULL;
25 }
26
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
39 /* Returns true if a bit is set in the current loglevel mask
40  */
41 static inline bool qemu_loglevel_mask(int mask)
42 {
43     return (qemu_loglevel & mask) != 0;
44 }
45
46 /* Logging functions: */
47
48 /* main logging function
49  */
50 void GCC_FMT_ATTR(1, 2) qemu_log(const char *fmt, ...);
51
52 /* vfprintf-like logging function
53  */
54 static inline void qemu_log_vprintf(const char *fmt, va_list va)
55 {
56     if (qemu_logfile) {
57         vfprintf(qemu_logfile, fmt, va);
58     }
59 }
60
61 /* log only if a bit is set on the current loglevel mask
62  */
63 void GCC_FMT_ATTR(2, 3) qemu_log_mask(int mask, const char *fmt, ...);
64
65
66 /* Special cases: */
67
68 #ifdef NEED_CPU_H
69 /* cpu_dump_state() logging functions: */
70 static inline void log_cpu_state(CPUArchState *env1, int flags)
71 {
72     if (qemu_log_enabled()) {
73         cpu_dump_state(env1, qemu_logfile, fprintf, flags);
74     }
75 }
76
77 static inline void log_cpu_state_mask(int mask, CPUArchState *env1, int flags)
78 {
79     if (qemu_loglevel & mask) {
80         log_cpu_state(env1, flags);
81     }
82 }
83
84 /* disas() and target_disas() to qemu_logfile: */
85 static inline void log_target_disas(target_ulong start, target_ulong len,
86                                     int flags)
87 {
88     target_disas(qemu_logfile, start, len, flags);
89 }
90
91 static inline void log_disas(void *code, unsigned long size)
92 {
93     disas(qemu_logfile, code, size);
94 }
95
96 #if defined(CONFIG_USER_ONLY)
97 /* page_dump() output to the log file: */
98 static inline void log_page_dump(void)
99 {
100     page_dump(qemu_logfile);
101 }
102 #endif
103 #endif
104
105
106 /* Maintenance: */
107
108 /* fflush() the log file */
109 static inline void qemu_log_flush(void)
110 {
111     fflush(qemu_logfile);
112 }
113
114 /* Close the log file */
115 static inline void qemu_log_close(void)
116 {
117     fclose(qemu_logfile);
118     qemu_logfile = NULL;
119 }
120
121 /* Set up a new log file */
122 static inline void qemu_log_set_file(FILE *f)
123 {
124     qemu_logfile = f;
125 }
126
127 /* Set up a new log file, only if none is set */
128 static inline void qemu_log_try_set_file(FILE *f)
129 {
130     if (!qemu_logfile) {
131         qemu_logfile = f;
132     }
133 }
134
135 /* define log items */
136 typedef struct CPULogItem {
137     int mask;
138     const char *name;
139     const char *help;
140 } CPULogItem;
141
142 extern const CPULogItem cpu_log_items[];
143
144 void cpu_set_log(int log_flags);
145 void cpu_set_log_filename(const char *filename);
146 int cpu_str_to_log_mask(const char *str);
147
148 #endif
This page took 0.029448 seconds and 4 git commands to generate.