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