xref: /openbmc/qemu/include/tcg/debuginfo.h (revision 861bbc88)
1 /*
2  * Debug information support.
3  *
4  * SPDX-License-Identifier: GPL-2.0-or-later
5  */
6 
7 #ifndef TCG_DEBUGINFO_H
8 #define TCG_DEBUGINFO_H
9 
10 #include "qemu/bitops.h"
11 
12 /*
13  * Debuginfo describing a certain address.
14  */
15 struct debuginfo_query {
16     uint64_t address;    /* Input: address. */
17     int flags;           /* Input: debuginfo subset. */
18     const char *symbol;  /* Symbol that the address is part of. */
19     uint64_t offset;     /* Offset from the symbol. */
20     const char *file;    /* Source file associated with the address. */
21     int line;            /* Line number in the source file. */
22 };
23 
24 /*
25  * Debuginfo subsets.
26  */
27 #define DEBUGINFO_SYMBOL BIT(1)
28 #define DEBUGINFO_LINE   BIT(2)
29 
30 #if defined(CONFIG_TCG) && defined(CONFIG_LIBDW)
31 /*
32  * Load debuginfo for the specified guest ELF image.
33  * Return true on success, false on failure.
34  */
35 void debuginfo_report_elf(const char *name, int fd, uint64_t bias);
36 
37 /*
38  * Take the debuginfo lock.
39  */
40 void debuginfo_lock(void);
41 
42 /*
43  * Fill each on N Qs with the debuginfo about Q->ADDRESS as specified by
44  * Q->FLAGS:
45  *
46  * - DEBUGINFO_SYMBOL: update Q->SYMBOL and Q->OFFSET. If symbol debuginfo is
47  *                     missing, then leave them as is.
48  * - DEBUINFO_LINE: update Q->FILE and Q->LINE. If line debuginfo is missing,
49  *                  then leave them as is.
50  *
51  * This function must be called under the debuginfo lock. The results can be
52  * accessed only until the debuginfo lock is released.
53  */
54 void debuginfo_query(struct debuginfo_query *q, size_t n);
55 
56 /*
57  * Release the debuginfo lock.
58  */
59 void debuginfo_unlock(void);
60 #else
61 static inline void debuginfo_report_elf(const char *image_name, int image_fd,
62                                         uint64_t load_bias)
63 {
64 }
65 
66 static inline void debuginfo_lock(void)
67 {
68 }
69 
70 static inline void debuginfo_query(struct debuginfo_query *q, size_t n)
71 {
72 }
73 
74 static inline void debuginfo_unlock(void)
75 {
76 }
77 #endif
78 
79 #endif
80