17#define DEBUG_TYPE "orc"
31 [](std::vector<ExecutorAddrRange> CodeRanges,
ExecutorAddr DSOBase,
35 CodeRanges, DSOBase, DWARFRange, CompactUnwindRange);
47 [](std::vector<ExecutorAddrRange> CodeRanges) {
56 "__unw_add_find_dynamic_unwind_sections";
58 "__unw_remove_find_dynamic_unwind_sections";
59static std::unique_ptr<UnwindInfoManager>
Instance;
76 std::lock_guard<std::mutex> Lock(M);
81 auto AddFn = (int (*)(
void *))dlsym(RTLD_DEFAULT,
AddFnName);
85 auto RemoveFn = (int (*)(
void *))dlsym(RTLD_DEFAULT,
RemoveFnName);
91 if (
auto Err = AddFn((
void *)&findSections)) {
94 dbgs() <<
"Failed call to " <<
AddFnName <<
": error = " << Err <<
"\n";
118 return Instance->registerSectionsImpl(CodeRanges, DSOBase, DWARFEHFrame,
124 return Instance->deregisterSectionsImpl(CodeRanges);
127int UnwindInfoManager::findSectionsImpl(uintptr_t
Addr, UnwindSections *Info) {
128 std::lock_guard<std::mutex> Lock(M);
129 auto I = UWSecs.upper_bound(
Addr);
130 if (
I == UWSecs.begin())
137int UnwindInfoManager::findSections(uintptr_t
Addr, UnwindSections *Info) {
141Error UnwindInfoManager::registerSectionsImpl(
144 std::lock_guard<std::mutex> Lock(M);
145 for (
auto &R : CodeRanges)
146 UWSecs[R.Start.getValue()] =
147 UnwindSections{
static_cast<uintptr_t
>(DSOBase.
getValue()),
149 static_cast<size_t>(DWARFEHFrame.
size()),
151 static_cast<size_t>(CompactUnwind.
size())};
155Error UnwindInfoManager::deregisterSectionsImpl(
157 std::lock_guard<std::mutex> Lock(M);
158 for (
auto &R : CodeRanges) {
159 auto I = UWSecs.find(
R.Start.getValue());
160 if (
I == UWSecs.end())
161 return make_error<StringError>(
162 "No unwind-info sections registered for range " +
163 formatv(
"{0:x} - {1:x}",
R.Start,
R.End),
Analysis containing CSE Info
static orc::shared::CWrapperFunctionResult llvm_orc_rt_alt_UnwindInfoManager_register(const char *ArgData, size_t ArgSize)
static orc::shared::CWrapperFunctionResult llvm_orc_rt_alt_UnwindInfoManager_deregister(const char *ArgData, size_t ArgSize)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Represents an address in the executor process.
uint64_t getValue() const
static ExecutorAddr fromPtr(T *Ptr, UnwrapFn &&Unwrap=UnwrapFn())
Create an ExecutorAddr from the given pointer.
static LLVM_ABI bool TryEnable()
If the libunwind find-dynamic-unwind-info callback registration APIs are available then this method w...
static LLVM_ABI void addBootstrapSymbols(StringMap< ExecutorAddr > &M)
static LLVM_ABI Error deregisterSections(ArrayRef< orc::ExecutorAddrRange > CodeRanges)
LLVM_ABI ~UnwindInfoManager()
static LLVM_ABI Error registerSections(ArrayRef< orc::ExecutorAddrRange > CodeRanges, orc::ExecutorAddr DSOBase, orc::ExecutorAddrRange DWARFEHFrame, orc::ExecutorAddrRange CompactUnwind)
SPS tag type for sequences.
LLVM_ABI const char * UnwindInfoManagerDeregisterActionName
LLVM_ABI const char * UnwindInfoManagerRegisterActionName
static std::unique_ptr< UnwindInfoManager > Instance
static const char * RemoveFnName
static int(* RemoveFindDynamicUnwindSections)(void *)
static const char * AddFnName
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Represents an address range in the exceutor process.
ExecutorAddrDiff size() const