1 //===-- UnwindTable.h -------------------------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef liblldb_UnwindTable_h 10 #define liblldb_UnwindTable_h 11 12 #include <map> 13 #include <mutex> 14 15 #include "lldb/lldb-private.h" 16 17 namespace lldb_private { 18 19 // A class which holds all the FuncUnwinders objects for a given ObjectFile. 20 // The UnwindTable is populated with FuncUnwinders objects lazily during the 21 // debug session. 22 23 class UnwindTable { 24 public: 25 /// Create an Unwind table using the data in the given module. 26 explicit UnwindTable(Module &module); 27 28 ~UnwindTable(); 29 30 lldb_private::DWARFCallFrameInfo *GetEHFrameInfo(); 31 lldb_private::DWARFCallFrameInfo *GetDebugFrameInfo(); 32 33 lldb_private::CompactUnwindInfo *GetCompactUnwindInfo(); 34 35 ArmUnwindInfo *GetArmUnwindInfo(); 36 SymbolFile *GetSymbolFile(); 37 38 lldb::FuncUnwindersSP GetFuncUnwindersContainingAddress(const Address &addr, 39 SymbolContext &sc); 40 41 bool GetAllowAssemblyEmulationUnwindPlans(); 42 43 // Normally when we create a new FuncUnwinders object we track it in this 44 // UnwindTable so it can be reused later. But for the target modules show- 45 // unwind we want to create brand new UnwindPlans for the function of 46 // interest - so ignore any existing FuncUnwinders for that function and 47 // don't add this new one to our UnwindTable. This FuncUnwinders object does 48 // have a reference to the UnwindTable but the lifetime of this uncached 49 // FuncUnwinders is expected to be short so in practice this will not be a 50 // problem. 51 lldb::FuncUnwindersSP 52 GetUncachedFuncUnwindersContainingAddress(const Address &addr, 53 SymbolContext &sc); 54 55 ArchSpec GetArchitecture(); 56 57 private: 58 void Dump(Stream &s); 59 60 void Initialize(); 61 llvm::Optional<AddressRange> GetAddressRange(const Address &addr, 62 SymbolContext &sc); 63 64 typedef std::map<lldb::addr_t, lldb::FuncUnwindersSP> collection; 65 typedef collection::iterator iterator; 66 typedef collection::const_iterator const_iterator; 67 68 Module &m_module; 69 collection m_unwinds; 70 71 bool m_initialized; // delay some initialization until ObjectFile is set up 72 std::mutex m_mutex; 73 74 std::unique_ptr<DWARFCallFrameInfo> m_eh_frame_up; 75 std::unique_ptr<DWARFCallFrameInfo> m_debug_frame_up; 76 std::unique_ptr<CompactUnwindInfo> m_compact_unwind_up; 77 std::unique_ptr<ArmUnwindInfo> m_arm_unwind_up; 78 79 DISALLOW_COPY_AND_ASSIGN(UnwindTable); 80 }; 81 82 } // namespace lldb_private 83 84 #endif // liblldb_UnwindTable_h 85