microfmt
Zero-allocation C++ formatting for constrained environments
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | List of all members
microfmt::exception_frame_ref Class Reference

Type-erased, two-word handle decoding exception/trap frames. More...

#include <exception_frame.hpp>

Classes

struct  vtable
 Virtual table of trap-frame operations. More...
 

Public Member Functions

constexpr exception_frame_ref () noexcept=default
 Constructs an empty (invalid) handle.
 
template<typename ArchTag , typename Traits = exception_frame_traits<ArchTag>, std::enable_if_t< std::is_void_v< typename Traits::context_type >, int > = 0>
constexpr exception_frame_ref (ArchTag) noexcept
 Constructs a handle for a stateless architecture tag.
 
template<typename ArchTag , typename Context , typename Traits = exception_frame_traits<ArchTag>, std::enable_if_t<!std::is_void_v< typename Traits::context_type > &&std::is_convertible_v< const Context *, const typename Traits::context_type * >, int > = 0>
constexpr exception_frame_ref (ArchTag, const Context &ctx RELOCO_LIFETIMEBOUND RELOCO_LIFETIME_CAPTURE_BY_THIS) noexcept
 Constructs a handle for a stateful architecture tag.
 
template<typename ArchTag , typename Context , std::enable_if_t<!std::is_lvalue_reference_v< Context >, int > = 0>
constexpr exception_frame_ref (ArchTag, Context &&)=delete
 
bool decode (uintptr_t trap_frame_addr, trap_context &out_trap) const noexcept
 Decodes raw trap frame memory into a uniform trap_context.
 
bool next_trap_frame (uintptr_t current_trap_frame_addr, uintptr_t &next_trap_frame_addr) const noexcept
 Follows links to outer/nested trap frames.
 
microfmt::string_view describe_reason (uint64_t vector_or_reason) const noexcept
 Returns a textual description of a vector/reason code.
 
constexpr operator bool () const noexcept
 Reports whether the handle is bound to a decoder.
 

Static Public Member Functions

template<typename ArchTag , typename Traits = exception_frame_traits<ArchTag>, std::enable_if_t< std::is_void_v< typename Traits::context_type >, int > = 0>
static constexpr exception_frame_ref make () noexcept
 Creates a handle for a stateless architecture tag.
 
template<typename ArchTag , typename Context , typename Traits = exception_frame_traits<ArchTag>, std::enable_if_t<!std::is_void_v< typename Traits::context_type >, int > = 0>
static constexpr exception_frame_ref make (const Context &ctx RELOCO_LIFETIMEBOUND) noexcept
 Creates a handle for a stateful architecture tag.
 
template<typename ArchTag , typename Context , std::enable_if_t<!std::is_lvalue_reference_v< Context >, int > = 0>
static exception_frame_ref make (Context &&)=delete
 

Detailed Description

Type-erased, two-word handle decoding exception/trap frames.

Constructor & Destructor Documentation

◆ exception_frame_ref() [1/4]

constexpr microfmt::exception_frame_ref::exception_frame_ref ( )
constexprdefaultnoexcept

Constructs an empty (invalid) handle.

◆ exception_frame_ref() [2/4]

template<typename ArchTag , typename Traits = exception_frame_traits<ArchTag>, std::enable_if_t< std::is_void_v< typename Traits::context_type >, int > = 0>
constexpr microfmt::exception_frame_ref::exception_frame_ref ( ArchTag  )
inlineexplicitconstexprnoexcept

Constructs a handle for a stateless architecture tag.

Template Parameters
ArchTagArchitecture tag type.
TraitsSpecialized traits, enabled when context_type is void.

◆ exception_frame_ref() [3/4]

template<typename ArchTag , typename Context , typename Traits = exception_frame_traits<ArchTag>, std::enable_if_t<!std::is_void_v< typename Traits::context_type > &&std::is_convertible_v< const Context *, const typename Traits::context_type * >, int > = 0>
constexpr microfmt::exception_frame_ref::exception_frame_ref ( ArchTag  ,
const Context &ctx RELOCO_LIFETIMEBOUND  RELOCO_LIFETIME_CAPTURE_BY_THIS 
)
inlineconstexprnoexcept

Constructs a handle for a stateful architecture tag.

Template Parameters
ArchTagArchitecture tag type.
ContextConcrete context type.
TraitsSpecialized traits, enabled when context_type is non-void and Context converts to it.
Parameters
ctxContext object decoding trap frames.

◆ exception_frame_ref() [4/4]

template<typename ArchTag , typename Context , std::enable_if_t<!std::is_lvalue_reference_v< Context >, int > = 0>
constexpr microfmt::exception_frame_ref::exception_frame_ref ( ArchTag  ,
Context &&   
)
constexprdelete

Member Function Documentation

◆ decode()

bool microfmt::exception_frame_ref::decode ( uintptr_t  trap_frame_addr,
trap_context &  out_trap 
) const
inlinenoexcept

Decodes raw trap frame memory into a uniform trap_context.

Parameters
trap_frame_addrAddress of the raw trap frame.
out_trapReceives the decoded, normalized snapshot.
Returns
true on success, false when the handle is empty or decoding fails.

◆ describe_reason()

microfmt::string_view microfmt::exception_frame_ref::describe_reason ( uint64_t  vector_or_reason) const
inlinenoexcept

Returns a textual description of a vector/reason code.

Parameters
vector_or_reasonVector number or reason code.
Returns
Human-readable description, or an empty view when unavailable.

◆ make() [1/3]

template<typename ArchTag , typename Traits = exception_frame_traits<ArchTag>, std::enable_if_t< std::is_void_v< typename Traits::context_type >, int > = 0>
static constexpr exception_frame_ref microfmt::exception_frame_ref::make ( )
inlinestaticconstexprnoexcept

Creates a handle for a stateless architecture tag.

Template Parameters
ArchTagArchitecture tag type.
TraitsSpecialized traits, enabled when context_type is void.
Returns
An exception_frame_ref for the tag.

◆ make() [2/3]

template<typename ArchTag , typename Context , typename Traits = exception_frame_traits<ArchTag>, std::enable_if_t<!std::is_void_v< typename Traits::context_type >, int > = 0>
static constexpr exception_frame_ref microfmt::exception_frame_ref::make ( const Context &ctx  RELOCO_LIFETIMEBOUND)
inlinestaticconstexprnoexcept

Creates a handle for a stateful architecture tag.

Template Parameters
ArchTagArchitecture tag type.
ContextConcrete context type.
TraitsSpecialized traits, enabled when context_type is non-void.
Parameters
ctxContext object decoding trap frames.
Returns
An exception_frame_ref bound to ctx.

◆ make() [3/3]

template<typename ArchTag , typename Context , std::enable_if_t<!std::is_lvalue_reference_v< Context >, int > = 0>
static exception_frame_ref microfmt::exception_frame_ref::make ( Context &&  )
staticdelete

◆ next_trap_frame()

bool microfmt::exception_frame_ref::next_trap_frame ( uintptr_t  current_trap_frame_addr,
uintptr_t &  next_trap_frame_addr 
) const
inlinenoexcept

Follows links to outer/nested trap frames.

Parameters
current_trap_frame_addrAddress of the current trap frame.
next_trap_frame_addrReceives the next trap frame address.
Returns
true when a next frame was found.

◆ operator bool()

constexpr microfmt::exception_frame_ref::operator bool ( ) const
inlineexplicitconstexprnoexcept

Reports whether the handle is bound to a decoder.

Returns
true when the handle is valid.

The documentation for this class was generated from the following file: