20#define DEBUG_TYPE "orc"
34 [](std::vector<ExecutorAddrRange> CodeRanges,
ExecutorAddr DSOBase,
38 CodeRanges, DSOBase, DWARFRange, CompactUnwindRange);
50 [](std::vector<ExecutorAddrRange> CodeRanges) {
59 "__unw_add_find_dynamic_unwind_sections";
61 "__unw_remove_find_dynamic_unwind_sections";
62static std::unique_ptr<UnwindInfoManager>
Instance;
79 std::lock_guard<std::mutex> Lock(M);
84 auto AddFn = (int (*)(
void *))dlsym(RTLD_DEFAULT,
AddFnName);
88 auto RemoveFn = (int (*)(
void *))dlsym(RTLD_DEFAULT,
RemoveFnName);
94 if (
auto Err = AddFn((
void *)&findSections)) {
97 dbgs() <<
"Failed call to " <<
AddFnName <<
": error = " << Err <<
"\n";
122 M[Mangle.mangledCopy(SNs.RegisterSectionsName)] =
124 M[Mangle.mangledCopy(SNs.DeregisterSectionsName)] =
132 return Instance->registerSectionsImpl(CodeRanges, DSOBase, DWARFEHFrame,
138 return Instance->deregisterSectionsImpl(CodeRanges);
141int UnwindInfoManager::findSectionsImpl(
uintptr_t Addr, UnwindSections *Info) {
142 std::lock_guard<std::mutex> Lock(M);
143 auto I = UWSecs.upper_bound(Addr);
144 if (
I == UWSecs.begin())
151int UnwindInfoManager::findSections(
uintptr_t Addr, UnwindSections *Info) {
152 return Instance->findSectionsImpl(Addr, Info);
155Error UnwindInfoManager::registerSectionsImpl(
158 std::lock_guard<std::mutex> Lock(M);
159 for (
auto &R : CodeRanges)
160 UWSecs[R.Start.getValue()] =
163 static_cast<size_t>(DWARFEHFrame.
size()),
165 static_cast<size_t>(CompactUnwind.
size())};
169Error UnwindInfoManager::deregisterSectionsImpl(
171 std::lock_guard<std::mutex> Lock(M);
172 for (
auto &R : CodeRanges) {
173 auto I = UWSecs.find(
R.Start.getValue());
174 if (
I == UWSecs.end())
176 "No unwind-info sections registered for range " +
177 formatv(
"{0:x} - {1:x}",
R.Start,
R.End),
static orc::shared::CWrapperFunctionBuffer llvm_orc_rt_alt_UnwindInfoManager_deregister(const char *ArgData, size_t ArgSize)
static orc::shared::CWrapperFunctionBuffer llvm_orc_rt_alt_UnwindInfoManager_register(const char *ArgData, size_t ArgSize)
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",...
Triple - Helper class for working with autoconf configuration names.
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.
Applies linker name-mangling for a target.
static LLVM_ABI bool TryEnable()
If the libunwind find-dynamic-unwind-info callback registration APIs are available then this method w...
UnwindInfoManager(UnwindInfoManager &&)=delete
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 SymbolNameSpec UnwindInfoManagerRegisterActionName
LLVM_ABI const SymbolNameSpec UnwindInfoManagerDeregisterActionName
const LLVM_ABI MachOUnwindInfoRegistrarSymbolNames orc_rt_MachOUnwindInfoRegistrarSPSSymbols
Default symbol names for the ORC runtime's StandaloneMachOUnwindInfoRegistrar SPS interface.
SPSTuple< SPSExecutorAddr, SPSExecutorAddr > SPSExecutorAddrRange
static std::unique_ptr< UnwindInfoManager > Instance
static const char * RemoveFnName
static int(* RemoveFindDynamicUnwindSections)(void *)
static const char * AddFnName
LLVM_ABI std::string getProcessTriple()
getProcessTriple() - Return an appropriate target triple for generating code to be loaded into the cu...
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.
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
ArrayRef(const T &OneElt) -> ArrayRef< T >
Represents an address range in the exceutor process.
ExecutorAddrDiff size() const