Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:42:53

0001 //===-- UnwindTable.h -------------------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLDB_SYMBOL_UNWINDTABLE_H
0010 #define LLDB_SYMBOL_UNWINDTABLE_H
0011 
0012 #include <map>
0013 #include <mutex>
0014 #include <optional>
0015 
0016 #include "lldb/lldb-private.h"
0017 
0018 namespace lldb_private {
0019 
0020 // A class which holds all the FuncUnwinders objects for a given ObjectFile.
0021 // The UnwindTable is populated with FuncUnwinders objects lazily during the
0022 // debug session.
0023 
0024 class UnwindTable {
0025 public:
0026   /// Create an Unwind table using the data in the given module.
0027   explicit UnwindTable(Module &module);
0028 
0029   ~UnwindTable();
0030 
0031   lldb_private::CallFrameInfo *GetObjectFileUnwindInfo();
0032 
0033   lldb_private::DWARFCallFrameInfo *GetEHFrameInfo();
0034   lldb_private::DWARFCallFrameInfo *GetDebugFrameInfo();
0035 
0036   lldb_private::CompactUnwindInfo *GetCompactUnwindInfo();
0037 
0038   ArmUnwindInfo *GetArmUnwindInfo();
0039   SymbolFile *GetSymbolFile();
0040 
0041   lldb::FuncUnwindersSP GetFuncUnwindersContainingAddress(const Address &addr,
0042                                                           SymbolContext &sc);
0043 
0044   bool GetAllowAssemblyEmulationUnwindPlans();
0045 
0046   // Normally when we create a new FuncUnwinders object we track it in this
0047   // UnwindTable so it can be reused later.  But for the target modules show-
0048   // unwind we want to create brand new UnwindPlans for the function of
0049   // interest - so ignore any existing FuncUnwinders for that function and
0050   // don't add this new one to our UnwindTable. This FuncUnwinders object does
0051   // have a reference to the UnwindTable but the lifetime of this uncached
0052   // FuncUnwinders is expected to be short so in practice this will not be a
0053   // problem.
0054   lldb::FuncUnwindersSP
0055   GetUncachedFuncUnwindersContainingAddress(const Address &addr,
0056                                             const SymbolContext &sc);
0057 
0058   ArchSpec GetArchitecture();
0059 
0060   /// Called after an ObjectFile/SymbolFile has been added to a Module to add
0061   /// any new unwind sections that may now be available.
0062   void ModuleWasUpdated();
0063 
0064 private:
0065   void Dump(Stream &s);
0066 
0067   void Initialize();
0068   std::optional<AddressRange> GetAddressRange(const Address &addr,
0069                                               const SymbolContext &sc);
0070 
0071   typedef std::map<lldb::addr_t, lldb::FuncUnwindersSP> collection;
0072   typedef collection::iterator iterator;
0073   typedef collection::const_iterator const_iterator;
0074 
0075   Module &m_module;
0076   collection m_unwinds;
0077 
0078   bool m_scanned_all_unwind_sources; // true when we have looked at the
0079                                      // ObjectFile and SymbolFile for all
0080                                      // sources of unwind information; false if
0081                                      // we haven't done that yet, or one of the
0082                                      // files has been updated in the Module.
0083   std::mutex m_mutex;
0084 
0085   std::unique_ptr<CallFrameInfo> m_object_file_unwind_up;
0086   std::unique_ptr<DWARFCallFrameInfo> m_eh_frame_up;
0087   std::unique_ptr<DWARFCallFrameInfo> m_debug_frame_up;
0088   std::unique_ptr<CompactUnwindInfo> m_compact_unwind_up;
0089   std::unique_ptr<ArmUnwindInfo> m_arm_unwind_up;
0090 
0091   UnwindTable(const UnwindTable &) = delete;
0092   const UnwindTable &operator=(const UnwindTable &) = delete;
0093 };
0094 
0095 } // namespace lldb_private
0096 
0097 #endif // LLDB_SYMBOL_UNWINDTABLE_H