Line data Source code
1 0 : /*
2 : * Copyright (c) 2024 Meta Platforms
3 : *
4 : * SPDX-License-Identifier: Apache-2.0
5 : */
6 :
7 : #ifndef ZEPHYR_INCLUDE_DEBUG_SYMTAB_H_
8 : #define ZEPHYR_INCLUDE_DEBUG_SYMTAB_H_
9 :
10 : #include <stdint.h>
11 :
12 : #ifdef __cplusplus
13 : extern "C" {
14 : #endif
15 :
16 : /**
17 : * @defgroup symtab_apis Symbol Table API
18 : * @ingroup debug
19 : * @{
20 : */
21 :
22 : /**
23 : * @cond INTERNAL_HIDDEN
24 : */
25 :
26 : struct z_symtab_entry {
27 : const uint32_t offset;
28 : const char *const name;
29 : };
30 :
31 : /**
32 : * INTERNAL_HIDDEN @endcond
33 : */
34 :
35 0 : struct symtab_info {
36 : /* Absolute address of the first symbol */
37 0 : const uintptr_t first_addr;
38 : /* Number of symbol entries */
39 0 : const uint32_t length;
40 : /* Symbol entries */
41 0 : const struct z_symtab_entry *const entries;
42 : };
43 :
44 : /**
45 : * @brief Get the pointer to the symbol table.
46 : *
47 : * @return Pointer to the symbol table.
48 : */
49 1 : const struct symtab_info *symtab_get(void);
50 :
51 : /**
52 : * @brief Find the symbol name with a binary search
53 : *
54 : * @param[in] addr Address of the symbol to find
55 : * @param[out] offset Offset of the symbol from the nearest symbol. If the symbol can't be found,
56 : * this will be 0.
57 : *
58 : * @return Name of the nearest symbol if found, otherwise "?" is returned.
59 : */
60 1 : const char *symtab_find_symbol_name(uintptr_t addr, uint32_t *offset);
61 :
62 : /**
63 : * @}
64 : */
65 :
66 : #ifdef __cplusplus
67 : }
68 : #endif
69 :
70 : #endif /* ZEPHYR_INCLUDE_DEBUG_SYMTAB_H_ */
|