| 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 | |
| 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 | # ifdef BOOST_STACKTRACE_TEST_IMPL_LIB |
| 24 | # define BOOST_ST_API BOOST_SYMBOL_EXPORT |
| 25 | # else |
| 26 | # define BOOST_ST_API BOOST_SYMBOL_IMPORT |
| 27 | # endif |
| 28 | #else |
| 29 | # ifdef BOOST_STACKTRACE_TEST_EXPORTS_TABLE_USAGE |
| 30 | # define BOOST_ST_API BOOST_SYMBOL_VISIBLE |
| 31 | # else |
| 32 | # define BOOST_ST_API |
| 33 | # endif |
| 34 | #endif |
| 35 | |
| 36 | typedef std::pair<boost::stacktrace::stacktrace, boost::stacktrace::stacktrace> st_pair; |
| 37 | typedef st_pair (*foo1_t)(int i); |
| 38 | BOOST_ST_API st_pair function_from_library(int i, foo1_t foo1); |
| 39 | BOOST_ST_API boost::stacktrace::stacktrace return_from_nested_namespaces(); |
| 40 | BOOST_ST_API boost::stacktrace::stacktrace make_some_stacktrace1(); |
| 41 | BOOST_ST_API boost::stacktrace::stacktrace make_some_stacktrace2(); |
| 42 | |
| 43 | #ifdef BOOST_STACKTRACE_TEST_EXPORTS_TABLE_USAGE |
| 44 | BOOST_SYMBOL_VISIBLE |
| 45 | #endif |
| 46 | inline st_pair function_from_main_translation_unit(int i) { |
| 47 | if (i) { |
| 48 | return function_from_library(i: i - 1, foo1: function_from_main_translation_unit); |
| 49 | } |
| 50 | |
| 51 | std::pair<stacktrace, stacktrace> ret; |
| 52 | try { |
| 53 | throw std::logic_error("test" ); |
| 54 | } catch (const std::logic_error& /*e*/) { |
| 55 | ret.second = stacktrace(); |
| 56 | return ret; |
| 57 | } |
| 58 | } |
| 59 | |