[ORC] Switch to singleton pattern for UnwindInfoManager. (#126691) · llvm/llvm-project@4fa5987 (original) (raw)
`@@ -15,14 +15,13 @@
`
15
15
`#define LLVM_EXECUTIONENGINE_ORC_TARGETPROCESS_UNWINDINFOMANAGER_H
`
16
16
``
17
17
`#include "llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h"
`
18
``
`-
#include "llvm/ExecutionEngine/Orc/TargetProcess/ExecutorBootstrapService.h"
`
19
18
`#include "llvm/Support/Error.h"
`
20
19
`#include
`
21
20
`#include
`
22
21
``
23
22
`namespace llvm::orc {
`
24
23
``
25
``
`-
class UnwindInfoManager : public ExecutorBootstrapService {
`
``
24
`+
class UnwindInfoManager {
`
26
25
`public:
`
27
26
`// This struct's layout should match the unw_dynamic_unwind_sections struct
`
28
27
`// from libunwind/src/libunwid_ext.h.
`
`@@ -34,43 +33,40 @@ class UnwindInfoManager : public ExecutorBootstrapService {
`
34
33
`size_t compact_unwind_section_length;
`
35
34
` };
`
36
35
``
``
36
`+
UnwindInfoManager(UnwindInfoManager &&) = delete;
`
``
37
`+
UnwindInfoManager &operator=(UnwindInfoManager &&) = delete;
`
``
38
`+
~UnwindInfoManager();
`
``
39
+
37
40
`/// If the libunwind find-dynamic-unwind-info callback registration APIs are
`
38
``
`-
/// available then this method will return an UnwindInfoManager instance,
`
39
``
`-
/// otherwise it will return nullptr.
`
40
``
`-
static std::unique_ptr TryCreate();
`
``
41
`+
/// available then this method will instantiate a global UnwindInfoManager
`
``
42
`+
/// instance suitable for the process and return true. Otherwise it will
`
``
43
`+
/// return false.
`
``
44
`+
static bool TryEnable();
`
41
45
``
42
``
`-
Error shutdown() override;
`
43
``
`-
void addBootstrapSymbols(StringMap &M) override;
`
``
46
`+
static void addBootstrapSymbols(StringMap &M);
`
44
47
``
45
``
`-
Error enable(void *FindDynamicUnwindSections);
`
46
``
`-
Error disable(void);
`
``
48
`+
static Error registerSections(ArrayReforc::ExecutorAddrRange CodeRanges,
`
``
49
`+
orc::ExecutorAddr DSOBase,
`
``
50
`+
orc::ExecutorAddrRange DWARFEHFrame,
`
``
51
`+
orc::ExecutorAddrRange CompactUnwind);
`
47
52
``
48
``
`-
Error registerSections(ArrayReforc::ExecutorAddrRange CodeRanges,
`
49
``
`-
orc::ExecutorAddr DSOBase,
`
50
``
`-
orc::ExecutorAddrRange DWARFEHFrame,
`
51
``
`-
orc::ExecutorAddrRange CompactUnwind);
`
``
53
`+
static Error deregisterSections(ArrayReforc::ExecutorAddrRange CodeRanges);
`
52
54
``
53
``
`-
Error deregisterSections(ArrayReforc::ExecutorAddrRange CodeRanges);
`
``
55
`+
private:
`
``
56
`+
UnwindInfoManager() = default;
`
54
57
``
55
``
`-
int findSections(uintptr_t Addr, UnwindSections *Info);
`
``
58
`+
int findSectionsImpl(uintptr_t Addr, UnwindSections *Info);
`
``
59
`+
static int findSections(uintptr_t Addr, UnwindSections *Info);
`
56
60
``
57
``
`-
private:
`
58
``
`-
UnwindInfoManager(int (*AddFindDynamicUnwindSections)(void *),
`
59
``
`-
int (*RemoveFindDynamicUnwindSections)(void *))
`
60
``
`-
: AddFindDynamicUnwindSections(AddFindDynamicUnwindSections),
`
61
``
`-
RemoveFindDynamicUnwindSections(RemoveFindDynamicUnwindSections) {}
`
``
61
`+
Error registerSectionsImpl(ArrayReforc::ExecutorAddrRange CodeRanges,
`
``
62
`+
orc::ExecutorAddr DSOBase,
`
``
63
`+
orc::ExecutorAddrRange DWARFEHFrame,
`
``
64
`+
orc::ExecutorAddrRange CompactUnwind);
`
62
65
``
63
``
`-
static int findSectionsHelper(UnwindInfoManager *Instance, uintptr_t Addr,
`
64
``
`-
UnwindSections *Info);
`
``
66
`+
Error deregisterSectionsImpl(ArrayReforc::ExecutorAddrRange CodeRanges);
`
65
67
``
66
68
` std::mutex M;
`
67
69
` std::map<uintptr_t, UnwindSections> UWSecs;
`
68
``
-
69
``
`-
int (*AddFindDynamicUnwindSections)(void *) = nullptr;
`
70
``
`-
int (*RemoveFindDynamicUnwindSections)(void *) = nullptr;
`
71
``
`-
void *FindDynamicUnwindSections = nullptr;
`
72
``
-
73
``
`-
static const char *AddFnName, *RemoveFnName;
`
74
70
`};
`
75
71
``
76
72
`} // namespace llvm::orc
`