1#ifndef NEFORCE_CORE_SYSTEM_STACKTRACE_HPP__
2#define NEFORCE_CORE_SYSTEM_STACKTRACE_HPP__
14NEFORCE_BEGIN_NAMESPACE__
39 void* address_ =
nullptr;
51 explicit frame(
void* addr) noexcept :
58 NEFORCE_NODISCARD
void*
address() const noexcept {
return address_; }
66 NEFORCE_NODISCARD
string name()
const;
73 NEFORCE_NODISCARD
bool operator==(
const frame& other)
const noexcept {
return address_ == other.address_; }
80 NEFORCE_NODISCARD
bool operator!=(
const frame& other)
const noexcept {
return !(*
this == other); }
108 NEFORCE_NODISCARD
size_t size() const noexcept {
return frames_.size(); }
114 NEFORCE_NODISCARD
bool empty() const noexcept {
return frames_.empty(); }
121 NEFORCE_NODISCARD
const frame&
operator[](
const size_t idx)
const noexcept {
return frames_[idx]; }
128 NEFORCE_NODISCARD
frame&
operator[](
const size_t idx)
noexcept {
return frames_[idx]; }
134 NEFORCE_NODISCARD
auto begin() const noexcept {
return frames_.begin(); }
140 NEFORCE_NODISCARD
auto end() const noexcept {
return frames_.end(); }
146 NEFORCE_NODISCARD
auto cbegin() const noexcept {
return frames_.cbegin(); }
152 NEFORCE_NODISCARD
auto cend() const noexcept {
return frames_.cend(); }
165NEFORCE_END_NAMESPACE__
NEFORCE_NODISCARD string to_string() const
转换为字符串
NEFORCE_NODISCARD bool operator!=(const frame &other) const noexcept
不等比较
NEFORCE_NODISCARD string name() const
获取函数符号名称
NEFORCE_NODISCARD bool operator==(const frame &other) const noexcept
相等比较
NEFORCE_NODISCARD void * address() const noexcept
获取返回地址
frame(void *addr) noexcept
从地址构造堆栈帧
NEFORCE_NODISCARD string to_string() const
转换为字符串
NEFORCE_NODISCARD size_t size() const noexcept
获取堆栈深度
NEFORCE_NODISCARD auto end() const noexcept
获取结束常量迭代器
stacktrace(size_t skip=0, size_t max_depth=64)
构造函数,捕获当前堆栈
NEFORCE_NODISCARD auto begin() const noexcept
获取起始常量迭代器
NEFORCE_NODISCARD const frame & operator[](const size_t idx) const noexcept
常量索引访问
NEFORCE_NODISCARD auto cend() const noexcept
获取结束常量迭代器
NEFORCE_NODISCARD frame & operator[](const size_t idx) noexcept
索引访问
NEFORCE_NODISCARD auto cbegin() const noexcept
获取起始常量迭代器
NEFORCE_NODISCARD bool empty() const noexcept
检查堆栈是否为空