From e1fc48ef3d8250e31ec06407a05b04db5d7cbc3b Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Mon, 2 Jan 2017 15:58:05 -0800 Subject: [PATCH 01/24] .travis.yml --- .travis.yml | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..661d6bd --- /dev/null +++ b/.travis.yml @@ -0,0 +1,95 @@ +# Copyright 2017 Emil Dotchevski +# Copyright 2016 Peter Dimov +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt) + +language: cpp + +sudo: false + +python: "2.7" + +os: + - linux + - osx + +branches: + only: + - master + - develop + +env: + matrix: + - BOGUS_JOB=true + +addons: + apt: + packages: + - g++-4.9 + - g++-4.6.3 + - g++-5 + - g++-6 + - clang-3.6 + - clang-3.7 + - clang-3.8 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-precise + - llvm-toolchain-precise-3.6 + - llvm-toolchain-precise-3.7 + - llvm-toolchain-precise-3.8 + +matrix: + + exclude: + - env: BOGUS_JOB=true + + include: + - os: linux + env: TOOLSET=gcc COMPILER=g++-4.6.3 CXXSTD=c++11 + + - os: linux + env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=c++11 + + - os: linux + env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=c++11 + + - os: linux + env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=c++11 + + - os: linux + env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=c++1z + + - os: linux + env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=c++11 + + - os: linux + env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=c++11 + + - os: linux + env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=c++11 + + - os: osx + env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++11 + +install: + - cd .. + - git clone -b $TRAVIS_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root + - cd boost-root + - git submodule update --init tools/build + - git submodule update --init tools/inspect + - git submodule update --init libs/config + - git submodule update --init tools/boostdep + - cp -r $TRAVIS_BUILD_DIR/* libs/exception + - python tools/boostdep/depinst/depinst.py exception + - ./bootstrap.sh + - ./b2 headers + +script: + - |- + echo "using $TOOLSET : : $COMPILER : -std=$CXXSTD ;" > ~/user-config.jam + - ./b2 libs/exception/test toolset=$TOOLSET + +notifications: + email: + on_success: always From 66b39f31369519b07183b823d1f230c1cc6815bd Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Mon, 2 Jan 2017 16:31:33 -0800 Subject: [PATCH 02/24] removed attempting to install g++-4.6.3 in .travis.yml --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 661d6bd..490730d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,7 +26,6 @@ addons: apt: packages: - g++-4.9 - - g++-4.6.3 - g++-5 - g++-6 - clang-3.6 From 119dbf688fb27ea2ed9a6e7139382cf61df487c8 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Mon, 2 Jan 2017 16:42:16 -0800 Subject: [PATCH 03/24] Hopefully g++-4.6.3 will in .travis.yml now. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 490730d..16d7071 100644 --- a/.travis.yml +++ b/.travis.yml @@ -45,7 +45,7 @@ matrix: include: - os: linux - env: TOOLSET=gcc COMPILER=g++-4.6.3 CXXSTD=c++11 + env: TOOLSET=gcc COMPILER=g++ CXXSTD=c++11 - os: linux env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=c++11 From 32a3bda6cc2e3a34680eef5189a0434ef4d7d0df Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Mon, 2 Jan 2017 16:47:03 -0800 Subject: [PATCH 04/24] Removed c++11 for g++-4.6.3 invocation. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 16d7071..450fd47 100644 --- a/.travis.yml +++ b/.travis.yml @@ -45,7 +45,7 @@ matrix: include: - os: linux - env: TOOLSET=gcc COMPILER=g++ CXXSTD=c++11 + env: TOOLSET=gcc COMPILER=g++ - os: linux env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=c++11 From 2cdbdfcf4e7972664aaa431be6a7148d94f2e5d0 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Mon, 2 Jan 2017 17:04:32 -0800 Subject: [PATCH 05/24] Deleting unused test/exception_hpp_test.cpp, removing c++11 from build requests. --- .travis.yml | 18 +++++++++--------- test/exception_hpp_test.cpp | 7 ------- 2 files changed, 9 insertions(+), 16 deletions(-) delete mode 100644 test/exception_hpp_test.cpp diff --git a/.travis.yml b/.travis.yml index 450fd47..243c569 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,28 +48,28 @@ matrix: env: TOOLSET=gcc COMPILER=g++ - os: linux - env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=c++11 + env: TOOLSET=gcc COMPILER=g++-4.9 - os: linux - env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=c++11 + env: TOOLSET=gcc COMPILER=g++-5 - os: linux - env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=c++11 + env: TOOLSET=gcc COMPILER=g++-6 - os: linux - env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=c++1z + env: TOOLSET=gcc COMPILER=g++-6 - os: linux - env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=c++11 + env: TOOLSET=clang COMPILER=clang++-3.6 - os: linux - env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=c++11 + env: TOOLSET=clang COMPILER=clang++-3.7 - os: linux - env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=c++11 + env: TOOLSET=clang COMPILER=clang++-3.8 - os: osx - env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++11 + env: TOOLSET=clang COMPILER=clang++ install: - cd .. @@ -86,7 +86,7 @@ install: script: - |- - echo "using $TOOLSET : : $COMPILER : -std=$CXXSTD ;" > ~/user-config.jam + echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam - ./b2 libs/exception/test toolset=$TOOLSET notifications: diff --git a/test/exception_hpp_test.cpp b/test/exception_hpp_test.cpp deleted file mode 100644 index 6f77efe..0000000 --- a/test/exception_hpp_test.cpp +++ /dev/null @@ -1,7 +0,0 @@ -//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc. - -//Distributed under the Boost Software License, Version 1.0. (See accompanying -//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#include -#include From 07d5ef529bda80376995de1b2241b66c7c768fcb Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Tue, 3 Jan 2017 00:00:52 -0800 Subject: [PATCH 06/24] Added error_info_basic_test.cpp to test ticket 11874 --- test/Jamfile.v2 | 1 + test/error_info_basic_test.cpp | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 test/error_info_basic_test.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index e7cf00d..53d277f 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -34,6 +34,7 @@ run exception_test.cpp ; run enable_error_info_test.cpp helper1.cpp ; run throw_exception_test.cpp helper2.cpp ; run errno_test.cpp ; +run error_info_basic_test.cpp ; run error_info_lv_test.cpp ; run error_info_lv_const_test.cpp ; run error_info_rv_test.cpp ; diff --git a/test/error_info_basic_test.cpp b/test/error_info_basic_test.cpp new file mode 100644 index 0000000..45d2fcf --- /dev/null +++ b/test/error_info_basic_test.cpp @@ -0,0 +1,28 @@ +//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc. + +//Distributed under the Boost Software License, Version 1.0. (See accompanying +//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include + +struct my_exception: virtual boost::exception {}; +typedef boost::error_info error_info_string; + +int +main() + { + try + { + throw my_exception() << error_info_string("doh"); + } + catch( my_exception & e ) + { + BOOST_TEST(boost::get_error_info(e) && !strcmp(boost::get_error_info(e)->c_str(),"doh")); + } + return 0; + } From 59666dcdb0bf487441ef84e739a708afcb46b54c Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Tue, 3 Jan 2017 00:06:25 -0800 Subject: [PATCH 07/24] Adding missing include in error_info_basic_test.cpp --- test/error_info_basic_test.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/error_info_basic_test.cpp b/test/error_info_basic_test.cpp index 45d2fcf..021eabc 100644 --- a/test/error_info_basic_test.cpp +++ b/test/error_info_basic_test.cpp @@ -3,12 +3,13 @@ //Distributed under the Boost Software License, Version 1.0. (See accompanying //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -#include #include #include #include #include #include +#include +#include struct my_exception: virtual boost::exception {}; typedef boost::error_info error_info_string; From 6d1c2c434b0bea16e292085a6177d17f9092e5f6 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Tue, 3 Jan 2017 10:42:30 -0800 Subject: [PATCH 08/24] Adding c++0x to gcc command line --- .travis.yml | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 243c569..9cefc35 100644 --- a/.travis.yml +++ b/.travis.yml @@ -45,31 +45,28 @@ matrix: include: - os: linux - env: TOOLSET=gcc COMPILER=g++ + env: TOOLSET=gcc COMPILER=g++ CXXSTD=c++0x - os: linux - env: TOOLSET=gcc COMPILER=g++-4.9 + env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=c++0x - os: linux - env: TOOLSET=gcc COMPILER=g++-5 + env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=c++0x - os: linux - env: TOOLSET=gcc COMPILER=g++-6 + env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=c++0x - os: linux - env: TOOLSET=gcc COMPILER=g++-6 + env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=c++0x - os: linux - env: TOOLSET=clang COMPILER=clang++-3.6 + env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=c++0x - os: linux - env: TOOLSET=clang COMPILER=clang++-3.7 - - - os: linux - env: TOOLSET=clang COMPILER=clang++-3.8 + env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=c++0x - os: osx - env: TOOLSET=clang COMPILER=clang++ + env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++0x install: - cd .. @@ -86,7 +83,7 @@ install: script: - |- - echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam + echo "using $TOOLSET : : $COMPILER : -std=$CXXSTD ;" > ~/user-config.jam - ./b2 libs/exception/test toolset=$TOOLSET notifications: From 406d3c87f7f95d1fbca3e27e6cd2b7e0f5d355a8 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Tue, 3 Jan 2017 12:17:27 -0800 Subject: [PATCH 09/24] Maybe fixing 11874 --- include/boost/exception/detail/error_info_impl.hpp | 12 ++++++------ include/boost/exception/info.hpp | 14 +++++++------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/include/boost/exception/detail/error_info_impl.hpp b/include/boost/exception/detail/error_info_impl.hpp index ecd086d..ed593be 100644 --- a/include/boost/exception/detail/error_info_impl.hpp +++ b/include/boost/exception/detail/error_info_impl.hpp @@ -47,24 +47,24 @@ boost typedef T value_type; - error_info( value_type const & value ); + error_info( value_type const & v ); #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES error_info( error_info const & ); - error_info( value_type && value ) BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(value_type(std::move(value)))); - error_info( error_info && x ) BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(value_type(std::move(x.value_)))); + error_info( value_type && v ) BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(value_type(std::move(v)))); + error_info( error_info && x ) BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(value_type(std::move(x.v_)))); #endif ~error_info() throw(); value_type const & value() const { - return value_; + return v_; } value_type & value() { - return value_; + return v_; } private: @@ -75,7 +75,7 @@ boost std::string name_value_string() const; - value_type value_; + value_type v_; }; } diff --git a/include/boost/exception/info.hpp b/include/boost/exception/info.hpp index f06df42..5b7c17b 100644 --- a/include/boost/exception/info.hpp +++ b/include/boost/exception/info.hpp @@ -41,8 +41,8 @@ boost template inline error_info:: - error_info( value_type const & value ): - value_(value) + error_info( value_type const & v ): + v_(v) { } @@ -51,21 +51,21 @@ boost inline error_info:: error_info( error_info const & x ): - value_(x.value_) + v_(x.v_) { } template inline error_info:: - error_info( value_type && value ) BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(value_type(std::move(value)))): - value_(std::move(value)) + error_info( value_type && v ) BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(value_type(std::move(v)))): + v_(std::move(v)) { } template inline error_info:: - error_info( error_info && x ) BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(value_type(std::move(x.value_)))): - value_(std::move(x.value_)) + error_info( error_info && x ) BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(value_type(std::move(x.v_)))): + v_(std::move(x.v_)) { } #endif From 972667f52e9a79536f10bed5032f1a5afc294238 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Tue, 3 Jan 2017 14:35:11 -0800 Subject: [PATCH 10/24] Tweaks to try to defeat g++4.6.3 --- .../exception/detail/error_info_impl.hpp | 31 +++++++++------ include/boost/exception/info.hpp | 39 ------------------- test/error_info_basic_test.cpp | 20 +++++----- 3 files changed, 29 insertions(+), 61 deletions(-) diff --git a/include/boost/exception/detail/error_info_impl.hpp b/include/boost/exception/detail/error_info_impl.hpp index ed593be..479ef54 100644 --- a/include/boost/exception/detail/error_info_impl.hpp +++ b/include/boost/exception/detail/error_info_impl.hpp @@ -44,37 +44,44 @@ boost public exception_detail::error_info_base { public: - typedef T value_type; - - error_info( value_type const & v ); + error_info( value_type const & v ): + v_(v) + { + } #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - error_info( error_info const & ); - error_info( value_type && v ) BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(value_type(std::move(v)))); - error_info( error_info && x ) BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(value_type(std::move(x.v_)))); + error_info( error_info const & x ): + v_(x.v_) + { + } + error_info( value_type && v ) BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(value_type(std::move(v)))): + v_(std::move(v)) + { + } + error_info( error_info && x ) BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(value_type(std::move(x.v_)))): + v_(std::move(x.v_)) + { + } #endif - ~error_info() throw(); - + ~error_info() throw() + { + } value_type const & value() const { return v_; } - value_type & value() { return v_; } - private: error_info & operator=( error_info const & ); #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES error_info & operator=( error_info && x ); #endif - std::string name_value_string() const; - value_type v_; }; } diff --git a/include/boost/exception/info.hpp b/include/boost/exception/info.hpp index 5b7c17b..71abe53 100644 --- a/include/boost/exception/info.hpp +++ b/include/boost/exception/info.hpp @@ -38,45 +38,6 @@ boost return '[' + error_info_name(x) + "] = " + to_string_stub(x.value()) + '\n'; } - template - inline - error_info:: - error_info( value_type const & v ): - v_(v) - { - } - -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - template - inline - error_info:: - error_info( error_info const & x ): - v_(x.v_) - { - } - template - inline - error_info:: - error_info( value_type && v ) BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(value_type(std::move(v)))): - v_(std::move(v)) - { - } - template - inline - error_info:: - error_info( error_info && x ) BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(value_type(std::move(x.v_)))): - v_(std::move(x.v_)) - { - } -#endif - - template - inline - error_info:: - ~error_info() throw() - { - } - template inline std::string diff --git a/test/error_info_basic_test.cpp b/test/error_info_basic_test.cpp index 021eabc..aa8d6a7 100644 --- a/test/error_info_basic_test.cpp +++ b/test/error_info_basic_test.cpp @@ -16,14 +16,14 @@ typedef boost::error_info error_info_str int main() - { - try - { - throw my_exception() << error_info_string("doh"); - } - catch( my_exception & e ) - { - BOOST_TEST(boost::get_error_info(e) && !strcmp(boost::get_error_info(e)->c_str(),"doh")); - } + { + try + { + throw my_exception() << error_info_string("doh"); + } + catch( my_exception & e ) + { + BOOST_TEST(boost::get_error_info(e) && !strcmp(boost::get_error_info(e)->c_str(),"doh")); + } return 0; - } + } From d39ba0008800b58b888ddfa28de8f479f99bf963 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Tue, 3 Jan 2017 15:05:12 -0800 Subject: [PATCH 11/24] Added more g++ versions to .travis.yml --- .travis.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.travis.yml b/.travis.yml index 9cefc35..507b9eb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,6 +25,8 @@ env: addons: apt: packages: + - g++-4.7 + - g++-4.8 - g++-4.9 - g++-5 - g++-6 @@ -47,6 +49,12 @@ matrix: - os: linux env: TOOLSET=gcc COMPILER=g++ CXXSTD=c++0x + - os: linux + env: TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=c++0x + + - os: linux + env: TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=c++0x + - os: linux env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=c++0x From e8877d4837e53df97d38158a875edf850a01d61a Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Tue, 3 Jan 2017 15:25:52 -0800 Subject: [PATCH 12/24] Workaround for 11874 --- include/boost/exception/detail/error_info_impl.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/boost/exception/detail/error_info_impl.hpp b/include/boost/exception/detail/error_info_impl.hpp index 479ef54..6fc542c 100644 --- a/include/boost/exception/detail/error_info_impl.hpp +++ b/include/boost/exception/detail/error_info_impl.hpp @@ -49,6 +49,7 @@ boost v_(v) { } +#if (__GNUC__*100+__GNUC_MINOR__!=406) //workaround for g++ bug #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES error_info( error_info const & x ): v_(x.v_) @@ -62,6 +63,7 @@ boost v_(std::move(x.v_)) { } +#endif #endif ~error_info() throw() { From 0eee18787631be1d84249174a47fcc156c6f9f8e Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Mon, 20 Feb 2017 18:23:36 -0800 Subject: [PATCH 13/24] #include config before anything else --- include/boost/exception/N3757.hpp | 7 ++++--- include/boost/exception/all.hpp | 11 +---------- .../detail/clone_current_exception.hpp | 3 +++ .../boost/exception/detail/error_info_impl.hpp | 9 +++++---- .../boost/exception/detail/exception_ptr.hpp | 13 +++++++------ .../exception/detail/is_output_streamable.hpp | 5 +++-- .../boost/exception/detail/object_hex_dump.hpp | 13 +++++++------ include/boost/exception/detail/type_info.hpp | 13 +++++++------ .../boost/exception/diagnostic_information.hpp | 17 ++++++++++------- .../exception/enable_current_exception.hpp | 5 +++++ include/boost/exception/enable_error_info.hpp | 5 +++++ include/boost/exception/errinfo_errno.hpp | 9 +++++---- include/boost/exception/get_error_info.hpp | 14 ++++++++------ include/boost/exception/info.hpp | 14 ++++++++------ include/boost/exception/info_tuple.hpp | 7 ++++--- include/boost/exception/to_string.hpp | 9 +++++---- include/boost/exception/to_string_stub.hpp | 9 +++++---- 17 files changed, 92 insertions(+), 71 deletions(-) diff --git a/include/boost/exception/N3757.hpp b/include/boost/exception/N3757.hpp index 23b0606..1bc298d 100644 --- a/include/boost/exception/N3757.hpp +++ b/include/boost/exception/N3757.hpp @@ -5,6 +5,10 @@ #ifndef UUID_9011016A11A711E3B46CD9FA6088709B #define UUID_9011016A11A711E3B46CD9FA6088709B + +#include +#include + #if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) #pragma GCC system_header #endif @@ -12,9 +16,6 @@ #pragma warning(push,1) #endif -#include -#include - namespace boost { diff --git a/include/boost/exception/all.hpp b/include/boost/exception/all.hpp index 32eb150..58b02d0 100644 --- a/include/boost/exception/all.hpp +++ b/include/boost/exception/all.hpp @@ -5,13 +5,8 @@ #ifndef UUID_316FDA946C0D11DEA9CBAE5255D89593 #define UUID_316FDA946C0D11DEA9CBAE5255D89593 -#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) -#pragma GCC system_header -#endif -#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) -#pragma warning(push,1) -#endif +#include #include #include #include @@ -29,8 +24,4 @@ #include #include #endif - -#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) -#pragma warning(pop) -#endif #endif diff --git a/include/boost/exception/detail/clone_current_exception.hpp b/include/boost/exception/detail/clone_current_exception.hpp index 6fc1374..3d86deb 100644 --- a/include/boost/exception/detail/clone_current_exception.hpp +++ b/include/boost/exception/detail/clone_current_exception.hpp @@ -5,6 +5,9 @@ #ifndef UUID_81522C0EB56511DFAB613DB0DFD72085 #define UUID_81522C0EB56511DFAB613DB0DFD72085 + +#include + #if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) #pragma GCC system_header #endif diff --git a/include/boost/exception/detail/error_info_impl.hpp b/include/boost/exception/detail/error_info_impl.hpp index ecd086d..6e0bf61 100644 --- a/include/boost/exception/detail/error_info_impl.hpp +++ b/include/boost/exception/detail/error_info_impl.hpp @@ -5,6 +5,11 @@ #ifndef UUID_CE6983AC753411DDA764247956D89593 #define UUID_CE6983AC753411DDA764247956D89593 + +#include +#include +#include + #if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) #pragma GCC system_header #endif @@ -12,10 +17,6 @@ #pragma warning(push,1) #endif -#include -#include -#include - namespace boost { diff --git a/include/boost/exception/detail/exception_ptr.hpp b/include/boost/exception/detail/exception_ptr.hpp index cac64e6..5aa4773 100644 --- a/include/boost/exception/detail/exception_ptr.hpp +++ b/include/boost/exception/detail/exception_ptr.hpp @@ -5,12 +5,6 @@ #ifndef UUID_618474C2DE1511DEB74A388C56D89593 #define UUID_618474C2DE1511DEB74A388C56D89593 -#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) -#pragma GCC system_header -#endif -#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) -#pragma warning(push,1) -#endif #include #ifdef BOOST_NO_EXCEPTIONS @@ -30,6 +24,13 @@ #include #include +#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma GCC system_header +#endif +#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma warning(push,1) +#endif + namespace boost { diff --git a/include/boost/exception/detail/is_output_streamable.hpp b/include/boost/exception/detail/is_output_streamable.hpp index 847f348..10e5c51 100644 --- a/include/boost/exception/detail/is_output_streamable.hpp +++ b/include/boost/exception/detail/is_output_streamable.hpp @@ -5,6 +5,9 @@ #ifndef UUID_898984B4076411DD973EDFA055D89593 #define UUID_898984B4076411DD973EDFA055D89593 + +#include + #if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) #pragma GCC system_header #endif @@ -12,8 +15,6 @@ #pragma warning(push,1) #endif -#include - namespace boost { diff --git a/include/boost/exception/detail/object_hex_dump.hpp b/include/boost/exception/detail/object_hex_dump.hpp index 53c8bf6..267bf0b 100644 --- a/include/boost/exception/detail/object_hex_dump.hpp +++ b/include/boost/exception/detail/object_hex_dump.hpp @@ -5,12 +5,6 @@ #ifndef UUID_6F463AC838DF11DDA3E6909F56D89593 #define UUID_6F463AC838DF11DDA3E6909F56D89593 -#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) -#pragma GCC system_header -#endif -#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) -#pragma warning(push,1) -#endif #include #include @@ -19,6 +13,13 @@ #include #include +#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma GCC system_header +#endif +#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma warning(push,1) +#endif + namespace boost { diff --git a/include/boost/exception/detail/type_info.hpp b/include/boost/exception/detail/type_info.hpp index b8c7d48..739ac57 100644 --- a/include/boost/exception/detail/type_info.hpp +++ b/include/boost/exception/detail/type_info.hpp @@ -5,6 +5,13 @@ #ifndef UUID_C3E1741C754311DDB2834CCA55D89593 #define UUID_C3E1741C754311DDB2834CCA55D89593 + +#include +#include +#include +#include +#include + #if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) #pragma GCC system_header #endif @@ -12,12 +19,6 @@ #pragma warning(push,1) #endif -#include -#include -#include -#include -#include - namespace boost { diff --git a/include/boost/exception/diagnostic_information.hpp b/include/boost/exception/diagnostic_information.hpp index 305e8ed..48f06a0 100644 --- a/include/boost/exception/diagnostic_information.hpp +++ b/include/boost/exception/diagnostic_information.hpp @@ -5,12 +5,6 @@ #ifndef UUID_0552D49838DD11DD90146B8956D89593 #define UUID_0552D49838DD11DD90146B8956D89593 -#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) -#pragma GCC system_header -#endif -#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) -#pragma warning(push,1) -#endif #include #include @@ -22,9 +16,18 @@ #include #include #include - #ifndef BOOST_NO_EXCEPTIONS #include +#endif + +#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma GCC system_header +#endif +#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma warning(push,1) +#endif + +#ifndef BOOST_NO_EXCEPTIONS namespace boost { diff --git a/include/boost/exception/enable_current_exception.hpp b/include/boost/exception/enable_current_exception.hpp index 9881053..495cc90 100644 --- a/include/boost/exception/enable_current_exception.hpp +++ b/include/boost/exception/enable_current_exception.hpp @@ -3,4 +3,9 @@ //Distributed under the Boost Software License, Version 1.0. (See accompanying //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#ifndef UUID_851700A4F7CF11E6B2EE06DD14915323 +#define UUID_851700A4F7CF11E6B2EE06DD14915323 + #include + +#endif diff --git a/include/boost/exception/enable_error_info.hpp b/include/boost/exception/enable_error_info.hpp index 9881053..202217a 100644 --- a/include/boost/exception/enable_error_info.hpp +++ b/include/boost/exception/enable_error_info.hpp @@ -3,4 +3,9 @@ //Distributed under the Boost Software License, Version 1.0. (See accompanying //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#ifndef UUID_A0F7404AF7CF11E6908227DD14915323 +#define UUID_A0F7404AF7CF11E6908227DD14915323 + #include + +#endif diff --git a/include/boost/exception/errinfo_errno.hpp b/include/boost/exception/errinfo_errno.hpp index de44e17..ebd8f25 100644 --- a/include/boost/exception/errinfo_errno.hpp +++ b/include/boost/exception/errinfo_errno.hpp @@ -5,6 +5,11 @@ #ifndef UUID_F0EE17BE6C1211DE87FF459155D89593 #define UUID_F0EE17BE6C1211DE87FF459155D89593 + +#include +#include +#include + #if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) #pragma GCC system_header #endif @@ -13,10 +18,6 @@ #pragma warning(disable:4996) #endif -#include -#include -#include - namespace boost { diff --git a/include/boost/exception/get_error_info.hpp b/include/boost/exception/get_error_info.hpp index 51a21ba..831717d 100644 --- a/include/boost/exception/get_error_info.hpp +++ b/include/boost/exception/get_error_info.hpp @@ -5,6 +5,14 @@ #ifndef UUID_1A590226753311DD9E4CCF6156D89593 #define UUID_1A590226753311DD9E4CCF6156D89593 + +#include +#include +#include +#include +#include +#include + #if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) #pragma GCC system_header #endif @@ -12,12 +20,6 @@ #pragma warning(push,1) #endif -#include -#include -#include -#include -#include - namespace boost { diff --git a/include/boost/exception/info.hpp b/include/boost/exception/info.hpp index f06df42..3a830cf 100644 --- a/include/boost/exception/info.hpp +++ b/include/boost/exception/info.hpp @@ -5,13 +5,8 @@ #ifndef UUID_8D22C4CA9CC811DCAA9133D256D89593 #define UUID_8D22C4CA9CC811DCAA9133D256D89593 -#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) -#pragma GCC system_header -#endif -#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) -#pragma warning(push,1) -#endif +#include #include #include #include @@ -19,6 +14,13 @@ #include #include +#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma GCC system_header +#endif +#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma warning(push,1) +#endif + namespace boost { diff --git a/include/boost/exception/info_tuple.hpp b/include/boost/exception/info_tuple.hpp index 70154fd..7c16d75 100644 --- a/include/boost/exception/info_tuple.hpp +++ b/include/boost/exception/info_tuple.hpp @@ -5,6 +5,10 @@ #ifndef UUID_63EE924290FB11DC87BB856555D89593 #define UUID_63EE924290FB11DC87BB856555D89593 + +#include +#include + #if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) #pragma GCC system_header #endif @@ -12,9 +16,6 @@ #pragma warning(push,1) #endif -#include -#include - namespace boost { diff --git a/include/boost/exception/to_string.hpp b/include/boost/exception/to_string.hpp index 68541d2..51425b1 100644 --- a/include/boost/exception/to_string.hpp +++ b/include/boost/exception/to_string.hpp @@ -5,6 +5,11 @@ #ifndef UUID_7E48761AD92811DC9011477D56D89593 #define UUID_7E48761AD92811DC9011477D56D89593 + +#include +#include +#include + #if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) #pragma GCC system_header #endif @@ -12,10 +17,6 @@ #pragma warning(push,1) #endif -#include -#include -#include - namespace boost { diff --git a/include/boost/exception/to_string_stub.hpp b/include/boost/exception/to_string_stub.hpp index b6ab31c..8ff5e47 100644 --- a/include/boost/exception/to_string_stub.hpp +++ b/include/boost/exception/to_string_stub.hpp @@ -5,6 +5,11 @@ #ifndef UUID_E788439ED9F011DCB181F25B55D89593 #define UUID_E788439ED9F011DCB181F25B55D89593 + +#include +#include +#include + #if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) #pragma GCC system_header #endif @@ -12,10 +17,6 @@ #pragma warning(push,1) #endif -#include -#include -#include - namespace boost { From 4ea8555871a55cbe8f39bc87acf515bc5d45f4da Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Tue, 21 Feb 2017 11:41:51 -0800 Subject: [PATCH 14/24] Removed double-including of config. --- include/boost/exception/info.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/include/boost/exception/info.hpp b/include/boost/exception/info.hpp index 88e5960..c99578a 100644 --- a/include/boost/exception/info.hpp +++ b/include/boost/exception/info.hpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) From cf05dc079b06f5f942b2bf4f74ecbdaf41fd815a Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Mon, 13 Mar 2017 15:07:09 -0700 Subject: [PATCH 15/24] Removing non-intrusive exception_ptr support. --- build/Jamfile.v2 | 14 - .../detail/clone_current_exception.hpp | 59 ---- .../boost/exception/detail/exception_ptr.hpp | 215 +++++------- include/boost/exception/exception_data.hpp | 81 +++++ src/clone_current_exception_non_intrusive.cpp | 320 ------------------ test/Jamfile.v2 | 1 - test/cloning_test.cpp | 21 -- test/unknown_exception_test.cpp | 19 -- 8 files changed, 173 insertions(+), 557 deletions(-) delete mode 100644 build/Jamfile.v2 delete mode 100644 include/boost/exception/detail/clone_current_exception.hpp create mode 100644 include/boost/exception/exception_data.hpp delete mode 100644 src/clone_current_exception_non_intrusive.cpp diff --git a/build/Jamfile.v2 b/build/Jamfile.v2 deleted file mode 100644 index fb47659..0000000 --- a/build/Jamfile.v2 +++ /dev/null @@ -1,14 +0,0 @@ -# Boost Exception Library build Jamfile -# -# Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc. -# -# Distributed under the Boost Software License, Version 1.0. (See accompanying -# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -project boost/exception - : source-location ../src - : requirements static - ; - -lib boost_exception : clone_current_exception_non_intrusive.cpp ; -boost-install boost_exception ; diff --git a/include/boost/exception/detail/clone_current_exception.hpp b/include/boost/exception/detail/clone_current_exception.hpp deleted file mode 100644 index 3d86deb..0000000 --- a/include/boost/exception/detail/clone_current_exception.hpp +++ /dev/null @@ -1,59 +0,0 @@ -//Copyright (c) 2006-2013 Emil Dotchevski and Reverge Studios, Inc. - -//Distributed under the Boost Software License, Version 1.0. (See accompanying -//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#ifndef UUID_81522C0EB56511DFAB613DB0DFD72085 -#define UUID_81522C0EB56511DFAB613DB0DFD72085 - -#include - -#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) -#pragma GCC system_header -#endif -#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) -#pragma warning(push,1) -#endif - -#ifdef BOOST_NO_EXCEPTIONS -# error This header requires exception handling to be enabled. -#endif - -namespace -boost - { - namespace - exception_detail - { - class clone_base; - -#ifdef BOOST_ENABLE_NON_INTRUSIVE_EXCEPTION_PTR - int clone_current_exception_non_intrusive( clone_base const * & cloned ); -#endif - - namespace - clone_current_exception_result - { - int const success=0; - int const bad_alloc=1; - int const bad_exception=2; - int const not_supported=3; - } - - inline - int - clone_current_exception( clone_base const * & cloned ) - { -#ifdef BOOST_ENABLE_NON_INTRUSIVE_EXCEPTION_PTR - return clone_current_exception_non_intrusive(cloned); -#else - return clone_current_exception_result::not_supported; -#endif - } - } - } - -#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) -#pragma warning(pop) -#endif -#endif diff --git a/include/boost/exception/detail/exception_ptr.hpp b/include/boost/exception/detail/exception_ptr.hpp index 5aa4773..24c4fba 100644 --- a/include/boost/exception/detail/exception_ptr.hpp +++ b/include/boost/exception/detail/exception_ptr.hpp @@ -14,7 +14,6 @@ #include #include #include -#include #ifndef BOOST_NO_RTTI #include #endif @@ -303,131 +302,101 @@ boost exception_ptr current_exception_impl() { - exception_detail::clone_base const * e=0; - switch( - exception_detail::clone_current_exception(e) ) + try { - case exception_detail::clone_current_exception_result:: - success: - { - BOOST_ASSERT(e!=0); - return exception_ptr(shared_ptr(e)); - } - case exception_detail::clone_current_exception_result:: - bad_alloc: - { - BOOST_ASSERT(!e); - return exception_detail::exception_ptr_static_exception_object::e; - } - case exception_detail::clone_current_exception_result:: - bad_exception: - { - BOOST_ASSERT(!e); - return exception_detail::exception_ptr_static_exception_object::e; - } - default: - BOOST_ASSERT(0); - case exception_detail::clone_current_exception_result:: - not_supported: - { - BOOST_ASSERT(!e); - try - { - throw; - } - catch( - exception_detail::clone_base & e ) - { - return exception_ptr(shared_ptr(e.clone())); - } - catch( - std::domain_error & e ) - { - return exception_detail::current_exception_std_exception(e); - } - catch( - std::invalid_argument & e ) - { - return exception_detail::current_exception_std_exception(e); - } - catch( - std::length_error & e ) - { - return exception_detail::current_exception_std_exception(e); - } - catch( - std::out_of_range & e ) - { - return exception_detail::current_exception_std_exception(e); - } - catch( - std::logic_error & e ) - { - return exception_detail::current_exception_std_exception(e); - } - catch( - std::range_error & e ) - { - return exception_detail::current_exception_std_exception(e); - } - catch( - std::overflow_error & e ) - { - return exception_detail::current_exception_std_exception(e); - } - catch( - std::underflow_error & e ) - { - return exception_detail::current_exception_std_exception(e); - } - catch( - std::ios_base::failure & e ) - { - return exception_detail::current_exception_std_exception(e); - } - catch( - std::runtime_error & e ) - { - return exception_detail::current_exception_std_exception(e); - } - catch( - std::bad_alloc & e ) - { - return exception_detail::current_exception_std_exception(e); - } + throw; + } + catch( + exception_detail::clone_base & e ) + { + return exception_ptr(shared_ptr(e.clone())); + } + catch( + std::domain_error & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::invalid_argument & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::length_error & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::out_of_range & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::logic_error & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::range_error & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::overflow_error & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::underflow_error & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::ios_base::failure & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::runtime_error & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::bad_alloc & e ) + { + return exception_detail::current_exception_std_exception(e); + } #ifndef BOOST_NO_TYPEID - catch( - std::bad_cast & e ) - { - return exception_detail::current_exception_std_exception(e); - } - catch( - std::bad_typeid & e ) - { - return exception_detail::current_exception_std_exception(e); - } + catch( + std::bad_cast & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::bad_typeid & e ) + { + return exception_detail::current_exception_std_exception(e); + } #endif - catch( - std::bad_exception & e ) - { - return exception_detail::current_exception_std_exception(e); - } - catch( - std::exception & e ) - { - return exception_detail::current_exception_unknown_std_exception(e); - } - catch( - boost::exception & e ) - { - return exception_detail::current_exception_unknown_boost_exception(e); - } - catch( - ... ) - { - return exception_detail::current_exception_unknown_exception(); - } - } + catch( + std::bad_exception & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::exception & e ) + { + return exception_detail::current_exception_unknown_std_exception(e); + } + catch( + boost::exception & e ) + { + return exception_detail::current_exception_unknown_boost_exception(e); + } + catch( + ... ) + { + return exception_detail::current_exception_unknown_exception(); } } } diff --git a/include/boost/exception/exception_data.hpp b/include/boost/exception/exception_data.hpp new file mode 100644 index 0000000..cf2ded1 --- /dev/null +++ b/include/boost/exception/exception_data.hpp @@ -0,0 +1,81 @@ +//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc. + +//Distributed under the Boost Software License, Version 1.0. (See accompanying +//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef UUID_D63C9FFE03C611E7B6F710AB63EDCBF1 +#define UUID_D63C9FFE03C611E7B6F710AB63EDCBF1 + +namespace +boost + { + class + exception_datum + { + exception_datum( exception_datum const & ); + exception_datum & operator=( exception_datum const & ); + std::type_info ti_; + shared_ptr v_; + public: + explicit + template + exception_datum( T const & v ): + ti_(typeid(T)), + v_(make_shared(v)) + { + } + template + T * + cast() + { + if( typeid(T)==ti_ ) + return static_cast(v_.get()); + else + return 0; + } + }; + class + exception_data + { + std::map data_; + protected: + exception_data() + { + } + ~exception_data() + { + } + public: + template + exception_data & + set( char const * tag, T const & value ) + { + data_[tag]=exception_datum(value); + return *this; + } + template + T const * + get( char const * tag ) const + { + auto it=data_.find(tag); + if( it!=data_.end() ) + return it->cast(); + else + return 0; + } + }; + } + +catch( +exception_data & d ) + { + d["file_name"].set("foo.txt"); + d["file_name"].get(); + + d.set("file_name","foo.txt"); + throw; + } + +throw_exception(foo_error(),make_pair("errno",errno),pair("width",width)); + +#endif diff --git a/src/clone_current_exception_non_intrusive.cpp b/src/clone_current_exception_non_intrusive.cpp deleted file mode 100644 index 1710cd7..0000000 --- a/src/clone_current_exception_non_intrusive.cpp +++ /dev/null @@ -1,320 +0,0 @@ -//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc. - -//Distributed under the Boost Software License, Version 1.0. (See accompanying -//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -//This MSVC-specific cpp file implements non-intrusive cloning of exception objects. -//Based on an exception_ptr implementation by Anthony Williams. - -#ifdef BOOST_NO_EXCEPTIONS -#error This file requires exception handling to be enabled. -#endif - -#include - -#if defined(BOOST_ENABLE_NON_INTRUSIVE_EXCEPTION_PTR) && defined(_MSC_VER) && defined(_M_IX86) && !defined(_M_X64) - -//Non-intrusive cloning support implemented below, only for MSVC versions mentioned above. -//Thanks Anthony Williams! - -#include -#include -#ifndef BOOST_NO_RTTI -#include -#endif -#include -#include - -namespace - { - unsigned const exception_maximum_parameters=15; - unsigned const exception_noncontinuable=1; - -#if _MSC_VER==1310 - int const exception_info_offset=0x74; -#elif (_MSC_VER==1400 || _MSC_VER==1500) - int const exception_info_offset=0x80; -#else - int const exception_info_offset=-1; -#endif - - struct - exception_record - { - unsigned long ExceptionCode; - unsigned long ExceptionFlags; - exception_record * ExceptionRecord; - void * ExceptionAddress; - unsigned long NumberParameters; - ULONG_PTR ExceptionInformation[exception_maximum_parameters]; - }; - - struct - exception_pointers - { - exception_record * ExceptionRecord; - void * ContextRecord; - }; - - unsigned const cpp_exception_code=0xE06D7363; - unsigned const cpp_exception_magic_flag=0x19930520; - unsigned const cpp_exception_parameter_count=3; - - struct - dummy_exception_type - { - }; - - typedef int(dummy_exception_type::*normal_copy_constructor_ptr)(void * src); - typedef int(dummy_exception_type::*copy_constructor_with_virtual_base_ptr)(void * src,void * dst); - typedef void (dummy_exception_type::*destructor_ptr)(); - - union - cpp_copy_constructor - { - normal_copy_constructor_ptr normal_copy_constructor; - copy_constructor_with_virtual_base_ptr copy_constructor_with_virtual_base; - }; - - enum - cpp_type_flags - { - class_is_simple_type=1, - class_has_virtual_base=4 - }; - - struct - cpp_type_info - { - unsigned flags; -#ifndef BOOST_NO_RTTI - void const * type_info; -#else - std::type_info * type_info; -#endif - int this_offset; - int vbase_descr; - int vbase_offset; - unsigned long size; - cpp_copy_constructor copy_constructor; - }; - - struct - cpp_type_info_table - { - unsigned count; - const cpp_type_info * info[1]; - }; - - struct - cpp_exception_type - { - unsigned flags; - destructor_ptr destructor; - void(*custom_handler)(); - cpp_type_info_table const * type_info_table; - }; - - struct - exception_object_deleter - { - cpp_exception_type const & et_; - - exception_object_deleter( cpp_exception_type const & et ): - et_(et) - { - } - - void - operator()( void * obj ) - { - BOOST_ASSERT(obj!=0); - dummy_exception_type * dummy_exception_ptr=reinterpret_cast(obj); - (dummy_exception_ptr->*(et_.destructor))(); - free(obj); - } - }; - - cpp_type_info const & - get_cpp_type_info( cpp_exception_type const & et ) - { - cpp_type_info const * ti = et.type_info_table->info[0]; - BOOST_ASSERT(ti!=0); - return *ti; - } - - void - copy_msvc_exception( void * dst, void * src, cpp_type_info const & ti ) - { - if( !(ti.flags & class_is_simple_type) && ti.copy_constructor.normal_copy_constructor ) - { - dummy_exception_type * dummy_exception_ptr = reinterpret_cast(dst); - if( ti.flags & class_has_virtual_base ) - (dummy_exception_ptr->*(ti.copy_constructor.copy_constructor_with_virtual_base))(src,dst); - else - (dummy_exception_ptr->*(ti.copy_constructor.normal_copy_constructor))(src); - } - else - memmove(dst,src,ti.size); - } - - boost::shared_ptr - clone_msvc_exception( void * src, cpp_exception_type const & et ) - { - assert(src!=0); - cpp_type_info const & ti=get_cpp_type_info(et); - if( void * dst = malloc(ti.size) ) - { - try - { - copy_msvc_exception(dst,src,ti); - } - catch( - ... ) - { - free(dst); - throw; - } - return boost::shared_ptr(dst,exception_object_deleter(et)); - } - else - throw std::bad_alloc(); - } - - class - cloned_exception: - public boost::exception_detail::clone_base - { - cloned_exception( cloned_exception const & ); - cloned_exception & operator=( cloned_exception const & ); - - cpp_exception_type const & et_; - boost::shared_ptr exc_; - - public: - - cloned_exception( void * exc, cpp_exception_type const & et ): - et_(et), - exc_(clone_msvc_exception(exc,et_)) - { - } - - ~cloned_exception() throw() - { - } - - boost::exception_detail::clone_base const * - clone() const - { - return new cloned_exception(exc_.get(),et_); - } - - void - rethrow() const - { - cpp_type_info const & ti=get_cpp_type_info(et_); - void * dst = _alloca(ti.size); - copy_msvc_exception(dst,exc_.get(),ti); - ULONG_PTR args[cpp_exception_parameter_count]; - args[0]=cpp_exception_magic_flag; - args[1]=reinterpret_cast(dst); - args[2]=reinterpret_cast(&et_); - RaiseException(cpp_exception_code,EXCEPTION_NONCONTINUABLE,cpp_exception_parameter_count,args); - } - }; - - bool - is_cpp_exception( EXCEPTION_RECORD const * record ) - { - return record && - (record->ExceptionCode==cpp_exception_code) && - (record->NumberParameters==cpp_exception_parameter_count) && - (record->ExceptionInformation[0]==cpp_exception_magic_flag); - } - - unsigned long - exception_cloning_filter( int & result, boost::exception_detail::clone_base const * & ptr, void * info_ ) - { - BOOST_ASSERT(exception_info_offset>=0); - BOOST_ASSERT(info_!=0); - EXCEPTION_POINTERS * info=reinterpret_cast(info_); - EXCEPTION_RECORD * record=info->ExceptionRecord; - if( is_cpp_exception(record) ) - { - if( !record->ExceptionInformation[2] ) - record = *reinterpret_cast(reinterpret_cast(_errno())+exception_info_offset); - if( is_cpp_exception(record) && record->ExceptionInformation[2] ) - try - { - ptr = new cloned_exception( - reinterpret_cast(record->ExceptionInformation[1]), - *reinterpret_cast(record->ExceptionInformation[2])); - result = boost::exception_detail::clone_current_exception_result::success; - } - catch( - std::bad_alloc & ) - { - result = boost::exception_detail::clone_current_exception_result::bad_alloc; - } - catch( - ... ) - { - result = boost::exception_detail::clone_current_exception_result::bad_exception; - } - } - return EXCEPTION_EXECUTE_HANDLER; - } - } - -namespace -boost - { - namespace - exception_detail - { - int - clone_current_exception_non_intrusive( clone_base const * & cloned ) - { - BOOST_ASSERT(!cloned); - int result = clone_current_exception_result::not_supported; - if( exception_info_offset>=0 ) - { - clone_base const * ptr=0; - __try - { - throw; - } - __except(exception_cloning_filter(result,ptr,GetExceptionInformation())) - { - } - if( result==clone_current_exception_result::success ) - cloned=ptr; - } - BOOST_ASSERT(result!=clone_current_exception_result::success || cloned); - return result; - } - } - } - -#else - -//On all other compilers, return clone_current_exception_result::not_supported. -//On such platforms, only the intrusive enable_current_exception() cloning will work. - -#include - -namespace -boost - { - namespace - exception_detail - { - int - clone_current_exception_non_intrusive( clone_base const * & ) - { - return clone_current_exception_result::not_supported; - } - } - } - -#endif diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 53d277f..97bc3ec 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -44,7 +44,6 @@ run refcount_ptr_test.cpp ; run current_exception_cast_test.cpp ; run no_exceptions_test.cpp : : : off ; run errinfos_test.cpp ; -run exception_ptr_test.cpp/BOOST_ENABLE_NON_INTRUSIVE_EXCEPTION_PTR ../../thread/src/tss_null.cpp /boost/exception /boost//thread : : : multi : non_intrusive_exception_ptr_test ; run exception_ptr_test.cpp ../../thread/src/tss_null.cpp /boost//thread : : : multi ; run N3757_test.cpp ; diff --git a/test/cloning_test.cpp b/test/cloning_test.cpp index c5a4ae9..70010aa 100644 --- a/test/cloning_test.cpp +++ b/test/cloning_test.cpp @@ -395,11 +395,6 @@ main() BOOST_TEST(false); } catch( - derives_std_exception & ) - { - //Yay! Non-intrusive cloning supported! - } - catch( boost::unknown_exception & e ) { #ifndef BOOST_NO_RTTI @@ -449,14 +444,6 @@ main() BOOST_TEST(false); } catch( - derives_std_boost_exception & x ) - { - //Yay! Non-intrusive cloning supported! - BOOST_TEST(boost::get_error_info(x)); - if( int const * p=boost::get_error_info(x) ) - BOOST_TEST(*p==42); - } - catch( boost::unknown_exception & x ) { BOOST_TEST(boost::get_error_info(x)); @@ -518,14 +505,6 @@ main() BOOST_TEST(false); } catch( - derives_boost_exception & x ) - { - //Yay! Non-intrusive cloning supported! - BOOST_TEST(boost::get_error_info(x)); - if( int const * p=boost::get_error_info(x) ) - BOOST_TEST(*p==42); - } - catch( boost::unknown_exception & x ) { BOOST_TEST(boost::get_error_info(x)); diff --git a/test/unknown_exception_test.cpp b/test/unknown_exception_test.cpp index bf474ba..4918b44 100644 --- a/test/unknown_exception_test.cpp +++ b/test/unknown_exception_test.cpp @@ -62,15 +62,6 @@ main() BOOST_TEST(false); } catch( - boost::exception & x ) - { - //Yay! Non-intrusive cloning supported! - if( int const * d=boost::get_error_info(x) ) - BOOST_TEST( 42==*d ); - else - BOOST_TEST(false); - } - catch( ... ) { BOOST_TEST(false); @@ -110,11 +101,6 @@ main() { } catch( - std::exception & ) - { - //Yay! Non-intrusive cloning supported! - } - catch( ... ) { BOOST_TEST(false); @@ -128,11 +114,6 @@ main() { } catch( - std::exception & ) - { - //Yay! Non-intrusive cloning supported! - } - catch( ... ) { BOOST_TEST(false); From 10550b69d4239cd98ce35cffa5f1c26a56e0df7e Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Mon, 13 Mar 2017 16:08:34 -0700 Subject: [PATCH 16/24] Deleting accidentally committed file. --- include/boost/exception/exception_data.hpp | 81 ---------------------- 1 file changed, 81 deletions(-) delete mode 100644 include/boost/exception/exception_data.hpp diff --git a/include/boost/exception/exception_data.hpp b/include/boost/exception/exception_data.hpp deleted file mode 100644 index cf2ded1..0000000 --- a/include/boost/exception/exception_data.hpp +++ /dev/null @@ -1,81 +0,0 @@ -//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc. - -//Distributed under the Boost Software License, Version 1.0. (See accompanying -//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#ifndef UUID_D63C9FFE03C611E7B6F710AB63EDCBF1 -#define UUID_D63C9FFE03C611E7B6F710AB63EDCBF1 - -namespace -boost - { - class - exception_datum - { - exception_datum( exception_datum const & ); - exception_datum & operator=( exception_datum const & ); - std::type_info ti_; - shared_ptr v_; - public: - explicit - template - exception_datum( T const & v ): - ti_(typeid(T)), - v_(make_shared(v)) - { - } - template - T * - cast() - { - if( typeid(T)==ti_ ) - return static_cast(v_.get()); - else - return 0; - } - }; - class - exception_data - { - std::map data_; - protected: - exception_data() - { - } - ~exception_data() - { - } - public: - template - exception_data & - set( char const * tag, T const & value ) - { - data_[tag]=exception_datum(value); - return *this; - } - template - T const * - get( char const * tag ) const - { - auto it=data_.find(tag); - if( it!=data_.end() ) - return it->cast(); - else - return 0; - } - }; - } - -catch( -exception_data & d ) - { - d["file_name"].set("foo.txt"); - d["file_name"].get(); - - d.set("file_name","foo.txt"); - throw; - } - -throw_exception(foo_error(),make_pair("errno",errno),pair("width",width)); - -#endif From 991d600f0110059bb396428d164bc62840771ba6 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Wed, 15 Mar 2017 11:39:42 -0700 Subject: [PATCH 17/24] Fixing bug in exception_ptr cloning of error_info objects. --- .../exception/detail/error_info_impl.hpp | 8 +++-- include/boost/exception/info.hpp | 6 +++- test/exception_ptr_test.cpp | 33 +++++++++++++++++++ 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/include/boost/exception/detail/error_info_impl.hpp b/include/boost/exception/detail/error_info_impl.hpp index 1928d4a..9f3e21e 100644 --- a/include/boost/exception/detail/error_info_impl.hpp +++ b/include/boost/exception/detail/error_info_impl.hpp @@ -29,8 +29,7 @@ boost public: virtual std::string name_value_string() const = 0; - - protected: + virtual error_info_base * clone() const = 0; virtual ~error_info_base() throw() @@ -44,6 +43,11 @@ boost error_info: public exception_detail::error_info_base { + error_info_base * + clone() const + { + return new error_info(*this); + } public: typedef T value_type; error_info( value_type const & v ): diff --git a/include/boost/exception/info.hpp b/include/boost/exception/info.hpp index c99578a..f7ac50e 100644 --- a/include/boost/exception/info.hpp +++ b/include/boost/exception/info.hpp @@ -142,7 +142,11 @@ boost refcount_ptr p; error_info_container_impl * c=new error_info_container_impl; p.adopt(c); - c->info_ = info_; + for( error_info_map::const_iterator i=info_.begin(),e=info_.end(); i!=e; ++i ) + { + shared_ptr cp(i->second->clone()); + c->info_.insert(std::make_pair(i->first,cp)); + } return p; } }; diff --git a/test/exception_ptr_test.cpp b/test/exception_ptr_test.cpp index 193fabc..4c626c5 100644 --- a/test/exception_ptr_test.cpp +++ b/test/exception_ptr_test.cpp @@ -121,9 +121,42 @@ check( boost::shared_ptr const & t ) } } +void +test_deep_copy() + { + int const * p1=0; + boost::exception_ptr p; + try + { + BOOST_THROW_EXCEPTION(exc() << answer(42)); + BOOST_ERROR("BOOST_THROW_EXCEPTION didn't throw"); + } + catch( + exc & e ) + { + p1=boost::get_error_info(e); + p=boost::current_exception(); + } + BOOST_TEST(p1!=0); + BOOST_TEST(p); + try + { + boost::rethrow_exception(p); + BOOST_ERROR("rethrow_exception didn't throw"); + } + catch( + exc & e ) + { + int const * p2=boost::get_error_info(e); + BOOST_TEST(p2!=0 && *p2==42); + BOOST_TEST(p2!=p1); + } + } + int main() { + test_deep_copy(); BOOST_TEST(++exc_count==1); try { From 464e7f9d090f50d1597d63c1a6fc60fc14682b3a Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Thu, 30 Mar 2017 16:56:13 -0700 Subject: [PATCH 18/24] error_info rvalue reference constructors changed to use is_nothrow_move_constructible --- .travis.yml | 3 +++ include/boost/exception/detail/error_info_impl.hpp | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 507b9eb..4709f81 100644 --- a/.travis.yml +++ b/.travis.yml @@ -64,6 +64,9 @@ matrix: - os: linux env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=c++0x + - os: linux + env: TOOLSET=clang COMPILER=clang++-3.0 CXXSTD=c++0x + - os: linux env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=c++0x diff --git a/include/boost/exception/detail/error_info_impl.hpp b/include/boost/exception/detail/error_info_impl.hpp index 1928d4a..a3063b2 100644 --- a/include/boost/exception/detail/error_info_impl.hpp +++ b/include/boost/exception/detail/error_info_impl.hpp @@ -7,6 +7,9 @@ #define UUID_CE6983AC753411DDA764247956D89593 #include +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES +#include +#endif #include #include @@ -56,11 +59,11 @@ boost v_(x.v_) { } - error_info( value_type && v ) BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(value_type(std::move(v)))): + error_info( value_type && v ) BOOST_NOEXCEPT_IF(boost::is_nothtrow_move_contluctible::value)): v_(std::move(v)) { } - error_info( error_info && x ) BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(value_type(std::move(x.v_)))): + error_info( error_info && x ) BOOST_NOEXCEPT_IF(boost::is_nothtrow_move_contluctible::value)): v_(std::move(x.v_)) { } From 73f3e4796e7c942de5354ed004a52c79c3a28b9d Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Thu, 30 Mar 2017 17:09:43 -0700 Subject: [PATCH 19/24] Typo --- include/boost/exception/detail/error_info_impl.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/exception/detail/error_info_impl.hpp b/include/boost/exception/detail/error_info_impl.hpp index 2c85d3c..0a7989f 100644 --- a/include/boost/exception/detail/error_info_impl.hpp +++ b/include/boost/exception/detail/error_info_impl.hpp @@ -63,11 +63,11 @@ boost v_(x.v_) { } - error_info( value_type && v ) BOOST_NOEXCEPT_IF(boost::is_nothtrow_move_contluctible::value)): + error_info( T && v ) BOOST_NOEXCEPT_IF(boost::is_nothrow_move_constructible::value)): v_(std::move(v)) { } - error_info( error_info && x ) BOOST_NOEXCEPT_IF(boost::is_nothtrow_move_contluctible::value)): + error_info( error_info && x ) BOOST_NOEXCEPT_IF(boost::is_nothrow_move_constructible::value)): v_(std::move(x.v_)) { } From bed7f3147f586187ea43afb8167ef06f9906e532 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Thu, 30 Mar 2017 17:09:43 -0700 Subject: [PATCH 20/24] Typo --- include/boost/exception/detail/error_info_impl.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/exception/detail/error_info_impl.hpp b/include/boost/exception/detail/error_info_impl.hpp index 2c85d3c..6c48d61 100644 --- a/include/boost/exception/detail/error_info_impl.hpp +++ b/include/boost/exception/detail/error_info_impl.hpp @@ -63,11 +63,11 @@ boost v_(x.v_) { } - error_info( value_type && v ) BOOST_NOEXCEPT_IF(boost::is_nothtrow_move_contluctible::value)): + error_info( T && v ) BOOST_NOEXCEPT_IF(boost::is_nothrow_move_constructible::value): v_(std::move(v)) { } - error_info( error_info && x ) BOOST_NOEXCEPT_IF(boost::is_nothtrow_move_contluctible::value)): + error_info( error_info && x ) BOOST_NOEXCEPT_IF(boost::is_nothrow_move_constructible::value): v_(std::move(x.v_)) { } From e0d31c79abc44d6b8f678a5e4eeea772146d1ee1 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Thu, 30 Mar 2017 18:01:18 -0700 Subject: [PATCH 21/24] Adding clang 3.0? --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 4709f81..77af3a0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,12 +30,14 @@ addons: - g++-4.9 - g++-5 - g++-6 + - clang-3.0 - clang-3.6 - clang-3.7 - clang-3.8 sources: - ubuntu-toolchain-r-test - llvm-toolchain-precise + - llvm-toolchain-precise-3.0 - llvm-toolchain-precise-3.6 - llvm-toolchain-precise-3.7 - llvm-toolchain-precise-3.8 From 7599ec73a2b29d997c2573f848bbbdecc6cecf70 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Thu, 30 Mar 2017 18:06:45 -0700 Subject: [PATCH 22/24] No clang 3.0 --- .travis.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 77af3a0..507b9eb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,14 +30,12 @@ addons: - g++-4.9 - g++-5 - g++-6 - - clang-3.0 - clang-3.6 - clang-3.7 - clang-3.8 sources: - ubuntu-toolchain-r-test - llvm-toolchain-precise - - llvm-toolchain-precise-3.0 - llvm-toolchain-precise-3.6 - llvm-toolchain-precise-3.7 - llvm-toolchain-precise-3.8 @@ -66,9 +64,6 @@ matrix: - os: linux env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=c++0x - - os: linux - env: TOOLSET=clang COMPILER=clang++-3.0 CXXSTD=c++0x - - os: linux env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=c++0x From 32d831c4b2c1b23c44b3665c1fe48c6801929dc3 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Sun, 23 Apr 2017 17:58:28 -0700 Subject: [PATCH 23/24] restoring non-intrusive exception_ptr code --- build/Jamfile.v2 | 14 + .../detail/clone_current_exception.hpp | 56 +++ .../boost/exception/detail/exception_ptr.hpp | 219 +++++++----- src/clone_current_exception_non_intrusive.cpp | 320 ++++++++++++++++++ test/Jamfile.v2 | 1 + test/cloning_test.cpp | 21 ++ test/exception_ptr_test.cpp | 60 ++-- test/unknown_exception_test.cpp | 19 ++ 8 files changed, 586 insertions(+), 124 deletions(-) create mode 100644 build/Jamfile.v2 create mode 100644 include/boost/exception/detail/clone_current_exception.hpp create mode 100644 src/clone_current_exception_non_intrusive.cpp diff --git a/build/Jamfile.v2 b/build/Jamfile.v2 new file mode 100644 index 0000000..fb47659 --- /dev/null +++ b/build/Jamfile.v2 @@ -0,0 +1,14 @@ +# Boost Exception Library build Jamfile +# +# Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc. +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +project boost/exception + : source-location ../src + : requirements static + ; + +lib boost_exception : clone_current_exception_non_intrusive.cpp ; +boost-install boost_exception ; diff --git a/include/boost/exception/detail/clone_current_exception.hpp b/include/boost/exception/detail/clone_current_exception.hpp new file mode 100644 index 0000000..6fc1374 --- /dev/null +++ b/include/boost/exception/detail/clone_current_exception.hpp @@ -0,0 +1,56 @@ +//Copyright (c) 2006-2013 Emil Dotchevski and Reverge Studios, Inc. + +//Distributed under the Boost Software License, Version 1.0. (See accompanying +//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef UUID_81522C0EB56511DFAB613DB0DFD72085 +#define UUID_81522C0EB56511DFAB613DB0DFD72085 +#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma GCC system_header +#endif +#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma warning(push,1) +#endif + +#ifdef BOOST_NO_EXCEPTIONS +# error This header requires exception handling to be enabled. +#endif + +namespace +boost + { + namespace + exception_detail + { + class clone_base; + +#ifdef BOOST_ENABLE_NON_INTRUSIVE_EXCEPTION_PTR + int clone_current_exception_non_intrusive( clone_base const * & cloned ); +#endif + + namespace + clone_current_exception_result + { + int const success=0; + int const bad_alloc=1; + int const bad_exception=2; + int const not_supported=3; + } + + inline + int + clone_current_exception( clone_base const * & cloned ) + { +#ifdef BOOST_ENABLE_NON_INTRUSIVE_EXCEPTION_PTR + return clone_current_exception_non_intrusive(cloned); +#else + return clone_current_exception_result::not_supported; +#endif + } + } + } + +#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#pragma warning(pop) +#endif +#endif diff --git a/include/boost/exception/detail/exception_ptr.hpp b/include/boost/exception/detail/exception_ptr.hpp index 24c4fba..8e19f0d 100644 --- a/include/boost/exception/detail/exception_ptr.hpp +++ b/include/boost/exception/detail/exception_ptr.hpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #ifndef BOOST_NO_RTTI #include @@ -302,101 +303,131 @@ boost exception_ptr current_exception_impl() { - try + exception_detail::clone_base const * e=0; + switch( + exception_detail::clone_current_exception(e) ) { - throw; - } - catch( - exception_detail::clone_base & e ) - { - return exception_ptr(shared_ptr(e.clone())); - } - catch( - std::domain_error & e ) - { - return exception_detail::current_exception_std_exception(e); - } - catch( - std::invalid_argument & e ) - { - return exception_detail::current_exception_std_exception(e); - } - catch( - std::length_error & e ) - { - return exception_detail::current_exception_std_exception(e); - } - catch( - std::out_of_range & e ) - { - return exception_detail::current_exception_std_exception(e); - } - catch( - std::logic_error & e ) - { - return exception_detail::current_exception_std_exception(e); - } - catch( - std::range_error & e ) - { - return exception_detail::current_exception_std_exception(e); - } - catch( - std::overflow_error & e ) - { - return exception_detail::current_exception_std_exception(e); - } - catch( - std::underflow_error & e ) - { - return exception_detail::current_exception_std_exception(e); - } - catch( - std::ios_base::failure & e ) - { - return exception_detail::current_exception_std_exception(e); - } - catch( - std::runtime_error & e ) - { - return exception_detail::current_exception_std_exception(e); - } - catch( - std::bad_alloc & e ) - { - return exception_detail::current_exception_std_exception(e); - } -#ifndef BOOST_NO_TYPEID - catch( - std::bad_cast & e ) - { - return exception_detail::current_exception_std_exception(e); - } - catch( - std::bad_typeid & e ) - { - return exception_detail::current_exception_std_exception(e); - } -#endif - catch( - std::bad_exception & e ) - { - return exception_detail::current_exception_std_exception(e); - } - catch( - std::exception & e ) - { - return exception_detail::current_exception_unknown_std_exception(e); - } - catch( - boost::exception & e ) - { - return exception_detail::current_exception_unknown_boost_exception(e); - } - catch( - ... ) - { - return exception_detail::current_exception_unknown_exception(); + case exception_detail::clone_current_exception_result:: + success: + { + BOOST_ASSERT(e!=0); + return exception_ptr(shared_ptr(e)); + } + case exception_detail::clone_current_exception_result:: + bad_alloc: + { + BOOST_ASSERT(!e); + return exception_detail::exception_ptr_static_exception_object::e; + } + case exception_detail::clone_current_exception_result:: + bad_exception: + { + BOOST_ASSERT(!e); + return exception_detail::exception_ptr_static_exception_object::e; + } + default: + BOOST_ASSERT(0); + case exception_detail::clone_current_exception_result:: + not_supported: + { + BOOST_ASSERT(!e); + try + { + throw; + } + catch( + exception_detail::clone_base & e ) + { + return exception_ptr(shared_ptr(e.clone())); + } + catch( + std::domain_error & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::invalid_argument & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::length_error & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::out_of_range & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::logic_error & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::range_error & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::overflow_error & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::underflow_error & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::ios_base::failure & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::runtime_error & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::bad_alloc & e ) + { + return exception_detail::current_exception_std_exception(e); + } + #ifndef BOOST_NO_TYPEID + catch( + std::bad_cast & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::bad_typeid & e ) + { + return exception_detail::current_exception_std_exception(e); + } + #endif + catch( + std::bad_exception & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::exception & e ) + { + return exception_detail::current_exception_unknown_std_exception(e); + } + catch( + boost::exception & e ) + { + return exception_detail::current_exception_unknown_boost_exception(e); + } + catch( + ... ) + { + return exception_detail::current_exception_unknown_exception(); + } + } } } } diff --git a/src/clone_current_exception_non_intrusive.cpp b/src/clone_current_exception_non_intrusive.cpp new file mode 100644 index 0000000..1710cd7 --- /dev/null +++ b/src/clone_current_exception_non_intrusive.cpp @@ -0,0 +1,320 @@ +//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc. + +//Distributed under the Boost Software License, Version 1.0. (See accompanying +//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +//This MSVC-specific cpp file implements non-intrusive cloning of exception objects. +//Based on an exception_ptr implementation by Anthony Williams. + +#ifdef BOOST_NO_EXCEPTIONS +#error This file requires exception handling to be enabled. +#endif + +#include + +#if defined(BOOST_ENABLE_NON_INTRUSIVE_EXCEPTION_PTR) && defined(_MSC_VER) && defined(_M_IX86) && !defined(_M_X64) + +//Non-intrusive cloning support implemented below, only for MSVC versions mentioned above. +//Thanks Anthony Williams! + +#include +#include +#ifndef BOOST_NO_RTTI +#include +#endif +#include +#include + +namespace + { + unsigned const exception_maximum_parameters=15; + unsigned const exception_noncontinuable=1; + +#if _MSC_VER==1310 + int const exception_info_offset=0x74; +#elif (_MSC_VER==1400 || _MSC_VER==1500) + int const exception_info_offset=0x80; +#else + int const exception_info_offset=-1; +#endif + + struct + exception_record + { + unsigned long ExceptionCode; + unsigned long ExceptionFlags; + exception_record * ExceptionRecord; + void * ExceptionAddress; + unsigned long NumberParameters; + ULONG_PTR ExceptionInformation[exception_maximum_parameters]; + }; + + struct + exception_pointers + { + exception_record * ExceptionRecord; + void * ContextRecord; + }; + + unsigned const cpp_exception_code=0xE06D7363; + unsigned const cpp_exception_magic_flag=0x19930520; + unsigned const cpp_exception_parameter_count=3; + + struct + dummy_exception_type + { + }; + + typedef int(dummy_exception_type::*normal_copy_constructor_ptr)(void * src); + typedef int(dummy_exception_type::*copy_constructor_with_virtual_base_ptr)(void * src,void * dst); + typedef void (dummy_exception_type::*destructor_ptr)(); + + union + cpp_copy_constructor + { + normal_copy_constructor_ptr normal_copy_constructor; + copy_constructor_with_virtual_base_ptr copy_constructor_with_virtual_base; + }; + + enum + cpp_type_flags + { + class_is_simple_type=1, + class_has_virtual_base=4 + }; + + struct + cpp_type_info + { + unsigned flags; +#ifndef BOOST_NO_RTTI + void const * type_info; +#else + std::type_info * type_info; +#endif + int this_offset; + int vbase_descr; + int vbase_offset; + unsigned long size; + cpp_copy_constructor copy_constructor; + }; + + struct + cpp_type_info_table + { + unsigned count; + const cpp_type_info * info[1]; + }; + + struct + cpp_exception_type + { + unsigned flags; + destructor_ptr destructor; + void(*custom_handler)(); + cpp_type_info_table const * type_info_table; + }; + + struct + exception_object_deleter + { + cpp_exception_type const & et_; + + exception_object_deleter( cpp_exception_type const & et ): + et_(et) + { + } + + void + operator()( void * obj ) + { + BOOST_ASSERT(obj!=0); + dummy_exception_type * dummy_exception_ptr=reinterpret_cast(obj); + (dummy_exception_ptr->*(et_.destructor))(); + free(obj); + } + }; + + cpp_type_info const & + get_cpp_type_info( cpp_exception_type const & et ) + { + cpp_type_info const * ti = et.type_info_table->info[0]; + BOOST_ASSERT(ti!=0); + return *ti; + } + + void + copy_msvc_exception( void * dst, void * src, cpp_type_info const & ti ) + { + if( !(ti.flags & class_is_simple_type) && ti.copy_constructor.normal_copy_constructor ) + { + dummy_exception_type * dummy_exception_ptr = reinterpret_cast(dst); + if( ti.flags & class_has_virtual_base ) + (dummy_exception_ptr->*(ti.copy_constructor.copy_constructor_with_virtual_base))(src,dst); + else + (dummy_exception_ptr->*(ti.copy_constructor.normal_copy_constructor))(src); + } + else + memmove(dst,src,ti.size); + } + + boost::shared_ptr + clone_msvc_exception( void * src, cpp_exception_type const & et ) + { + assert(src!=0); + cpp_type_info const & ti=get_cpp_type_info(et); + if( void * dst = malloc(ti.size) ) + { + try + { + copy_msvc_exception(dst,src,ti); + } + catch( + ... ) + { + free(dst); + throw; + } + return boost::shared_ptr(dst,exception_object_deleter(et)); + } + else + throw std::bad_alloc(); + } + + class + cloned_exception: + public boost::exception_detail::clone_base + { + cloned_exception( cloned_exception const & ); + cloned_exception & operator=( cloned_exception const & ); + + cpp_exception_type const & et_; + boost::shared_ptr exc_; + + public: + + cloned_exception( void * exc, cpp_exception_type const & et ): + et_(et), + exc_(clone_msvc_exception(exc,et_)) + { + } + + ~cloned_exception() throw() + { + } + + boost::exception_detail::clone_base const * + clone() const + { + return new cloned_exception(exc_.get(),et_); + } + + void + rethrow() const + { + cpp_type_info const & ti=get_cpp_type_info(et_); + void * dst = _alloca(ti.size); + copy_msvc_exception(dst,exc_.get(),ti); + ULONG_PTR args[cpp_exception_parameter_count]; + args[0]=cpp_exception_magic_flag; + args[1]=reinterpret_cast(dst); + args[2]=reinterpret_cast(&et_); + RaiseException(cpp_exception_code,EXCEPTION_NONCONTINUABLE,cpp_exception_parameter_count,args); + } + }; + + bool + is_cpp_exception( EXCEPTION_RECORD const * record ) + { + return record && + (record->ExceptionCode==cpp_exception_code) && + (record->NumberParameters==cpp_exception_parameter_count) && + (record->ExceptionInformation[0]==cpp_exception_magic_flag); + } + + unsigned long + exception_cloning_filter( int & result, boost::exception_detail::clone_base const * & ptr, void * info_ ) + { + BOOST_ASSERT(exception_info_offset>=0); + BOOST_ASSERT(info_!=0); + EXCEPTION_POINTERS * info=reinterpret_cast(info_); + EXCEPTION_RECORD * record=info->ExceptionRecord; + if( is_cpp_exception(record) ) + { + if( !record->ExceptionInformation[2] ) + record = *reinterpret_cast(reinterpret_cast(_errno())+exception_info_offset); + if( is_cpp_exception(record) && record->ExceptionInformation[2] ) + try + { + ptr = new cloned_exception( + reinterpret_cast(record->ExceptionInformation[1]), + *reinterpret_cast(record->ExceptionInformation[2])); + result = boost::exception_detail::clone_current_exception_result::success; + } + catch( + std::bad_alloc & ) + { + result = boost::exception_detail::clone_current_exception_result::bad_alloc; + } + catch( + ... ) + { + result = boost::exception_detail::clone_current_exception_result::bad_exception; + } + } + return EXCEPTION_EXECUTE_HANDLER; + } + } + +namespace +boost + { + namespace + exception_detail + { + int + clone_current_exception_non_intrusive( clone_base const * & cloned ) + { + BOOST_ASSERT(!cloned); + int result = clone_current_exception_result::not_supported; + if( exception_info_offset>=0 ) + { + clone_base const * ptr=0; + __try + { + throw; + } + __except(exception_cloning_filter(result,ptr,GetExceptionInformation())) + { + } + if( result==clone_current_exception_result::success ) + cloned=ptr; + } + BOOST_ASSERT(result!=clone_current_exception_result::success || cloned); + return result; + } + } + } + +#else + +//On all other compilers, return clone_current_exception_result::not_supported. +//On such platforms, only the intrusive enable_current_exception() cloning will work. + +#include + +namespace +boost + { + namespace + exception_detail + { + int + clone_current_exception_non_intrusive( clone_base const * & ) + { + return clone_current_exception_result::not_supported; + } + } + } + +#endif diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 97bc3ec..53d277f 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -44,6 +44,7 @@ run refcount_ptr_test.cpp ; run current_exception_cast_test.cpp ; run no_exceptions_test.cpp : : : off ; run errinfos_test.cpp ; +run exception_ptr_test.cpp/BOOST_ENABLE_NON_INTRUSIVE_EXCEPTION_PTR ../../thread/src/tss_null.cpp /boost/exception /boost//thread : : : multi : non_intrusive_exception_ptr_test ; run exception_ptr_test.cpp ../../thread/src/tss_null.cpp /boost//thread : : : multi ; run N3757_test.cpp ; diff --git a/test/cloning_test.cpp b/test/cloning_test.cpp index 70010aa..c5a4ae9 100644 --- a/test/cloning_test.cpp +++ b/test/cloning_test.cpp @@ -395,6 +395,11 @@ main() BOOST_TEST(false); } catch( + derives_std_exception & ) + { + //Yay! Non-intrusive cloning supported! + } + catch( boost::unknown_exception & e ) { #ifndef BOOST_NO_RTTI @@ -444,6 +449,14 @@ main() BOOST_TEST(false); } catch( + derives_std_boost_exception & x ) + { + //Yay! Non-intrusive cloning supported! + BOOST_TEST(boost::get_error_info(x)); + if( int const * p=boost::get_error_info(x) ) + BOOST_TEST(*p==42); + } + catch( boost::unknown_exception & x ) { BOOST_TEST(boost::get_error_info(x)); @@ -505,6 +518,14 @@ main() BOOST_TEST(false); } catch( + derives_boost_exception & x ) + { + //Yay! Non-intrusive cloning supported! + BOOST_TEST(boost::get_error_info(x)); + if( int const * p=boost::get_error_info(x) ) + BOOST_TEST(*p==42); + } + catch( boost::unknown_exception & x ) { BOOST_TEST(boost::get_error_info(x)); diff --git a/test/exception_ptr_test.cpp b/test/exception_ptr_test.cpp index 4c626c5..367558c 100644 --- a/test/exception_ptr_test.cpp +++ b/test/exception_ptr_test.cpp @@ -123,40 +123,40 @@ check( boost::shared_ptr const & t ) void test_deep_copy() - { - int const * p1=0; - boost::exception_ptr p; - try - { - BOOST_THROW_EXCEPTION(exc() << answer(42)); - BOOST_ERROR("BOOST_THROW_EXCEPTION didn't throw"); - } - catch( - exc & e ) - { - p1=boost::get_error_info(e); - p=boost::current_exception(); - } - BOOST_TEST(p1!=0); - BOOST_TEST(p); - try - { - boost::rethrow_exception(p); - BOOST_ERROR("rethrow_exception didn't throw"); - } - catch( - exc & e ) - { - int const * p2=boost::get_error_info(e); - BOOST_TEST(p2!=0 && *p2==42); - BOOST_TEST(p2!=p1); - } - } + { + int const * p1=0; + boost::exception_ptr p; + try + { + BOOST_THROW_EXCEPTION(exc() << answer(42)); + BOOST_ERROR("BOOST_THROW_EXCEPTION didn't throw"); + } + catch( + exc & e ) + { + p1=boost::get_error_info(e); + p=boost::current_exception(); + } + BOOST_TEST(p1!=0); + BOOST_TEST(p); + try + { + boost::rethrow_exception(p); + BOOST_ERROR("rethrow_exception didn't throw"); + } + catch( + exc & e ) + { + int const * p2=boost::get_error_info(e); + BOOST_TEST(p2!=0 && *p2==42); + BOOST_TEST(p2!=p1); + } + } int main() { - test_deep_copy(); + test_deep_copy(); BOOST_TEST(++exc_count==1); try { diff --git a/test/unknown_exception_test.cpp b/test/unknown_exception_test.cpp index 4918b44..bf474ba 100644 --- a/test/unknown_exception_test.cpp +++ b/test/unknown_exception_test.cpp @@ -62,6 +62,15 @@ main() BOOST_TEST(false); } catch( + boost::exception & x ) + { + //Yay! Non-intrusive cloning supported! + if( int const * d=boost::get_error_info(x) ) + BOOST_TEST( 42==*d ); + else + BOOST_TEST(false); + } + catch( ... ) { BOOST_TEST(false); @@ -101,6 +110,11 @@ main() { } catch( + std::exception & ) + { + //Yay! Non-intrusive cloning supported! + } + catch( ... ) { BOOST_TEST(false); @@ -114,6 +128,11 @@ main() { } catch( + std::exception & ) + { + //Yay! Non-intrusive cloning supported! + } + catch( ... ) { BOOST_TEST(false); From 1a0e643211fdef4a7ef7745b950633bd6f0572e2 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Sun, 23 Apr 2017 18:09:22 -0700 Subject: [PATCH 24/24] 64-bit support in clone_current_exception_non_intrusive.cpp, thanks Martin Weiss --- src/clone_current_exception_non_intrusive.cpp | 115 +++++++++++------- 1 file changed, 72 insertions(+), 43 deletions(-) diff --git a/src/clone_current_exception_non_intrusive.cpp b/src/clone_current_exception_non_intrusive.cpp index 1710cd7..7ebd7b5 100644 --- a/src/clone_current_exception_non_intrusive.cpp +++ b/src/clone_current_exception_non_intrusive.cpp @@ -10,18 +10,17 @@ #error This file requires exception handling to be enabled. #endif +#include #include -#if defined(BOOST_ENABLE_NON_INTRUSIVE_EXCEPTION_PTR) && defined(_MSC_VER) && defined(_M_IX86) && !defined(_M_X64) +#if defined(BOOST_ENABLE_NON_INTRUSIVE_EXCEPTION_PTR) && defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64)) //Non-intrusive cloning support implemented below, only for MSVC versions mentioned above. //Thanks Anthony Williams! +//Thanks to Martin Weiss for implementing 64-bit support! #include #include -#ifndef BOOST_NO_RTTI -#include -#endif #include #include @@ -32,8 +31,10 @@ namespace #if _MSC_VER==1310 int const exception_info_offset=0x74; -#elif (_MSC_VER==1400 || _MSC_VER==1500) +#elif ((_MSC_VER==1400 || _MSC_VER==1500) && !defined _M_X64) int const exception_info_offset=0x80; +#elif ((_MSC_VER==1400 || _MSC_VER==1500) && defined _M_X64) + int const exception_info_offset=0xE0; #else int const exception_info_offset=-1; #endif @@ -58,7 +59,11 @@ namespace unsigned const cpp_exception_code=0xE06D7363; unsigned const cpp_exception_magic_flag=0x19930520; +#ifdef _M_X64 + unsigned const cpp_exception_parameter_count=4; +#else unsigned const cpp_exception_parameter_count=3; +#endif struct dummy_exception_type @@ -72,10 +77,18 @@ namespace union cpp_copy_constructor { + void * address; normal_copy_constructor_ptr normal_copy_constructor; copy_constructor_with_virtual_base_ptr copy_constructor_with_virtual_base; }; + union + cpp_destructor + { + void * address; + destructor_ptr destructor; + }; + enum cpp_type_flags { @@ -83,45 +96,46 @@ namespace class_has_virtual_base=4 }; + // ATTENTION: On x86 fields such as type_info and copy_constructor are really pointers + // but on 64bit these are 32bit offsets from HINSTANCE. Hints on the 64bit handling from + // http://blogs.msdn.com/b/oldnewthing/archive/2010/07/30/10044061.aspx . struct cpp_type_info { unsigned flags; -#ifndef BOOST_NO_RTTI - void const * type_info; -#else - std::type_info * type_info; -#endif + int type_info; int this_offset; int vbase_descr; int vbase_offset; unsigned long size; - cpp_copy_constructor copy_constructor; + int copy_constructor; }; struct cpp_type_info_table { unsigned count; - const cpp_type_info * info[1]; + int info; }; struct cpp_exception_type { unsigned flags; - destructor_ptr destructor; - void(*custom_handler)(); - cpp_type_info_table const * type_info_table; + int destructor; + int custom_handler; + int type_info_table; }; struct exception_object_deleter { cpp_exception_type const & et_; + size_t image_base_; - exception_object_deleter( cpp_exception_type const & et ): - et_(et) + exception_object_deleter( cpp_exception_type const & et, size_t image_base ): + et_(et), + image_base_(image_base) { } @@ -129,45 +143,54 @@ namespace operator()( void * obj ) { BOOST_ASSERT(obj!=0); - dummy_exception_type * dummy_exception_ptr=reinterpret_cast(obj); - (dummy_exception_ptr->*(et_.destructor))(); + dummy_exception_type* dummy_exception_ptr = static_cast(obj); + if( et_.destructor ) + { + cpp_destructor destructor; + destructor.address = reinterpret_cast(et_.destructor + image_base_); + (dummy_exception_ptr->*(destructor.destructor))(); + } free(obj); } }; cpp_type_info const & - get_cpp_type_info( cpp_exception_type const & et ) + get_cpp_type_info( cpp_exception_type const & et, size_t image_base ) { - cpp_type_info const * ti = et.type_info_table->info[0]; + cpp_type_info_table * const typearray = reinterpret_cast(et.type_info_table + image_base); + cpp_type_info * const ti = reinterpret_cast(typearray->info + image_base); BOOST_ASSERT(ti!=0); return *ti; } void - copy_msvc_exception( void * dst, void * src, cpp_type_info const & ti ) + copy_msvc_exception( void * dst, void * src, cpp_type_info const & ti, size_t image_base ) { - if( !(ti.flags & class_is_simple_type) && ti.copy_constructor.normal_copy_constructor ) + cpp_copy_constructor copy_constructor; + copy_constructor.address = reinterpret_cast(ti.copy_constructor + image_base); + + if( !(ti.flags & class_is_simple_type) && copy_constructor.normal_copy_constructor ) { - dummy_exception_type * dummy_exception_ptr = reinterpret_cast(dst); + dummy_exception_type * dummy_exception_ptr = static_cast(dst); if( ti.flags & class_has_virtual_base ) - (dummy_exception_ptr->*(ti.copy_constructor.copy_constructor_with_virtual_base))(src,dst); + (dummy_exception_ptr->*(copy_constructor.copy_constructor_with_virtual_base))(src,dst); else - (dummy_exception_ptr->*(ti.copy_constructor.normal_copy_constructor))(src); + (dummy_exception_ptr->*(copy_constructor.normal_copy_constructor))(src); } else memmove(dst,src,ti.size); } boost::shared_ptr - clone_msvc_exception( void * src, cpp_exception_type const & et ) + clone_msvc_exception( void * src, cpp_exception_type const & et, size_t image_base ) { - assert(src!=0); - cpp_type_info const & ti=get_cpp_type_info(et); + BOOST_ASSERT(src!=0); + cpp_type_info const & ti=get_cpp_type_info(et,image_base); if( void * dst = malloc(ti.size) ) { try { - copy_msvc_exception(dst,src,ti); + copy_msvc_exception(dst,src,ti,image_base); } catch( ... ) @@ -175,7 +198,7 @@ namespace free(dst); throw; } - return boost::shared_ptr(dst,exception_object_deleter(et)); + return boost::shared_ptr(dst,exception_object_deleter(et,image_base)); } else throw std::bad_alloc(); @@ -189,13 +212,21 @@ namespace cloned_exception & operator=( cloned_exception const & ); cpp_exception_type const & et_; + size_t image_base_; boost::shared_ptr exc_; public: + cloned_exception( EXCEPTION_RECORD const * record ): + et_(*reinterpret_cast(record->ExceptionInformation[2])), + image_base_((cpp_exception_parameter_count==4) ? record->ExceptionInformation[3] : 0), + exc_(clone_msvc_exception(reinterpret_cast(record->ExceptionInformation[1]),et_,image_base_)) + { + } - cloned_exception( void * exc, cpp_exception_type const & et ): + cloned_exception( void * exc, cpp_exception_type const & et, size_t image_base ): et_(et), - exc_(clone_msvc_exception(exc,et_)) + image_base_(image_base), + exc_(clone_msvc_exception(exc,et_,image_base)) { } @@ -206,19 +237,22 @@ namespace boost::exception_detail::clone_base const * clone() const { - return new cloned_exception(exc_.get(),et_); + return new cloned_exception(exc_.get(),et_,image_base_); } void rethrow() const { - cpp_type_info const & ti=get_cpp_type_info(et_); + cpp_type_info const & ti=get_cpp_type_info(et_,image_base_); void * dst = _alloca(ti.size); - copy_msvc_exception(dst,exc_.get(),ti); + copy_msvc_exception(dst,exc_.get(),ti,image_base_); ULONG_PTR args[cpp_exception_parameter_count]; args[0]=cpp_exception_magic_flag; args[1]=reinterpret_cast(dst); args[2]=reinterpret_cast(&et_); + if (cpp_exception_parameter_count==4) + args[3]=image_base_; + RaiseException(cpp_exception_code,EXCEPTION_NONCONTINUABLE,cpp_exception_parameter_count,args); } }; @@ -237,8 +271,7 @@ namespace { BOOST_ASSERT(exception_info_offset>=0); BOOST_ASSERT(info_!=0); - EXCEPTION_POINTERS * info=reinterpret_cast(info_); - EXCEPTION_RECORD * record=info->ExceptionRecord; + EXCEPTION_RECORD* record = static_cast(info_)->ExceptionRecord; if( is_cpp_exception(record) ) { if( !record->ExceptionInformation[2] ) @@ -246,9 +279,7 @@ namespace if( is_cpp_exception(record) && record->ExceptionInformation[2] ) try { - ptr = new cloned_exception( - reinterpret_cast(record->ExceptionInformation[1]), - *reinterpret_cast(record->ExceptionInformation[2])); + ptr = new cloned_exception(record); result = boost::exception_detail::clone_current_exception_result::success; } catch( @@ -301,8 +332,6 @@ boost //On all other compilers, return clone_current_exception_result::not_supported. //On such platforms, only the intrusive enable_current_exception() cloning will work. -#include - namespace boost {