Boost C++ 库

……被认为是世界上最受尊敬、设计最精妙的 C++ 库项目之一。 Herb SutterAndrei Alexandrescu《C++ 编码标准》

参考 - Boost C++ 函数库
PrevUpHomeNext

参考

namespace boost {
  namespace stacktrace {
    template<typename Allocator> class basic_stacktrace;

    typedef basic_stacktrace stacktrace;  // This is the typedef to use unless you'd like to provide a specific allocator to boost::stacktrace::basic_stacktrace. 
    template<typename Allocator1, typename Allocator2> 
      bool operator<(const basic_stacktrace< Allocator1 > &, 
                     const basic_stacktrace< Allocator2 > &);
    template<typename Allocator1, typename Allocator2> 
      bool operator==(const basic_stacktrace< Allocator1 > &, 
                      const basic_stacktrace< Allocator2 > &);

    // Comparison operators that provide platform dependant ordering and have amortized O(1) complexity; O(size()) worst case complexity; are Async-Handler-Safe. 
    template<typename Allocator1, typename Allocator2> 
      bool operator>(const basic_stacktrace< Allocator1 > & lhs, 
                     const basic_stacktrace< Allocator2 > & rhs);
    template<typename Allocator1, typename Allocator2> 
      bool operator<=(const basic_stacktrace< Allocator1 > & lhs, 
                      const basic_stacktrace< Allocator2 > & rhs);
    template<typename Allocator1, typename Allocator2> 
      bool operator>=(const basic_stacktrace< Allocator1 > & lhs, 
                      const basic_stacktrace< Allocator2 > & rhs);
    template<typename Allocator1, typename Allocator2> 
      bool operator!=(const basic_stacktrace< Allocator1 > & lhs, 
                      const basic_stacktrace< Allocator2 > & rhs);

    // Fast hashing support, O(st.size()) complexity; Async-Handler-Safe. 
    template<typename Allocator> 
      std::size_t hash_value(const basic_stacktrace< Allocator > & st);

    // Returns std::string with the stacktrace in a human readable format; unsafe to use in async handlers. 
    template<typename Allocator> 
      std::string to_string(const basic_stacktrace< Allocator > & bt);

    // Outputs stacktrace in a human readable format to the output stream os; unsafe to use in async handlers. 
    template<typename CharT, typename TraitsT, typename Allocator> 
      std::basic_ostream< CharT, TraitsT > & 
      operator<<(std::basic_ostream< CharT, TraitsT > & os, 
                 const basic_stacktrace< Allocator > & bt);
    namespace impl {
    }
  }
}

请使用 <boost/stacktrace/frame.hpp> 头文件,而不是这个!

namespace boost {
  namespace stacktrace {
    class frame;
  }
}
namespace boost {
  namespace stacktrace {

    // Comparison operators that provide platform dependant ordering and have O(1) complexity; are Async-Handler-Safe. 
    bool operator<(const frame & lhs, const frame & rhs);
    bool operator>(const frame & lhs, const frame & rhs);
    bool operator<=(const frame & lhs, const frame & rhs);
    bool operator>=(const frame & lhs, const frame & rhs);
    bool operator==(const frame & lhs, const frame & rhs);
    bool operator!=(const frame & lhs, const frame & rhs);

    // Fast hashing support, O(1) complexity; Async-Handler-Safe. 
    std::size_t hash_value(const frame & f);

    // Outputs stacktrace::frame in a human readable format to string; unsafe to use in async handlers. 
    std::string to_string(const frame & f);

    // Outputs stacktrace::frame in a human readable format to output stream; unsafe to use in async handlers. 
    template<typename CharT, typename TraitsT> 
      std::basic_ostream< CharT, TraitsT > & 
      operator<<(std::basic_ostream< CharT, TraitsT > & os, const frame & f);
  }
}

用于转储调用堆栈的理论上异步信号安全的低级函数。转储是 `void*` 的二进制序列化数组,因此您可以使用 Linux 命令 `od -tx8 -An stacktrace_dump_failename` 来读取它们,或者使用 boost::stacktrace::stacktrace::from_dump 函数。

namespace boost {
  namespace stacktrace {
    std::size_t safe_dump_to(void *, std::size_t);
    std::size_t safe_dump_to(std::size_t, void *, std::size_t);
    std::size_t safe_dump_to(const char *);
    std::size_t safe_dump_to(std::size_t, std::size_t, const char *);
    std::size_t safe_dump_to(platform_specific_descriptor);
    std::size_t safe_dump_to(std::size_t, std::size_t, 
                             platform_specific_descriptor);
  }
}

此头文件仅包含 boost::stacktrace::frameboost::stacktrace::basic_stacktrace、boost::stacktrace::stacktrace 的前向声明,不包含任何其他 Boost 头文件。

namespace boost {
  namespace stacktrace {
    namespace this_thread {
      void set_capture_stacktraces_at_throw(bool = true);
      bool get_capture_stacktraces_at_throw();
    }
  }
}

PrevUpHomeNext