switch debug logging to use qemu_log_mask()

Default qemu_log is written to stderr, or logged to file with -D
Additional qemu_log_masked(LOG_NYX) can be enabled with -d nyx
This commit is contained in:
Steffen Schulz 2022-05-22 22:44:59 +02:00 committed by Sergej Schumilo
parent bd34c46b85
commit f91ff284ee
3 changed files with 20 additions and 6 deletions

View File

@ -46,6 +46,7 @@ static inline bool qemu_log_separate(void)
#define CPU_LOG_TB_OP_IND (1 << 16) #define CPU_LOG_TB_OP_IND (1 << 16)
#define CPU_LOG_TB_FPU (1 << 17) #define CPU_LOG_TB_FPU (1 << 17)
#define CPU_LOG_PLUGIN (1 << 18) #define CPU_LOG_PLUGIN (1 << 18)
#define LOG_NYX (1 << 19)
/* Lock output for a series of related logs. Since this is not needed /* Lock output for a series of related logs. Since this is not needed
* for a single qemu_log / qemu_log_mask / qemu_log_mask_and_addr, we * for a single qemu_log / qemu_log_mask / qemu_log_mask_and_addr, we

View File

@ -5,9 +5,13 @@
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include "qemu/osdep.h"
#include "qemu-common.h"
#include "qemu/log.h"
#define ENABLE_BACKTRACES #define ENABLE_BACKTRACES
#define QEMU_PT_PRINT_PREFIX "[QEMU-PT]\t" #define QEMU_PT_PRINT_PREFIX "[QEMU-NYX] "
#define CORE_PREFIX "Core: " #define CORE_PREFIX "Core: "
#define MEM_PREFIX "Memory: " #define MEM_PREFIX "Memory: "
#define RELOAD_PREFIX "Reload: " #define RELOAD_PREFIX "Reload: "
@ -27,11 +31,16 @@
#ifdef NYX_DEBUG #ifdef NYX_DEBUG
#define debug_printf(format, ...) printf (format, ##__VA_ARGS__) /*
#define debug_fprintf(fd, format, ...) fprintf (fd, format, ##__VA_ARGS__) * qemu_log() is the standard logging enabled with -D
#define QEMU_PT_PRINTF(PREFIX, format, ...) printf (QEMU_PT_PRINT_PREFIX COLOR PREFIX format ENDC "\n", ##__VA_ARGS__) * qemu_log_mask() is activated with additional -t nyx option
#define QEMU_PT_PRINTF_DBG(PREFIX, format, ...) printf (QEMU_PT_PRINT_PREFIX PREFIX "(%s#:%d)\t"format, __BASE_FILE__, __LINE__, ##__VA_ARGS__) */
#define QEMU_PT_PRINTF_DEBUG(format, ...) fprintf (stderr, QEMU_PT_PRINT_PREFIX DEBUG_VM_PREFIX "(%s#:%d)\t"format "\n", __BASE_FILE__, __LINE__, ##__VA_ARGS__) #define debug_printf(format, ...) qemu_log_mask(LOG_NYX, QEMU_PT_PRINT_PREFIX "(%s#:%d)\t"format, __BASE_FILE__, __LINE__, ##__VA_ARGS__)
#define debug_fprintf(fd, format, ...) qemu_log_mask(LOG_NYX, QEMU_PT_PRINT_PREFIX "(%s#:%d)\t"format, __BASE_FILE__, __LINE__, ##__VA_ARGS__)
#define QEMU_PT_PRINTF(PREFIX, format, ...) qemu_log_mask(LOG_NYX, QEMU_PT_PRINT_PREFIX COLOR PREFIX format ENDC "\n", ##__VA_ARGS__)
#define QEMU_PT_PRINTF_DBG(PREFIX, format, ...) qemu_log_mask(LOG_NYX, QEMU_PT_PRINT_PREFIX PREFIX "(%s#:%d)\t"format, __BASE_FILE__, __LINE__, ##__VA_ARGS__)
#define QEMU_PT_PRINTF_DEBUG(format, ...) qemu_log_mask(LOG_NYX, QEMU_PT_PRINT_PREFIX DEBUG_VM_PREFIX "(%s#:%d)\t"format, __BASE_FILE__, __LINE__, ##__VA_ARGS__)
#else #else
#define debug_printf(format, ...) #define debug_printf(format, ...)
#define debug_fprintf(fd, format, ...) #define debug_fprintf(fd, format, ...)

View File

@ -273,6 +273,10 @@ const QEMULogItem qemu_log_items[] = {
{ CPU_LOG_TB_NOCHAIN, "nochain", { CPU_LOG_TB_NOCHAIN, "nochain",
"do not chain compiled TBs so that \"exec\" and \"cpu\" show\n" "do not chain compiled TBs so that \"exec\" and \"cpu\" show\n"
"complete traces" }, "complete traces" },
#ifdef QEMU_NYX
{ LOG_NYX, "nyx",
"trace Nyx/Redqueen execution" },
#endif
#ifdef CONFIG_PLUGIN #ifdef CONFIG_PLUGIN
{ CPU_LOG_PLUGIN, "plugin", "output from TCG plugins\n"}, { CPU_LOG_PLUGIN, "plugin", "output from TCG plugins\n"},
#endif #endif