2016-01-07 16:55:28 +03:00
|
|
|
#ifndef QEMU_EXEC_LOG_H
|
|
|
|
#define QEMU_EXEC_LOG_H
|
|
|
|
|
|
|
|
#include "qemu/log.h"
|
2019-07-09 18:20:52 +03:00
|
|
|
#include "hw/core/cpu.h"
|
2016-01-07 16:55:28 +03:00
|
|
|
#include "disas/disas.h"
|
|
|
|
|
|
|
|
/* 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)
|
|
|
|
{
|
2019-11-19 00:15:27 +03:00
|
|
|
QemuLogFile *logfile;
|
|
|
|
|
2016-01-07 16:55:28 +03:00
|
|
|
if (qemu_log_enabled()) {
|
2019-11-19 00:15:27 +03:00
|
|
|
rcu_read_lock();
|
2020-09-23 13:56:46 +03:00
|
|
|
logfile = qatomic_rcu_read(&qemu_logfile);
|
2019-11-19 00:15:27 +03:00
|
|
|
if (logfile) {
|
|
|
|
cpu_dump_state(cpu, logfile->fd, flags);
|
|
|
|
}
|
|
|
|
rcu_read_unlock();
|
2016-01-07 16:55:28 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef NEED_CPU_H
|
|
|
|
/* disas() and target_disas() to qemu_logfile: */
|
|
|
|
static inline void log_target_disas(CPUState *cpu, target_ulong start,
|
2017-09-14 18:38:35 +03:00
|
|
|
target_ulong len)
|
2016-01-07 16:55:28 +03:00
|
|
|
{
|
2019-11-19 00:15:27 +03:00
|
|
|
QemuLogFile *logfile;
|
|
|
|
rcu_read_lock();
|
2020-09-23 13:56:46 +03:00
|
|
|
logfile = qatomic_rcu_read(&qemu_logfile);
|
2019-11-19 00:15:27 +03:00
|
|
|
if (logfile) {
|
|
|
|
target_disas(logfile->fd, cpu, start, len);
|
|
|
|
}
|
|
|
|
rcu_read_unlock();
|
2016-01-07 16:55:28 +03:00
|
|
|
}
|
|
|
|
|
2020-09-10 22:15:04 +03:00
|
|
|
static inline void log_disas(void *code, unsigned long size)
|
2016-01-07 16:55:28 +03:00
|
|
|
{
|
2019-11-19 00:15:27 +03:00
|
|
|
QemuLogFile *logfile;
|
|
|
|
rcu_read_lock();
|
2020-09-23 13:56:46 +03:00
|
|
|
logfile = qatomic_rcu_read(&qemu_logfile);
|
2019-11-19 00:15:27 +03:00
|
|
|
if (logfile) {
|
2020-09-10 22:15:04 +03:00
|
|
|
disas(logfile->fd, code, size);
|
2019-11-19 00:15:27 +03:00
|
|
|
}
|
|
|
|
rcu_read_unlock();
|
2016-01-07 16:55:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
|
|
|
/* page_dump() output to the log file: */
|
2019-12-05 15:25:15 +03:00
|
|
|
static inline void log_page_dump(const char *operation)
|
2016-01-07 16:55:28 +03:00
|
|
|
{
|
2019-12-05 15:25:15 +03:00
|
|
|
FILE *logfile = qemu_log_lock();
|
2019-11-19 00:15:27 +03:00
|
|
|
if (logfile) {
|
2019-12-05 15:25:15 +03:00
|
|
|
qemu_log("page layout changed following %s\n", operation);
|
|
|
|
page_dump(logfile);
|
2019-11-19 00:15:27 +03:00
|
|
|
}
|
2019-12-05 15:25:15 +03:00
|
|
|
qemu_log_unlock(logfile);
|
2016-01-07 16:55:28 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|