| 1 | // Copyright Antony Polukhin, 2016-2024. |
|---|---|
| 2 | // |
| 3 | // Distributed under the Boost Software License, Version 1.0. (See |
| 4 | // accompanying file LICENSE_1_0.txt or copy at |
| 5 | // http://www.boost.org/LICENSE_1_0.txt) |
| 6 | |
| 7 | #define BOOST_USER_CONFIG <libs/stacktrace/example/user_config.hpp> |
| 8 | |
| 9 | #include <boost/array.hpp> |
| 10 | #include <exception> // std::set_terminate, std::abort |
| 11 | #include <boost/stacktrace.hpp> |
| 12 | #include <iostream> // std::cerr |
| 13 | BOOST_NOINLINE void foo(int i); |
| 14 | BOOST_NOINLINE void bar(int i); |
| 15 | |
| 16 | BOOST_NOINLINE void bar(int i) { |
| 17 | boost::array<int, 5> a = {.elems: {-1, -231, -123, -23, -32}}; |
| 18 | if (i >= 0) { |
| 19 | foo(i: a[i]); |
| 20 | } else { |
| 21 | std::cerr << "Terminate called:\n"<< boost::stacktrace::stacktrace() << '\n'; |
| 22 | std::exit(status: 0); |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | BOOST_NOINLINE void foo(int i) { |
| 27 | bar(i: --i); |
| 28 | } |
| 29 | |
| 30 | int main() { |
| 31 | foo(i: 5); |
| 32 | |
| 33 | return 2; |
| 34 | } |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 |
