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