LLDB  mainline
UnwindTable.h
Go to the documentation of this file.
1 //===-- UnwindTable.h -------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLDB_SYMBOL_UNWINDTABLE_H
10 #define LLDB_SYMBOL_UNWINDTABLE_H
11 
12 #include <map>
13 #include <mutex>
14 
15 #include "lldb/lldb-private.h"
16 
17 namespace lldb_private {
18 
19 // A class which holds all the FuncUnwinders objects for a given ObjectFile.
20 // The UnwindTable is populated with FuncUnwinders objects lazily during the
21 // debug session.
22 
23 class UnwindTable {
24 public:
25  /// Create an Unwind table using the data in the given module.
26  explicit UnwindTable(Module &module);
27 
28  ~UnwindTable();
29 
31 
34 
36 
39 
40  lldb::FuncUnwindersSP GetFuncUnwindersContainingAddress(const Address &addr,
41  SymbolContext &sc);
42 
44 
45  // Normally when we create a new FuncUnwinders object we track it in this
46  // UnwindTable so it can be reused later. But for the target modules show-
47  // unwind we want to create brand new UnwindPlans for the function of
48  // interest - so ignore any existing FuncUnwinders for that function and
49  // don't add this new one to our UnwindTable. This FuncUnwinders object does
50  // have a reference to the UnwindTable but the lifetime of this uncached
51  // FuncUnwinders is expected to be short so in practice this will not be a
52  // problem.
53  lldb::FuncUnwindersSP
55  SymbolContext &sc);
56 
58 
59 private:
60  void Dump(Stream &s);
61 
62  void Initialize();
63  llvm::Optional<AddressRange> GetAddressRange(const Address &addr,
64  SymbolContext &sc);
65 
66  typedef std::map<lldb::addr_t, lldb::FuncUnwindersSP> collection;
67  typedef collection::iterator iterator;
68  typedef collection::const_iterator const_iterator;
69 
72 
73  bool m_initialized; // delay some initialization until ObjectFile is set up
74  std::mutex m_mutex;
75 
76  std::unique_ptr<CallFrameInfo> m_object_file_unwind_up;
77  std::unique_ptr<DWARFCallFrameInfo> m_eh_frame_up;
78  std::unique_ptr<DWARFCallFrameInfo> m_debug_frame_up;
79  std::unique_ptr<CompactUnwindInfo> m_compact_unwind_up;
80  std::unique_ptr<ArmUnwindInfo> m_arm_unwind_up;
81 
82  UnwindTable(const UnwindTable &) = delete;
83  const UnwindTable &operator=(const UnwindTable &) = delete;
84 };
85 
86 } // namespace lldb_private
87 
88 #endif // LLDB_SYMBOL_UNWINDTABLE_H
lldb_private::UnwindTable::GetSymbolFile
SymbolFile * GetSymbolFile()
Definition: UnwindTable.cpp:201
lldb_private::UnwindTable::GetUncachedFuncUnwindersContainingAddress
lldb::FuncUnwindersSP GetUncachedFuncUnwindersContainingAddress(const Address &addr, SymbolContext &sc)
Definition: UnwindTable.cpp:153
lldb_private::SymbolFile
Definition: SymbolFile.h:38
lldb_private::UnwindTable::GetEHFrameInfo
lldb_private::DWARFCallFrameInfo * GetEHFrameInfo()
Definition: UnwindTable.cpp:181
lldb_private::ArchSpec
Definition: ArchSpec.h:33
lldb_private::UnwindTable::GetDebugFrameInfo
lldb_private::DWARFCallFrameInfo * GetDebugFrameInfo()
Definition: UnwindTable.cpp:186
lldb_private::UnwindTable::GetArchitecture
ArchSpec GetArchitecture()
Definition: UnwindTable.cpp:203
lldb_private::UnwindTable::const_iterator
collection::const_iterator const_iterator
Definition: UnwindTable.h:68
lldb_private::UnwindTable::collection
std::map< lldb::addr_t, lldb::FuncUnwindersSP > collection
Definition: UnwindTable.h:66
lldb_private::UnwindTable::GetAddressRange
llvm::Optional< AddressRange > GetAddressRange(const Address &addr, SymbolContext &sc)
Definition: UnwindTable.cpp:88
lldb_private::UnwindTable::Initialize
void Initialize()
Definition: UnwindTable.cpp:39
lldb_private::UnwindTable::m_module
Module & m_module
Definition: UnwindTable.h:70
lldb_private::ArmUnwindInfo
Definition: ArmUnwindInfo.h:30
lldb_private::Module
Definition: Module.h:85
lldb_private::UnwindTable
Definition: UnwindTable.h:23
lldb_private::UnwindTable::GetAllowAssemblyEmulationUnwindPlans
bool GetAllowAssemblyEmulationUnwindPlans()
Definition: UnwindTable.cpp:205
lldb_private::Stream
Definition: Stream.h:28
lldb_private::UnwindTable::~UnwindTable
~UnwindTable()
lldb_private::SymbolContext
Definition: SymbolContext.h:33
lldb_private::CompactUnwindInfo
Definition: CompactUnwindInfo.h:36
lldb_private::UnwindTable::m_mutex
std::mutex m_mutex
Definition: UnwindTable.h:74
lldb_private::UnwindTable::operator=
const UnwindTable & operator=(const UnwindTable &)=delete
lldb_private::UnwindTable::iterator
collection::iterator iterator
Definition: UnwindTable.h:67
lldb_private::UnwindTable::m_eh_frame_up
std::unique_ptr< DWARFCallFrameInfo > m_eh_frame_up
Definition: UnwindTable.h:77
lldb_private::UnwindTable::m_arm_unwind_up
std::unique_ptr< ArmUnwindInfo > m_arm_unwind_up
Definition: UnwindTable.h:80
lldb_private::UnwindTable::GetCompactUnwindInfo
lldb_private::CompactUnwindInfo * GetCompactUnwindInfo()
Definition: UnwindTable.cpp:191
lldb_private::UnwindTable::m_debug_frame_up
std::unique_ptr< DWARFCallFrameInfo > m_debug_frame_up
Definition: UnwindTable.h:78
lldb_private::UnwindTable::m_initialized
bool m_initialized
Definition: UnwindTable.h:73
lldb_private::CallFrameInfo
Definition: CallFrameInfo.h:16
lldb_private::UnwindTable::GetObjectFileUnwindInfo
lldb_private::CallFrameInfo * GetObjectFileUnwindInfo()
Definition: UnwindTable.cpp:176
lldb_private::UnwindTable::GetArmUnwindInfo
ArmUnwindInfo * GetArmUnwindInfo()
Definition: UnwindTable.cpp:196
lldb_private::UnwindTable::UnwindTable
UnwindTable(Module &module)
Create an Unwind table using the data in the given module.
Definition: UnwindTable.cpp:31
lldb_private::UnwindTable::GetFuncUnwindersContainingAddress
lldb::FuncUnwindersSP GetFuncUnwindersContainingAddress(const Address &addr, SymbolContext &sc)
Definition: UnwindTable.cpp:115
lldb-private.h
lldb_private::Address
Definition: Address.h:59
lldb_private::DWARFCallFrameInfo
Definition: DWARFCallFrameInfo.h:33
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::UnwindTable::m_compact_unwind_up
std::unique_ptr< CompactUnwindInfo > m_compact_unwind_up
Definition: UnwindTable.h:79
lldb_private::UnwindTable::Dump
void Dump(Stream &s)
Definition: UnwindTable.cpp:164
lldb_private::UnwindTable::m_unwinds
collection m_unwinds
Definition: UnwindTable.h:71
lldb_private::UnwindTable::m_object_file_unwind_up
std::unique_ptr< CallFrameInfo > m_object_file_unwind_up
Definition: UnwindTable.h:76