1 #ifndef QEMU_LOG_H 2 #define QEMU_LOG_H 3 4 /* A small part of this API is split into its own header */ 5 #include "qemu/log-for-trace.h" 6 7 /* 8 * The new API: 9 */ 10 11 /* Returns true if qemu_log() will really write somewhere. */ 12 bool qemu_log_enabled(void); 13 14 /* Returns true if qemu_log() will write somewhere other than stderr. */ 15 bool qemu_log_separate(void); 16 17 #define CPU_LOG_TB_OUT_ASM (1 << 0) 18 #define CPU_LOG_TB_IN_ASM (1 << 1) 19 #define CPU_LOG_TB_OP (1 << 2) 20 #define CPU_LOG_TB_OP_OPT (1 << 3) 21 #define CPU_LOG_INT (1 << 4) 22 #define CPU_LOG_EXEC (1 << 5) 23 #define CPU_LOG_PCALL (1 << 6) 24 #define CPU_LOG_TB_CPU (1 << 8) 25 #define CPU_LOG_RESET (1 << 9) 26 #define LOG_UNIMP (1 << 10) 27 #define LOG_GUEST_ERROR (1 << 11) 28 #define CPU_LOG_MMU (1 << 12) 29 #define CPU_LOG_TB_NOCHAIN (1 << 13) 30 #define CPU_LOG_PAGE (1 << 14) 31 /* LOG_TRACE (1 << 15) is defined in log-for-trace.h */ 32 #define CPU_LOG_TB_OP_IND (1 << 16) 33 #define CPU_LOG_TB_FPU (1 << 17) 34 #define CPU_LOG_PLUGIN (1 << 18) 35 /* LOG_STRACE is used for user-mode strace logging. */ 36 #define LOG_STRACE (1 << 19) 37 #define LOG_PER_THREAD (1 << 20) 38 #define CPU_LOG_TB_VPU (1 << 21) 39 #define LOG_TB_OP_PLUGIN (1 << 22) 40 #define LOG_INVALID_MEM (1 << 23) 41 42 /* Lock/unlock output. */ 43 44 FILE *qemu_log_trylock(void) G_GNUC_WARN_UNUSED_RESULT; 45 void qemu_log_unlock(FILE *fd); 46 47 /* Logging functions: */ 48 49 /* log only if a bit is set on the current loglevel mask: 50 * @mask: bit to check in the mask 51 * @fmt: printf-style format string 52 * @args: optional arguments for format string 53 */ 54 #define qemu_log_mask(MASK, FMT, ...) \ 55 do { \ 56 if (unlikely(qemu_loglevel_mask(MASK))) { \ 57 qemu_log(FMT, ## __VA_ARGS__); \ 58 } \ 59 } while (0) 60 61 /* log only if a bit is set on the current loglevel mask 62 * and we are in the address range we care about: 63 * @mask: bit to check in the mask 64 * @addr: address to check in dfilter 65 * @fmt: printf-style format string 66 * @args: optional arguments for format string 67 */ 68 #define qemu_log_mask_and_addr(MASK, ADDR, FMT, ...) \ 69 do { \ 70 if (unlikely(qemu_loglevel_mask(MASK)) && \ 71 qemu_log_in_addr_range(ADDR)) { \ 72 qemu_log(FMT, ## __VA_ARGS__); \ 73 } \ 74 } while (0) 75 76 /* Maintenance: */ 77 78 /* define log items */ 79 typedef struct QEMULogItem { 80 int mask; 81 const char *name; 82 const char *help; 83 } QEMULogItem; 84 85 extern const QEMULogItem qemu_log_items[]; 86 87 bool qemu_set_log(int log_flags, Error **errp); 88 bool qemu_set_log_filename(const char *filename, Error **errp); 89 bool qemu_set_log_filename_flags(const char *name, int flags, Error **errp); 90 void qemu_set_dfilter_ranges(const char *ranges, Error **errp); 91 bool qemu_log_in_addr_range(uint64_t addr); 92 int qemu_str_to_log_mask(const char *str); 93 94 /* Print a usage message listing all the valid logging categories 95 * to the specified FILE*. 96 */ 97 void qemu_print_log_usage(FILE *f); 98 99 #endif 100