|
4 | 4 | // accompanying file LICENSE_1_0.txt or copy at |
5 | 5 | // http://www.boost.org/LICENSE_1_0.txt) |
6 | 6 |
|
7 | | -#include <boost/stacktrace.hpp> |
8 | | -#include <boost/static_assert.hpp> |
| 7 | +#include <boost/config.hpp> |
| 8 | +#ifdef BOOST_HAS_PRAGMA_ONCE |
| 9 | +# pragma once |
| 10 | +#endif |
9 | 11 |
|
| 12 | +#include <boost/static_assert.hpp> |
10 | 13 | #include <boost/predef/os/windows.h> |
11 | 14 |
|
12 | 15 | #if BOOST_OS_WINDOWS |
13 | 16 | # include <boost/stacktrace/detail/stacktrace_windows.hpp> |
14 | | -//#elif defined(__has_include) && (!defined(__GNUC__) || __GNUC__ > 4) |
15 | | -//# if __has_include(<libunwind.h>) |
16 | | -//# include <boost/stacktrace/detail/stacktrace_libunwind.hpp> |
17 | | -//# endif |
18 | 17 | #elif defined(BOOST_STACKTRACE_USE_LIBUNWIND) |
19 | 18 | # include <boost/stacktrace/detail/stacktrace_libunwind.hpp> |
20 | 19 | #elif defined(BOOST_STACKTRACE_USE_BACKTRACE) |
21 | 20 | # include <boost/stacktrace/detail/stacktrace_linux.hpp> |
| 21 | +#elif defined(__has_include) && (!defined(__GNUC__) || __GNUC__ > 4) |
| 22 | +# if __has_include(<libunwind.h>) |
| 23 | +# include <boost/stacktrace/detail/stacktrace_libunwind.hpp> |
| 24 | +# elif __has_include(<execinfo.h>) |
| 25 | +# include <boost/stacktrace/detail/stacktrace_linux.hpp> |
| 26 | +# endif |
22 | 27 | #else |
23 | 28 | # error No suitable backtrace backend found |
24 | 29 | #endif |
25 | 30 |
|
26 | 31 | namespace boost { namespace stacktrace { |
27 | 32 |
|
28 | | -using boost::stacktrace::detail::backtrace_holder; |
29 | | - |
30 | 33 | template <class T> |
31 | | -inline backtrace_holder& to_bt(T& data) BOOST_NOEXCEPT { |
32 | | - return *reinterpret_cast<backtrace_holder*>(&data); |
| 34 | +inline boost::stacktrace::detail::backtrace_holder& to_bt(T& data) BOOST_NOEXCEPT { |
| 35 | + return *reinterpret_cast<boost::stacktrace::detail::backtrace_holder*>(&data); |
33 | 36 | } |
34 | 37 |
|
35 | 38 | template <class T> |
36 | | -inline const backtrace_holder& to_bt(const T& data) BOOST_NOEXCEPT { |
37 | | - return *reinterpret_cast<const backtrace_holder*>(&data); |
| 39 | +inline const boost::stacktrace::detail::backtrace_holder& to_bt(const T& data) BOOST_NOEXCEPT { |
| 40 | + return *reinterpret_cast<const boost::stacktrace::detail::backtrace_holder*>(&data); |
38 | 41 | } |
39 | 42 |
|
40 | 43 |
|
41 | 44 | stacktrace::stacktrace() BOOST_NOEXCEPT { |
42 | | - new (&data_) backtrace_holder(); |
| 45 | + new (&impl_) boost::stacktrace::detail::backtrace_holder(); |
43 | 46 | } |
44 | 47 |
|
45 | 48 | stacktrace::stacktrace(const stacktrace& bt) BOOST_NOEXCEPT { |
46 | | - new (&data_) backtrace_holder(to_bt(bt.data_)); |
| 49 | + new (&impl_) boost::stacktrace::detail::backtrace_holder(to_bt(bt.impl_)); |
47 | 50 | } |
48 | 51 |
|
49 | 52 | stacktrace& stacktrace::operator=(const stacktrace& bt) BOOST_NOEXCEPT { |
50 | | - to_bt(data_) = to_bt(bt.data_); |
| 53 | + to_bt(impl_) = to_bt(bt.impl_); |
51 | 54 | return *this; |
52 | 55 | } |
53 | 56 |
|
54 | 57 | stacktrace::~stacktrace() BOOST_NOEXCEPT { |
55 | | - BOOST_STATIC_ASSERT_MSG(sizeof(data_) >= sizeof(backtrace_holder), "Too small storage for holding backtrace"); |
56 | | - to_bt(data_).~backtrace_holder(); |
| 58 | + BOOST_STATIC_ASSERT_MSG(sizeof(impl_) >= sizeof(boost::stacktrace::detail::backtrace_holder), "Too small storage for holding backtrace"); |
| 59 | + to_bt(impl_).~backtrace_holder(); |
57 | 60 | } |
58 | 61 |
|
59 | 62 | std::size_t stacktrace::size() const BOOST_NOEXCEPT { |
60 | | - return to_bt(data_).size(); |
| 63 | + return to_bt(impl_).size(); |
61 | 64 | } |
62 | 65 |
|
63 | | -stacktrace::frame_t stacktrace::operator[](std::size_t frame) const BOOST_NOEXCEPT { |
64 | | - return to_bt(data_).get_frame(frame); |
| 66 | +std::string stacktrace::operator[](std::size_t frame) const BOOST_NOEXCEPT { |
| 67 | + return to_bt(impl_).get_frame(frame); |
65 | 68 | } |
66 | 69 |
|
67 | 70 |
|
|
0 commit comments