diff --git a/example/debug_function.cpp b/example/debug_function.cpp index 0a9159c..80ab527 100644 --- a/example/debug_function.cpp +++ b/example/debug_function.cpp @@ -11,8 +11,10 @@ #include // std::exit void print_signal_handler_and_exit() { - void* p = reinterpret_cast(::signal(SIGSEGV, SIG_DFL)); - boost::stacktrace::frame f(p); + typedef void(*function_t)(int); + + function_t old_signal_function = ::signal(SIGSEGV, SIG_DFL); + boost::stacktrace::frame f(old_signal_function); std::cout << f << std::endl; std::exit(0); } diff --git a/include/boost/stacktrace/detail/frame_decl.hpp b/include/boost/stacktrace/detail/frame_decl.hpp index 6574efa..2484c5c 100644 --- a/include/boost/stacktrace/detail/frame_decl.hpp +++ b/include/boost/stacktrace/detail/frame_decl.hpp @@ -18,6 +18,7 @@ #include #include // boost::stacktrace::detail::native_frame_ptr_t +#include #include @@ -82,6 +83,17 @@ public: : addr_(addr) {} + /// @brief Constructs frame that references function_addr and could later generate information about that function using platform specific features. + /// + /// @b Complexity: O(1). + /// + /// @b Async-Handler-Safety: Safe. + /// @throws Nothing. + template + explicit frame(T* function_addr) BOOST_NOEXCEPT + : addr_(boost::stacktrace::detail::void_ptr_cast(function_addr)) + {} + /// @returns Name of the frame (function name in a human readable form). /// /// @b Complexity: unknown (lots of platform specific work).