mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-01-12 18:15:40 +00:00
924d4599cc
Running barebox on qemu-system-mips* with '-d unimp' overloads stderr by very very many mips_cpu_handle_mmu_fault() messages: mips_cpu_handle_mmu_fault address=b80003fd ret 0 physical 00000000180003fd prot 3 mips_cpu_handle_mmu_fault address=a0800884 ret 0 physical 0000000000800884 prot 3 mips_cpu_handle_mmu_fault pc a080cd80 ad b80003fd rw 0 mmu_idx 0 So it's very difficult to find LOG_UNIMP message. The mips_cpu_handle_mmu_fault() messages appear on enabling ANY logging! It's not very handy. Adding separate log category for *_cpu_handle_mmu_fault() logging fixes the problem. Backports commit 339aaf5b7f26d1e638641c59a44883b7654bd8ea from qemu
120 lines
2.5 KiB
C
120 lines
2.5 KiB
C
#ifndef QEMU_LOG_H
|
|
#define QEMU_LOG_H
|
|
|
|
#include <stdarg.h>
|
|
#include "unicorn/platform.h"
|
|
#include "qemu/compiler.h"
|
|
#include "qom/cpu.h"
|
|
|
|
/* Private global variables, don't use */
|
|
extern FILE *qemu_logfile;
|
|
extern int qemu_loglevel;
|
|
|
|
/*
|
|
* The new API:
|
|
*
|
|
*/
|
|
|
|
/* Log settings checking macros: */
|
|
|
|
/* Returns true if qemu_log() will really write somewhere
|
|
*/
|
|
static inline bool qemu_log_enabled(void)
|
|
{
|
|
return qemu_logfile != NULL;
|
|
}
|
|
|
|
#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_IOPORT (1 << 7)
|
|
#define CPU_LOG_TB_CPU (1 << 8)
|
|
#define CPU_LOG_RESET (1 << 9)
|
|
#define LOG_UNIMP (1 << 10)
|
|
#define LOG_GUEST_ERROR (1 << 11)
|
|
#define CPU_LOG_MMU (1 << 12)
|
|
#define CPU_LOG_TB_NOCHAIN (1 << 13)
|
|
|
|
/* Returns true if a bit is set in the current loglevel mask
|
|
*/
|
|
static inline bool qemu_loglevel_mask(int mask)
|
|
{
|
|
return (qemu_loglevel & mask) != 0;
|
|
}
|
|
|
|
/* Logging functions: */
|
|
|
|
/* main logging function
|
|
*/
|
|
void GCC_FMT_ATTR(1, 2) qemu_log(const char *fmt, ...);
|
|
|
|
/* vfprintf-like logging function
|
|
*/
|
|
static inline void GCC_FMT_ATTR(1, 0)
|
|
qemu_log_vprintf(const char *fmt, va_list va)
|
|
{
|
|
if (qemu_logfile) {
|
|
vfprintf(qemu_logfile, fmt, va);
|
|
}
|
|
}
|
|
|
|
/* log only if a bit is set on the current loglevel mask
|
|
*/
|
|
void GCC_FMT_ATTR(2, 3) qemu_log_mask(int mask, const char *fmt, ...);
|
|
|
|
|
|
/* Special cases: */
|
|
|
|
/* cpu_dump_state() logging functions: */
|
|
/**
|
|
* log_cpu_state:
|
|
* @cpu: The CPU whose state is to be logged.
|
|
* @flags: Flags what to log.
|
|
*
|
|
* Logs the output of cpu_dump_state().
|
|
*/
|
|
static inline void log_cpu_state(CPUState *cpu, int flags)
|
|
{
|
|
if (qemu_log_enabled()) {
|
|
cpu_dump_state(cpu, qemu_logfile, fprintf, flags);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* log_cpu_state_mask:
|
|
* @mask: Mask when to log.
|
|
* @cpu: The CPU whose state is to be logged.
|
|
* @flags: Flags what to log.
|
|
*
|
|
* Logs the output of cpu_dump_state() if loglevel includes @mask.
|
|
*/
|
|
static inline void log_cpu_state_mask(int mask, CPUState *cpu, int flags)
|
|
{
|
|
if (qemu_loglevel & mask) {
|
|
log_cpu_state(cpu, flags);
|
|
}
|
|
}
|
|
|
|
/* fflush() the log file */
|
|
static inline void qemu_log_flush(void)
|
|
{
|
|
fflush(qemu_logfile);
|
|
}
|
|
|
|
/* Close the log file */
|
|
static inline void qemu_log_close(void)
|
|
{
|
|
if (qemu_logfile) {
|
|
if (qemu_logfile != stderr) {
|
|
fclose(qemu_logfile);
|
|
}
|
|
qemu_logfile = NULL;
|
|
}
|
|
}
|
|
|
|
#endif
|