1 // Copyright Antony Polukhin, 2016-2017.
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)
8 #include <boost/stacktrace/stacktrace.hpp>
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"
14 #if !defined(BOOST_USE_WINDOWS_H) && defined(_WINDOWS_H)
15 #error "windows.h header leaked into the boost/stacktrace/stacktrace.hpp"
20 using namespace boost::stacktrace
;
22 #ifdef BOOST_STACKTRACE_DYN_LINK
23 # define BOOST_ST_API BOOST_SYMBOL_EXPORT
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
) {
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() {
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
;
59 return get_backtrace_from_nested_namespaces();
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);
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);
80 BOOST_ST_API BOOST_NOINLINE
boost::stacktrace::stacktrace
bar1() {
81 boost::stacktrace::stacktrace result
= bar1_impl();
85 BOOST_ST_API BOOST_NOINLINE
boost::stacktrace::stacktrace
bar2() {
86 boost::stacktrace::stacktrace result
= bar2_impl();