44 uintptr_t start_address{0};
47 uintptr_t end_address{0};
58 bool executable{
false};
63 [[nodiscard]]
constexpr bool contains(uintptr_t addr)
const noexcept {
64 return addr >= start_address && addr < end_address;
96 bool (*classify_address)(
const void *ctx, uintptr_t virt_addr,
memory_region_info &out_info)
noexcept =
nullptr;
108 std::enable_if_t<std::is_void_v<typename Traits::context_type>,
int> = 0>
114 template <
typename Tag,
typename Context,
typename Traits = memory_
classifier_traits<Tag>,
115 std::enable_if_t<!std::is_
void_v<
typename Traits::context_type> &&
116 std::is_convertible_v<const Context *, const
typename Traits::context_type *>,
118 constexpr memory_classifier_ref(Tag,
const Context &ctx RELOCO_LIFETIMEBOUND RELOCO_LIFETIME_CAPTURE_BY_THIS) noexcept
119 : ctx_(&ctx), vtbl_(&s_vtbl<Tag>) {}
121 template <
typename Tag,
typename Context, std::enable_if_t<!std::is_lvalue_reference_v<Context>,
int> = 0>
124 template <
typename Tag,
typename Traits = memory_
classifier_traits<Tag>,
125 std::enable_if_t<std::is_
void_v<
typename Traits::context_type>,
int> = 0>
130 template <
typename Tag,
typename Context,
typename Traits = memory_
classifier_traits<Tag>,
131 std::enable_if_t<!std::is_
void_v<
typename Traits::context_type>,
int> = 0>
136 template <
typename Tag,
typename Context, std::enable_if_t<!std::is_lvalue_reference_v<Context>,
int> = 0>
146 if (vtbl_ ==
nullptr || vtbl_->classify_address ==
nullptr)
148 return vtbl_->classify_address(ctx_.get(), virt_addr, out_info);
154 [[nodiscard]]
constexpr explicit operator bool() const noexcept {
return vtbl_ !=
nullptr; }
157 template <
typename Tag>
158 static bool classify_entry(
const void *context, uintptr_t address,
memory_region_info &info)
noexcept {
160 if constexpr (std::is_void_v<context_type>) {
163 const auto &typed_context = *
static_cast<const context_type *
>(context);
164 return memory_classifier_traits<Tag>::classify_address(value_ref<const context_type>(typed_context), address,
169 template <
typename Tag>
static constexpr vtable s_vtbl{&classify_entry<Tag>};
171 value_ptr<const void> ctx_{};
172 const vtable *vtbl_{
nullptr};
175template <typename Tag, bool Stateless = std::is_void_v<typename memory_classifier_traits<Tag>::context_type>>
185 [[nodiscard]]
constexpr value_ref<context_type>
context() &
noexcept RELOCO_LIFETIMEBOUND {
186 return value_ref<context_type>(context_);
189 [[nodiscard]]
constexpr value_ref<const context_type>
context() const & noexcept RELOCO_LIFETIMEBOUND {
190 return value_ref<const context_type>(context_);
197 value_ref<context_type>
context() && =
delete;
198 value_ref<const context_type>
context() const && = delete;
Type-erased remote address-space access and remote string/object views.
constexpr memory_classifier_ref ref() const &noexcept RELOCO_LIFETIMEBOUND
Definition memory_classifier.hpp:193
constexpr value_ref< context_type > context() &noexcept RELOCO_LIFETIMEBOUND
Definition memory_classifier.hpp:185
constexpr value_ref< const context_type > context() const &noexcept RELOCO_LIFETIMEBOUND
Definition memory_classifier.hpp:189
value_ref< context_type > context() &&=delete
value_ref< const context_type > context() const &&=delete
typename traits_type::context_type context_type
Definition memory_classifier.hpp:181
constexpr memory_classifier(context_type context) noexcept
Definition memory_classifier.hpp:183
static constexpr memory_classifier_ref ref() noexcept
Definition memory_classifier.hpp:207
Type-erased, two-word handle for classifying memory regions and addresses.
Definition memory_classifier.hpp:81
constexpr memory_classifier_ref() noexcept=default
Constructs an empty (invalid) handle.
constexpr memory_classifier_ref(Tag, Context &&)=delete
bool classify_address(uintptr_t virt_addr, memory_region_info &out_info) const noexcept
Classifies a target virtual address.
Definition memory_classifier.hpp:145
static memory_classifier_ref make(Context &&)=delete
static constexpr memory_classifier_ref make() noexcept
Definition memory_classifier.hpp:126
static constexpr memory_classifier_ref make(const Context &ctx RELOCO_LIFETIMEBOUND) noexcept
Definition memory_classifier.hpp:132
constexpr memory_classifier_ref(Tag, const Context &ctx RELOCO_LIFETIMEBOUND RELOCO_LIFETIME_CAPTURE_BY_THIS) noexcept
Constructs a handle for a stateful classifier tag.
Definition memory_classifier.hpp:118
Definition memory_classifier.hpp:176
#define MICROFMT_API_CLASS
Definition compat.hpp:181
memory_region_type
Enumeration of classified memory region types.
Definition memory_classifier.hpp:20
Virtual table of memory classification operations.
Definition memory_classifier.hpp:86
Static customization point describing a memory classifier backend.
Definition memory_classifier.hpp:72
Detailed description of a classified memory region or address.
Definition memory_classifier.hpp:42
constexpr bool contains(uintptr_t addr) const noexcept
Checks if a given virtual address falls within this region.
Definition memory_classifier.hpp:63