]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Symbol/UnwindTable.h
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[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 the
22 // 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 be reused later.  But for the target modules show-
43   // unwind we want to create brand new UnwindPlans for the function of
44   // interest - so ignore any existing FuncUnwinders for that function and
45   // don't add this new one to our UnwindTable. This FuncUnwinders object does
46   // have a reference to the UnwindTable but the lifetime of this uncached
47   // FuncUnwinders is expected to be short so in practice this will not be a
48   // problem.
49   lldb::FuncUnwindersSP
50   GetUncachedFuncUnwindersContainingAddress(const Address &addr,
51                                             SymbolContext &sc);
52
53   ArchSpec GetArchitecture();
54
55 private:
56   void Dump(Stream &s);
57
58   void Initialize();
59   llvm::Optional<AddressRange> GetAddressRange(const Address &addr,
60                                                SymbolContext &sc);
61
62   typedef std::map<lldb::addr_t, lldb::FuncUnwindersSP> collection;
63   typedef collection::iterator iterator;
64   typedef collection::const_iterator const_iterator;
65
66   ObjectFile &m_object_file;
67   collection m_unwinds;
68
69   bool m_initialized; // delay some initialization until ObjectFile is set up
70   std::mutex m_mutex;
71
72   std::unique_ptr<DWARFCallFrameInfo> m_eh_frame_up;
73   std::unique_ptr<DWARFCallFrameInfo> m_debug_frame_up;
74   std::unique_ptr<CompactUnwindInfo> m_compact_unwind_up;
75   std::unique_ptr<ArmUnwindInfo> m_arm_unwind_up;
76
77   DISALLOW_COPY_AND_ASSIGN(UnwindTable);
78 };
79
80 } // namespace lldb_private
81
82 #endif // liblldb_UnwindTable_h