Debian Codegraph @

libdrgn/orc_info.h

raw
1 // Copyright (c) Meta Platforms, Inc. and affiliates.
2 // SPDX-License-Identifier: LGPL-2.1-or-later
3
4 /**
5 * @file
6 *
7 * ORC unwinder support.
8 *
9 * See @ref DebugInfo.
10 */
11
12 #ifndef DRGN_ORC_INFO_H
13 #define DRGN_ORC_INFO_H
14
15 #include <stdbool.h>
16 #include <stdint.h>
17
18 #include "cfi.h"
19
20 struct drgn_module;
21
22 /**
23 * @ingroup DebugInfo
24 *
25 * @{
26 */
27
28 /** ORC unwinder data for a @ref drgn_module. */
29 struct drgn_module_orc_info {
30 /**
31 * Ranges where unwinding with ORC should be preferred over DWARF CFI,
32 * sorted by start address.
33 *
34 * ORC may be preferred if configured by the user or for special ORC
35 * entries; see drgn_raw_orc_entry_is_preferred().
36 */
37 struct uint64_range *preferred;
38 /** Number of ranges in @ref preferred. */
39 size_t num_preferred;
40 /**
41 * Base for calculating program counter corresponding to an ORC unwinder
42 * entry.
43 *
44 * This is the address of the `.orc_unwind_ip` ELF section. It is the
45 * actual loaded location, with any bias already applied.
46 *
47 * @sa drgn_module_orc_info::entries
48 */
49 uint64_t pc_base;
50 /**
51 * Offsets for calculating program counter corresponding to an ORC
52 * unwinder entry.
53 *
54 * This is the contents of the `.orc_unwind_ip` ELF section, byte
55 * swapped to the host's byte order if necessary.
56 *
57 * @sa drgn_module_orc_info::entries
58 */
59 int32_t *pc_offsets;
60 /**
61 * ORC unwinder entries.
62 *
63 * This is the contents of the `.orc_unwind` ELF section, byte swapped
64 * to the host's byte order and normalized to the latest version of the
65 * format if necessary.
66 *
67 * Entry `i` specifies how to unwind the stack if
68 * `orc_pc(i) <= PC < orc_pc(i + 1)`, where
69 * `orc_pc(i) = pc_base + 4 * i + pc_offsets[i]`.
70 */
71 struct drgn_orc_entry *entries;
72 /** Number of ORC unwinder entries. */
73 unsigned int num_entries;
74 /** Version of the ORC format. See @ref orc.h. */
75 int version;
76 /** Whether to byte swap data */
77 bool bswap;
78 };
79
80 void drgn_module_orc_info_deinit(struct drgn_module *module);
81
82 struct drgn_error *drgn_module_parse_orc(struct drgn_module *module,
83 bool use_builtin);
84
85 bool drgn_module_should_prefer_orc_cfi(struct drgn_module *module, uint64_t pc);
86
87 struct drgn_error *
88 drgn_module_find_orc_cfi(struct drgn_module *module, uint64_t pc,
89 struct drgn_cfi_row **row_ret, bool *interrupted_ret,
90 drgn_register_number *ret_addr_regno_ret);
91
92 /** @} */
93
94 #endif /* DRGN_ORC_INFO_H */