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 <atomic>
13#include <map>
14#include <mutex>
15#include <optional>
16
17#include "lldb/lldb-private.h"
18
19namespace lldb_private {
20
21// A class which holds all the FuncUnwinders objects for a given ObjectFile.
22// The UnwindTable is populated with FuncUnwinders objects lazily during the
23// debug session.
24
26public:
27 /// Create an Unwind table using the data in the given module.
28 explicit UnwindTable(Module &module);
29
31
33
36
38
41
44 const SymbolContext &sc);
45
46 /// Return the start of the function containing \p addr according to the
47 /// object file's own unwind info (the .pdata RUNTIME_FUNCTION on PE/COFF
48 /// x64), or an invalid address if there is none.
50
52
53 // Normally when we create a new FuncUnwinders object we track it in this
54 // UnwindTable so it can be reused later. But for the target modules show-
55 // unwind we want to create brand new UnwindPlans for the function of
56 // interest - so ignore any existing FuncUnwinders for that function and
57 // don't add this new one to our UnwindTable. This FuncUnwinders object does
58 // have a reference to the UnwindTable but the lifetime of this uncached
59 // FuncUnwinders is expected to be short so in practice this will not be a
60 // problem.
63 const SymbolContext &sc);
64
66
67 /// Called after an ObjectFile/SymbolFile has been added to a Module to add
68 /// any new unwind sections that may now be available.
69 void ModuleWasUpdated();
70
71private:
72 void Dump(Stream &s);
73
74 void Initialize();
76
77 typedef std::map<lldb::addr_t, lldb::FuncUnwindersSP> collection;
78 typedef collection::iterator iterator;
79 typedef collection::const_iterator const_iterator;
80
83
84 /// This is true when we have looked at the ObjectFile and SymbolFile for all
85 /// sources of unwind information; false if we haven't done that yet, or one
86 /// of the files has been updated in the Module.
88 std::mutex m_mutex;
89
90 std::unique_ptr<CallFrameInfo> m_object_file_unwind_up;
91 std::unique_ptr<DWARFCallFrameInfo> m_eh_frame_up;
92 std::unique_ptr<DWARFCallFrameInfo> m_debug_frame_up;
93 std::unique_ptr<CompactUnwindInfo> m_compact_unwind_up;
94 std::unique_ptr<ArmUnwindInfo> m_arm_unwind_up;
95
96 UnwindTable(const UnwindTable &) = delete;
97 const UnwindTable &operator=(const UnwindTable &) = delete;
98};
99
100} // namespace lldb_private
101
102#endif // LLDB_SYMBOL_UNWINDTABLE_H
A section + offset based address class.
Definition Address.h:62
An architecture specification class.
Definition ArchSpec.h:32
A class that describes an executable image and its associated object and symbol files.
Definition Module.h:91
A stream class that can stream formatted output to a file.
Definition Stream.h:28
Defines a symbol context baton that can be handed other debug core functions.
Provides public interface for all SymbolFiles.
Definition SymbolFile.h:51
AddressRanges GetAddressRanges(const Address &addr, const SymbolContext &sc)
lldb_private::DWARFCallFrameInfo * GetEHFrameInfo()
std::unique_ptr< DWARFCallFrameInfo > m_debug_frame_up
Definition UnwindTable.h:92
std::unique_ptr< CallFrameInfo > m_object_file_unwind_up
Definition UnwindTable.h:90
ArmUnwindInfo * GetArmUnwindInfo()
std::unique_ptr< DWARFCallFrameInfo > m_eh_frame_up
Definition UnwindTable.h:91
UnwindTable(Module &module)
Create an Unwind table using the data in the given module.
Address GetFunctionStartFromObjectFileUnwindInfo(const Address &addr)
Return the start of the function containing addr according to the object file's own unwind info (the ...
std::unique_ptr< CompactUnwindInfo > m_compact_unwind_up
Definition UnwindTable.h:93
const UnwindTable & operator=(const UnwindTable &)=delete
collection::const_iterator const_iterator
Definition UnwindTable.h:79
lldb::FuncUnwindersSP GetFuncUnwindersContainingAddress(const Address &addr, const SymbolContext &sc)
void ModuleWasUpdated()
Called after an ObjectFile/SymbolFile has been added to a Module to add any new unwind sections that ...
std::atomic< bool > m_scanned_all_unwind_sources
This is true when we have looked at the ObjectFile and SymbolFile for all sources of unwind informati...
Definition UnwindTable.h:87
std::map< lldb::addr_t, lldb::FuncUnwindersSP > collection
Definition UnwindTable.h:77
UnwindTable(const UnwindTable &)=delete
lldb_private::DWARFCallFrameInfo * GetDebugFrameInfo()
lldb::FuncUnwindersSP GetUncachedFuncUnwindersContainingAddress(const Address &addr, const SymbolContext &sc)
lldb_private::CompactUnwindInfo * GetCompactUnwindInfo()
lldb_private::CallFrameInfo * GetObjectFileUnwindInfo()
collection::iterator iterator
Definition UnwindTable.h:78
std::unique_ptr< ArmUnwindInfo > m_arm_unwind_up
Definition UnwindTable.h:94
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::FuncUnwinders > FuncUnwindersSP