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_STACKTRACE_TEST_IMPL_LIB 1 8 #include "test_impl.hpp" 9 10 using namespace boost::stacktrace; 11 function_from_library(int i,foo1_t foo1)12BOOST_ST_API BOOST_NOINLINE std::pair<stacktrace, stacktrace> function_from_library(int i, foo1_t foo1) { 13 if (i) { 14 return foo1(--i); 15 } else { 16 return foo1(i); 17 } 18 } 19 20 21 namespace very_very_very_very_very_very_long_namespace { 22 namespace very_very_very_very_very_very_long_namespace { 23 namespace very_very_very_very_very_very_long_namespace { 24 namespace very_very_very_very_very_very_long_namespace { 25 namespace very_very_very_very_very_very_long_namespace { 26 namespace very_very_very_very_very_very_long_namespace { 27 namespace very_very_very_very_very_very_long_namespace { 28 namespace very_very_very_very_very_very_long_namespace { 29 namespace very_very_very_very_very_very_long_namespace { 30 namespace very_very_very_very_very_very_long_namespace { get_backtrace_from_nested_namespaces()31 BOOST_ST_API BOOST_NOINLINE stacktrace get_backtrace_from_nested_namespaces() { 32 return stacktrace(); 33 } 34 }}}}}}}}}} 35 return_from_nested_namespaces()36BOOST_ST_API BOOST_NOINLINE stacktrace return_from_nested_namespaces() { 37 using very_very_very_very_very_very_long_namespace::very_very_very_very_very_very_long_namespace::very_very_very_very_very_very_long_namespace 38 ::very_very_very_very_very_very_long_namespace::very_very_very_very_very_very_long_namespace::very_very_very_very_very_very_long_namespace 39 ::very_very_very_very_very_very_long_namespace::very_very_very_very_very_very_long_namespace::very_very_very_very_very_very_long_namespace 40 ::very_very_very_very_very_very_long_namespace::get_backtrace_from_nested_namespaces; 41 42 return get_backtrace_from_nested_namespaces(); 43 } 44 make_some_stacktrace1_impl(int d=0)45BOOST_ST_API BOOST_NOINLINE boost::stacktrace::stacktrace make_some_stacktrace1_impl(int d = 0) { 46 boost::stacktrace::stacktrace result(0, 4); 47 if (result.size() < 4) { 48 if (d > 4) throw std::runtime_error("Stack is not growing in test OR stacktrace fails to work in `bar1` function."); 49 return make_some_stacktrace1_impl(d + 1); 50 } 51 return result; 52 } 53 make_some_stacktrace2_impl(int d=0)54BOOST_ST_API BOOST_NOINLINE boost::stacktrace::stacktrace make_some_stacktrace2_impl(int d = 0) { 55 boost::stacktrace::stacktrace result(0, 4); 56 if (result.size() < 4) { 57 if (d > 4) throw std::runtime_error("Stack is not growing in test OR stacktrace fails to work in `bar2` function."); 58 return make_some_stacktrace2_impl(d + 1); 59 } 60 return result; 61 } 62 make_some_stacktrace1()63BOOST_ST_API BOOST_NOINLINE boost::stacktrace::stacktrace make_some_stacktrace1() { 64 boost::stacktrace::stacktrace result = make_some_stacktrace1_impl(); 65 return result; 66 } 67 make_some_stacktrace2()68BOOST_ST_API BOOST_NOINLINE boost::stacktrace::stacktrace make_some_stacktrace2() { 69 boost::stacktrace::stacktrace result = make_some_stacktrace2_impl(); 70 return result; 71 } 72 73