Paolo Bonzini | 508127e | 2016-01-07 16:55:28 +0300 | [diff] [blame] | 1 | #ifndef QEMU_EXEC_LOG_H |
| 2 | #define QEMU_EXEC_LOG_H |
| 3 | |
| 4 | #include "qemu/log.h" |
Markus Armbruster | 2e5b09f | 2019-07-09 17:20:52 +0200 | [diff] [blame] | 5 | #include "hw/core/cpu.h" |
Paolo Bonzini | 508127e | 2016-01-07 16:55:28 +0300 | [diff] [blame] | 6 | #include "disas/disas.h" |
| 7 | |
| 8 | /* cpu_dump_state() logging functions: */ |
| 9 | /** |
| 10 | * log_cpu_state: |
| 11 | * @cpu: The CPU whose state is to be logged. |
| 12 | * @flags: Flags what to log. |
| 13 | * |
| 14 | * Logs the output of cpu_dump_state(). |
| 15 | */ |
| 16 | static inline void log_cpu_state(CPUState *cpu, int flags) |
| 17 | { |
Richard Henderson | bf619ea | 2022-04-17 11:30:04 -0700 | [diff] [blame] | 18 | FILE *f = qemu_log_trylock(); |
| 19 | if (f) { |
| 20 | cpu_dump_state(cpu, f, flags); |
| 21 | qemu_log_unlock(f); |
Paolo Bonzini | 508127e | 2016-01-07 16:55:28 +0300 | [diff] [blame] | 22 | } |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * log_cpu_state_mask: |
| 27 | * @mask: Mask when to log. |
| 28 | * @cpu: The CPU whose state is to be logged. |
| 29 | * @flags: Flags what to log. |
| 30 | * |
| 31 | * Logs the output of cpu_dump_state() if loglevel includes @mask. |
| 32 | */ |
| 33 | static inline void log_cpu_state_mask(int mask, CPUState *cpu, int flags) |
| 34 | { |
| 35 | if (qemu_loglevel & mask) { |
| 36 | log_cpu_state(cpu, flags); |
| 37 | } |
| 38 | } |
| 39 | |
Paolo Bonzini | 508127e | 2016-01-07 16:55:28 +0300 | [diff] [blame] | 40 | #endif |