• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright Antony Polukhin, 2016-2020.
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 
bar(int i)16 BOOST_NOINLINE void bar(int i) {
17     boost::array<int, 5> a = {{-1, -231, -123, -23, -32}};
18     if (i >= 0) {
19         foo(a[i]);
20     } else {
21         std::cerr << "Terminate called:\n" << boost::stacktrace::stacktrace() << '\n';
22         std::exit(0);
23     }
24 }
25 
foo(int i)26 BOOST_NOINLINE void foo(int i) {
27     bar(--i);
28 }
29 
main()30 int main() {
31     foo(5);
32 
33     return 2;
34 }
35 
36 
37 
38 
39