]>
Commit | Line | Data |
---|---|---|
79383c9c BS |
1 | #ifndef QEMU_LOG_H |
2 | #define QEMU_LOG_H | |
3 | ||
6d2c5146 | 4 | /* The deprecated global variables: */ |
79383c9c BS |
5 | extern FILE *logfile; |
6 | extern int loglevel; | |
7 | ||
6d2c5146 AL |
8 | /* |
9 | * The new API: | |
10 | * | |
11 | */ | |
12 | ||
13 | /* Log settings checking macros: */ | |
14 | ||
15 | /* Returns true if qemu_log() will really write somewhere | |
16 | */ | |
17 | #define qemu_log_enabled() (logfile != NULL) | |
18 | ||
5726c27f BS |
19 | #define CPU_LOG_TB_OUT_ASM (1 << 0) |
20 | #define CPU_LOG_TB_IN_ASM (1 << 1) | |
21 | #define CPU_LOG_TB_OP (1 << 2) | |
22 | #define CPU_LOG_TB_OP_OPT (1 << 3) | |
23 | #define CPU_LOG_INT (1 << 4) | |
24 | #define CPU_LOG_EXEC (1 << 5) | |
25 | #define CPU_LOG_PCALL (1 << 6) | |
26 | #define CPU_LOG_IOPORT (1 << 7) | |
27 | #define CPU_LOG_TB_CPU (1 << 8) | |
28 | #define CPU_LOG_RESET (1 << 9) | |
29 | ||
6d2c5146 AL |
30 | /* Returns true if a bit is set in the current loglevel mask |
31 | */ | |
32 | #define qemu_loglevel_mask(b) ((loglevel & (b)) != 0) | |
33 | ||
6d2c5146 AL |
34 | /* Logging functions: */ |
35 | ||
36 | /* main logging function | |
37 | */ | |
38 | #define qemu_log(...) do { \ | |
39 | if (logfile) \ | |
40 | fprintf(logfile, ## __VA_ARGS__); \ | |
41 | } while (0) | |
42 | ||
43 | /* vfprintf-like logging function | |
44 | */ | |
45 | #define qemu_log_vprintf(fmt, va) do { \ | |
46 | if (logfile) \ | |
47 | vfprintf(logfile, fmt, va); \ | |
48 | } while (0) | |
49 | ||
50 | /* log only if a bit is set on the current loglevel mask | |
51 | */ | |
52 | #define qemu_log_mask(b, ...) do { \ | |
53 | if (loglevel & (b)) \ | |
54 | fprintf(logfile, ## __VA_ARGS__); \ | |
55 | } while (0) | |
56 | ||
57 | ||
6d2c5146 AL |
58 | /* Special cases: */ |
59 | ||
3b823210 | 60 | #ifdef NEED_CPU_H |
6d2c5146 AL |
61 | /* cpu_dump_state() logging functions: */ |
62 | #define log_cpu_state(env, f) cpu_dump_state((env), logfile, fprintf, (f)); | |
63 | #define log_cpu_state_mask(b, env, f) do { \ | |
64 | if (loglevel & (b)) log_cpu_state((env), (f)); \ | |
65 | } while (0) | |
66 | ||
67 | /* disas() and target_disas() to logfile: */ | |
68 | #define log_target_disas(start, len, flags) \ | |
69 | target_disas(logfile, (start), (len), (flags)) | |
70 | #define log_disas(start, len) \ | |
71 | disas(logfile, (start), (len)) | |
72 | ||
73 | /* page_dump() output to the log file: */ | |
74 | #define log_page_dump() page_dump(logfile) | |
3b823210 | 75 | #endif |
6d2c5146 AL |
76 | |
77 | ||
6d2c5146 AL |
78 | /* Maintenance: */ |
79 | ||
80 | /* fflush() the log file */ | |
81 | #define qemu_log_flush() fflush(logfile) | |
82 | ||
83 | /* Close the log file */ | |
84 | #define qemu_log_close() do { \ | |
85 | fclose(logfile); \ | |
86 | logfile = NULL; \ | |
87 | } while (0) | |
88 | ||
89 | /* Set up a new log file */ | |
90 | #define qemu_log_set_file(f) do { \ | |
91 | logfile = (f); \ | |
92 | } while (0) | |
93 | ||
94 | /* Set up a new log file, only if none is set */ | |
95 | #define qemu_log_try_set_file(f) do { \ | |
96 | if (!logfile) \ | |
97 | logfile = (f); \ | |
98 | } while (0) | |
99 | ||
5726c27f BS |
100 | /* define log items */ |
101 | typedef struct CPULogItem { | |
102 | int mask; | |
103 | const char *name; | |
104 | const char *help; | |
105 | } CPULogItem; | |
106 | ||
107 | extern const CPULogItem cpu_log_items[]; | |
108 | ||
109 | void cpu_set_log(int log_flags); | |
110 | void cpu_set_log_filename(const char *filename); | |
111 | int cpu_str_to_log_mask(const char *str); | |
6d2c5146 | 112 | |
79383c9c | 113 | #endif |