10b57cec5SDimitry Andric //===-- UnwindTable.h -------------------------------------------*- C++ -*-===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric 9*5ffd83dbSDimitry Andric #ifndef LLDB_SYMBOL_UNWINDTABLE_H 10*5ffd83dbSDimitry Andric #define LLDB_SYMBOL_UNWINDTABLE_H 110b57cec5SDimitry Andric 120b57cec5SDimitry Andric #include <map> 130b57cec5SDimitry Andric #include <mutex> 140b57cec5SDimitry Andric 150b57cec5SDimitry Andric #include "lldb/lldb-private.h" 160b57cec5SDimitry Andric 170b57cec5SDimitry Andric namespace lldb_private { 180b57cec5SDimitry Andric 190b57cec5SDimitry Andric // A class which holds all the FuncUnwinders objects for a given ObjectFile. 200b57cec5SDimitry Andric // The UnwindTable is populated with FuncUnwinders objects lazily during the 210b57cec5SDimitry Andric // debug session. 220b57cec5SDimitry Andric 230b57cec5SDimitry Andric class UnwindTable { 240b57cec5SDimitry Andric public: 250b57cec5SDimitry Andric /// Create an Unwind table using the data in the given module. 260b57cec5SDimitry Andric explicit UnwindTable(Module &module); 270b57cec5SDimitry Andric 280b57cec5SDimitry Andric ~UnwindTable(); 290b57cec5SDimitry Andric 309dba64beSDimitry Andric lldb_private::CallFrameInfo *GetObjectFileUnwindInfo(); 319dba64beSDimitry Andric 320b57cec5SDimitry Andric lldb_private::DWARFCallFrameInfo *GetEHFrameInfo(); 330b57cec5SDimitry Andric lldb_private::DWARFCallFrameInfo *GetDebugFrameInfo(); 340b57cec5SDimitry Andric 350b57cec5SDimitry Andric lldb_private::CompactUnwindInfo *GetCompactUnwindInfo(); 360b57cec5SDimitry Andric 370b57cec5SDimitry Andric ArmUnwindInfo *GetArmUnwindInfo(); 380b57cec5SDimitry Andric SymbolFile *GetSymbolFile(); 390b57cec5SDimitry Andric 400b57cec5SDimitry Andric lldb::FuncUnwindersSP GetFuncUnwindersContainingAddress(const Address &addr, 410b57cec5SDimitry Andric SymbolContext &sc); 420b57cec5SDimitry Andric 430b57cec5SDimitry Andric bool GetAllowAssemblyEmulationUnwindPlans(); 440b57cec5SDimitry Andric 450b57cec5SDimitry Andric // Normally when we create a new FuncUnwinders object we track it in this 460b57cec5SDimitry Andric // UnwindTable so it can be reused later. But for the target modules show- 470b57cec5SDimitry Andric // unwind we want to create brand new UnwindPlans for the function of 480b57cec5SDimitry Andric // interest - so ignore any existing FuncUnwinders for that function and 490b57cec5SDimitry Andric // don't add this new one to our UnwindTable. This FuncUnwinders object does 500b57cec5SDimitry Andric // have a reference to the UnwindTable but the lifetime of this uncached 510b57cec5SDimitry Andric // FuncUnwinders is expected to be short so in practice this will not be a 520b57cec5SDimitry Andric // problem. 530b57cec5SDimitry Andric lldb::FuncUnwindersSP 540b57cec5SDimitry Andric GetUncachedFuncUnwindersContainingAddress(const Address &addr, 550b57cec5SDimitry Andric SymbolContext &sc); 560b57cec5SDimitry Andric 570b57cec5SDimitry Andric ArchSpec GetArchitecture(); 580b57cec5SDimitry Andric 590b57cec5SDimitry Andric private: 600b57cec5SDimitry Andric void Dump(Stream &s); 610b57cec5SDimitry Andric 620b57cec5SDimitry Andric void Initialize(); 630b57cec5SDimitry Andric llvm::Optional<AddressRange> GetAddressRange(const Address &addr, 640b57cec5SDimitry Andric SymbolContext &sc); 650b57cec5SDimitry Andric 660b57cec5SDimitry Andric typedef std::map<lldb::addr_t, lldb::FuncUnwindersSP> collection; 670b57cec5SDimitry Andric typedef collection::iterator iterator; 680b57cec5SDimitry Andric typedef collection::const_iterator const_iterator; 690b57cec5SDimitry Andric 700b57cec5SDimitry Andric Module &m_module; 710b57cec5SDimitry Andric collection m_unwinds; 720b57cec5SDimitry Andric 730b57cec5SDimitry Andric bool m_initialized; // delay some initialization until ObjectFile is set up 740b57cec5SDimitry Andric std::mutex m_mutex; 750b57cec5SDimitry Andric 769dba64beSDimitry Andric std::unique_ptr<CallFrameInfo> m_object_file_unwind_up; 770b57cec5SDimitry Andric std::unique_ptr<DWARFCallFrameInfo> m_eh_frame_up; 780b57cec5SDimitry Andric std::unique_ptr<DWARFCallFrameInfo> m_debug_frame_up; 790b57cec5SDimitry Andric std::unique_ptr<CompactUnwindInfo> m_compact_unwind_up; 800b57cec5SDimitry Andric std::unique_ptr<ArmUnwindInfo> m_arm_unwind_up; 810b57cec5SDimitry Andric 82*5ffd83dbSDimitry Andric UnwindTable(const UnwindTable &) = delete; 83*5ffd83dbSDimitry Andric const UnwindTable &operator=(const UnwindTable &) = delete; 840b57cec5SDimitry Andric }; 850b57cec5SDimitry Andric 860b57cec5SDimitry Andric } // namespace lldb_private 870b57cec5SDimitry Andric 88*5ffd83dbSDimitry Andric #endif // LLDB_SYMBOL_UNWINDTABLE_H 89