Skip to content

Commit bd616a7

Browse files
committed
Make a basic usecase the default one, add tests and create a target library for that
1 parent 3ec1c49 commit bd616a7

10 files changed

Lines changed: 81 additions & 66 deletions

File tree

build/Jamfile.v2

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,21 @@ lib boost_stacktrace_addr2line
9191

9292
boost-install boost_stacktrace_addr2line ;
9393

94+
lib boost_stacktrace_basic
95+
: # sources
96+
../src/basic.cpp
97+
: # requirements
98+
<warnings>all
99+
<target-os>linux:<library>dl
100+
<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
101+
[ check-target-builds ../build//WinDbg : <build>no ]
102+
: # default build
103+
: # usage-requirements
104+
#<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
105+
;
106+
107+
boost-install boost_stacktrace_basic ;
108+
94109
lib boost_stacktrace_windbg
95110
: # sources
96111
../src/windbg.cpp

include/boost/stacktrace/detail/backend.ipp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright Antony Polukhin, 2016.
1+
// Copyright Antony Polukhin, 2016-2017.
22
//
33
// Distributed under the Boost Software License, Version 1.0. (See
44
// accompanying file LICENSE_1_0.txt or copy at
@@ -16,12 +16,10 @@
1616

1717
#if defined(BOOST_STACKTRACE_USE_NOOP)
1818
# include <boost/stacktrace/detail/backend_noop.hpp>
19-
#elif defined(BOOST_STACKTRACE_USE_WINDBG)
20-
# include <boost/stacktrace/detail/backend_windows.hpp>
21-
#elif defined(BOOST_STACKTRACE_USE_BACKTRACE) || defined(BOOST_STACKTRACE_USE_ADDR2LINE)
22-
# include <boost/stacktrace/detail/backend_posix.hpp>
19+
#elif defined(BOOST_MSVC)
20+
# include <boost/stacktrace/detail/backend_msvc.hpp>
2321
#else
24-
# error No suitable backtrace backend found
22+
# include <boost/stacktrace/detail/backend_unwind.hpp>
2523
#endif
2624

2725
#endif // BOOST_STACKTRACE_DETAIL_BACKEND_IPP

include/boost/stacktrace/detail/backend_windows.hpp renamed to include/boost/stacktrace/detail/backend_msvc.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
// Copyright Antony Polukhin, 2016.
1+
// Copyright Antony Polukhin, 2016-2017.
22
//
33
// Distributed under the Boost Software License, Version 1.0. (See
44
// accompanying file LICENSE_1_0.txt or copy at
55
// http://www.boost.org/LICENSE_1_0.txt)
66

7-
#ifndef BOOST_STACKTRACE_DETAIL_BACKEND_WINDOWS_HPP
8-
#define BOOST_STACKTRACE_DETAIL_BACKEND_WINDOWS_HPP
7+
#ifndef BOOST_STACKTRACE_DETAIL_BACKEND_MSVC_HPP
8+
#define BOOST_STACKTRACE_DETAIL_BACKEND_MSVC_HPP
99

1010
#include <boost/config.hpp>
1111
#ifdef BOOST_HAS_PRAGMA_ONCE
@@ -303,4 +303,4 @@ std::size_t frame::source_line() const {
303303

304304
}} // namespace boost::stacktrace
305305

306-
#endif // BOOST_STACKTRACE_DETAIL_BACKEND_LINUX_HPP
306+
#endif // BOOST_STACKTRACE_DETAIL_BACKEND_MSVC_HPP

include/boost/stacktrace/detail/backend_posix.hpp renamed to include/boost/stacktrace/detail/backend_unwind.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
// accompanying file LICENSE_1_0.txt or copy at
55
// http://www.boost.org/LICENSE_1_0.txt)
66

7-
#ifndef BOOST_STACKTRACE_DETAIL_BACKEND_POSIX_HPP
8-
#define BOOST_STACKTRACE_DETAIL_BACKEND_POSIX_HPP
7+
#ifndef BOOST_STACKTRACE_DETAIL_BACKEND_UNWIND_HPP
8+
#define BOOST_STACKTRACE_DETAIL_BACKEND_UNWIND_HPP
99

1010
#include <boost/config.hpp>
1111
#ifdef BOOST_HAS_PRAGMA_ONCE
@@ -131,4 +131,4 @@ std::string frame::name() const {
131131

132132
}} // namespace boost::stacktrace
133133

134-
#endif // BOOST_STACKTRACE_DETAIL_BACKEND_POSIX_HPP
134+
#endif // BOOST_STACKTRACE_DETAIL_BACKEND_UNWIND_HPP

include/boost/stacktrace/detail/unwind_base_impls.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@
1717
namespace boost { namespace stacktrace { namespace detail {
1818

1919
struct to_string_using_nothing {
20+
std::string res;
21+
2022
void prepare_function_name(const void* addr) {
2123
res = boost::stacktrace::frame(addr).name();
2224
}
2325

24-
bool prepare_source_location() const BOOST_NOEXCEPT {
26+
bool prepare_source_location(const void* /*addr*/) const BOOST_NOEXCEPT {
2527
return false;
2628
}
2729
};
@@ -33,6 +35,8 @@ inline std::string name_impl(const void* /*addr*/) {
3335
return std::string();
3436
}
3537

38+
} // namespace detail
39+
3640
std::string frame::source_file() const {
3741
return std::string();
3842
}
@@ -41,6 +45,6 @@ std::size_t frame::source_line() const {
4145
return 0;
4246
}
4347

44-
}}} // namespace boost::stacktrace::detail
48+
}} // namespace boost::stacktrace
4549

4650
#endif // BOOST_STACKTRACE_DETAIL_UNWIND_BASE_IMPLS_HPP

include/boost/stacktrace/frame.hpp

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright Antony Polukhin, 2016.
1+
// Copyright Antony Polukhin, 2016-2017.
22
//
33
// Distributed under the Boost Software License, Version 1.0. (See
44
// accompanying file LICENSE_1_0.txt or copy at
@@ -26,26 +26,6 @@
2626
# define BOOST_STACKTRACE_DYN_LINK
2727
#endif
2828

29-
// Backend autodetection
30-
#if !defined(BOOST_STACKTRACE_USE_NOOP) && !defined(BOOST_STACKTRACE_USE_WINDBG) && !defined(BOOST_STACKTRACE_USE_ADDR2LINE) \
31-
&& !defined(BOOST_STACKTRACE_USE_BACKTRACE) && !defined(BOOST_STACKTRACE_USE_HEADER)
32-
33-
#if defined(__has_include) && (!defined(__GNUC__) || __GNUC__ > 4 || BOOST_CLANG)
34-
# if __has_include("Dbgeng.h")
35-
# define BOOST_STACKTRACE_USE_WINDBG
36-
# else
37-
# define BOOST_STACKTRACE_USE_ADDR2LINE
38-
# endif
39-
#else
40-
# if defined(BOOST_WINDOWS)
41-
# define BOOST_STACKTRACE_USE_WINDBG
42-
# else
43-
# define BOOST_STACKTRACE_USE_ADDR2LINE
44-
# endif
45-
#endif
46-
47-
#endif
48-
4929
#ifdef BOOST_STACKTRACE_LINK
5030
# if defined(BOOST_STACKTRACE_DYN_LINK)
5131
# ifdef BOOST_STACKTRACE_INTERNAL_BUILD_LIBS
@@ -61,7 +41,6 @@
6141
#endif
6242

6343

64-
6544
namespace boost { namespace stacktrace {
6645

6746
class frame;

include/boost/stacktrace/stacktrace.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright Antony Polukhin, 2016.
1+
// Copyright Antony Polukhin, 2016-2017.
22
//
33
// Distributed under the Boost Software License, Version 1.0. (See
44
// accompanying file LICENSE_1_0.txt or copy at

src/basic.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Copyright Antony Polukhin, 2016.
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_INTERNAL_BUILD_LIBS
8+
#define BOOST_STACKTRACE_LINK
9+
#include <boost/stacktrace/detail/backend.ipp>

test/Jamfile.v2

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,50 +24,60 @@ project
2424
<warnings>all
2525
<debug-symbols>on
2626
<test-info>always_show_run_output
27-
<target-os>linux:<cxxflags>"-fvisibility=hidden"
2827
;
2928

29+
local RDYNAMIC = <target-os>freebsd:<linkflags>"-rdynamic" <target-os>solaris:<linkflags>"-Bdynamic" <target-os>aix:<linkflags>"-rdynamic"
30+
<target-os>qnxnto,<toolset>qcc:<linkflags>"-Bdynamic" <target-os>qnxnto,<toolset>gcc:<linkflags>"-rdynamic"
31+
<target-os>android:<linkflags>"-rdynamic" <target-os>linux:<linkflags>"-rdynamic" <target-os>darwin,<toolset>gcc:<linkflags>"-dynamic"
32+
<target-os>darwin,<toolset>clang:<linkflags>"-rdynamic" <target-os>iphone:<linkflags>"-rdynamic" ;
3033

31-
local BT_DEPS = <target-os>linux:<library>dl <library>backtrace [ check-target-builds ../build//libbacktrace : : <build>no ] ;
32-
local UNWD_DEPS = <target-os>linux:<library>dl [ check-target-builds ../build//addr2line : : <build>no ] ;
33-
local WIND_DEPS = <library>Dbghelp [ check-target-builds ../build//WinDbg : : <build>no ] ;
34-
local NOOP_DEPS = ;
35-
local AUTO_DEPS = <target-os>linux:<library>dl [ check-target-builds ../build//WinDbg : <library>Dbghelp ] ;
34+
local HIDE_SYMBS = <target-os>linux:<cxxflags>"-fvisibility=hidden" ;
3635

37-
local LINKSHARED_BT = <link>shared <define>BOOST_STACKTRACE_DYN_LINK <library>/boost/stacktrace//boost_stacktrace_backtrace $(BT_DEPS) ;
38-
local LINKSHARED_UNWD = <link>shared <define>BOOST_STACKTRACE_DYN_LINK <library>/boost/stacktrace//boost_stacktrace_addr2line $(UNWD_DEPS) ;
39-
local LINKSHARED_WIND = <link>shared <define>BOOST_STACKTRACE_DYN_LINK <library>/boost/stacktrace//boost_stacktrace_windbg $(WIND_DEPS) ;
40-
local LINKSHARED_NOOP = <link>shared <define>BOOST_STACKTRACE_DYN_LINK <library>/boost/stacktrace//boost_stacktrace_noop $(NOOP_DEPS) ;
36+
local BT_DEPS = $(HIDE_SYMBS) <target-os>linux:<library>dl <library>backtrace [ check-target-builds ../build//libbacktrace : : <build>no ] ;
37+
local UNWD_DEPS = $(HIDE_SYMBS) <target-os>linux:<library>dl [ check-target-builds ../build//addr2line : : <build>no ] ;
38+
local WIND_DEPS = $(HIDE_SYMBS) <library>Dbghelp [ check-target-builds ../build//WinDbg : : <build>no ] ;
39+
local NOOP_DEPS = $(HIDE_SYMBS) ;
40+
local BASIC_DEPS = $(RDYNAMIC) <target-os>linux:<library>dl [ check-target-builds ../build//WinDbg : <build>no ] ;
41+
42+
local LINKSHARED_BT = <link>shared <define>BOOST_STACKTRACE_DYN_LINK <library>/boost/stacktrace//boost_stacktrace_backtrace $(BT_DEPS) ;
43+
local LINKSHARED_UNWD = <link>shared <define>BOOST_STACKTRACE_DYN_LINK <library>/boost/stacktrace//boost_stacktrace_addr2line $(UNWD_DEPS) ;
44+
local LINKSHARED_WIND = <link>shared <define>BOOST_STACKTRACE_DYN_LINK <library>/boost/stacktrace//boost_stacktrace_windbg $(WIND_DEPS) ;
45+
local LINKSHARED_NOOP = <link>shared <define>BOOST_STACKTRACE_DYN_LINK <library>/boost/stacktrace//boost_stacktrace_noop $(NOOP_DEPS) ;
46+
local LINKSHARED_BASIC = <link>shared <define>BOOST_STACKTRACE_DYN_LINK <library>/boost/stacktrace//boost_stacktrace_basic $(BASIC_DEPS) ;
4147

4248
lib test_impl_lib_backtrace : test_impl.cpp : $(LINKSHARED_BT) ;
4349
lib test_impl_lib_addr2line : test_impl.cpp : $(LINKSHARED_UNWD) ;
4450
lib test_impl_lib_windbg : test_impl.cpp : $(LINKSHARED_WIND) ;
4551
lib test_impl_lib_noop : test_impl.cpp : $(LINKSHARED_NOOP) ;
4652

53+
obj test_impl_nohide-obj : test_impl.cpp : $(LINKSHARED_BASIC) ;
54+
lib test_impl_lib_basic : test_impl_nohide-obj : $(LINKSHARED_BASIC) ;
55+
4756
test-suite stacktrace_tests
4857
:
4958
# Header only tests
50-
[ run test.cpp test_impl.cpp : : : <define>BOOST_STACKTRACE_USE_BACKTRACE $(BT_DEPS) : backtrace_ho ]
51-
[ run test.cpp test_impl.cpp : : : <define>BOOST_STACKTRACE_USE_ADDR2LINE $(UNWD_DEPS) : addr2line_ho ]
52-
[ run test.cpp test_impl.cpp : : : <define>BOOST_STACKTRACE_USE_WINDBG $(WIND_DEPS) : windbg_ho ]
53-
[ run test_noop.cpp test_impl.cpp : : : <define>BOOST_STACKTRACE_USE_NOOP $(NOOP_DEPS) : noop_ho ]
54-
[ run test.cpp test_impl.cpp : : : $(AUTO_DEPS) : autodetect_ho ]
59+
[ run test.cpp test_impl.cpp : : : <define>BOOST_STACKTRACE_USE_BACKTRACE $(BT_DEPS) : backtrace_ho ]
60+
[ run test.cpp test_impl.cpp : : : <define>BOOST_STACKTRACE_USE_ADDR2LINE $(UNWD_DEPS) : addr2line_ho ]
61+
[ run test_noop.cpp test_impl.cpp : : : <define>BOOST_STACKTRACE_USE_NOOP $(NOOP_DEPS) : noop_ho ]
62+
[ run test.cpp test_impl.cpp : : : $(WIND_DEPS) : windbg_ho ]
63+
[ run test.cpp test_impl.cpp : : : $(BASIC_DEPS) : basic_ho ]
5564

5665
# Test with shared linked backends
57-
[ run test.cpp : : : <library>.//test_impl_lib_backtrace $(LINKSHARED_BT) : backtrace_lib ]
58-
[ run test.cpp : : : <library>.//test_impl_lib_addr2line $(LINKSHARED_UNWD) : addr2line_lib ]
59-
[ run test.cpp : : : <library>.//test_impl_lib_windbg $(LINKSHARED_WIND) : windbg_lib ]
60-
[ run test_noop.cpp : : : <library>.//test_impl_lib_noop $(LINKSHARED_NOOP) : noop_lib ]
66+
[ run test.cpp : : : <library>.//test_impl_lib_backtrace $(LINKSHARED_BT) : backtrace_lib ]
67+
[ run test.cpp : : : <library>.//test_impl_lib_addr2line $(LINKSHARED_UNWD) : addr2line_lib ]
68+
[ run test.cpp : : : <library>.//test_impl_lib_windbg $(LINKSHARED_WIND) : windbg_lib ]
69+
[ run test_noop.cpp : : : <library>.//test_impl_lib_noop $(LINKSHARED_NOOP) : noop_lib ]
70+
[ run test.cpp : : : <library>.//test_impl_lib_basic $(LINKSHARED_BASIC) : basic_lib ]
6171
;
6272

6373
# Assuring that examples compile and run. Adding sources from `examples` directory to the `type_index` test suite.
6474
for local p in [ glob ../example/*.cpp ]
6575
{
66-
stacktrace_tests += [ run $(p) : : : $(LINKSHARED_BT) : backtrace_$(p[1]:B) ] ;
67-
stacktrace_tests += [ run $(p) : : : $(LINKSHARED_UNWD) : addr2line_$(p[1]:B) ] ;
68-
stacktrace_tests += [ run $(p) : : : $(LINKSHARED_WIND) : windbg_$(p[1]:B) ] ;
69-
stacktrace_tests += [ run $(p) : : : $(LINKSHARED_NOOP) : noop_$(p[1]:B) ] ;
70-
stacktrace_tests += [ run $(p) : : : $(AUTO_DEPS) : autodetect_$(p[1]:B) ] ;
76+
stacktrace_tests += [ run $(p) : : : $(LINKSHARED_BT) : backtrace_$(p[1]:B) ] ;
77+
stacktrace_tests += [ run $(p) : : : $(LINKSHARED_UNWD) : addr2line_$(p[1]:B) ] ;
78+
stacktrace_tests += [ run $(p) : : : $(LINKSHARED_WIND) : windbg_$(p[1]:B) ] ;
79+
stacktrace_tests += [ run $(p) : : : $(LINKSHARED_NOOP) : noop_$(p[1]:B) ] ;
80+
stacktrace_tests += [ run $(p) : : : $(LINKSHARED_BASIC) : basic_$(p[1]:B) ] ;
7181

7282
}
7383

test/test.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,12 @@ void test_nested() {
8282
BOOST_TEST(ss1.str().find(" in ") != std::string::npos);
8383
BOOST_TEST(ss2.str().find(" in ") != std::string::npos);
8484

85-
#if defined(BOOST_STACKTRACE_DYN_LINK) || !defined(BOOST_STACKTRACE_USE_BACKTRACE)
86-
BOOST_TEST(ss1.str().find("foo1") != std::string::npos);
8785
BOOST_TEST(ss1.str().find("foo2") != std::string::npos);
88-
BOOST_TEST(ss2.str().find("foo1") != std::string::npos);
8986
BOOST_TEST(ss2.str().find("foo2") != std::string::npos);
90-
#endif
87+
88+
BOOST_TEST(ss1.str().find("foo1") != std::string::npos);
89+
BOOST_TEST(ss2.str().find("foo1") != std::string::npos);
90+
9191
//BOOST_TEST(false);
9292
}
9393

0 commit comments

Comments
 (0)