aboutsummaryrefslogtreecommitdiff
path: root/accel/tcg/debuginfo.h
blob: f064e1c144b88d66d9d1f546d9e42e30c01d499d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
 * Debug information support.
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

#ifndef ACCEL_TCG_DEBUGINFO_H
#define ACCEL_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