73 uintptr_t &next_pc)
noexcept;
105 bool (*find_hint)(
const void *ctx, uintptr_t pc,
unwind_hint &out_hint)
noexcept;
120 std::enable_if_t<std::is_convertible_v<const Context *, const typename Traits::context_type *>,
int> = 0>
122 const Context &ctx RELOCO_LIFETIMEBOUND RELOCO_LIFETIME_CAPTURE_BY_THIS) noexcept
123 : ctx_(&ctx), vtbl_(&s_vtbl<Tag>) {}
125 template <
typename Tag,
typename Context, std::enable_if_t<!std::is_lvalue_reference_v<Context>,
int> = 0>
128 template <
typename Tag,
typename Context,
typename Traits = unwind_h
int_registry_traits<Tag>>
133 template <
typename Tag,
typename Context, std::enable_if_t<!std::is_lvalue_reference_v<Context>,
int> = 0>
145 return vtbl_->find_hint(ctx_.get(), pc, out_hint);
152 [[nodiscard]]
constexpr explicit operator bool() const noexcept {
return vtbl_ !=
nullptr; }
155 template <
typename Tag>
156 static constexpr vtable s_vtbl{[](
const void *context, uintptr_t pc,
unwind_hint &hint)
noexcept {
158 const auto &typed_context = *
static_cast<const context_type *
>(context);
162 value_ptr<const void> ctx_{};
163 const vtable *vtbl_{
nullptr};
176 [[nodiscard]]
constexpr value_ref<context_type>
context() &
noexcept RELOCO_LIFETIMEBOUND {
177 return value_ref<context_type>(context_);
180 [[nodiscard]]
constexpr value_ref<const context_type>
context() const & noexcept RELOCO_LIFETIMEBOUND {
181 return value_ref<const context_type>(context_);
190 value_ref<context_type>
context() && =
delete;
191 value_ref<const context_type>
context() const && = delete;
220 if (hint_count_ >= MaxHints)
222 RELOCO_BEGIN_UNSAFE_BUFFER_USAGE;
224 hints_[hint_count_++] = hint;
226 RELOCO_END_UNSAFE_BUFFER_USAGE;
238 RELOCO_BEGIN_UNSAFE_BUFFER_USAGE;
240 for (
size_t i = 0; i < hint_count_; ++i) {
241 if (hints_[i].contains(pc)) {
242 out_hint = hints_[i];
247 RELOCO_END_UNSAFE_BUFFER_USAGE;
256 [[nodiscard]]
constexpr size_t size() const noexcept {
return hint_count_; }
262 size_t hint_count_{0};
272 return context->find_hint(pc, out_hint);
Type-erased, two-word handle to a remote address space.
Definition address_space.hpp:204
Zero-allocation, type-erased handle for inspecting and modifying CPU registers from a frame context.
Definition register_context.hpp:118
Zero-allocation hint registry with fixed capacity.
Definition unwind_hint.hpp:207
constexpr unwind_hint_registry_context() noexcept=default
Constructs an empty registry.
constexpr size_t size() const noexcept
Returns the number of stored hints.
Definition unwind_hint.hpp:256
constexpr bool find_hint(uintptr_t pc, unwind_hint &out_hint) const noexcept
Linear scan for the hint covering a PC.
Definition unwind_hint.hpp:237
Type-erased, two-word handle to an unwind hint registry.
Definition unwind_hint.hpp:95
constexpr unwind_hint_registry_ref(Tag, Context &&)=delete
constexpr unwind_hint_registry_ref() noexcept=default
Constructs an empty (invalid) handle.
static unwind_hint_registry_ref make(Context &&)=delete
bool find_hint(uintptr_t pc, unwind_hint &out_hint) const noexcept
Looks up the hint covering a PC.
Definition unwind_hint.hpp:142
static constexpr unwind_hint_registry_ref make(const Context &ctx RELOCO_LIFETIMEBOUND) noexcept
Definition unwind_hint.hpp:129
Typed owner for an unwind-hint registry traits specialization.
Definition unwind_hint.hpp:169
value_ref< context_type > context() &&=delete
constexpr value_ref< context_type > context() &noexcept RELOCO_LIFETIMEBOUND
Definition unwind_hint.hpp:176
constexpr unwind_hint_registry(context_type context) noexcept
Definition unwind_hint.hpp:174
constexpr unwind_hint_registry_ref ref() const &noexcept RELOCO_LIFETIMEBOUND
Definition unwind_hint.hpp:184
value_ref< const context_type > context() const &&=delete
typename traits_type::context_type context_type
Definition unwind_hint.hpp:172
constexpr value_ref< const context_type > context() const &noexcept RELOCO_LIFETIMEBOUND
Definition unwind_hint.hpp:180
#define MICROFMT_API_CLASS
Definition compat.hpp:181
Definition unwind_hint.hpp:20
Virtual table of registry operations.
Definition unwind_hint.hpp:100
static bool find_hint(value_ref< const context_type > context, uintptr_t pc, unwind_hint &out_hint) noexcept
Definition unwind_hint.hpp:271
Definition unwind_hint.hpp:18
PC-range descriptor for direct, layout-based fallback unwinding.
Definition unwind_hint.hpp:35
bool(*)(address_space_ref space, register_context_ref reg_ctx, uintptr_t &next_fp, uintptr_t &next_pc) noexcept unwind_routine_t
Signature of a custom unwind routine provided by the hint.
Definition unwind_hint.hpp:73
uintptr_t pc_end
Exclusive end of the covered PC range.
Definition unwind_hint.hpp:39
uintptr_t pc_start
Inclusive start of the covered PC range.
Definition unwind_hint.hpp:37
unwind_routine_t routine
Custom routine handler, or nullptr to use layout-based fallback.
Definition unwind_hint.hpp:78
constexpr bool contains(uintptr_t pc) const noexcept
Reports whether a PC falls within the hint range.
Definition unwind_hint.hpp:85