35 out.write(
"<fault:nullptr>");
41 context.resolved = {};
42 if (resolver.resolve(addr, context) && ((context.resolved.has_symbol()) || context.resolved.has_image())) {
43 const auto &info = context.resolved;
46 if (info.has_symbol()) {
47 if (info.has_image()) {
48 out.write(info.image_name);
52 if (info.offset_from_symbol > 0) {
54 detail::format_unsigned<detail::radix::hex>(out,
static_cast<uint64_t
>(info.offset_from_symbol),
false, 0);
58 out.write(info.image_name);
60 detail::format_unsigned<detail::radix::hex>(out,
static_cast<uint64_t
>(info.offset_from_image),
false, 0);
97 : addr_(addr), resolver_(resolver), context_(&context) {}
103 [[nodiscard]]
constexpr uintptr_t
address() const noexcept {
return addr_; }
108 [[nodiscard]]
constexpr bool is_null() const noexcept {
return addr_ == 0; }
123 symbol_resolver_ref resolver_{};
125 value_ptr<symbol_resolution_context> context_{};
145 auto spec = ctx.spec();
162 if (mode ==
'x' || mode ==
'p' || !fn.resolver()) {
196 span<std::byte> scratch RELOCO_LIFETIMEBOUND,
198 : addr_(addr), space_(space), resolver_(resolver), scratch_(scratch), symbol_context_(&symbol_context) {}
204 [[nodiscard]]
constexpr uintptr_t
address() const noexcept {
return addr_; }
209 [[nodiscard]]
constexpr bool is_null() const noexcept {
return addr_ == 0; }
215 [[nodiscard]] expected<T *, remote_load_error>
load() const noexcept RELOCO_LIFETIMEBOUND {
217 return unexpected(remote_load_error::null_address);
218 if (scratch_.size() <
sizeof(T))
219 return unexpected(remote_load_error::scratch_too_small);
220 if (
reinterpret_cast<uintptr_t
>(scratch_.data()) %
alignof(T) != 0)
221 return unexpected(remote_load_error::scratch_misaligned);
223 return unexpected(remote_load_error::invalid_address_space);
225 auto *out_ptr =
static_cast<T *
>(
static_cast<void *
>(scratch_.data()));
226 if (!space_.read_bytes(addr_, out_ptr,
sizeof(T)))
227 return unexpected(remote_load_error::read_failed);
242 return *symbol_context_;
249 address_space_ref space_{};
251 symbol_resolver_ref resolver_{};
253 span<std::byte> scratch_{};
255 value_ptr<symbol_resolution_context> symbol_context_{};
269 microfmt::string_view spec_{
""};
283 if (view.is_null()) {
288 auto staged = view.load();
296 elem_fmt.parse(pctx);
297 elem_fmt.format(**staged, out);
Type-erased remote address-space access and remote string/object views.
Type-erased, two-word handle to a remote address space.
Definition address_space.hpp:204
Definition microfmt.hpp:881
Lazily-loaded remote object reference with diagnostics support.
Definition remote_diagnostics.hpp:185
constexpr remote_diag_ref(uintptr_t addr, address_space_ref space, symbol_resolver_ref resolver, span< std::byte > scratch RELOCO_LIFETIMEBOUND, symbol_resolution_context &symbol_context RELOCO_LIFETIMEBOUND) noexcept
Constructs a diagnostics-aware remote object reference.
Definition remote_diagnostics.hpp:195
constexpr bool is_null() const noexcept
Reports whether the reference points to address zero.
Definition remote_diagnostics.hpp:209
expected< T *, remote_load_error > load() const noexcept RELOCO_LIFETIMEBOUND
Loads the object into the scratch buffer.
Definition remote_diagnostics.hpp:215
constexpr address_space_ref space() const noexcept
Returns the address space handle.
Definition remote_diagnostics.hpp:235
constexpr symbol_resolution_context & symbol_context() const noexcept RELOCO_LIFETIMEBOUND
Definition remote_diagnostics.hpp:241
constexpr uintptr_t address() const noexcept
Returns the remote object address.
Definition remote_diagnostics.hpp:204
constexpr symbol_resolver_ref resolver() const noexcept
Returns the symbol resolver handle.
Definition remote_diagnostics.hpp:240
Symbolic view of a remote function / code pointer.
Definition remote_diagnostics.hpp:82
constexpr symbol_resolution_context & context() const noexcept RELOCO_LIFETIMEBOUND
Returns caller-owned symbol-resolution temporaries.
Definition remote_diagnostics.hpp:117
constexpr uintptr_t address() const noexcept
Returns the code address.
Definition remote_diagnostics.hpp:103
constexpr bool is_null() const noexcept
Reports whether the address is null.
Definition remote_diagnostics.hpp:108
constexpr symbol_resolver_ref resolver() const noexcept
Returns the symbol resolver handle.
Definition remote_diagnostics.hpp:113
constexpr remote_fn_ptr() noexcept=default
Constructs an empty (null) view.
Formattable view resolving and rendering a remote code address.
Definition symbol_resolver.hpp:327
Type-erased, two-word handle to a symbol resolver.
Definition symbol_resolver.hpp:132
#define MICROFMT_API_CLASS
Definition compat.hpp:181
reloco::sink sink
Type-erased, zero-allocation output sink.
Definition microfmt.hpp:46
RELOCO_CONSTEXPR20 void format_to(const sink &out, microfmt::string_view fmt, const Args &...args) noexcept
Definition microfmt.hpp:1766
void format_remote_fault(const sink &out, uintptr_t addr, symbol_resolver_ref resolver, symbol_resolution_context &context) noexcept
Formats a human-readable description of a faulting address.
Definition remote_diagnostics.hpp:32
constexpr auto as_demangled(microfmt::string_view sym) noexcept
Wraps a symbol for demangled formatting.
Definition demangle.hpp:523
Caller-owned temporary storage for one symbol resolution.
Definition symbol_resolver.hpp:100
Type-erased symbol resolution for remote addresses and formattable symbol views.