2008-08-30 11:51:20 +02:00
|
|
|
#ifndef QEMU_LOG_H
|
|
|
|
#define QEMU_LOG_H
|
|
|
|
|
2012-06-03 18:35:32 +02:00
|
|
|
|
|
|
|
/* Private global variables, don't use */
|
|
|
|
extern FILE *qemu_logfile;
|
|
|
|
extern int qemu_loglevel;
|
2008-08-30 11:51:20 +02:00
|
|
|
|
2009-01-15 22:52:11 +01:00
|
|
|
/*
|
|
|
|
* The new API:
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Log settings checking macros: */
|
|
|
|
|
|
|
|
/* Returns true if qemu_log() will really write somewhere
|
|
|
|
*/
|
2012-06-03 18:35:32 +02:00
|
|
|
static inline bool qemu_log_enabled(void)
|
|
|
|
{
|
|
|
|
return qemu_logfile != NULL;
|
|
|
|
}
|
2009-01-15 22:52:11 +01:00
|
|
|
|
2015-11-13 13:16:27 +01:00
|
|
|
/* Returns true if qemu_log() will write somewhere else than stderr
|
|
|
|
*/
|
|
|
|
static inline bool qemu_log_separate(void)
|
|
|
|
{
|
|
|
|
return qemu_logfile != NULL && qemu_logfile != stderr;
|
|
|
|
}
|
|
|
|
|
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)
|
2016-01-07 14:55:30 +01:00
|
|
|
#define LOG_TRACE (1 << 15)
|
2012-06-03 17:03:23 +02:00
|
|
|
|
2009-01-15 22:52:11 +01:00
|
|
|
/* Returns true if a bit is set in the current loglevel mask
|
|
|
|
*/
|
2012-06-03 18:35:32 +02:00
|
|
|
static inline bool qemu_loglevel_mask(int mask)
|
|
|
|
{
|
|
|
|
return (qemu_loglevel & mask) != 0;
|
|
|
|
}
|
2009-01-15 22:52:11 +01:00
|
|
|
|
|
|
|
/* Logging functions: */
|
|
|
|
|
|
|
|
/* main logging function
|
|
|
|
*/
|
2012-06-03 18:35:32 +02:00
|
|
|
void GCC_FMT_ATTR(1, 2) qemu_log(const char *fmt, ...);
|
2009-01-15 22:52:11 +01:00
|
|
|
|
|
|
|
/* vfprintf-like logging function
|
|
|
|
*/
|
2012-06-23 20:41:10 +02:00
|
|
|
static inline void GCC_FMT_ATTR(1, 0)
|
|
|
|
qemu_log_vprintf(const char *fmt, va_list va)
|
2012-06-03 18:35:32 +02:00
|
|
|
{
|
|
|
|
if (qemu_logfile) {
|
|
|
|
vfprintf(qemu_logfile, fmt, va);
|
|
|
|
}
|
|
|
|
}
|
2009-01-15 22:52:11 +01:00
|
|
|
|
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
|
|
|
|
2015-12-04 13:12:57 +01:00
|
|
|
void qemu_set_log(int log_flags);
|
|
|
|
void qemu_log_needs_buffers(void);
|
2016-06-15 19:27:16 +02:00
|
|
|
void qemu_set_log_filename(const char *filename, 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);
|
|
|
|
|
2016-03-16 12:36:52 +01:00
|
|
|
/* fflush() the log file */
|
|
|
|
void qemu_log_flush(void);
|
|
|
|
/* Close the log file */
|
|
|
|
void qemu_log_close(void);
|
|
|
|
|
2008-08-30 11:51:20 +02:00
|
|
|
#endif
|