Use qemu_log_trylock/unlock instead of the raw rcu_read. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20220417183019.755276-25-richard.henderson@linaro.org>
		
			
				
	
	
		
			41 lines
		
	
	
		
			857 B
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
		
			857 B
		
	
	
	
		
			C
		
	
	
	
	
	
#ifndef QEMU_EXEC_LOG_H
 | 
						|
#define QEMU_EXEC_LOG_H
 | 
						|
 | 
						|
#include "qemu/log.h"
 | 
						|
#include "hw/core/cpu.h"
 | 
						|
#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)
 | 
						|
{
 | 
						|
    FILE *f = qemu_log_trylock();
 | 
						|
    if (f) {
 | 
						|
        cpu_dump_state(cpu, f, flags);
 | 
						|
        qemu_log_unlock(f);
 | 
						|
    }
 | 
						|
}
 | 
						|
 | 
						|
/**
 | 
						|
 * 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);
 | 
						|
    }
 | 
						|
}
 | 
						|
 | 
						|
#endif
 |