]>
git.proxmox.com Git - qemu.git/blob - qemu-log.c
4 * Copyright (c) 2003 Fabrice Bellard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
20 #include "qemu-common.h"
24 static const char *logfilename
= "qemu.log";
26 static const char *logfilename
= "/tmp/qemu.log";
30 static int log_append
= 0;
32 /* enable or disable low levels log */
33 void cpu_set_log(int log_flags
)
36 if (loglevel
&& !logfile
) {
37 logfile
= fopen(logfilename
, log_append
? "a" : "w");
42 #if !defined(CONFIG_SOFTMMU)
43 /* must avoid mmap() usage of glibc by setting a buffer "by hand" */
45 static char logfile_buf
[4096];
46 setvbuf(logfile
, logfile_buf
, _IOLBF
, sizeof(logfile_buf
));
49 /* Win32 doesn't support line-buffering, so use unbuffered output. */
50 setvbuf(logfile
, NULL
, _IONBF
, 0);
52 setvbuf(logfile
, NULL
, _IOLBF
, 0);
56 if (!loglevel
&& logfile
) {
62 void cpu_set_log_filename(const char *filename
)
64 logfilename
= strdup(filename
);
69 cpu_set_log(loglevel
);
72 const CPULogItem cpu_log_items
[] = {
73 { CPU_LOG_TB_OUT_ASM
, "out_asm",
74 "show generated host assembly code for each compiled TB" },
75 { CPU_LOG_TB_IN_ASM
, "in_asm",
76 "show target assembly code for each compiled TB" },
77 { CPU_LOG_TB_OP
, "op",
78 "show micro ops for each compiled TB" },
79 { CPU_LOG_TB_OP_OPT
, "op_opt",
82 "before eflags optimization and "
84 "after liveness analysis" },
86 "show interrupts/exceptions in short format" },
87 { CPU_LOG_EXEC
, "exec",
88 "show trace before each executed TB (lots of logs)" },
89 { CPU_LOG_TB_CPU
, "cpu",
90 "show CPU state before block translation" },
92 { CPU_LOG_PCALL
, "pcall",
93 "show protected mode far calls/returns/exceptions" },
94 { CPU_LOG_RESET
, "cpu_reset",
95 "show CPU state before CPU resets" },
98 { CPU_LOG_IOPORT
, "ioport",
99 "show all i/o ports accesses" },
104 static int cmp1(const char *s1
, int n
, const char *s2
)
106 if (strlen(s2
) != n
) {
109 return memcmp(s1
, s2
, n
) == 0;
112 /* takes a comma separated list of log masks. Return 0 if error. */
113 int cpu_str_to_log_mask(const char *str
)
115 const CPULogItem
*item
;
126 if (cmp1(p
,p1
-p
,"all")) {
127 for (item
= cpu_log_items
; item
->mask
!= 0; item
++) {
131 for (item
= cpu_log_items
; item
->mask
!= 0; item
++) {
132 if (cmp1(p
, p1
- p
, item
->name
)) {