2008-08-30 11:51:20 +02:00
|
|
|
#ifndef QEMU_LOG_H
|
|
|
|
#define QEMU_LOG_H
|
|
|
|
|
2018-02-13 15:00:29 +01:00
|
|
|
/* A small part of this API is split into its own header */
|
|
|
|
#include "qemu/log-for-trace.h"
|
2008-08-30 11:51:20 +02:00
|
|
|
|
2009-01-15 22:52:11 +01:00
|
|
|
/*
|
|
|
|
* The new API:
|
|
|
|
*/
|
|
|
|
|
2022-04-17 20:30:05 +02:00
|
|
|
/* Returns true if qemu_log() will really write somewhere. */
|
|
|
|
bool qemu_log_enabled(void);
|
2019-11-18 22:15:27 +01:00
|
|
|
|
2022-04-17 20:30:05 +02:00
|
|
|
/* Returns true if qemu_log() will write somewhere other than stderr. */
|
|
|
|
bool qemu_log_separate(void);
|
2015-11-13 13:16:27 +01:00
|
|
|
|
2012-06-03 17:03:23 +02:00
|
|
|
#define CPU_LOG_TB_OUT_ASM (1 << 0)
|
|
|
|
#define CPU_LOG_TB_IN_ASM (1 << 1)
|
|
|
|
#define CPU_LOG_TB_OP (1 << 2)
|
|
|
|
#define CPU_LOG_TB_OP_OPT (1 << 3)
|
|
|
|
#define CPU_LOG_INT (1 << 4)
|
|
|
|
#define CPU_LOG_EXEC (1 << 5)
|
|
|
|
#define CPU_LOG_PCALL (1 << 6)
|
|
|
|
#define CPU_LOG_TB_CPU (1 << 8)
|
|
|
|
#define CPU_LOG_RESET (1 << 9)
|
2012-06-03 19:04:28 +02:00
|
|
|
#define LOG_UNIMP (1 << 10)
|
2012-10-18 15:11:35 +02:00
|
|
|
#define LOG_GUEST_ERROR (1 << 11)
|
2014-12-13 17:48:18 +01:00
|
|
|
#define CPU_LOG_MMU (1 << 12)
|
2015-09-17 00:33:53 +02:00
|
|
|
#define CPU_LOG_TB_NOCHAIN (1 << 13)
|
2015-11-13 12:32:19 +01:00
|
|
|
#define CPU_LOG_PAGE (1 << 14)
|
2018-02-13 15:00:29 +01:00
|
|
|
/* LOG_TRACE (1 << 15) is defined in log-for-trace.h */
|
2016-06-24 05:34:33 +02:00
|
|
|
#define CPU_LOG_TB_OP_IND (1 << 16)
|
2018-05-15 15:58:44 +02:00
|
|
|
#define CPU_LOG_TB_FPU (1 << 17)
|
2019-10-11 17:34:05 +02:00
|
|
|
#define CPU_LOG_PLUGIN (1 << 18)
|
2020-02-04 03:54:14 +01:00
|
|
|
/* LOG_STRACE is used for user-mode strace logging. */
|
|
|
|
#define LOG_STRACE (1 << 19)
|
2022-04-17 20:30:19 +02:00
|
|
|
#define LOG_PER_THREAD (1 << 20)
|
2023-04-10 14:44:50 +02:00
|
|
|
#define CPU_LOG_TB_VPU (1 << 21)
|
2012-06-03 17:03:23 +02:00
|
|
|
|
2022-04-17 20:29:46 +02:00
|
|
|
/* Lock/unlock output. */
|
2016-09-23 00:17:10 +02:00
|
|
|
|
2022-04-17 20:29:58 +02:00
|
|
|
FILE *qemu_log_trylock(void) G_GNUC_WARN_UNUSED_RESULT;
|
2022-04-17 20:29:46 +02:00
|
|
|
void qemu_log_unlock(FILE *fd);
|
2016-09-23 00:17:10 +02:00
|
|
|
|
2009-01-15 22:52:11 +01:00
|
|
|
/* Logging functions: */
|
|
|
|
|
2016-03-15 19:12:03 +01:00
|
|
|
/* log only if a bit is set on the current loglevel mask:
|
|
|
|
* @mask: bit to check in the mask
|
|
|
|
* @fmt: printf-style format string
|
|
|
|
* @args: optional arguments for format string
|
2009-01-15 22:52:11 +01:00
|
|
|
*/
|
2016-03-15 19:12:03 +01:00
|
|
|
#define qemu_log_mask(MASK, FMT, ...) \
|
|
|
|
do { \
|
|
|
|
if (unlikely(qemu_loglevel_mask(MASK))) { \
|
|
|
|
qemu_log(FMT, ## __VA_ARGS__); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
2009-01-15 22:52:11 +01:00
|
|
|
|
2016-03-15 15:30:21 +01:00
|
|
|
/* log only if a bit is set on the current loglevel mask
|
|
|
|
* and we are in the address range we care about:
|
|
|
|
* @mask: bit to check in the mask
|
|
|
|
* @addr: address to check in dfilter
|
|
|
|
* @fmt: printf-style format string
|
|
|
|
* @args: optional arguments for format string
|
|
|
|
*/
|
|
|
|
#define qemu_log_mask_and_addr(MASK, ADDR, FMT, ...) \
|
|
|
|
do { \
|
|
|
|
if (unlikely(qemu_loglevel_mask(MASK)) && \
|
|
|
|
qemu_log_in_addr_range(ADDR)) { \
|
|
|
|
qemu_log(FMT, ## __VA_ARGS__); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
2009-01-15 22:52:11 +01:00
|
|
|
/* Maintenance: */
|
|
|
|
|
2012-06-03 17:03:23 +02:00
|
|
|
/* define log items */
|
2013-02-11 17:41:25 +01:00
|
|
|
typedef struct QEMULogItem {
|
2012-06-03 17:03:23 +02:00
|
|
|
int mask;
|
|
|
|
const char *name;
|
|
|
|
const char *help;
|
2013-02-11 17:41:25 +01:00
|
|
|
} QEMULogItem;
|
2012-06-03 17:03:23 +02:00
|
|
|
|
2013-02-11 17:41:25 +01:00
|
|
|
extern const QEMULogItem qemu_log_items[];
|
2012-06-03 17:03:23 +02:00
|
|
|
|
2022-04-17 20:29:44 +02:00
|
|
|
bool qemu_set_log(int log_flags, Error **errp);
|
2022-04-17 20:29:43 +02:00
|
|
|
bool qemu_set_log_filename(const char *filename, Error **errp);
|
2022-04-17 20:30:07 +02:00
|
|
|
bool qemu_set_log_filename_flags(const char *name, int flags, Error **errp);
|
2016-06-15 19:27:15 +02:00
|
|
|
void qemu_set_dfilter_ranges(const char *ranges, Error **errp);
|
2016-03-15 15:30:20 +01:00
|
|
|
bool qemu_log_in_addr_range(uint64_t addr);
|
2013-02-11 17:41:22 +01:00
|
|
|
int qemu_str_to_log_mask(const char *str);
|
2009-01-15 22:52:11 +01:00
|
|
|
|
2013-02-11 17:41:21 +01:00
|
|
|
/* Print a usage message listing all the valid logging categories
|
|
|
|
* to the specified FILE*.
|
|
|
|
*/
|
|
|
|
void qemu_print_log_usage(FILE *f);
|
|
|
|
|
2008-08-30 11:51:20 +02:00
|
|
|
#endif
|