]> Git Repo - qemu.git/blame - include/qemu/log.h
sysemu/os-win32: Test for and use _lock_file/_unlock_file
[qemu.git] / include / qemu / log.h
CommitLineData
79383c9c
BS
1#ifndef QEMU_LOG_H
2#define QEMU_LOG_H
3
be0aa7ac
PM
4/* A small part of this API is split into its own header */
5#include "qemu/log-for-trace.h"
79383c9c 6
6d2c5146
AL
7/*
8 * The new API:
6d2c5146
AL
9 */
10
7fc493f8
RH
11/* Returns true if qemu_log() will really write somewhere. */
12bool qemu_log_enabled(void);
7606488c 13
7fc493f8
RH
14/* Returns true if qemu_log() will write somewhere other than stderr. */
15bool qemu_log_separate(void);
013a2942 16
5726c27f
BS
17#define CPU_LOG_TB_OUT_ASM (1 << 0)
18#define CPU_LOG_TB_IN_ASM (1 << 1)
19#define CPU_LOG_TB_OP (1 << 2)
20#define CPU_LOG_TB_OP_OPT (1 << 3)
21#define CPU_LOG_INT (1 << 4)
22#define CPU_LOG_EXEC (1 << 5)
23#define CPU_LOG_PCALL (1 << 6)
5726c27f
BS
24#define CPU_LOG_TB_CPU (1 << 8)
25#define CPU_LOG_RESET (1 << 9)
dafdf1ab 26#define LOG_UNIMP (1 << 10)
e54eba19 27#define LOG_GUEST_ERROR (1 << 11)
339aaf5b 28#define CPU_LOG_MMU (1 << 12)
89a82cd4 29#define CPU_LOG_TB_NOCHAIN (1 << 13)
13829020 30#define CPU_LOG_PAGE (1 << 14)
be0aa7ac 31/* LOG_TRACE (1 << 15) is defined in log-for-trace.h */
5a18407f 32#define CPU_LOG_TB_OP_IND (1 << 16)
ae765180 33#define CPU_LOG_TB_FPU (1 << 17)
ca76a669 34#define CPU_LOG_PLUGIN (1 << 18)
4b25a506
JK
35/* LOG_STRACE is used for user-mode strace logging. */
36#define LOG_STRACE (1 << 19)
5726c27f 37
c59fe6e5 38/* Lock/unlock output. */
1ee73216 39
27ea8133 40FILE *qemu_log_trylock(void) G_GNUC_WARN_UNUSED_RESULT;
c59fe6e5 41void qemu_log_unlock(FILE *fd);
1ee73216 42
6d2c5146
AL
43/* Logging functions: */
44
7ee60623
PM
45/* log only if a bit is set on the current loglevel mask:
46 * @mask: bit to check in the mask
47 * @fmt: printf-style format string
48 * @args: optional arguments for format string
6d2c5146 49 */
7ee60623
PM
50#define qemu_log_mask(MASK, FMT, ...) \
51 do { \
52 if (unlikely(qemu_loglevel_mask(MASK))) { \
53 qemu_log(FMT, ## __VA_ARGS__); \
54 } \
55 } while (0)
6d2c5146 56
d977e1c2
AB
57/* log only if a bit is set on the current loglevel mask
58 * and we are in the address range we care about:
59 * @mask: bit to check in the mask
60 * @addr: address to check in dfilter
61 * @fmt: printf-style format string
62 * @args: optional arguments for format string
63 */
64#define qemu_log_mask_and_addr(MASK, ADDR, FMT, ...) \
65 do { \
66 if (unlikely(qemu_loglevel_mask(MASK)) && \
67 qemu_log_in_addr_range(ADDR)) { \
68 qemu_log(FMT, ## __VA_ARGS__); \
69 } \
70 } while (0)
71
6d2c5146
AL
72/* Maintenance: */
73
5726c27f 74/* define log items */
38dad9e5 75typedef struct QEMULogItem {
5726c27f
BS
76 int mask;
77 const char *name;
78 const char *help;
38dad9e5 79} QEMULogItem;
5726c27f 80
38dad9e5 81extern const QEMULogItem qemu_log_items[];
5726c27f 82
c5955f4f 83bool qemu_set_log(int log_flags, Error **errp);
e2c7c6a4 84bool qemu_set_log_filename(const char *filename, Error **errp);
bd6fee9f 85void qemu_set_dfilter_ranges(const char *ranges, Error **errp);
3514552e 86bool qemu_log_in_addr_range(uint64_t addr);
4fde1eba 87int qemu_str_to_log_mask(const char *str);
6d2c5146 88
59a6fa6e
PM
89/* Print a usage message listing all the valid logging categories
90 * to the specified FILE*.
91 */
92void qemu_print_log_usage(FILE *f);
93
99affd1d
DL
94/* Close the log file */
95void qemu_log_close(void);
96
79383c9c 97#endif
This page took 0.811265 seconds and 4 git commands to generate.