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