File indexing completed on 2026-05-10 08:42:51
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLDB_SYMBOL_COMPACTUNWINDINFO_H
0010 #define LLDB_SYMBOL_COMPACTUNWINDINFO_H
0011
0012 #include "lldb/Symbol/ObjectFile.h"
0013 #include "lldb/Symbol/UnwindPlan.h"
0014 #include "lldb/Utility/DataExtractor.h"
0015 #include "lldb/Utility/RangeMap.h"
0016 #include "lldb/lldb-private.h"
0017 #include <mutex>
0018 #include <vector>
0019
0020 namespace lldb_private {
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 class CompactUnwindInfo {
0037 public:
0038 CompactUnwindInfo(ObjectFile &objfile, lldb::SectionSP §ion);
0039
0040 ~CompactUnwindInfo();
0041
0042 bool GetUnwindPlan(Target &target, Address addr, UnwindPlan &unwind_plan);
0043
0044 bool IsValid(const lldb::ProcessSP &process_sp);
0045
0046 private:
0047
0048
0049
0050
0051
0052 struct UnwindIndex {
0053 uint32_t function_offset = 0;
0054
0055 uint32_t second_level = 0;
0056
0057
0058 uint32_t lsda_array_start = 0;
0059
0060 uint32_t lsda_array_end =
0061 0;
0062 bool sentinal_entry = false;
0063
0064
0065
0066 UnwindIndex() = default;
0067
0068 bool operator<(const CompactUnwindInfo::UnwindIndex &rhs) const {
0069 return function_offset < rhs.function_offset;
0070 }
0071
0072 bool operator==(const CompactUnwindInfo::UnwindIndex &rhs) const {
0073 return function_offset == rhs.function_offset;
0074 }
0075 };
0076
0077
0078
0079 struct FunctionInfo {
0080 uint32_t encoding = 0;
0081 Address lsda_address;
0082 Address personality_ptr_address;
0083
0084
0085 uint32_t valid_range_offset_start = 0;
0086
0087 uint32_t valid_range_offset_end =
0088 0;
0089 FunctionInfo() = default;
0090 };
0091
0092 struct UnwindHeader {
0093 uint32_t version;
0094 uint32_t common_encodings_array_offset = 0;
0095 uint32_t common_encodings_array_count = 0;
0096 uint32_t personality_array_offset = 0;
0097 uint32_t personality_array_count = 0;
0098
0099 UnwindHeader() = default;
0100 };
0101
0102 void ScanIndex(const lldb::ProcessSP &process_sp);
0103
0104 bool GetCompactUnwindInfoForFunction(Target &target, Address address,
0105 FunctionInfo &unwind_info);
0106
0107 lldb::offset_t
0108 BinarySearchRegularSecondPage(uint32_t entry_page_offset,
0109 uint32_t entry_count, uint32_t function_offset,
0110 uint32_t *entry_func_start_offset,
0111 uint32_t *entry_func_end_offset);
0112
0113 uint32_t BinarySearchCompressedSecondPage(uint32_t entry_page_offset,
0114 uint32_t entry_count,
0115 uint32_t function_offset_to_find,
0116 uint32_t function_offset_base,
0117 uint32_t *entry_func_start_offset,
0118 uint32_t *entry_func_end_offset);
0119
0120 uint32_t GetLSDAForFunctionOffset(uint32_t lsda_offset, uint32_t lsda_count,
0121 uint32_t function_offset);
0122
0123 bool CreateUnwindPlan_x86_64(Target &target, FunctionInfo &function_info,
0124 UnwindPlan &unwind_plan,
0125 Address pc_or_function_start);
0126
0127 bool CreateUnwindPlan_i386(Target &target, FunctionInfo &function_info,
0128 UnwindPlan &unwind_plan,
0129 Address pc_or_function_start);
0130
0131 bool CreateUnwindPlan_arm64(Target &target, FunctionInfo &function_info,
0132 UnwindPlan &unwind_plan,
0133 Address pc_or_function_start);
0134
0135 bool CreateUnwindPlan_armv7(Target &target, FunctionInfo &function_info,
0136 UnwindPlan &unwind_plan,
0137 Address pc_or_function_start);
0138
0139 ObjectFile &m_objfile;
0140 lldb::SectionSP m_section_sp;
0141 lldb::WritableDataBufferSP
0142 m_section_contents_if_encrypted;
0143
0144
0145
0146 std::mutex m_mutex;
0147 std::vector<UnwindIndex> m_indexes;
0148
0149 LazyBool m_indexes_computed;
0150
0151
0152
0153
0154 DataExtractor m_unwindinfo_data;
0155 bool m_unwindinfo_data_computed;
0156
0157
0158 UnwindHeader m_unwind_header;
0159 };
0160
0161 }
0162
0163 #endif