]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/stacktrace/test/test_impl.cpp
2aa726d5c4168fb51920a589c421e4b9c8a4f007
[ceph.git] / ceph / src / boost / libs / stacktrace / test / test_impl.cpp
1 // Copyright Antony Polukhin, 2016-2017.
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
8 #include <boost/stacktrace/stacktrace.hpp>
9
10 #if defined(BOOST_LEXICAL_CAST_TRY_LEXICAL_CONVERT_HPP) || defined(BOOST_LEXICAL_CAST_BAD_LEXICAL_CAST_HPP)
11 #error "LexicalCast headers leaked into the boost/stacktrace/stacktrace.hpp"
12 #endif
13
14 #if !defined(BOOST_USE_WINDOWS_H) && defined(_WINDOWS_H)
15 #error "windows.h header leaked into the boost/stacktrace/stacktrace.hpp"
16 #endif
17
18 #include <stdexcept>
19
20 using namespace boost::stacktrace;
21
22 #ifdef BOOST_STACKTRACE_DYN_LINK
23 # define BOOST_ST_API BOOST_SYMBOL_EXPORT
24 #else
25 # define BOOST_ST_API
26 #endif
27
28 typedef std::pair<stacktrace, stacktrace> (*foo1_t)(int i);
29 BOOST_ST_API BOOST_NOINLINE std::pair<stacktrace, stacktrace> foo2(int i, foo1_t foo1) {
30 if (i) {
31 return foo1(--i);
32 } else {
33 return foo1(i);
34 }
35 }
36
37
38 namespace very_very_very_very_very_very_long_namespace {
39 namespace very_very_very_very_very_very_long_namespace {
40 namespace very_very_very_very_very_very_long_namespace {
41 namespace very_very_very_very_very_very_long_namespace {
42 namespace very_very_very_very_very_very_long_namespace {
43 namespace very_very_very_very_very_very_long_namespace {
44 namespace very_very_very_very_very_very_long_namespace {
45 namespace very_very_very_very_very_very_long_namespace {
46 namespace very_very_very_very_very_very_long_namespace {
47 namespace very_very_very_very_very_very_long_namespace {
48 BOOST_ST_API BOOST_NOINLINE stacktrace get_backtrace_from_nested_namespaces() {
49 return stacktrace();
50 }
51 }}}}}}}}}}
52
53 BOOST_ST_API BOOST_NOINLINE stacktrace return_from_nested_namespaces() {
54 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
55 ::very_very_very_very_very_very_long_namespace::very_very_very_very_very_very_long_namespace::very_very_very_very_very_very_long_namespace
56 ::very_very_very_very_very_very_long_namespace::very_very_very_very_very_very_long_namespace::very_very_very_very_very_very_long_namespace
57 ::very_very_very_very_very_very_long_namespace::get_backtrace_from_nested_namespaces;
58
59 return get_backtrace_from_nested_namespaces();
60 }
61
62 BOOST_ST_API BOOST_NOINLINE boost::stacktrace::stacktrace bar1_impl(int d = 0) {
63 boost::stacktrace::stacktrace result(0, 4);
64 if (result.size() < 4) {
65 if (d > 4) throw std::runtime_error("Stack is not growing in test OR stacktrace fails to work in `bar1` function.");
66 return bar1_impl(d + 1);
67 }
68 return result;
69 }
70
71 BOOST_ST_API BOOST_NOINLINE boost::stacktrace::stacktrace bar2_impl(int d = 0) {
72 boost::stacktrace::stacktrace result(0, 4);
73 if (result.size() < 4) {
74 if (d > 4) throw std::runtime_error("Stack is not growing in test OR stacktrace fails to work in `bar2` function.");
75 return bar2_impl(d + 1);
76 }
77 return result;
78 }
79
80 BOOST_ST_API BOOST_NOINLINE boost::stacktrace::stacktrace bar1() {
81 boost::stacktrace::stacktrace result = bar1_impl();
82 return result;
83 }
84
85 BOOST_ST_API BOOST_NOINLINE boost::stacktrace::stacktrace bar2() {
86 boost::stacktrace::stacktrace result = bar2_impl();
87 return result;
88 }
89