UnwindTable.h revision 314564
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
18namespace 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
24class UnwindTable {
25public:
26  UnwindTable(ObjectFile &objfile);
27  ~UnwindTable();
28
29  lldb_private::DWARFCallFrameInfo *GetEHFrameInfo();
30
31  lldb_private::CompactUnwindInfo *GetCompactUnwindInfo();
32
33  ArmUnwindInfo *GetArmUnwindInfo();
34
35  lldb::FuncUnwindersSP GetFuncUnwindersContainingAddress(const Address &addr,
36                                                          SymbolContext &sc);
37
38  bool GetAllowAssemblyEmulationUnwindPlans();
39
40  // Normally when we create a new FuncUnwinders object we track it in this
41  // UnwindTable so it can
42  // be reused later.  But for the target modules show-unwind we want to create
43  // brand new
44  // UnwindPlans for the function of interest - so ignore any existing
45  // FuncUnwinders for that
46  // function and don't add this new one to our UnwindTable.
47  // This FuncUnwinders object does have a reference to the UnwindTable but the
48  // lifetime of this
49  // uncached FuncUnwinders is expected to be short so in practice this will not
50  // be a problem.
51  lldb::FuncUnwindersSP
52  GetUncachedFuncUnwindersContainingAddress(const Address &addr,
53                                            SymbolContext &sc);
54
55  bool GetArchitecture(lldb_private::ArchSpec &arch);
56
57private:
58  void Dump(Stream &s);
59
60  void Initialize();
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<CompactUnwindInfo> m_compact_unwind_up;
74  std::unique_ptr<ArmUnwindInfo> m_arm_unwind_up;
75
76  DISALLOW_COPY_AND_ASSIGN(UnwindTable);
77};
78
79} // namespace lldb_private
80
81#endif // liblldb_UnwindTable_h
82