diff --git a/include/qemu/log.h b/include/qemu/log.h index a91105b2ad..a99095f7be 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -46,6 +46,7 @@ static inline bool qemu_log_separate(void) #define CPU_LOG_TB_OP_IND (1 << 16) #define CPU_LOG_TB_FPU (1 << 17) #define CPU_LOG_PLUGIN (1 << 18) +#define LOG_NYX (1 << 19) /* 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 diff --git a/nyx/debug.h b/nyx/debug.h index f79ce82a8c..d988444eb1 100644 --- a/nyx/debug.h +++ b/nyx/debug.h @@ -5,9 +5,13 @@ #include #include +#include "qemu/osdep.h" +#include "qemu-common.h" +#include "qemu/log.h" + #define ENABLE_BACKTRACES -#define QEMU_PT_PRINT_PREFIX "[QEMU-PT]\t" +#define QEMU_PT_PRINT_PREFIX "[QEMU-NYX] " #define CORE_PREFIX "Core: " #define MEM_PREFIX "Memory: " #define RELOAD_PREFIX "Reload: " @@ -27,11 +31,16 @@ #ifdef NYX_DEBUG -#define debug_printf(format, ...) printf (format, ##__VA_ARGS__) -#define debug_fprintf(fd, format, ...) fprintf (fd, format, ##__VA_ARGS__) -#define QEMU_PT_PRINTF(PREFIX, format, ...) printf (QEMU_PT_PRINT_PREFIX COLOR PREFIX format ENDC "\n", ##__VA_ARGS__) -#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__) +/* + * qemu_log() is the standard logging enabled with -D + * qemu_log_mask() is activated with additional -t nyx option + */ +#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 #define debug_printf(format, ...) #define debug_fprintf(fd, format, ...) diff --git a/util/log.c b/util/log.c index 1ca13059ee..d862e9047a 100644 --- a/util/log.c +++ b/util/log.c @@ -273,6 +273,10 @@ const QEMULogItem qemu_log_items[] = { { CPU_LOG_TB_NOCHAIN, "nochain", "do not chain compiled TBs so that \"exec\" and \"cpu\" show\n" "complete traces" }, +#ifdef QEMU_NYX + { LOG_NYX, "nyx", + "trace Nyx/Redqueen execution" }, +#endif #ifdef CONFIG_PLUGIN { CPU_LOG_PLUGIN, "plugin", "output from TCG plugins\n"}, #endif