accel/tcg: Move perf and debuginfo support to tcg/

tcg/ should not depend on accel/tcg/, but perf and debuginfo
support provided by the latter are being used by tcg/tcg.c.

Since that's the only user, move both to tcg/.

Suggested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20231212003837.64090-5-iii@linux.ibm.com>
Message-Id: <20240125054631.78867-5-philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Ilya Leoshkevich 2024-01-25 06:46:30 +01:00 committed by Richard Henderson
parent ad66ac2b3a
commit 327b75a469
13 changed files with 20 additions and 21 deletions

79
include/tcg/debuginfo.h Normal file
View file

@ -0,0 +1,79 @@
/*
* Debug information support.
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef TCG_DEBUGINFO_H
#define TCG_DEBUGINFO_H
#include "qemu/bitops.h"
/*
* Debuginfo describing a certain address.
*/
struct debuginfo_query {
uint64_t address; /* Input: address. */
int flags; /* Input: debuginfo subset. */
const char *symbol; /* Symbol that the address is part of. */
uint64_t offset; /* Offset from the symbol. */
const char *file; /* Source file associated with the address. */
int line; /* Line number in the source file. */
};
/*
* Debuginfo subsets.
*/
#define DEBUGINFO_SYMBOL BIT(1)
#define DEBUGINFO_LINE BIT(2)
#if defined(CONFIG_TCG) && defined(CONFIG_LIBDW)
/*
* Load debuginfo for the specified guest ELF image.
* Return true on success, false on failure.
*/
void debuginfo_report_elf(const char *name, int fd, uint64_t bias);
/*
* Take the debuginfo lock.
*/
void debuginfo_lock(void);
/*
* Fill each on N Qs with the debuginfo about Q->ADDRESS as specified by
* Q->FLAGS:
*
* - DEBUGINFO_SYMBOL: update Q->SYMBOL and Q->OFFSET. If symbol debuginfo is
* missing, then leave them as is.
* - DEBUINFO_LINE: update Q->FILE and Q->LINE. If line debuginfo is missing,
* then leave them as is.
*
* This function must be called under the debuginfo lock. The results can be
* accessed only until the debuginfo lock is released.
*/
void debuginfo_query(struct debuginfo_query *q, size_t n);
/*
* Release the debuginfo lock.
*/
void debuginfo_unlock(void);
#else
static inline void debuginfo_report_elf(const char *image_name, int image_fd,
uint64_t load_bias)
{
}
static inline void debuginfo_lock(void)
{
}
static inline void debuginfo_query(struct debuginfo_query *q, size_t n)
{
}
static inline void debuginfo_unlock(void)
{
}
#endif
#endif

49
include/tcg/perf.h Normal file
View file

@ -0,0 +1,49 @@
/*
* Linux perf perf-<pid>.map and jit-<pid>.dump integration.
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef TCG_PERF_H
#define TCG_PERF_H
#if defined(CONFIG_TCG) && defined(CONFIG_LINUX)
/* Start writing perf-<pid>.map. */
void perf_enable_perfmap(void);
/* Start writing jit-<pid>.dump. */
void perf_enable_jitdump(void);
/* Add information about TCG prologue to profiler maps. */
void perf_report_prologue(const void *start, size_t size);
/* Add information about JITted guest code to profiler maps. */
void perf_report_code(uint64_t guest_pc, TranslationBlock *tb,
const void *start);
/* Stop writing perf-<pid>.map and/or jit-<pid>.dump. */
void perf_exit(void);
#else
static inline void perf_enable_perfmap(void)
{
}
static inline void perf_enable_jitdump(void)
{
}
static inline void perf_report_prologue(const void *start, size_t size)
{
}
static inline void perf_report_code(uint64_t guest_pc, TranslationBlock *tb,
const void *start)
{
}
static inline void perf_exit(void)
{
}
#endif
#endif