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 95ffd83dbSDimitry Andric #ifndef LLDB_SYMBOL_UNWINDTABLE_H 105ffd83dbSDimitry Andric #define LLDB_SYMBOL_UNWINDTABLE_H 110b57cec5SDimitry Andric 120b57cec5SDimitry Andric #include <map> 130b57cec5SDimitry Andric #include <mutex> 14bdd1243dSDimitry Andric #include <optional> 150b57cec5SDimitry Andric 160b57cec5SDimitry Andric #include "lldb/lldb-private.h" 170b57cec5SDimitry Andric 180b57cec5SDimitry Andric namespace lldb_private { 190b57cec5SDimitry Andric 200b57cec5SDimitry Andric // A class which holds all the FuncUnwinders objects for a given ObjectFile. 210b57cec5SDimitry Andric // The UnwindTable is populated with FuncUnwinders objects lazily during the 220b57cec5SDimitry Andric // debug session. 230b57cec5SDimitry Andric 240b57cec5SDimitry Andric class UnwindTable { 250b57cec5SDimitry Andric public: 260b57cec5SDimitry Andric /// Create an Unwind table using the data in the given module. 270b57cec5SDimitry Andric explicit UnwindTable(Module &module); 280b57cec5SDimitry Andric 290b57cec5SDimitry Andric ~UnwindTable(); 300b57cec5SDimitry Andric 319dba64beSDimitry Andric lldb_private::CallFrameInfo *GetObjectFileUnwindInfo(); 329dba64beSDimitry Andric 330b57cec5SDimitry Andric lldb_private::DWARFCallFrameInfo *GetEHFrameInfo(); 340b57cec5SDimitry Andric lldb_private::DWARFCallFrameInfo *GetDebugFrameInfo(); 350b57cec5SDimitry Andric 360b57cec5SDimitry Andric lldb_private::CompactUnwindInfo *GetCompactUnwindInfo(); 370b57cec5SDimitry Andric 380b57cec5SDimitry Andric ArmUnwindInfo *GetArmUnwindInfo(); 390b57cec5SDimitry Andric SymbolFile *GetSymbolFile(); 400b57cec5SDimitry Andric 410b57cec5SDimitry Andric lldb::FuncUnwindersSP GetFuncUnwindersContainingAddress(const Address &addr, 420b57cec5SDimitry Andric SymbolContext &sc); 430b57cec5SDimitry Andric 440b57cec5SDimitry Andric bool GetAllowAssemblyEmulationUnwindPlans(); 450b57cec5SDimitry Andric 460b57cec5SDimitry Andric // Normally when we create a new FuncUnwinders object we track it in this 470b57cec5SDimitry Andric // UnwindTable so it can be reused later. But for the target modules show- 480b57cec5SDimitry Andric // unwind we want to create brand new UnwindPlans for the function of 490b57cec5SDimitry Andric // interest - so ignore any existing FuncUnwinders for that function and 500b57cec5SDimitry Andric // don't add this new one to our UnwindTable. This FuncUnwinders object does 510b57cec5SDimitry Andric // have a reference to the UnwindTable but the lifetime of this uncached 520b57cec5SDimitry Andric // FuncUnwinders is expected to be short so in practice this will not be a 530b57cec5SDimitry Andric // problem. 540b57cec5SDimitry Andric lldb::FuncUnwindersSP 550b57cec5SDimitry Andric GetUncachedFuncUnwindersContainingAddress(const Address &addr, 56*06c3fb27SDimitry Andric const SymbolContext &sc); 570b57cec5SDimitry Andric 580b57cec5SDimitry Andric ArchSpec GetArchitecture(); 590b57cec5SDimitry Andric 600b57cec5SDimitry Andric private: 610b57cec5SDimitry Andric void Dump(Stream &s); 620b57cec5SDimitry Andric 630b57cec5SDimitry Andric void Initialize(); 64bdd1243dSDimitry Andric std::optional<AddressRange> GetAddressRange(const Address &addr, 65*06c3fb27SDimitry Andric const SymbolContext &sc); 660b57cec5SDimitry Andric 670b57cec5SDimitry Andric typedef std::map<lldb::addr_t, lldb::FuncUnwindersSP> collection; 680b57cec5SDimitry Andric typedef collection::iterator iterator; 690b57cec5SDimitry Andric typedef collection::const_iterator const_iterator; 700b57cec5SDimitry Andric 710b57cec5SDimitry Andric Module &m_module; 720b57cec5SDimitry Andric collection m_unwinds; 730b57cec5SDimitry Andric 740b57cec5SDimitry Andric bool m_initialized; // delay some initialization until ObjectFile is set up 750b57cec5SDimitry Andric std::mutex m_mutex; 760b57cec5SDimitry Andric 779dba64beSDimitry Andric std::unique_ptr<CallFrameInfo> m_object_file_unwind_up; 780b57cec5SDimitry Andric std::unique_ptr<DWARFCallFrameInfo> m_eh_frame_up; 790b57cec5SDimitry Andric std::unique_ptr<DWARFCallFrameInfo> m_debug_frame_up; 800b57cec5SDimitry Andric std::unique_ptr<CompactUnwindInfo> m_compact_unwind_up; 810b57cec5SDimitry Andric std::unique_ptr<ArmUnwindInfo> m_arm_unwind_up; 820b57cec5SDimitry Andric 835ffd83dbSDimitry Andric UnwindTable(const UnwindTable &) = delete; 845ffd83dbSDimitry Andric const UnwindTable &operator=(const UnwindTable &) = delete; 850b57cec5SDimitry Andric }; 860b57cec5SDimitry Andric 870b57cec5SDimitry Andric } // namespace lldb_private 880b57cec5SDimitry Andric 895ffd83dbSDimitry Andric #endif // LLDB_SYMBOL_UNWINDTABLE_H 90