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 #include <optional>
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  /// Create an Unwind table using the data in the given module.
27  explicit UnwindTable(Module &module);
28 
29  ~UnwindTable();
30 
32 
35 
37 
40 
41  lldb::FuncUnwindersSP GetFuncUnwindersContainingAddress(const Address &addr,
42  SymbolContext &sc);
43 
45 
46  // Normally when we create a new FuncUnwinders object we track it in this
47  // UnwindTable so it can be reused later. But for the target modules show-
48  // unwind we want to create brand new UnwindPlans for the function of
49  // interest - so ignore any existing FuncUnwinders for that function and
50  // don't add this new one to our UnwindTable. This FuncUnwinders object does
51  // have a reference to the UnwindTable but the lifetime of this uncached
52  // FuncUnwinders is expected to be short so in practice this will not be a
53  // problem.
54  lldb::FuncUnwindersSP
56  SymbolContext &sc);
57 
59 
60 private:
61  void Dump(Stream &s);
62 
63  void Initialize();
64  std::optional<AddressRange> GetAddressRange(const Address &addr,
65  SymbolContext &sc);
66 
67  typedef std::map<lldb::addr_t, lldb::FuncUnwindersSP> collection;
68  typedef collection::iterator iterator;
69  typedef collection::const_iterator const_iterator;
70 
73 
74  bool m_initialized; // delay some initialization until ObjectFile is set up
75  std::mutex m_mutex;
76 
77  std::unique_ptr<CallFrameInfo> m_object_file_unwind_up;
78  std::unique_ptr<DWARFCallFrameInfo> m_eh_frame_up;
79  std::unique_ptr<DWARFCallFrameInfo> m_debug_frame_up;
80  std::unique_ptr<CompactUnwindInfo> m_compact_unwind_up;
81  std::unique_ptr<ArmUnwindInfo> m_arm_unwind_up;
82 
83  UnwindTable(const UnwindTable &) = delete;
84  const UnwindTable &operator=(const UnwindTable &) = delete;
85 };
86 
87 } // namespace lldb_private
88 
89 #endif // LLDB_SYMBOL_UNWINDTABLE_H
lldb_private::UnwindTable::GetSymbolFile
SymbolFile * GetSymbolFile()
Definition: UnwindTable.cpp:202
lldb_private::UnwindTable::GetUncachedFuncUnwindersContainingAddress
lldb::FuncUnwindersSP GetUncachedFuncUnwindersContainingAddress(const Address &addr, SymbolContext &sc)
Definition: UnwindTable.cpp:154
lldb_private::SymbolFile
Provides public interface for all SymbolFiles.
Definition: SymbolFile.h:47
lldb_private::UnwindTable::GetEHFrameInfo
lldb_private::DWARFCallFrameInfo * GetEHFrameInfo()
Definition: UnwindTable.cpp:182
lldb_private::ArchSpec
Definition: ArchSpec.h:32
lldb_private::UnwindTable::GetDebugFrameInfo
lldb_private::DWARFCallFrameInfo * GetDebugFrameInfo()
Definition: UnwindTable.cpp:187
lldb_private::UnwindTable::GetArchitecture
ArchSpec GetArchitecture()
Definition: UnwindTable.cpp:204
lldb_private::UnwindTable::const_iterator
collection::const_iterator const_iterator
Definition: UnwindTable.h:69
lldb_private::UnwindTable::collection
std::map< lldb::addr_t, lldb::FuncUnwindersSP > collection
Definition: UnwindTable.h:67
lldb_private::UnwindTable::Initialize
void Initialize()
Definition: UnwindTable.cpp:40
lldb_private::UnwindTable::m_module
Module & m_module
Definition: UnwindTable.h:71
lldb_private::ArmUnwindInfo
Definition: ArmUnwindInfo.h:30
lldb_private::Module
Definition: Module.h:87
lldb_private::UnwindTable
Definition: UnwindTable.h:24
lldb_private::UnwindTable::GetAllowAssemblyEmulationUnwindPlans
bool GetAllowAssemblyEmulationUnwindPlans()
Definition: UnwindTable.cpp:206
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:75
lldb_private::UnwindTable::operator=
const UnwindTable & operator=(const UnwindTable &)=delete
lldb_private::UnwindTable::iterator
collection::iterator iterator
Definition: UnwindTable.h:68
lldb_private::UnwindTable::m_eh_frame_up
std::unique_ptr< DWARFCallFrameInfo > m_eh_frame_up
Definition: UnwindTable.h:78
lldb_private::UnwindTable::m_arm_unwind_up
std::unique_ptr< ArmUnwindInfo > m_arm_unwind_up
Definition: UnwindTable.h:81
lldb_private::UnwindTable::GetCompactUnwindInfo
lldb_private::CompactUnwindInfo * GetCompactUnwindInfo()
Definition: UnwindTable.cpp:192
lldb_private::UnwindTable::m_debug_frame_up
std::unique_ptr< DWARFCallFrameInfo > m_debug_frame_up
Definition: UnwindTable.h:79
lldb_private::UnwindTable::GetAddressRange
std::optional< AddressRange > GetAddressRange(const Address &addr, SymbolContext &sc)
Definition: UnwindTable.cpp:89
lldb_private::UnwindTable::m_initialized
bool m_initialized
Definition: UnwindTable.h:74
lldb_private::CallFrameInfo
Definition: CallFrameInfo.h:16
lldb_private::UnwindTable::GetObjectFileUnwindInfo
lldb_private::CallFrameInfo * GetObjectFileUnwindInfo()
Definition: UnwindTable.cpp:177
lldb_private::UnwindTable::GetArmUnwindInfo
ArmUnwindInfo * GetArmUnwindInfo()
Definition: UnwindTable.cpp:197
lldb_private::UnwindTable::UnwindTable
UnwindTable(Module &module)
Create an Unwind table using the data in the given module.
Definition: UnwindTable.cpp:32
lldb_private::UnwindTable::GetFuncUnwindersContainingAddress
lldb::FuncUnwindersSP GetFuncUnwindersContainingAddress(const Address &addr, SymbolContext &sc)
Definition: UnwindTable.cpp:116
lldb-private.h
lldb_private::Address
Definition: Address.h:59
lldb_private::DWARFCallFrameInfo
Definition: DWARFCallFrameInfo.h:34
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:80
lldb_private::UnwindTable::Dump
void Dump(Stream &s)
Definition: UnwindTable.cpp:165
lldb_private::UnwindTable::m_unwinds
collection m_unwinds
Definition: UnwindTable.h:72
lldb_private::UnwindTable::m_object_file_unwind_up
std::unique_ptr< CallFrameInfo > m_object_file_unwind_up
Definition: UnwindTable.h:77