Fixes for linkage and tests

This commit is contained in:
Antony Polukhin
2016-09-14 21:58:15 +03:00
parent 326d931bb0
commit 76cfb88fc0
5 changed files with 70 additions and 31 deletions

View File

@@ -21,8 +21,12 @@
# define BOOST_STACKTRACE_LINK
#endif
#if defined(BOOST_STACKTRACE_LINK) && !defined(BOOST_STACKTRACE_DYN_LINK) && defined(BOOST_ALL_DYN_LINK)
# define BOOST_STACKTRACE_DYN_LINK
#endif
#ifdef BOOST_STACKTRACE_LINK
# if defined(BOOST_STACKTRACE_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)
# if defined(BOOST_STACKTRACE_DYN_LINK)
# ifdef BOOST_STACKTRACE_INTERNAL_BUILD_LIBS
# define BOOST_STACKTRACE_FUNCTION BOOST_SYMBOL_EXPORT
# else

View File

@@ -12,6 +12,7 @@
# pragma once
#endif
#include <boost/stacktrace.hpp>
#include <boost/stacktrace/detail/stacktrace_helpers.hpp>
#include <boost/core/no_exceptions_support.hpp>
@@ -19,6 +20,14 @@
#include "DbgHelp.h"
#include <WinBase.h>
#if !defined(BOOST_ALL_NO_LIB)
# define BOOST_LIB_NAME Dbghelp
# ifdef BOOST_STACKTRACE_DYN_LINK
# define BOOST_DYN_LINK
# endif
# include <boost/config/auto_link.hpp>
#endif
namespace boost { namespace stacktrace { namespace detail {
struct symbol_info_with_stack {

View File

@@ -18,33 +18,45 @@ project
<target-os>linux:<cxxflags>"-fvisibility=hidden"
;
lib test_impl_lib : test_impl.cpp : <define>BOOST_STACKTRACE_DYN_LINK <link>shared ;
local HONLY_UNW = <define>BOOST_STACKTRACE_USE_LIBUNWIND <library>unwind [ check-target-builds ../build//libunwind : : <build>no ] ;
local HONLY_BT = <define>BOOST_STACKTRACE_USE_BACKTRACE <target-os>linux:<library>dl [ check-target-builds ../build//backtrace : : <build>no ] ;
local HONLY_WIND = <define>BOOST_STACKTRACE_USE_WINDBG <library>Dbghelp [ check-target-builds ../build//WinDbg : : <build>no ] ;
local HONLY_AUTO = <target-os>linux:<library>dl <target-os>windows:<library>Dbghelp [ check-target-builds ../build//libunwind : <library>unwind ] ;
local HONLY_NOOP = <define>BOOST_STACKTRACE_USE_NOOP ;
local LINKST = <link>shared <define>BOOST_STACKTRACE_DYN_LINK <library>.//test_impl_lib ;
local UNW_DEPS = <library>unwind [ check-target-builds ../build//libunwind : : <build>no ] ;
local BT_DEPS = <target-os>linux:<library>dl [ check-target-builds ../build//backtrace : : <build>no ] ;
local WIND_DEPS = <library>Dbghelp [ check-target-builds ../build//WinDbg : : <build>no ] ;
local NOOP_DEPS = ;
local AUTO_DEPS = <target-os>linux:<library>dl [ check-target-builds ../build//WinDbg : <library>Dbghelp ] [ check-target-builds ../build//libunwind : <library>unwind ] ;
local LINKSHARED_UNW = <link>shared <define>BOOST_STACKTRACE_DYN_LINK <library>/boost/stacktrace//boost_stacktrace_libunwind $(UNW_DEPS) ;
local LINKSHARED_BT = <link>shared <define>BOOST_STACKTRACE_DYN_LINK <library>/boost/stacktrace//boost_stacktrace_backtrace $(BT_DEPS) ;
local LINKSHARED_WIND = <link>shared <define>BOOST_STACKTRACE_DYN_LINK <library>/boost/stacktrace//boost_stacktrace_windbg $(WIND_DEPS) ;
local LINKSHARED_NOOP = <link>shared <define>BOOST_STACKTRACE_DYN_LINK <library>/boost/stacktrace//boost_stacktrace_noop $(NOOP_DEPS) ;
lib test_impl_lib_libunwind : test_impl.cpp : $(LINKSHARED_UNW) ;
lib test_impl_lib_backtrace : test_impl.cpp : $(LINKSHARED_BT) ;
lib test_impl_lib_windbg : test_impl.cpp : $(LINKSHARED_WIND) ;
lib test_impl_lib_noop : test_impl.cpp : $(LINKSHARED_NOOP) ;
test-suite stacktrace_tests
:
[ run test.cpp test_impl.cpp : : : $(HONLY_UNW) : libunwind_ho ]
[ run test.cpp test_impl.cpp : : : $(HONLY_BT) : backtrace_ho ]
[ run test.cpp test_impl.cpp : : : $(HONLY_WIND) : windbg_ho ]
[ run test.cpp test_impl.cpp : : : $(HONLY_AUTO) : autodetect_ho ]
[ run test_noop.cpp test_impl.cpp : : : $(HONLY_NOOP) : noop_ho ]
# Header only tests
[ run test.cpp test_impl.cpp : : : <define>BOOST_STACKTRACE_USE_LIBUNWIND $(UNW_DEPS) : libunwind_ho ]
[ run test.cpp test_impl.cpp : : : <define>BOOST_STACKTRACE_USE_BACKTRACE $(BT_DEPS) : backtrace_ho ]
[ run test.cpp test_impl.cpp : : : <define>BOOST_STACKTRACE_USE_WINDBG $(WIND_DEPS) : windbg_ho ]
[ run test_noop.cpp test_impl.cpp : : : <define>BOOST_STACKTRACE_USE_NOOP $(NOOP_DEPS) : noop_ho ]
[ run test.cpp test_impl.cpp : : : $(AUTO_DEPS) : autodetect_ho ]
[ run test.cpp : : : $(LINKST) <library>/boost/stacktrace//boost_stacktrace_libunwind [ check-target-builds ../build//libunwind : : <build>no ] : libunwind_lib ]
[ run test.cpp : : : $(LINKST) <library>/boost/stacktrace//boost_stacktrace_backtrace [ check-target-builds ../build//backtrace : : <build>no ] : backtrace_lib ]
[ run test.cpp : : : $(LINKST) <library>/boost/stacktrace//boost_stacktrace_windbg [ check-target-builds ../build//WinDbg : : <build>no ] : windbg_lib ]
[ run test_noop.cpp : : : $(LINKST) <library>/boost/stacktrace//boost_stacktrace_noop : noop_lib ]
# Test wih shared linked backends
[ run test.cpp : : : <library>.//test_impl_lib_libunwind $(LINKSHARED_UNW) : libunwind_lib ]
[ run test.cpp : : : <library>.//test_impl_lib_backtrace $(LINKSHARED_BT) : backtrace_lib ]
[ run test.cpp : : : <library>.//test_impl_lib_windbg $(LINKSHARED_WIND) : windbg_lib ]
[ run test_noop.cpp : : : <library>.//test_impl_lib_noop $(LINKSHARED_NOOP) : noop_lib ]
[ run ../example/getting_started.cpp : : : $(HONLY_UNW) : libunwind_getting_started ]
[ run ../example/getting_started.cpp : : : $(HONLY_BT) : backtrace_getting_started ]
[ run ../example/getting_started.cpp : : : $(HONLY_WIND) : windbg_getting_started ]
[ run ../example/getting_started.cpp : : : $(HONLY_AUTO) : auto_getting_started ]
[ run ../example/getting_started.cpp : : : $(HONLY_NOOP) : noop_getting_started ]
# Making sure that the examples work
[ run ../example/getting_started.cpp : : : $(LINKSHARED_UNW) : libunwind_getting_started ]
[ run ../example/getting_started.cpp : : : $(LINKSHARED_BT) : backtrace_getting_started ]
[ run ../example/getting_started.cpp : : : $(LINKSHARED_WIND) : windbg_getting_started ]
[ run ../example/getting_started.cpp : : : $(LINKSHARED_NOOP) : noop_getting_started ]
[ run ../example/getting_started.cpp : : : $(AUTO_DEPS) : auto_getting_started ]
;

View File

@@ -12,9 +12,16 @@
#include <boost/core/lightweight_test.hpp>
using boost::stacktrace::stacktrace;
BOOST_SYMBOL_IMPORT std::pair<stacktrace, stacktrace> foo2(int i);
BOOST_SYMBOL_IMPORT std::pair<stacktrace, stacktrace> foo1(int i);
BOOST_SYMBOL_IMPORT stacktrace return_from_nested_namespaces();
#ifdef BOOST_STACKTRACE_DYN_LINK
# define BOOST_ST_API BOOST_SYMBOL_IMPORT
#else
# define BOOST_ST_API
#endif
BOOST_ST_API std::pair<stacktrace, stacktrace> foo2(int i);
BOOST_ST_API std::pair<stacktrace, stacktrace> foo1(int i);
BOOST_ST_API stacktrace return_from_nested_namespaces();
void test_deeply_nested_namespaces() {
std::stringstream ss;
@@ -22,7 +29,7 @@ void test_deeply_nested_namespaces() {
std::cout << ss.str() << '\n';
BOOST_TEST(ss.str().find("main") != std::string::npos);
#if defined(BOOST_STACKTRACE_LINK) || !defined(BOOST_STACKTRACE_USE_BACKTRACE)
#if defined(BOOST_STACKTRACE_DYN_LINK) || !defined(BOOST_STACKTRACE_USE_BACKTRACE)
BOOST_TEST(ss.str().find("get_backtrace_from_nested_namespaces") != std::string::npos);
#endif
}
@@ -46,7 +53,7 @@ void test_nested() {
BOOST_TEST(ss1.str().find("main") != std::string::npos);
BOOST_TEST(ss2.str().find("main") != std::string::npos);
#if defined(BOOST_STACKTRACE_LINK) || !defined(BOOST_STACKTRACE_USE_BACKTRACE)
#if defined(BOOST_STACKTRACE_DYN_LINK) || !defined(BOOST_STACKTRACE_USE_BACKTRACE)
BOOST_TEST(ss1.str().find("foo1") != std::string::npos);
BOOST_TEST(ss1.str().find("foo2") != std::string::npos);
BOOST_TEST(ss2.str().find("foo1") != std::string::npos);

View File

@@ -9,8 +9,15 @@
#include <stdexcept>
using namespace boost::stacktrace;
BOOST_SYMBOL_EXPORT BOOST_NOINLINE std::pair<stacktrace, stacktrace> foo1(int i);
BOOST_SYMBOL_EXPORT BOOST_NOINLINE std::pair<stacktrace, stacktrace> foo2(int i);
#ifdef BOOST_STACKTRACE_DYN_LINK
# define BOOST_ST_API BOOST_SYMBOL_EXPORT
#else
# define BOOST_ST_API
#endif
BOOST_ST_API BOOST_NOINLINE std::pair<stacktrace, stacktrace> foo1(int i);
BOOST_ST_API BOOST_NOINLINE std::pair<stacktrace, stacktrace> foo2(int i);
std::pair<stacktrace, stacktrace> foo1(int i) {
if (i) {
@@ -45,12 +52,12 @@ namespace very_very_very_very_very_very_long_namespace {
namespace very_very_very_very_very_very_long_namespace {
namespace very_very_very_very_very_very_long_namespace {
namespace very_very_very_very_very_very_long_namespace {
BOOST_SYMBOL_EXPORT BOOST_NOINLINE stacktrace get_backtrace_from_nested_namespaces() {
BOOST_ST_API BOOST_NOINLINE stacktrace get_backtrace_from_nested_namespaces() {
return stacktrace();
}
}}}}}}}}}}
BOOST_SYMBOL_EXPORT BOOST_NOINLINE stacktrace return_from_nested_namespaces() {
BOOST_ST_API BOOST_NOINLINE stacktrace return_from_nested_namespaces() {
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
::very_very_very_very_very_very_long_namespace::very_very_very_very_very_very_long_namespace::very_very_very_very_very_very_long_namespace
::very_very_very_very_very_very_long_namespace::very_very_very_very_very_very_long_namespace::very_very_very_very_very_very_long_namespace