Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-26 08:54:26

0001 // Copyright Antony Polukhin, 2023-2024.
0002 //
0003 // Distributed under the Boost Software License, Version 1.0. (See
0004 // accompanying file LICENSE_1_0.txt or copy at
0005 // http://www.boost.org/LICENSE_1_0.txt)
0006 
0007 #ifndef BOOST_STACKTRACE_THIS_THREAD_HPP
0008 #define BOOST_STACKTRACE_THIS_THREAD_HPP
0009 
0010 #include <boost/config.hpp>
0011 #ifdef BOOST_HAS_PRAGMA_ONCE
0012 #   pragma once
0013 #endif
0014 
0015 #include <boost/stacktrace/stacktrace.hpp>
0016 
0017 namespace boost { namespace stacktrace { namespace this_thread {
0018 
0019 /// @brief Invoking the function with the enable parameter equal to `true`
0020 /// enables capturing of stacktraces by the current thread of execution at
0021 /// exception object construction if the `boost_stacktrace_from_exception`
0022 /// library is linked to the current binary; disables otherwise.
0023 ///
0024 /// Implements https://wg21.link/p2370r1
0025 inline void set_capture_stacktraces_at_throw(bool enable = true) noexcept {
0026 #if defined(__GNUC__) && defined(__ELF__)
0027     if (impl::ref_capture_stacktraces_at_throw) {
0028         impl::ref_capture_stacktraces_at_throw() = enable;
0029     }
0030 #elif defined(BOOST_MSVC)
0031     if (bool* p = boost_stacktrace_impl_ref_capture_stacktraces_at_throw()) {
0032         *p = enable;
0033     }
0034 #endif
0035     (void)enable;
0036 }
0037 
0038 /// @return whether the capturing of stacktraces by the current thread of
0039 /// execution is enabled and
0040 /// boost::stacktrace::basic_stacktrace::from_current_exception may return a
0041 /// non empty stacktrace.
0042 ///
0043 /// Returns true if set_capture_stacktraces_at_throw(false) was not called
0044 /// and the `boost_stacktrace_from_exception` is linked to the current binary.
0045 ///
0046 /// Implements https://wg21.link/p2370r1
0047 inline bool get_capture_stacktraces_at_throw() noexcept {
0048 #if defined(__GNUC__) && defined(__ELF__)
0049     if (impl::ref_capture_stacktraces_at_throw) {
0050         return impl::ref_capture_stacktraces_at_throw();
0051     }
0052 #elif defined(BOOST_MSVC)
0053     if (bool* p = boost_stacktrace_impl_ref_capture_stacktraces_at_throw()) {
0054         return *p;
0055     }
0056 #endif
0057     return false;
0058 }
0059 
0060 }}} // namespace boost::stacktrace::this_thread
0061 
0062 #endif // BOOST_STACKTRACE_THIS_THREAD_HPP