From 68574f5b83f560ab802bef79c6ae5795493efc1d Mon Sep 17 00:00:00 2001 From: antonyzhilin Date: Thu, 8 Feb 2024 11:34:30 +0300 Subject: [PATCH] feat third_party: use system Boost.Stacktrace --- .github/workflows/ci.yml | 2 +- .mapping.json | 36 +- CODEOWNERS | 1 - cmake/Stacktrace.cmake | 28 ++ cmake/templates/Config.cmake.in | 8 +- external-deps/boost.yaml | 161 ------- scripts/docs/en/deps/debian-11.md | 1 + scripts/docs/en/deps/ubuntu-18.04.md | 1 + scripts/docs/en/deps/ubuntu-20.04.md | 1 + scripts/docs/en/deps/ubuntu-21.10.md | 1 + scripts/docs/en/deps/ubuntu-22.04.md | 1 + third_party/Readme.md | 1 - third_party/boost_stacktrace/CMakeLists.txt | 76 ---- third_party/boost_stacktrace/README.md | 17 - .../include/boost/core/demangle.hpp | 128 ------ .../include/boost/stacktrace.hpp | 19 - .../stacktrace/detail/addr2line_impls.hpp | 226 ---------- .../boost/stacktrace/detail/collect_msvc.ipp | 33 -- .../boost/stacktrace/detail/collect_noop.ipp | 25 -- .../stacktrace/detail/collect_unwind.ipp | 72 --- .../boost/stacktrace/detail/frame_decl.hpp | 159 ------- .../boost/stacktrace/detail/frame_msvc.ipp | 390 ---------------- .../boost/stacktrace/detail/frame_noop.ipp | 44 -- .../boost/stacktrace/detail/frame_unwind.ipp | 103 ----- .../stacktrace/detail/libbacktrace_impls.hpp | 236 ---------- .../detail/location_from_symbol.hpp | 105 ----- .../boost/stacktrace/detail/pop_options.h | 12 - .../boost/stacktrace/detail/push_options.h | 39 -- .../stacktrace/detail/safe_dump_noop.ipp | 37 -- .../stacktrace/detail/safe_dump_posix.ipp | 59 --- .../boost/stacktrace/detail/safe_dump_win.ipp | 66 --- .../boost/stacktrace/detail/to_dec_array.hpp | 46 -- .../boost/stacktrace/detail/to_hex_array.hpp | 54 --- .../stacktrace/detail/try_dec_convert.hpp | 29 -- .../stacktrace/detail/unwind_base_impls.hpp | 50 --- .../boost/stacktrace/detail/void_ptr_cast.hpp | 46 -- .../include/boost/stacktrace/frame.hpp | 65 --- .../include/boost/stacktrace/safe_dump_to.hpp | 222 --------- .../include/boost/stacktrace/stacktrace.hpp | 424 ------------------ .../boost/stacktrace/stacktrace_fwd.hpp | 28 -- .../boost_stacktrace/src/addr2line.cpp | 16 - .../boost_stacktrace/src/backtrace.cpp | 16 - third_party/boost_stacktrace/src/basic.cpp | 15 - third_party/boost_stacktrace/src/noop.cpp | 11 - third_party/boost_stacktrace/src/windbg.cpp | 10 - .../boost_stacktrace/src/windbg_cached.cpp | 11 - universal/CMakeLists.txt | 14 +- 47 files changed, 53 insertions(+), 3092 deletions(-) create mode 100644 cmake/Stacktrace.cmake delete mode 100644 external-deps/boost.yaml delete mode 100644 third_party/boost_stacktrace/CMakeLists.txt delete mode 100644 third_party/boost_stacktrace/README.md delete mode 100644 third_party/boost_stacktrace/include/boost/core/demangle.hpp delete mode 100644 third_party/boost_stacktrace/include/boost/stacktrace.hpp delete mode 100644 third_party/boost_stacktrace/include/boost/stacktrace/detail/addr2line_impls.hpp delete mode 100644 third_party/boost_stacktrace/include/boost/stacktrace/detail/collect_msvc.ipp delete mode 100644 third_party/boost_stacktrace/include/boost/stacktrace/detail/collect_noop.ipp delete mode 100644 third_party/boost_stacktrace/include/boost/stacktrace/detail/collect_unwind.ipp delete mode 100644 third_party/boost_stacktrace/include/boost/stacktrace/detail/frame_decl.hpp delete mode 100644 third_party/boost_stacktrace/include/boost/stacktrace/detail/frame_msvc.ipp delete mode 100644 third_party/boost_stacktrace/include/boost/stacktrace/detail/frame_noop.ipp delete mode 100644 third_party/boost_stacktrace/include/boost/stacktrace/detail/frame_unwind.ipp delete mode 100644 third_party/boost_stacktrace/include/boost/stacktrace/detail/libbacktrace_impls.hpp delete mode 100644 third_party/boost_stacktrace/include/boost/stacktrace/detail/location_from_symbol.hpp delete mode 100644 third_party/boost_stacktrace/include/boost/stacktrace/detail/pop_options.h delete mode 100644 third_party/boost_stacktrace/include/boost/stacktrace/detail/push_options.h delete mode 100644 third_party/boost_stacktrace/include/boost/stacktrace/detail/safe_dump_noop.ipp delete mode 100644 third_party/boost_stacktrace/include/boost/stacktrace/detail/safe_dump_posix.ipp delete mode 100644 third_party/boost_stacktrace/include/boost/stacktrace/detail/safe_dump_win.ipp delete mode 100644 third_party/boost_stacktrace/include/boost/stacktrace/detail/to_dec_array.hpp delete mode 100644 third_party/boost_stacktrace/include/boost/stacktrace/detail/to_hex_array.hpp delete mode 100644 third_party/boost_stacktrace/include/boost/stacktrace/detail/try_dec_convert.hpp delete mode 100644 third_party/boost_stacktrace/include/boost/stacktrace/detail/unwind_base_impls.hpp delete mode 100644 third_party/boost_stacktrace/include/boost/stacktrace/detail/void_ptr_cast.hpp delete mode 100644 third_party/boost_stacktrace/include/boost/stacktrace/frame.hpp delete mode 100644 third_party/boost_stacktrace/include/boost/stacktrace/safe_dump_to.hpp delete mode 100644 third_party/boost_stacktrace/include/boost/stacktrace/stacktrace.hpp delete mode 100644 third_party/boost_stacktrace/include/boost/stacktrace/stacktrace_fwd.hpp delete mode 100644 third_party/boost_stacktrace/src/addr2line.cpp delete mode 100644 third_party/boost_stacktrace/src/backtrace.cpp delete mode 100644 third_party/boost_stacktrace/src/basic.cpp delete mode 100644 third_party/boost_stacktrace/src/noop.cpp delete mode 100644 third_party/boost_stacktrace/src/windbg.cpp delete mode 100644 third_party/boost_stacktrace/src/windbg_cached.cpp diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 718555b973ed..f335375dbddf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -134,7 +134,7 @@ jobs: [[ -z "${GITHUB_BASE_REF}" ]] && BRANCH_VAR=HEAD~1 || BRANCH_VAR=origin/${GITHUB_BASE_REF} echo "${BRANCH_VAR}" echo "$(git diff --name-only ${BRANCH_VAR})" - EXCLUDE_PATTERNS="-e '.pb.cc' -e '.pb.cpp' -e 'benchmark.cpp' -e '/boost_stacktrace/' -e '/pq-extra/' -e '/tools/' -e 'third_party' " + EXCLUDE_PATTERNS="-e '.pb.cc' -e '.pb.cpp' -e 'benchmark.cpp' -e '/pq-extra/' -e '/tools/' -e 'third_party' " LIST_CHECK_FILES=$(git diff --name-only ${BRANCH_VAR} | grep --color=never '.cpp' | grep -v ${EXCLUDE_PATTERNS} | tr '\n' ' ') if [[ -n ${LIST_CHECK_FILES} ]] then diff --git a/.mapping.json b/.mapping.json index 686c864c27fd..22f66a3501b5 100644 --- a/.mapping.json +++ b/.mapping.json @@ -168,6 +168,7 @@ "cmake/SetupLTO.cmake":"taxi/uservices/userver/cmake/SetupLTO.cmake", "cmake/SetupLinker.cmake":"taxi/uservices/userver/cmake/SetupLinker.cmake", "cmake/SetupProtobuf.cmake":"taxi/uservices/userver/cmake/SetupProtobuf.cmake", + "cmake/Stacktrace.cmake":"taxi/uservices/userver/cmake/Stacktrace.cmake", "cmake/UserverCxxCompileOptionsIfSupported.cmake":"taxi/uservices/userver/cmake/UserverCxxCompileOptionsIfSupported.cmake", "cmake/UserverRequireDWCAS.cmake":"taxi/uservices/userver/cmake/UserverRequireDWCAS.cmake", "cmake/UserverRequireDWCAS.cpp":"taxi/uservices/userver/cmake/UserverRequireDWCAS.cpp", @@ -1415,7 +1416,6 @@ "external-deps/UserverGBench.yaml":"taxi/uservices/userver/external-deps/UserverGBench.yaml", "external-deps/UserverGTest.yaml":"taxi/uservices/userver/external-deps/UserverGTest.yaml", "external-deps/UserverGrpc.yaml":"taxi/uservices/userver/external-deps/UserverGrpc.yaml", - "external-deps/boost.yaml":"taxi/uservices/userver/external-deps/boost.yaml", "external-deps/bson.yaml":"taxi/uservices/userver/external-deps/bson.yaml", "external-deps/c-ares.yaml":"taxi/uservices/userver/external-deps/c-ares.yaml", "external-deps/cctz.yaml":"taxi/uservices/userver/external-deps/cctz.yaml", @@ -2867,40 +2867,6 @@ "testsuite/tests/test_tcp_chaos.py":"taxi/uservices/userver/testsuite/tests/test_tcp_chaos.py", "testsuite/tests/test_udp_chaos.py":"taxi/uservices/userver/testsuite/tests/test_udp_chaos.py", "third_party/Readme.md":"taxi/uservices/userver/third_party/Readme.md", - "third_party/boost_stacktrace/CMakeLists.txt":"taxi/uservices/userver/third_party/boost_stacktrace/CMakeLists.txt", - "third_party/boost_stacktrace/README.md":"taxi/uservices/userver/third_party/boost_stacktrace/README.md", - "third_party/boost_stacktrace/include/boost/core/demangle.hpp":"taxi/uservices/userver/third_party/boost_stacktrace/include/boost/core/demangle.hpp", - "third_party/boost_stacktrace/include/boost/stacktrace.hpp":"taxi/uservices/userver/third_party/boost_stacktrace/include/boost/stacktrace.hpp", - "third_party/boost_stacktrace/include/boost/stacktrace/detail/addr2line_impls.hpp":"taxi/uservices/userver/third_party/boost_stacktrace/include/boost/stacktrace/detail/addr2line_impls.hpp", - "third_party/boost_stacktrace/include/boost/stacktrace/detail/collect_msvc.ipp":"taxi/uservices/userver/third_party/boost_stacktrace/include/boost/stacktrace/detail/collect_msvc.ipp", - "third_party/boost_stacktrace/include/boost/stacktrace/detail/collect_noop.ipp":"taxi/uservices/userver/third_party/boost_stacktrace/include/boost/stacktrace/detail/collect_noop.ipp", - "third_party/boost_stacktrace/include/boost/stacktrace/detail/collect_unwind.ipp":"taxi/uservices/userver/third_party/boost_stacktrace/include/boost/stacktrace/detail/collect_unwind.ipp", - "third_party/boost_stacktrace/include/boost/stacktrace/detail/frame_decl.hpp":"taxi/uservices/userver/third_party/boost_stacktrace/include/boost/stacktrace/detail/frame_decl.hpp", - "third_party/boost_stacktrace/include/boost/stacktrace/detail/frame_msvc.ipp":"taxi/uservices/userver/third_party/boost_stacktrace/include/boost/stacktrace/detail/frame_msvc.ipp", - "third_party/boost_stacktrace/include/boost/stacktrace/detail/frame_noop.ipp":"taxi/uservices/userver/third_party/boost_stacktrace/include/boost/stacktrace/detail/frame_noop.ipp", - "third_party/boost_stacktrace/include/boost/stacktrace/detail/frame_unwind.ipp":"taxi/uservices/userver/third_party/boost_stacktrace/include/boost/stacktrace/detail/frame_unwind.ipp", - "third_party/boost_stacktrace/include/boost/stacktrace/detail/libbacktrace_impls.hpp":"taxi/uservices/userver/third_party/boost_stacktrace/include/boost/stacktrace/detail/libbacktrace_impls.hpp", - "third_party/boost_stacktrace/include/boost/stacktrace/detail/location_from_symbol.hpp":"taxi/uservices/userver/third_party/boost_stacktrace/include/boost/stacktrace/detail/location_from_symbol.hpp", - "third_party/boost_stacktrace/include/boost/stacktrace/detail/pop_options.h":"taxi/uservices/userver/third_party/boost_stacktrace/include/boost/stacktrace/detail/pop_options.h", - "third_party/boost_stacktrace/include/boost/stacktrace/detail/push_options.h":"taxi/uservices/userver/third_party/boost_stacktrace/include/boost/stacktrace/detail/push_options.h", - "third_party/boost_stacktrace/include/boost/stacktrace/detail/safe_dump_noop.ipp":"taxi/uservices/userver/third_party/boost_stacktrace/include/boost/stacktrace/detail/safe_dump_noop.ipp", - "third_party/boost_stacktrace/include/boost/stacktrace/detail/safe_dump_posix.ipp":"taxi/uservices/userver/third_party/boost_stacktrace/include/boost/stacktrace/detail/safe_dump_posix.ipp", - "third_party/boost_stacktrace/include/boost/stacktrace/detail/safe_dump_win.ipp":"taxi/uservices/userver/third_party/boost_stacktrace/include/boost/stacktrace/detail/safe_dump_win.ipp", - "third_party/boost_stacktrace/include/boost/stacktrace/detail/to_dec_array.hpp":"taxi/uservices/userver/third_party/boost_stacktrace/include/boost/stacktrace/detail/to_dec_array.hpp", - "third_party/boost_stacktrace/include/boost/stacktrace/detail/to_hex_array.hpp":"taxi/uservices/userver/third_party/boost_stacktrace/include/boost/stacktrace/detail/to_hex_array.hpp", - "third_party/boost_stacktrace/include/boost/stacktrace/detail/try_dec_convert.hpp":"taxi/uservices/userver/third_party/boost_stacktrace/include/boost/stacktrace/detail/try_dec_convert.hpp", - "third_party/boost_stacktrace/include/boost/stacktrace/detail/unwind_base_impls.hpp":"taxi/uservices/userver/third_party/boost_stacktrace/include/boost/stacktrace/detail/unwind_base_impls.hpp", - "third_party/boost_stacktrace/include/boost/stacktrace/detail/void_ptr_cast.hpp":"taxi/uservices/userver/third_party/boost_stacktrace/include/boost/stacktrace/detail/void_ptr_cast.hpp", - "third_party/boost_stacktrace/include/boost/stacktrace/frame.hpp":"taxi/uservices/userver/third_party/boost_stacktrace/include/boost/stacktrace/frame.hpp", - "third_party/boost_stacktrace/include/boost/stacktrace/safe_dump_to.hpp":"taxi/uservices/userver/third_party/boost_stacktrace/include/boost/stacktrace/safe_dump_to.hpp", - "third_party/boost_stacktrace/include/boost/stacktrace/stacktrace.hpp":"taxi/uservices/userver/third_party/boost_stacktrace/include/boost/stacktrace/stacktrace.hpp", - "third_party/boost_stacktrace/include/boost/stacktrace/stacktrace_fwd.hpp":"taxi/uservices/userver/third_party/boost_stacktrace/include/boost/stacktrace/stacktrace_fwd.hpp", - "third_party/boost_stacktrace/src/addr2line.cpp":"taxi/uservices/userver/third_party/boost_stacktrace/src/addr2line.cpp", - "third_party/boost_stacktrace/src/backtrace.cpp":"taxi/uservices/userver/third_party/boost_stacktrace/src/backtrace.cpp", - "third_party/boost_stacktrace/src/basic.cpp":"taxi/uservices/userver/third_party/boost_stacktrace/src/basic.cpp", - "third_party/boost_stacktrace/src/noop.cpp":"taxi/uservices/userver/third_party/boost_stacktrace/src/noop.cpp", - "third_party/boost_stacktrace/src/windbg.cpp":"taxi/uservices/userver/third_party/boost_stacktrace/src/windbg.cpp", - "third_party/boost_stacktrace/src/windbg_cached.cpp":"taxi/uservices/userver/third_party/boost_stacktrace/src/windbg_cached.cpp", "third_party/compiler-rt/CMakeLists.txt":"taxi/uservices/userver/third_party/compiler-rt/CMakeLists.txt", "third_party/compiler-rt/LICENSE.TXT":"taxi/uservices/userver/third_party/compiler-rt/LICENSE.TXT", "third_party/compiler-rt/README.md":"taxi/uservices/userver/third_party/compiler-rt/README.md", diff --git a/CODEOWNERS b/CODEOWNERS index 84c6bf381071..6ffb2b25b2a6 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -24,7 +24,6 @@ /clickhouse/ @itrofimow /rabbitmq/ @itrofimow -/third_party/boost_stacktrace/ @antoshkka /third_party/pfr/ @ser-fedorov @antoshkka /third_party/uboost_coro/ @bugaevskiy @antoshkka diff --git a/cmake/Stacktrace.cmake b/cmake/Stacktrace.cmake new file mode 100644 index 000000000000..f8e6b165bde8 --- /dev/null +++ b/cmake/Stacktrace.cmake @@ -0,0 +1,28 @@ +include_guard(GLOBAL) + +function(_make_stacktrace_target TARGET Boost_VERSION_STRING) + # You can choose the implementation depending on your needs. + # See http://boostorg.github.io/stacktrace/stacktrace/configuration_and_build.html for more info. + option(USERVER_FEATURE_STACKTRACE "Allow capturing stacktraces using boost::stacktrace" ON) + + if(USERVER_FEATURE_STACKTRACE AND "${Boost_VERSION_STRING}" VERSION_LESS "1.69.0") + # See https://github.com/boostorg/stacktrace/commit/4123beb4af6ff4e36769905b87c206da39190847 + message(WARNING + "Pre-1.69 Boost.Stacktrace consumes a lot of memory and " + "decodes stack slowly. Disabling stacktrace support." + ) + set(USERVER_FEATURE_STACKTRACE OFF) + endif() + + if(CMAKE_SYSTEM_NAME MATCHES "Darwin" OR "${CMAKE_SYSTEM}" MATCHES "BSD") + set(USERVER_FEATURE_STACKTRACE OFF) + endif() + + add_library(userver-stacktrace INTERFACE) + if(USERVER_FEATURE_STACKTRACE) + target_link_libraries("${TARGET}" INTERFACE Boost::stacktrace_backtrace backtrace dl) + else() + target_link_libraries("${TARGET}" INTERFACE Boost::stacktrace_basic dl) + endif() + target_compile_definitions("${TARGET}" INTERFACE BOOST_STACKTRACE_LINK) +endfunction() diff --git a/cmake/templates/Config.cmake.in b/cmake/templates/Config.cmake.in index b92784850c8b..21a81f0a2628 100644 --- a/cmake/templates/Config.cmake.in +++ b/cmake/templates/Config.cmake.in @@ -10,7 +10,13 @@ check_required_components(Userver) include(CMakeFindDependencyMacro) find_package(Threads) -find_package(Boost REQUIRED COMPONENTS program_options filesystem regex) +find_package(Boost REQUIRED COMPONENTS + program_options + filesystem + regex + stacktrace_basic + stacktrace_backtrace +) find_package(Iconv REQUIRED) find_package(OpenSSL REQUIRED) find_package(fmt "8.1.1" REQUIRED) diff --git a/external-deps/boost.yaml b/external-deps/boost.yaml deleted file mode 100644 index fa1486c5c80c..000000000000 --- a/external-deps/boost.yaml +++ /dev/null @@ -1,161 +0,0 @@ -common-name: Boost -partials: - - name: filesystem - - includes: - find: - - names: - - boost/filesystem/config.hpp - - libraries: - find: - - names: - - boost_filesystem - - debian-names: - - libboost-filesystem-dev - formula-name: boost - rpm-names: - - boost-devel - pacman-names: - - boost - - - name: graph - - includes: - find: - - names: - - boost/graph/astar_search.hpp - - libraries: - find: - - names: - - boost_graph - - debian-names: - - libboost-graph-dev - formula-name: boost - rpm-names: - - boost-devel - pacman-names: - - boost - - - name: iostreams - - includes: - find: - - names: - - boost/iostreams/seek.hpp - - libraries: - find: - - names: - - boost_iostreams - - debian-names: - - libboost-iostreams-dev - formula-name: boost - rpm-names: - - boost-devel - pacman-names: - - boost - - - name: locale - - includes: - find: - - names: - - boost/locale/config.hpp - - libraries: - find: - - names: - - boost_locale - - debian-names: - - libboost-locale-dev - formula-name: boost - rpm-names: - - boost-devel - pacman-names: - - boost - - - name: program_options - - includes: - find: - - names: - - boost/program_options/config.hpp - - libraries: - find: - - names: - - boost_program_options - - debian-names: - - libboost-program-options-dev - formula-name: boost - rpm-names: - - boost-devel - pacman-names: - - boost - - - name: regex - - includes: - find: - - names: - - boost/regex/config.hpp - - libraries: - find: - - names: - - boost_regex - - debian-names: - - libboost-regex-dev - formula-name: boost - rpm-names: - - boost-devel - pacman-names: - - boost - - - name: thread - - includes: - find: - - names: - - boost/thread/mutex.hpp - - libraries: - find: - - names: - - boost_thread - - debian-names: - - libboost-thread-dev - formula-name: boost - rpm-names: - - boost-devel - pacman-names: - - boost - - - name: gregorian - - includes: - find: - - names: - - boost/date_time/gregorian/gregorian.hpp - - libraries: - find: - - names: - - boost_date_time - - debian-names: - - libboost-date-time-dev - formula-name: boost - rpm-names: - - boost-devel - pacman-names: - - boost diff --git a/scripts/docs/en/deps/debian-11.md b/scripts/docs/en/deps/debian-11.md index 3d5ea046abb9..a368d288089b 100644 --- a/scripts/docs/en/deps/debian-11.md +++ b/scripts/docs/en/deps/debian-11.md @@ -7,6 +7,7 @@ libboost-iostreams1.74-dev libboost-locale1.74-dev libboost-program-options1.74-dev libboost-regex1.74-dev +libboost-stacktrace1.74-dev libboost1.74-dev libbson-dev libc-ares-dev diff --git a/scripts/docs/en/deps/ubuntu-18.04.md b/scripts/docs/en/deps/ubuntu-18.04.md index 57a44fb8b259..22da7c7e8a43 100644 --- a/scripts/docs/en/deps/ubuntu-18.04.md +++ b/scripts/docs/en/deps/ubuntu-18.04.md @@ -10,6 +10,7 @@ libboost-iostreams1.65-dev libboost-locale1.65-dev libboost-program-options1.65-dev libboost-regex1.65-dev +libboost-stacktrace1.65-dev libboost1.65-dev libbson-dev libcrypto++-dev diff --git a/scripts/docs/en/deps/ubuntu-20.04.md b/scripts/docs/en/deps/ubuntu-20.04.md index 54118cbda2bc..b9495802ca67 100644 --- a/scripts/docs/en/deps/ubuntu-20.04.md +++ b/scripts/docs/en/deps/ubuntu-20.04.md @@ -10,6 +10,7 @@ libboost-locale1.71-dev libboost-program-options1.71-dev libboost-thread1.71-dev libboost-regex1.71-dev +libboost-stacktrace1.71-dev libboost1.71-dev libbson-dev libcctz-dev diff --git a/scripts/docs/en/deps/ubuntu-21.10.md b/scripts/docs/en/deps/ubuntu-21.10.md index c46ea54cad00..abb085a7361d 100644 --- a/scripts/docs/en/deps/ubuntu-21.10.md +++ b/scripts/docs/en/deps/ubuntu-21.10.md @@ -9,6 +9,7 @@ libboost-iostreams1.74-dev libboost-locale1.74-dev libboost-program-options1.74-dev libboost-regex1.74-dev +libboost-stacktrace1.74-dev libboost1.74-dev libbson-dev libc-ares-dev diff --git a/scripts/docs/en/deps/ubuntu-22.04.md b/scripts/docs/en/deps/ubuntu-22.04.md index cd86adc1b852..4668b8047940 100644 --- a/scripts/docs/en/deps/ubuntu-22.04.md +++ b/scripts/docs/en/deps/ubuntu-22.04.md @@ -9,6 +9,7 @@ libboost-iostreams1.74-dev libboost-locale1.74-dev libboost-program-options1.74-dev libboost-regex1.74-dev +libboost-stacktrace1.74-dev libboost1.74-dev libbson-dev libc-ares-dev diff --git a/third_party/Readme.md b/third_party/Readme.md index 73ea13cee14b..01fb175ea51b 100644 --- a/third_party/Readme.md +++ b/third_party/Readme.md @@ -2,7 +2,6 @@ This folder contains source codes from following open source projects: -* boost_stacktrace: https://github.com/boostorg/stacktrace/commit/7fedfa12654d18a9fa695de258763e93699c4636 (Boost 1.68.0) * pfr: https://github.com/boostorg/pfr/releases/tag/2.2.0 with increased via `python misc/generate_cpp17.py 200 > include/boost/pfr/detail/core17_generated.hpp` fields count limit * moodycamel: https://github.com/cameron314/concurrentqueue/releases/tag/v1.0.3 * rapidjson: https://github.com/Tencent/rapidjson/commit/083f359f5c36198accc2b9360ce1e32a333231d9 with RAPIDJSON_HAS_STDSTRING defined in rapidjson.h diff --git a/third_party/boost_stacktrace/CMakeLists.txt b/third_party/boost_stacktrace/CMakeLists.txt deleted file mode 100644 index 62cd5d3a83b1..000000000000 --- a/third_party/boost_stacktrace/CMakeLists.txt +++ /dev/null @@ -1,76 +0,0 @@ -project(userver-stacktrace CXX) -include(CheckIncludeFile) - -find_package(Boost REQUIRED) # Headers needed - -if(NOT MACOS AND "${CMAKE_SYSTEM}" MATCHES "BSD") - set(STACKTRACE_DEFAULT OFF) -else() - set(STACKTRACE_DEFAULT ON) -endif() - -# You can choose the implementation depending on your needs. -# See http://boostorg.github.io/stacktrace/stacktrace/configuration_and_build.html for more info. -option(USERVER_FEATURE_STACKTRACE "Allow capturing stacktraces using boost::stacktrace" ${STACKTRACE_DEFAULT}) -if (NOT USERVER_FEATURE_STACKTRACE) - set(BACKTRACE_USERVER_SOURCES src/noop.cpp) -elseif (WIN32) - CHECK_INCLUDE_FILE(dbgeng.h HAS_DBGENG_LIBRARY) - if(NOT HAS_DBGENG_LIBRARY) - message(FATAL_ERROR "Failed to find . Use -DUSERVER_FEATURE_STACKTRACE=0 or install the required packages.") - endif() - - set(BACKTRACE_USERVER_SOURCES src/windbg_cached.cpp) - set(BACKTRACE_USERVER_LIBRARIES ole32 dbgeng) - - #set(BACKTRACE_USERVER_SOURCES src/windbg.cpp) - #set(BACKTRACE_USERVER_LIBRARIES ole32 dbgeng) -elseif (MACOS) - set(BACKTRACE_USERVER_SOURCES src/basic.cpp) - set(BACKTRACE_USERVER_LIBRARIES dl) -else() - CHECK_INCLUDE_FILE(backtrace.h HAS_BACKTRACE_LIBRARY) - if (NOT HAS_BACKTRACE_LIBRARY) - # Attempt to find file in GCC specific path - file(GLOB BacktraceIncludeFiles - "/usr/lib/gcc/x86_64-linux-gnu/*/include/backtrace.h" - ) - list(SORT BacktraceIncludeFiles) - list(GET BacktraceIncludeFiles 0 BacktraceIncludeFile) - if (BacktraceIncludeFile) - message(STATUS "Found ${BacktraceIncludeFile}") - else() - message(FATAL_ERROR "Failed to find . Use -DUSERVER_FEATURE_STACKTRACE=0 or install \ - the required packages (for Ubuntu: build-essential or libgcc-*-dev).") - endif() - endif() - - #set(BACKTRACE_USERVER_SOURCES src/addr2line.cpp) - #set(BACKTRACE_USERVER_LIBRARIES dl) - - set(BACKTRACE_USERVER_SOURCES src/backtrace.cpp) - set(BACKTRACE_USERVER_LIBRARIES backtrace dl) - - #set(BACKTRACE_USERVER_SOURCES src/basic.cpp) - #set(BACKTRACE_USERVER_LIBRARIES dl) -endif() - -add_library(${PROJECT_NAME} OBJECT ${BACKTRACE_USERVER_SOURCES}) -if (BacktraceIncludeFile) - target_compile_definitions( - ${PROJECT_NAME} - PRIVATE BOOST_STACKTRACE_BACKTRACE_INCLUDE_FILE=<${BacktraceIncludeFile}> - ) -else() - target_compile_definitions( - ${PROJECT_NAME} PUBLIC BOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED=1 - ) -endif() -target_compile_definitions(${PROJECT_NAME} INTERFACE BOOST_STACKTRACE_LINK) -target_include_directories(${PROJECT_NAME} PUBLIC - $ - ${Boost_INCLUDE_DIRS}) - -target_link_libraries(${PROJECT_NAME} PUBLIC ${BACKTRACE_USERVER_LIBRARIES}) - -userver_install_targets(TARGETS ${PROJECT_NAME}) diff --git a/third_party/boost_stacktrace/README.md b/third_party/boost_stacktrace/README.md deleted file mode 100644 index ed3e97beda79..000000000000 --- a/third_party/boost_stacktrace/README.md +++ /dev/null @@ -1,17 +0,0 @@ -### Stacktrace -Library for storing and printing backtraces. -Taken from https://github.com/boostorg/stacktrace/commit/7fedfa12654d18a9fa695de258763e93699c4636 (Boost 1.68.0) -libbacktrace_impls.hpp updated from upstream https://github.com/boostorg/stacktrace/blob/4123beb4af6ff4e36769905b87c206da39190847/include/boost/stacktrace/detail/libbacktrace_impls.hpp to avoid big memory consumption and to speed up stack decoding. - -[Documentation and examples.](http://boostorg.github.io/stacktrace/index.html) - - -### Test results -@ | Build | Tests coverage | More info -----------------|-------------- | -------------- |----------- -Develop branch: | [![Build Status](https://travis-ci.org/boostorg/stacktrace.svg?branch=develop)](https://travis-ci.org/boostorg/stacktrace) [![Build status](https://ci.appveyor.com/api/projects/status/l3aak4j8k39rx08t/branch/develop?svg=true)](https://ci.appveyor.com/project/apolukhin/stacktrace/branch/develop) | [![Coverage Status](https://coveralls.io/repos/github/boostorg/stacktrace/badge.svg?branch=develop)](https://coveralls.io/github/boostorg/stacktrace?branch=develop) | [details...](http://www.boost.org/development/tests/develop/developer/stacktrace.html) -Master branch: | [![Build Status](https://travis-ci.org/boostorg/stacktrace.svg?branch=master)](https://travis-ci.org/boostorg/stacktrace) [![Build status](https://ci.appveyor.com/api/projects/status/l3aak4j8k39rx08t/branch/master?svg=true)](https://ci.appveyor.com/project/apolukhin/stacktrace/branch/master) | [![Coverage Status](https://coveralls.io/repos/github/boostorg/stacktrace/badge.svg?branch=master)](https://coveralls.io/github/boostorg/stacktrace?branch=master) | [details...](http://www.boost.org/development/tests/master/developer/stacktrace.html) - - -### License -Distributed under the [Boost Software License, Version 1.0](http://boost.org/LICENSE_1_0.txt). diff --git a/third_party/boost_stacktrace/include/boost/core/demangle.hpp b/third_party/boost_stacktrace/include/boost/core/demangle.hpp deleted file mode 100644 index 699a705b8f2b..000000000000 --- a/third_party/boost_stacktrace/include/boost/core/demangle.hpp +++ /dev/null @@ -1,128 +0,0 @@ -#ifndef BOOST_CORE_DEMANGLE_HPP_INCLUDED -#define BOOST_CORE_DEMANGLE_HPP_INCLUDED - -// core::demangle -// -// Copyright 2014 Peter Dimov -// Copyright 2014 Andrey Semashev -// -// 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 - -#if defined(BOOST_HAS_PRAGMA_ONCE) -# pragma once -#endif - -// __has_include is currently supported by GCC and Clang. However GCC 4.9 may have issues and -// returns 1 for 'defined( __has_include )', while '__has_include' is actually not supported: -// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63662 -#if defined( __has_include ) && (!defined( BOOST_GCC ) || (__GNUC__ + 0) >= 5) -# if __has_include() -# define BOOST_CORE_HAS_CXXABI_H -# endif -#elif defined( __GLIBCXX__ ) || defined( __GLIBCPP__ ) -# define BOOST_CORE_HAS_CXXABI_H -#endif - -#if defined( BOOST_CORE_HAS_CXXABI_H ) -# include -// For some archtectures (mips, mips64, x86, x86_64) cxxabi.h in Android NDK is implemented by gabi++ library -// (https://android.googlesource.com/platform/ndk/+/master/sources/cxx-stl/gabi++/), which does not implement -// abi::__cxa_demangle(). We detect this implementation by checking the include guard here. -# if defined( __GABIXX_CXXABI_H__ ) -# undef BOOST_CORE_HAS_CXXABI_H -# else -# include -# include -# endif -#endif - -namespace boost -{ - -namespace core -{ - -inline char const * demangle_alloc( char const * name ) BOOST_NOEXCEPT; -inline void demangle_free( char const * name ) BOOST_NOEXCEPT; - -class scoped_demangled_name -{ -private: - char const * m_p; - -public: - explicit scoped_demangled_name( char const * name ) BOOST_NOEXCEPT : - m_p( demangle_alloc( name ) ) - { - } - - ~scoped_demangled_name() BOOST_NOEXCEPT - { - demangle_free( m_p ); - } - - char const * get() const BOOST_NOEXCEPT - { - return m_p; - } - - scoped_demangled_name( scoped_demangled_name const& ) = delete; - scoped_demangled_name& operator= ( scoped_demangled_name const& ) = delete; -}; - - -#if defined( BOOST_CORE_HAS_CXXABI_H ) - -inline char const * demangle_alloc( char const * name ) BOOST_NOEXCEPT -{ - int status = 0; - std::size_t size = 0; - // NOLINTNEXTLINE(modernize-use-nullptr) - return abi::__cxa_demangle( name, NULL, &size, &status ); -} - -inline void demangle_free( char const * name ) BOOST_NOEXCEPT -{ - // NOLINTNEXTLINE(cppcoreguidelines-no-malloc,cppcoreguidelines-pro-type-const-cast) - std::free( const_cast< char* >( name ) ); -} - -inline std::string demangle( char const * name ) -{ - scoped_demangled_name demangled_name( name ); - char const * p = demangled_name.get(); - if( !p ) - p = name; - return p; -} - -#else - -inline char const * demangle_alloc( char const * name ) BOOST_NOEXCEPT -{ - return name; -} - -inline void demangle_free( char const * ) BOOST_NOEXCEPT -{ -} - -inline std::string demangle( char const * name ) -{ - return name; -} - -#endif - -} // namespace core - -} // namespace boost - -#undef BOOST_CORE_HAS_CXXABI_H - -#endif // #ifndef BOOST_CORE_DEMANGLE_HPP_INCLUDED diff --git a/third_party/boost_stacktrace/include/boost/stacktrace.hpp b/third_party/boost_stacktrace/include/boost/stacktrace.hpp deleted file mode 100644 index 6e1ec0489a1d..000000000000 --- a/third_party/boost_stacktrace/include/boost/stacktrace.hpp +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright Antony Polukhin, 2016-2017. -// -// 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 BOOST_STACKTRACE_HPP -#define BOOST_STACKTRACE_HPP - -#include -#ifdef BOOST_HAS_PRAGMA_ONCE -# pragma once -#endif - -#include -#include -#include - -#endif // BOOST_STACKTRACE_HPP diff --git a/third_party/boost_stacktrace/include/boost/stacktrace/detail/addr2line_impls.hpp b/third_party/boost_stacktrace/include/boost/stacktrace/detail/addr2line_impls.hpp deleted file mode 100644 index aae642242bf1..000000000000 --- a/third_party/boost_stacktrace/include/boost/stacktrace/detail/addr2line_impls.hpp +++ /dev/null @@ -1,226 +0,0 @@ -// Copyright Antony Polukhin, 2016-2018. -// -// 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 BOOST_STACKTRACE_DETAIL_ADDR2LINE_IMPLS_HPP -#define BOOST_STACKTRACE_DETAIL_ADDR2LINE_IMPLS_HPP - -#include -#ifdef BOOST_HAS_PRAGMA_ONCE -# pragma once -#endif - -#include -#include -#include -#include -#include - -#include -#include -#include - - -namespace boost { namespace stacktrace { namespace detail { - - -#if defined(BOOST_STACKTRACE_ADDR2LINE_LOCATION) && !defined(BOOST_NO_CXX11_CONSTEXPR) - -constexpr bool is_abs_path(const char* path) BOOST_NOEXCEPT { - return *path != '\0' && ( - *path == ':' || *path == '/' || is_abs_path(path + 1) - ); -} - -#endif - -class addr2line_pipe { - ::FILE* p; - ::pid_t pid; - -public: - explicit addr2line_pipe(const char *flag, const char* exec_path, const char* addr) BOOST_NOEXCEPT - : p(0) - , pid(0) - { - int pdes[2]; - #ifdef BOOST_STACKTRACE_ADDR2LINE_LOCATION - char prog_name[] = BOOST_STRINGIZE( BOOST_STACKTRACE_ADDR2LINE_LOCATION ); - #if !defined(BOOST_NO_CXX11_CONSTEXPR) && !defined(BOOST_NO_CXX11_STATIC_ASSERT) - static_assert( - boost::stacktrace::detail::is_abs_path( BOOST_STRINGIZE( BOOST_STACKTRACE_ADDR2LINE_LOCATION ) ), - "BOOST_STACKTRACE_ADDR2LINE_LOCATION must be an absolute path" - ); - #endif - - #else - char prog_name[] = "/usr/bin/addr2line"; - #endif - - char* argp[] = { - prog_name, - const_cast(flag), - const_cast(exec_path), - const_cast(addr), - 0 - }; - - if (::pipe(pdes) < 0) { - return; - } - - pid = ::fork(); - switch (pid) { - case -1: - // Failed... - ::close(pdes[0]); - ::close(pdes[1]); - return; - - case 0: - // We are the child. - ::close(STDERR_FILENO); - ::close(pdes[0]); - if (pdes[1] != STDOUT_FILENO) { - ::dup2(pdes[1], STDOUT_FILENO); - } - - // Do not use `execlp()`, `execvp()`, and `execvpe()` here! - // `exec*p*` functions are vulnerable to PATH variable evaluation attacks. - ::execv(prog_name, argp); - ::_exit(127); - } - - p = ::fdopen(pdes[0], "r"); - ::close(pdes[1]); - } - - operator ::FILE*() const BOOST_NOEXCEPT { - return p; - } - - ~addr2line_pipe() BOOST_NOEXCEPT { - if (p) { - ::fclose(p); - int pstat = 0; - ::kill(pid, SIGKILL); - ::waitpid(pid, &pstat, 0); - } - } -}; - -inline std::string addr2line(const char* flag, const void* addr) { - std::string res; - - boost::stacktrace::detail::location_from_symbol loc(addr); - if (!loc.empty()) { - res = loc.name(); - } else { - res.resize(16); - int rlin_size = ::readlink("/proc/self/exe", &res[0], res.size() - 1); - while (rlin_size == static_cast(res.size() - 1)) { - res.resize(res.size() * 4); - rlin_size = ::readlink("/proc/self/exe", &res[0], res.size() - 1); - } - if (rlin_size == -1) { - res.clear(); - return res; - } - res.resize(rlin_size); - } - - addr2line_pipe p(flag, res.c_str(), to_hex_array(addr).data()); - res.clear(); - - if (!p) { - return res; - } - - char data[32]; - while (!::feof(p)) { - if (::fgets(data, sizeof(data), p)) { - res += data; - } else { - break; - } - } - - // Trimming - while (!res.empty() && (res[res.size() - 1] == '\n' || res[res.size() - 1] == '\r')) { - res.erase(res.size() - 1); - } - - return res; -} - - -struct to_string_using_addr2line { - std::string res; - void prepare_function_name(const void* addr) { - res = boost::stacktrace::frame(addr).name(); - } - - bool prepare_source_location(const void* addr) { - //return addr2line("-Cfipe", addr); // Does not seem to work in all cases - std::string source_line = boost::stacktrace::detail::addr2line("-Cpe", addr); - if (!source_line.empty() && source_line[0] != '?') { - res += " at "; - res += source_line; - return true; - } - - return false; - } -}; - -template class to_string_impl_base; -typedef to_string_impl_base to_string_impl; - -inline std::string name_impl(const void* addr) { - std::string res = boost::stacktrace::detail::addr2line("-fe", addr); - res = res.substr(0, res.find_last_of('\n')); - res = boost::core::demangle(res.c_str()); - - if (res == "??") { - res.clear(); - } - - return res; -} - -} // namespace detail - -std::string frame::source_file() const { - std::string res; - res = boost::stacktrace::detail::addr2line("-e", addr_); - res = res.substr(0, res.find_last_of(':')); - if (res == "??") { - res.clear(); - } - - return res; -} - - -std::size_t frame::source_line() const { - std::size_t line_num = 0; - std::string res = boost::stacktrace::detail::addr2line("-e", addr_); - const std::size_t last = res.find_last_of(':'); - if (last == std::string::npos) { - return 0; - } - res = res.substr(last + 1); - - if (!boost::stacktrace::detail::try_dec_convert(res.c_str(), line_num)) { - return 0; - } - - return line_num; -} - - -}} // namespace boost::stacktrace - -#endif // BOOST_STACKTRACE_DETAIL_ADDR2LINE_IMPLS_HPP diff --git a/third_party/boost_stacktrace/include/boost/stacktrace/detail/collect_msvc.ipp b/third_party/boost_stacktrace/include/boost/stacktrace/detail/collect_msvc.ipp deleted file mode 100644 index ebe5904cd0d1..000000000000 --- a/third_party/boost_stacktrace/include/boost/stacktrace/detail/collect_msvc.ipp +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright Antony Polukhin, 2016-2018. -// -// 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 BOOST_STACKTRACE_DETAIL_COLLECT_MSVC_IPP -#define BOOST_STACKTRACE_DETAIL_COLLECT_MSVC_IPP - -#include -#ifdef BOOST_HAS_PRAGMA_ONCE -# pragma once -#endif - -#include - -#include - -namespace boost { namespace stacktrace { namespace detail { - -std::size_t this_thread_frames::collect(native_frame_ptr_t* out_frames, std::size_t max_frames_count, std::size_t skip) BOOST_NOEXCEPT { - return boost::winapi::RtlCaptureStackBackTrace( - static_cast(skip), - static_cast(max_frames_count), - const_cast(out_frames), - 0 - ); -} - - -}}} // namespace boost::stacktrace - -#endif // BOOST_STACKTRACE_DETAIL_COLLECT_MSVC_IPP diff --git a/third_party/boost_stacktrace/include/boost/stacktrace/detail/collect_noop.ipp b/third_party/boost_stacktrace/include/boost/stacktrace/detail/collect_noop.ipp deleted file mode 100644 index 6c7867fec5c2..000000000000 --- a/third_party/boost_stacktrace/include/boost/stacktrace/detail/collect_noop.ipp +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright Antony Polukhin, 2016-2018. -// -// 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 BOOST_STACKTRACE_DETAIL_COLLECT_NOOP_IPP -#define BOOST_STACKTRACE_DETAIL_COLLECT_NOOP_IPP - -#include -#ifdef BOOST_HAS_PRAGMA_ONCE -# pragma once -#endif - -#include - -namespace boost { namespace stacktrace { namespace detail { - -std::size_t this_thread_frames::collect(native_frame_ptr_t* /*out_frames*/, std::size_t /*max_frames_count*/, std::size_t /*skip*/) BOOST_NOEXCEPT { - return 0; -} - -}}} // namespace boost::stacktrace::detail - -#endif // BOOST_STACKTRACE_DETAIL_COLLECT_NOOP_IPP diff --git a/third_party/boost_stacktrace/include/boost/stacktrace/detail/collect_unwind.ipp b/third_party/boost_stacktrace/include/boost/stacktrace/detail/collect_unwind.ipp deleted file mode 100644 index f7c1f82f2bee..000000000000 --- a/third_party/boost_stacktrace/include/boost/stacktrace/detail/collect_unwind.ipp +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright Antony Polukhin, 2016-2018. -// -// 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 BOOST_STACKTRACE_DETAIL_COLLECT_UNWIND_IPP -#define BOOST_STACKTRACE_DETAIL_COLLECT_UNWIND_IPP - -#include -#ifdef BOOST_HAS_PRAGMA_ONCE -# pragma once -#endif - -#include - -#include -#include - -#if !defined(_GNU_SOURCE) && !defined(BOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED) && !defined(BOOST_WINDOWS) -#error "Boost.Stacktrace requires `_Unwind_Backtrace` function. Define `_GNU_SOURCE` macro or `BOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED` if _Unwind_Backtrace is available without `_GNU_SOURCE`." -#endif - -namespace boost { namespace stacktrace { namespace detail { - -struct unwind_state { - std::size_t frames_to_skip; - native_frame_ptr_t* current; - native_frame_ptr_t* end; -}; - -inline _Unwind_Reason_Code unwind_callback(::_Unwind_Context* context, void* arg) { - // Note: do not write `::_Unwind_GetIP` because it is a macro on some platforms. - // Use `_Unwind_GetIP` instead! - unwind_state* const state = static_cast(arg); - if (state->frames_to_skip) { - --state->frames_to_skip; - return _Unwind_GetIP(context) ? ::_URC_NO_REASON : ::_URC_END_OF_STACK; - } - - *state->current = reinterpret_cast( - _Unwind_GetIP(context) - ); - - ++state->current; - if (!*(state->current - 1) || state->current == state->end) { - return ::_URC_END_OF_STACK; - } - return ::_URC_NO_REASON; -} - -std::size_t this_thread_frames::collect(native_frame_ptr_t* out_frames, std::size_t max_frames_count, std::size_t skip) BOOST_NOEXCEPT { - std::size_t frames_count = 0; - if (!max_frames_count) { - return frames_count; - } - - boost::stacktrace::detail::unwind_state state = { skip + 1, out_frames, out_frames + max_frames_count }; - ::_Unwind_Backtrace(&boost::stacktrace::detail::unwind_callback, &state); - frames_count = state.current - out_frames; - - if (frames_count && out_frames[frames_count - 1] == 0) { - -- frames_count; - } - - return frames_count; -} - - -}}} // namespace boost::stacktrace::detail - -#endif // BOOST_STACKTRACE_DETAIL_COLLECT_UNWIND_IPP diff --git a/third_party/boost_stacktrace/include/boost/stacktrace/detail/frame_decl.hpp b/third_party/boost_stacktrace/include/boost/stacktrace/detail/frame_decl.hpp deleted file mode 100644 index ef43bfd7b81d..000000000000 --- a/third_party/boost_stacktrace/include/boost/stacktrace/detail/frame_decl.hpp +++ /dev/null @@ -1,159 +0,0 @@ -// Copyright Antony Polukhin, 2016-2018. -// -// 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 BOOST_STACKTRACE_DETAIL_FRAME_DECL_HPP -#define BOOST_STACKTRACE_DETAIL_FRAME_DECL_HPP - -#include -#ifdef BOOST_HAS_PRAGMA_ONCE -# pragma once -#endif - -#include -#include - -#include // boost::stacktrace::detail::native_frame_ptr_t -#include - -#include - -/// @file boost/stacktrace/detail/frame_decl.hpp -/// Use header instead of this one! - -namespace boost { namespace stacktrace { - -/// @class boost::stacktrace::frame boost/stacktrace/detail/frame_decl.hpp -/// @brief Class that stores frame/function address and can get information about it at runtime. -class frame { -public: - typedef boost::stacktrace::detail::native_frame_ptr_t native_frame_ptr_t; - -private: - /// @cond - native_frame_ptr_t addr_; - /// @endcond - -public: - /// @brief Constructs frame that references NULL address. - /// Calls to source_file() and source_line() will return empty string. - /// Calls to source_line() will return 0. - /// - /// @b Complexity: O(1). - /// - /// @b Async-Handler-Safety: Safe. - /// @throws Nothing. - BOOST_CONSTEXPR frame() BOOST_NOEXCEPT - : addr_(0) - {} - -#ifdef BOOST_STACKTRACE_DOXYGEN_INVOKED - /// @brief Copy constructs frame. - /// - /// @b Complexity: O(1). - /// - /// @b Async-Handler-Safety: Safe. - /// @throws Nothing. - constexpr frame(const frame&) = default; - - /// @brief Copy assigns frame. - /// - /// @b Complexity: O(1). - /// - /// @b Async-Handler-Safety: Safe. - /// @throws Nothing. - constexpr frame& operator=(const frame&) = default; -#endif - - /// @brief Constructs frame that references addr and could later generate information about that address using platform specific features. - /// - /// @b Complexity: O(1). - /// - /// @b Async-Handler-Safety: Safe. - /// @throws Nothing. - BOOST_CONSTEXPR explicit frame(native_frame_ptr_t addr) BOOST_NOEXCEPT - : addr_(addr) - {} - - /// @brief Constructs frame that references function_addr and could later generate information about that function using platform specific features. - /// - /// @b Complexity: O(1). - /// - /// @b Async-Handler-Safety: Safe. - /// @throws Nothing. - template - explicit frame(T* function_addr) BOOST_NOEXCEPT - : addr_(boost::stacktrace::detail::void_ptr_cast(function_addr)) - {} - - /// @returns Name of the frame (function name in a human readable form). - /// - /// @b Complexity: unknown (lots of platform specific work). - /// - /// @b Async-Handler-Safety: Unsafe. - /// @throws std::bad_alloc if not enough memory to construct resulting string. - BOOST_STACKTRACE_FUNCTION std::string name() const; - - /// @returns Address of the frame function. - /// - /// @b Complexity: O(1). - /// - /// @b Async-Handler-Safety: Safe. - /// @throws Nothing. - BOOST_CONSTEXPR native_frame_ptr_t address() const BOOST_NOEXCEPT { - return addr_; - } - - /// @returns Path to the source file, were the function of the frame is defined. Returns empty string - /// if this->source_line() == 0. - /// @throws std::bad_alloc if not enough memory to construct resulting string. - /// - /// @b Complexity: unknown (lots of platform specific work). - /// - /// @b Async-Handler-Safety: Unsafe. - BOOST_STACKTRACE_FUNCTION std::string source_file() const; - - /// @returns Code line in the source file, were the function of the frame is defined. - /// @throws std::bad_alloc if not enough memory to construct string for internal needs. - /// - /// @b Complexity: unknown (lots of platform specific work). - /// - /// @b Async-Handler-Safety: Unsafe. - BOOST_STACKTRACE_FUNCTION std::size_t source_line() const; - - /// @brief Checks that frame is not references NULL address. - /// @returns `true` if `this->address() != 0` - /// - /// @b Complexity: O(1) - /// - /// @b Async-Handler-Safety: Safe. - explicit operator bool() const BOOST_NOEXCEPT { - return !!*this; - } - - /// @brief Checks that frame references NULL address. - /// @returns `true` if `this->address() == 0` - /// - /// @b Complexity: O(1) - /// - /// @b Async-Handler-Safety: Safe. - BOOST_CONSTEXPR bool empty() const BOOST_NOEXCEPT { return !address(); } - - /// @cond - BOOST_CONSTEXPR bool operator!() const BOOST_NOEXCEPT { return !address(); } - /// @endcond -}; - - -namespace detail { - BOOST_STACKTRACE_FUNCTION std::string to_string(const frame* frames, std::size_t size); -} // namespace detail - -}} // namespace boost::stacktrace - - -#include - -#endif // BOOST_STACKTRACE_DETAIL_FRAME_DECL_HPP diff --git a/third_party/boost_stacktrace/include/boost/stacktrace/detail/frame_msvc.ipp b/third_party/boost_stacktrace/include/boost/stacktrace/detail/frame_msvc.ipp deleted file mode 100644 index 13810a21da34..000000000000 --- a/third_party/boost_stacktrace/include/boost/stacktrace/detail/frame_msvc.ipp +++ /dev/null @@ -1,390 +0,0 @@ -// Copyright Antony Polukhin, 2016-2018. -// -// 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 BOOST_STACKTRACE_DETAIL_FRAME_MSVC_IPP -#define BOOST_STACKTRACE_DETAIL_FRAME_MSVC_IPP - -#include -#ifdef BOOST_HAS_PRAGMA_ONCE -# pragma once -#endif - -#include - -#include -#include -#include -#include -#include -#include "dbgeng.h" - -#ifdef BOOST_MSVC -# pragma comment(lib, "ole32.lib") -# pragma comment(lib, "Dbgeng.lib") -#endif - - -#ifdef __CRT_UUID_DECL // for __MINGW32__ - __CRT_UUID_DECL(IDebugClient,0x27fe5639,0x8407,0x4f47,0x83,0x64,0xee,0x11,0x8f,0xb0,0x8a,0xc8) - __CRT_UUID_DECL(IDebugControl,0x5182e668,0x105e,0x416e,0xad,0x92,0x24,0xef,0x80,0x04,0x24,0xba) - __CRT_UUID_DECL(IDebugSymbols,0x8c31e98c,0x983a,0x48a5,0x90,0x16,0x6f,0xe5,0xd6,0x67,0xa9,0x50) -#elif defined(DEFINE_GUID) && !defined(BOOST_MSVC) - DEFINE_GUID(IID_IDebugClient,0x27fe5639,0x8407,0x4f47,0x83,0x64,0xee,0x11,0x8f,0xb0,0x8a,0xc8); - DEFINE_GUID(IID_IDebugControl,0x5182e668,0x105e,0x416e,0xad,0x92,0x24,0xef,0x80,0x04,0x24,0xba); - DEFINE_GUID(IID_IDebugSymbols,0x8c31e98c,0x983a,0x48a5,0x90,0x16,0x6f,0xe5,0xd6,0x67,0xa9,0x50); -#endif - - - -// Testing. Remove later -//# define __uuidof(x) ::IID_ ## x - -namespace boost { namespace stacktrace { namespace detail { - -class com_global_initer: boost::noncopyable { - bool ok_; - -public: - com_global_initer() BOOST_NOEXCEPT - : ok_(false) - { - // COINIT_MULTITHREADED means that we must serialize access to the objects manually. - // This is the fastest way to work. If user calls CoInitializeEx before us - we - // can end up with other mode (which is OK for us). - // - // If we call CoInitializeEx befire user - user may end up with different mode, which is a problem. - // So we need to call that initialization function as late as possible. - const DWORD res = ::CoInitializeEx(0, COINIT_MULTITHREADED); - ok_ = (res == S_OK || res == S_FALSE); - } - - ~com_global_initer() BOOST_NOEXCEPT { - if (ok_) { - ::CoUninitialize(); - } - } -}; - - -template -class com_holder: boost::noncopyable { - T* holder_; - -public: - com_holder(const com_global_initer&) BOOST_NOEXCEPT - : holder_(0) - {} - - T* operator->() const BOOST_NOEXCEPT { - return holder_; - } - - void** to_void_ptr_ptr() BOOST_NOEXCEPT { - return reinterpret_cast(&holder_); - } - - bool is_inited() const BOOST_NOEXCEPT { - return !!holder_; - } - - ~com_holder() BOOST_NOEXCEPT { - if (holder_) { - holder_->Release(); - } - } -}; - - -static std::string mingw_demangling_workaround(const std::string& s) { -#ifdef BOOST_GCC - if (s.empty()) { - return s; - } - - if (s[0] != '_') { - return boost::core::demangle(('_' + s).c_str()); - } - - return boost::core::demangle(s.c_str()); -#else - return s; -#endif -} - -class debugging_symbols: boost::noncopyable { - static void try_init_com(com_holder< ::IDebugSymbols>& idebug, const com_global_initer& com) BOOST_NOEXCEPT { - com_holder< ::IDebugClient> iclient(com); - if (S_OK != ::DebugCreate(__uuidof(IDebugClient), iclient.to_void_ptr_ptr())) { - return; - } - - com_holder< ::IDebugControl> icontrol(com); - const bool res0 = (S_OK == iclient->QueryInterface( - __uuidof(IDebugControl), - icontrol.to_void_ptr_ptr() - )); - if (!res0) { - return; - } - - const bool res1 = (S_OK == iclient->AttachProcess( - 0, - ::GetCurrentProcessId(), - DEBUG_ATTACH_NONINVASIVE | DEBUG_ATTACH_NONINVASIVE_NO_SUSPEND - )); - if (!res1) { - return; - } - - if (S_OK != icontrol->WaitForEvent(DEBUG_WAIT_DEFAULT, INFINITE)) { - return; - } - - // No cheking: QueryInterface sets the output parameter to NULL in case of error. - iclient->QueryInterface(__uuidof(IDebugSymbols), idebug.to_void_ptr_ptr()); - } - -#ifndef BOOST_STACKTRACE_USE_WINDBG_CACHED - - boost::stacktrace::detail::com_global_initer com_; - com_holder< ::IDebugSymbols> idebug_; -public: - debugging_symbols() BOOST_NOEXCEPT - : com_() - , idebug_(com_) - { - try_init_com(idebug_, com_); - } - -#else - -#ifdef BOOST_NO_CXX11_THREAD_LOCAL -# error Your compiler does not support C++11 thread_local storage. It`s impossible to build with BOOST_STACKTRACE_USE_WINDBG_CACHED. -#endif - - static com_holder< ::IDebugSymbols>& get_thread_local_debug_inst() BOOST_NOEXCEPT { - // [class.mfct]: A static local variable or local type in a member function always refers to the same entity, whether - // or not the member function is inline. - static thread_local boost::stacktrace::detail::com_global_initer com; - static thread_local com_holder< ::IDebugSymbols> idebug(com); - - if (!idebug.is_inited()) { - try_init_com(idebug, com); - } - - return idebug; - } - - com_holder< ::IDebugSymbols>& idebug_; -public: - debugging_symbols() BOOST_NOEXCEPT - : idebug_( get_thread_local_debug_inst() ) - {} - -#endif // #ifndef BOOST_STACKTRACE_USE_WINDBG_CACHED - - bool is_inited() const BOOST_NOEXCEPT { - return idebug_.is_inited(); - } - - std::string get_name_impl(const void* addr, std::string* module_name = 0) const { - std::string result; - if (!is_inited()) { - return result; - } - const ULONG64 offset = reinterpret_cast(addr); - - char name[256]; - name[0] = '\0'; - ULONG size = 0; - bool res = (S_OK == idebug_->GetNameByOffset( - offset, - name, - sizeof(name), - &size, - 0 - )); - - if (!res && size != 0) { - result.resize(size); - res = (S_OK == idebug_->GetNameByOffset( - offset, - &result[0], - static_cast(result.size()), - &size, - 0 - )); - } else if (res) { - result = name; - } - - if (!res) { - result.clear(); - return result; - } - - const std::size_t delimiter = result.find_first_of('!'); - if (module_name) { - *module_name = result.substr(0, delimiter); - } - - if (delimiter == std::string::npos) { - // If 'delimiter' is equal to 'std::string::npos' then we have only module name. - result.clear(); - return result; - } - - result = mingw_demangling_workaround( - result.substr(delimiter + 1) - ); - - return result; - } - - std::size_t get_line_impl(const void* addr) const BOOST_NOEXCEPT { - ULONG result = 0; - if (!is_inited()) { - return result; - } - - const bool is_ok = (S_OK == idebug_->GetLineByOffset( - reinterpret_cast(addr), - &result, - 0, - 0, - 0, - 0 - )); - - return (is_ok ? result : 0); - } - - std::pair get_source_file_line_impl(const void* addr) const { - std::pair result; - if (!is_inited()) { - return result; - } - const ULONG64 offset = reinterpret_cast(addr); - - char name[256]; - name[0] = 0; - ULONG size = 0; - ULONG line_num = 0; - bool res = (S_OK == idebug_->GetLineByOffset( - offset, - &line_num, - name, - sizeof(name), - &size, - 0 - )); - - if (res) { - result.first = name; - result.second = line_num; - return result; - } - - if (!res && size == 0) { - return result; - } - - result.first.resize(size); - res = (S_OK == idebug_->GetLineByOffset( - offset, - &line_num, - &result.first[0], - static_cast(result.first.size()), - &size, - 0 - )); - result.second = line_num; - - if (!res) { - result.first.clear(); - result.second = 0; - } - - return result; - } - - void to_string_impl(const void* addr, std::string& res) const { - if (!is_inited()) { - return; - } - - std::string module_name; - std::string name = this->get_name_impl(addr, &module_name); - if (!name.empty()) { - res += name; - } else { - res += to_hex_array(addr).data(); - } - - std::pair source_line = this->get_source_file_line_impl(addr); - if (!source_line.first.empty() && source_line.second) { - res += " at "; - res += source_line.first; - res += ':'; - res += boost::stacktrace::detail::to_dec_array(source_line.second).data(); - } else if (!module_name.empty()) { - res += " in "; - res += module_name; - } - } -}; - -std::string to_string(const frame* frames, std::size_t size) { - boost::stacktrace::detail::debugging_symbols idebug; - if (!idebug.is_inited()) { - return std::string(); - } - - std::string res; - res.reserve(64 * size); - for (std::size_t i = 0; i < size; ++i) { - if (i < 10) { - res += ' '; - } - res += boost::stacktrace::detail::to_dec_array(i).data(); - res += '#'; - res += ' '; - idebug.to_string_impl(frames[i].address(), res); - res += '\n'; - } - - return res; -} - -} // namespace detail - -std::string frame::name() const { - boost::stacktrace::detail::debugging_symbols idebug; - return idebug.get_name_impl(addr_); -} - - -std::string frame::source_file() const { - boost::stacktrace::detail::debugging_symbols idebug; - return idebug.get_source_file_line_impl(addr_).first; -} - -std::size_t frame::source_line() const { - boost::stacktrace::detail::debugging_symbols idebug; - return idebug.get_line_impl(addr_); -} - -std::string to_string(const frame& f) { - std::string res; - - boost::stacktrace::detail::debugging_symbols idebug; - idebug.to_string_impl(f.address(), res); - return res; -} - -}} // namespace boost::stacktrace - -#endif // BOOST_STACKTRACE_DETAIL_FRAME_MSVC_IPP diff --git a/third_party/boost_stacktrace/include/boost/stacktrace/detail/frame_noop.ipp b/third_party/boost_stacktrace/include/boost/stacktrace/detail/frame_noop.ipp deleted file mode 100644 index c33c351ad637..000000000000 --- a/third_party/boost_stacktrace/include/boost/stacktrace/detail/frame_noop.ipp +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright Antony Polukhin, 2016-2018. -// -// 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 BOOST_STACKTRACE_DETAIL_FRAME_NOOP_IPP -#define BOOST_STACKTRACE_DETAIL_FRAME_NOOP_IPP - -#include -#ifdef BOOST_HAS_PRAGMA_ONCE -# pragma once -#endif - -#include - -namespace boost { namespace stacktrace { namespace detail { - -std::string to_string(const frame* /*frames*/, std::size_t /*count*/) { - return std::string(); -} - -} // namespace detail - -std::string frame::name() const { - return std::string(); -} - -std::string frame::source_file() const { - return std::string(); -} - -std::size_t frame::source_line() const { - return 0; -} - -std::string to_string(const frame& /*f*/) { - return std::string(); -} - - -}} // namespace boost::stacktrace - -#endif // BOOST_STACKTRACE_DETAIL_FRAME_NOOP_IPP diff --git a/third_party/boost_stacktrace/include/boost/stacktrace/detail/frame_unwind.ipp b/third_party/boost_stacktrace/include/boost/stacktrace/detail/frame_unwind.ipp deleted file mode 100644 index 0e1a73167e17..000000000000 --- a/third_party/boost_stacktrace/include/boost/stacktrace/detail/frame_unwind.ipp +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright Antony Polukhin, 2016-2018. -// -// 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 BOOST_STACKTRACE_DETAIL_FRAME_UNWIND_IPP -#define BOOST_STACKTRACE_DETAIL_FRAME_UNWIND_IPP - -#include -#ifdef BOOST_HAS_PRAGMA_ONCE -# pragma once -#endif - -#include - -#include -#include -#include -#include - -#include - -#ifdef BOOST_STACKTRACE_USE_BACKTRACE -# include -#elif defined(BOOST_STACKTRACE_USE_ADDR2LINE) -# include -#else -# include -#endif - -namespace boost { namespace stacktrace { namespace detail { - -template -class to_string_impl_base: private Base { -public: - std::string operator()(boost::stacktrace::detail::native_frame_ptr_t addr) { - Base::res.clear(); - Base::prepare_function_name(addr); - if (!Base::res.empty()) { - Base::res = boost::core::demangle(Base::res.c_str()); - } else { - Base::res = to_hex_array(addr).data(); - } - - if (Base::prepare_source_location(addr)) { - return Base::res; - } - - boost::stacktrace::detail::location_from_symbol loc(addr); - if (!loc.empty()) { - Base::res += " in "; - Base::res += loc.name(); - } - - return Base::res; - } -}; - -std::string to_string(const frame* frames, std::size_t size) { - std::string res; - res.reserve(64 * size); - - to_string_impl impl; - - for (std::size_t i = 0; i < size; ++i) { - if (i < 10) { - res += ' '; - } - res += boost::stacktrace::detail::to_dec_array(i).data(); - res += '#'; - res += ' '; - res += impl(frames[i].address()); - res += '\n'; - } - - return res; -} - - -} // namespace detail - - -std::string frame::name() const { -#if !defined(BOOST_WINDOWS) && !defined(__CYGWIN__) - ::Dl_info dli; - const bool dl_ok = !!::dladdr(const_cast(addr_), &dli); // `dladdr` on Solaris accepts nonconst addresses - if (dl_ok && dli.dli_sname) { - return boost::core::demangle(dli.dli_sname); - } -#endif - return boost::stacktrace::detail::name_impl(addr_); -} - -std::string to_string(const frame& f) { - boost::stacktrace::detail::to_string_impl impl; - return impl(f.address()); -} - - -}} // namespace boost::stacktrace - -#endif // BOOST_STACKTRACE_DETAIL_FRAME_UNWIND_IPP diff --git a/third_party/boost_stacktrace/include/boost/stacktrace/detail/libbacktrace_impls.hpp b/third_party/boost_stacktrace/include/boost/stacktrace/detail/libbacktrace_impls.hpp deleted file mode 100644 index 6cbc5aab05ba..000000000000 --- a/third_party/boost_stacktrace/include/boost/stacktrace/detail/libbacktrace_impls.hpp +++ /dev/null @@ -1,236 +0,0 @@ -// Copyright Antony Polukhin, 2016-2018. -// -// 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 BOOST_STACKTRACE_DETAIL_LIBBACKTRACE_IMPLS_HPP -#define BOOST_STACKTRACE_DETAIL_LIBBACKTRACE_IMPLS_HPP - -#include -#ifdef BOOST_HAS_PRAGMA_ONCE -# pragma once -#endif - -#include -#include -#include -#include - -#ifdef BOOST_STACKTRACE_BACKTRACE_INCLUDE_FILE -# include BOOST_STACKTRACE_BACKTRACE_INCLUDE_FILE -#else -# include -#endif - -namespace boost { namespace stacktrace { namespace detail { - - -struct pc_data { - std::string* function; - std::string* filename; - std::size_t line; -}; - -inline void libbacktrace_syminfo_callback(void *data, uintptr_t /*pc*/, const char *symname, uintptr_t /*symval*/, uintptr_t /*symsize*/) { - pc_data& d = *static_cast(data); - if (d.function && symname) { - *d.function = symname; - } -} - -// Old versions of libbacktrace have different signature for the callback -inline void libbacktrace_syminfo_callback(void *data, uintptr_t pc, const char *symname, uintptr_t symval) { - boost::stacktrace::detail::libbacktrace_syminfo_callback(data, pc, symname, symval, 0); -} - -inline int libbacktrace_full_callback(void *data, uintptr_t /*pc*/, const char *filename, int lineno, const char *function) { - pc_data& d = *static_cast(data); - if (d.filename && filename) { - *d.filename = filename; - } - if (d.function && function) { - *d.function = function; - } - d.line = lineno; - return 0; -} - -inline void libbacktrace_error_callback(void* /*data*/, const char* /*msg*/, int /*errnum*/) BOOST_NOEXCEPT { - // Do nothing, just return. -} - -// Not async-signal-safe, so this method is not called from async-safe functions. -// -// This function is not async signal safe because: -// * Dynamic initialization of a block-scope variable with static storage duration could lock a mutex -// * No guarantees on `backtrace_create_state` function. -// -// Currently `backtrace_create_state` can not detect file name on Windows https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82543 -// That's why we provide a `prog_location` here. -BOOST_SYMBOL_VISIBLE inline ::backtrace_state* construct_state(const program_location& prog_location) BOOST_NOEXCEPT { - // [dcl.inline]: A static local variable in an inline function with external linkage always refers to the same object. - - // TODO: The most obvious solution: - // - //static ::backtrace_state* state = ::backtrace_create_state( - // prog_location.name(), - // 1, // allow safe concurrent usage of the same state - // boost::stacktrace::detail::libbacktrace_error_callback, - // 0 // pointer to data that will be passed to callback - //); - // - // - // Unfortunately, that solution segfaults when `construct_state()` function is in .so file - // and multiple threads concurrently work with state. - - -#ifndef BOOST_HAS_THREADS - static -#else - - // Result of `construct_state()` invocation is not stored by the callers, so `thread_local` - // gives a single `state` per thread and that state is not shared between threads in any way. - -# ifndef BOOST_NO_CXX11_THREAD_LOCAL - thread_local -# elif defined(__GNUC__) - static __thread -# else - /* just a local variable */ -# endif - -#endif - ::backtrace_state* state = ::backtrace_create_state( - prog_location.name(), - 0, - boost::stacktrace::detail::libbacktrace_error_callback, - 0 - ); - return state; -} - -struct to_string_using_backtrace { - std::string res; - boost::stacktrace::detail::program_location prog_location; - ::backtrace_state* state; - std::string filename; - std::size_t line; - - void prepare_function_name(const void* addr) { - boost::stacktrace::detail::pc_data data = {&res, &filename, 0}; - if (state) { - ::backtrace_pcinfo( - state, - reinterpret_cast(addr), - boost::stacktrace::detail::libbacktrace_full_callback, - boost::stacktrace::detail::libbacktrace_error_callback, - &data - ) - || - ::backtrace_syminfo( - state, - reinterpret_cast(addr), - boost::stacktrace::detail::libbacktrace_syminfo_callback, - boost::stacktrace::detail::libbacktrace_error_callback, - &data - ); - } - line = data.line; - } - - bool prepare_source_location(const void* /*addr*/) { - if (filename.empty() || !line) { - return false; - } - - res += " at "; - res += filename; - res += ':'; - res += boost::stacktrace::detail::to_dec_array(line).data(); - return true; - } - - to_string_using_backtrace() BOOST_NOEXCEPT { - state = boost::stacktrace::detail::construct_state(prog_location); - } -}; - -template class to_string_impl_base; -typedef to_string_impl_base to_string_impl; - -inline std::string name_impl(const void* addr) { - std::string res; - - boost::stacktrace::detail::program_location prog_location; - ::backtrace_state* state = boost::stacktrace::detail::construct_state(prog_location); - - boost::stacktrace::detail::pc_data data = {&res, 0, 0}; - if (state) { - ::backtrace_pcinfo( - state, - reinterpret_cast(addr), - boost::stacktrace::detail::libbacktrace_full_callback, - boost::stacktrace::detail::libbacktrace_error_callback, - &data - ) - || - ::backtrace_syminfo( - state, - reinterpret_cast(addr), - boost::stacktrace::detail::libbacktrace_syminfo_callback, - boost::stacktrace::detail::libbacktrace_error_callback, - &data - ); - } - if (!res.empty()) { - res = boost::core::demangle(res.c_str()); - } - - return res; -} - -} // namespace detail - -std::string frame::source_file() const { - std::string res; - - boost::stacktrace::detail::program_location prog_location; - ::backtrace_state* state = boost::stacktrace::detail::construct_state(prog_location); - - boost::stacktrace::detail::pc_data data = {0, &res, 0}; - if (state) { - ::backtrace_pcinfo( - state, - reinterpret_cast(addr_), - boost::stacktrace::detail::libbacktrace_full_callback, - boost::stacktrace::detail::libbacktrace_error_callback, - &data - ); - } - - return res; -} - -std::size_t frame::source_line() const { - boost::stacktrace::detail::program_location prog_location; - ::backtrace_state* state = boost::stacktrace::detail::construct_state(prog_location); - - boost::stacktrace::detail::pc_data data = {0, 0, 0}; - if (state) { - ::backtrace_pcinfo( - state, - reinterpret_cast(addr_), - boost::stacktrace::detail::libbacktrace_full_callback, - boost::stacktrace::detail::libbacktrace_error_callback, - &data - ); - } - - return data.line; -} - - -}} // namespace boost::stacktrace - -#endif // BOOST_STACKTRACE_DETAIL_LIBBACKTRACE_IMPLS_HPP diff --git a/third_party/boost_stacktrace/include/boost/stacktrace/detail/location_from_symbol.hpp b/third_party/boost_stacktrace/include/boost/stacktrace/detail/location_from_symbol.hpp deleted file mode 100644 index 60422323e6ca..000000000000 --- a/third_party/boost_stacktrace/include/boost/stacktrace/detail/location_from_symbol.hpp +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright Antony Polukhin, 2016-2018. -// -// 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 BOOST_STACKTRACE_DETAIL_LOCATION_FROM_SYMBOL_HPP -#define BOOST_STACKTRACE_DETAIL_LOCATION_FROM_SYMBOL_HPP - -#include -#ifdef BOOST_HAS_PRAGMA_ONCE -# pragma once -#endif - -#if !defined(BOOST_WINDOWS) && !defined(__CYGWIN__) -# include -#else -# include -#endif - -namespace boost { namespace stacktrace { namespace detail { - -#if !defined(BOOST_WINDOWS) && !defined(__CYGWIN__) -class location_from_symbol { - ::Dl_info dli_; - -public: - explicit location_from_symbol(const void* addr) BOOST_NOEXCEPT - : dli_() - { - if (!::dladdr(const_cast(addr), &dli_)) { // `dladdr` on Solaris accepts nonconst addresses - dli_.dli_fname = 0; - } - } - - bool empty() const BOOST_NOEXCEPT { - return !dli_.dli_fname; - } - - const char* name() const BOOST_NOEXCEPT { - return dli_.dli_fname; - } -}; - -class program_location { -public: - const char* name() const BOOST_NOEXCEPT { - return 0; - } -}; - -#else - -class location_from_symbol { - BOOST_STATIC_CONSTEXPR boost::winapi::DWORD_ DEFAULT_PATH_SIZE_ = 260; - char file_name_[DEFAULT_PATH_SIZE_]; - -public: - explicit location_from_symbol(const void* addr) BOOST_NOEXCEPT { - file_name_[0] = '\0'; - - boost::winapi::MEMORY_BASIC_INFORMATION_ mbi; - if (!boost::winapi::VirtualQuery(addr, &mbi, sizeof(mbi))) { - return; - } - - boost::winapi::HMODULE_ handle = reinterpret_cast(mbi.AllocationBase); - if (!boost::winapi::GetModuleFileNameA(handle, file_name_, DEFAULT_PATH_SIZE_)) { - file_name_[0] = '\0'; - return; - } - } - - bool empty() const BOOST_NOEXCEPT { - return file_name_[0] == '\0'; - } - - const char* name() const BOOST_NOEXCEPT { - return file_name_; - } -}; - -class program_location { - BOOST_STATIC_CONSTEXPR boost::winapi::DWORD_ DEFAULT_PATH_SIZE_ = 260; - char file_name_[DEFAULT_PATH_SIZE_]; - -public: - program_location() BOOST_NOEXCEPT { - file_name_[0] = '\0'; - - const boost::winapi::HMODULE_ handle = 0; - if (!boost::winapi::GetModuleFileNameA(handle, file_name_, DEFAULT_PATH_SIZE_)) { - file_name_[0] = '\0'; - } - } - - const char* name() const BOOST_NOEXCEPT { - return file_name_[0] ? file_name_ : 0; - } -}; -#endif - -}}} // namespace boost::stacktrace::detail - -#endif // BOOST_STACKTRACE_DETAIL_LOCATION_FROM_SYMBOL_HPP diff --git a/third_party/boost_stacktrace/include/boost/stacktrace/detail/pop_options.h b/third_party/boost_stacktrace/include/boost/stacktrace/detail/pop_options.h deleted file mode 100644 index 0faf6af47020..000000000000 --- a/third_party/boost_stacktrace/include/boost/stacktrace/detail/pop_options.h +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright Antony Polukhin, 2016-2018. -// -// 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) - -// No include guards! Intentionally. - -#ifdef BOOST_STACKTRACE_FUNCTION -# undef BOOST_STACKTRACE_FUNCTION -#endif - diff --git a/third_party/boost_stacktrace/include/boost/stacktrace/detail/push_options.h b/third_party/boost_stacktrace/include/boost/stacktrace/detail/push_options.h deleted file mode 100644 index 454e89cbbbfe..000000000000 --- a/third_party/boost_stacktrace/include/boost/stacktrace/detail/push_options.h +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright Antony Polukhin, 2016-2018. -// -// 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) - -// No include guards! Intentionally. - -// Link or header only -#if !defined(BOOST_STACKTRACE_LINK) && defined(BOOST_STACKTRACE_DYN_LINK) -# define BOOST_STACKTRACE_LINK -#endif - -#if defined(BOOST_STACKTRACE_LINK) && !defined(BOOST_STACKTRACE_DYN_LINK) && defined(BOOST_ALL_DYN_LINK) -# define BOOST_STACKTRACE_DYN_LINK -#endif - -#ifdef BOOST_STACKTRACE_LINK -# if defined(BOOST_STACKTRACE_DYN_LINK) -# ifdef BOOST_STACKTRACE_INTERNAL_BUILD_LIBS -# define BOOST_STACKTRACE_FUNCTION BOOST_SYMBOL_EXPORT -# else -# define BOOST_STACKTRACE_FUNCTION BOOST_SYMBOL_IMPORT -# endif -# else -# define BOOST_STACKTRACE_FUNCTION -# endif -#elif !defined(BOOST_STACKTRACE_DOXYGEN_INVOKED) -# define BOOST_STACKTRACE_FUNCTION inline -#endif - - -#ifndef BOOST_NOINLINE -# define BOOST_NOINLINE __attribute__ ((__noinline__)) -#endif - -#ifndef BOOST_FORCEINLINE -# define BOOST_FORCEINLINE inline __attribute__ ((__always_inline__)) -#endif diff --git a/third_party/boost_stacktrace/include/boost/stacktrace/detail/safe_dump_noop.ipp b/third_party/boost_stacktrace/include/boost/stacktrace/detail/safe_dump_noop.ipp deleted file mode 100644 index aee378d09785..000000000000 --- a/third_party/boost_stacktrace/include/boost/stacktrace/detail/safe_dump_noop.ipp +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright Antony Polukhin, 2016-2018. -// -// 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 BOOST_STACKTRACE_DETAIL_SAFE_DUMP_NOOP_IPP -#define BOOST_STACKTRACE_DETAIL_SAFE_DUMP_NOOP_IPP - -#include -#ifdef BOOST_HAS_PRAGMA_ONCE -# pragma once -#endif - -#include - -namespace boost { namespace stacktrace { namespace detail { - - -#if defined(BOOST_WINDOWS) -std::size_t dump(void* /*fd*/, const native_frame_ptr_t* /*frames*/, std::size_t /*frames_count*/) BOOST_NOEXCEPT { - return 0; -} -#else -std::size_t dump(int /*fd*/, const native_frame_ptr_t* /*frames*/, std::size_t /*frames_count*/) BOOST_NOEXCEPT { - return 0; -} -#endif - - -std::size_t dump(const char* /*file*/, const native_frame_ptr_t* /*frames*/, std::size_t /*frames_count*/) BOOST_NOEXCEPT { - return 0; -} - -}}} // namespace boost::stacktrace::detail - -#endif // BOOST_STACKTRACE_DETAIL_SAFE_DUMP_NOOP_IPP diff --git a/third_party/boost_stacktrace/include/boost/stacktrace/detail/safe_dump_posix.ipp b/third_party/boost_stacktrace/include/boost/stacktrace/detail/safe_dump_posix.ipp deleted file mode 100644 index cfe3e41d8031..000000000000 --- a/third_party/boost_stacktrace/include/boost/stacktrace/detail/safe_dump_posix.ipp +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright Antony Polukhin, 2016-2018. -// -// 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 BOOST_STACKTRACE_DETAIL_SAFE_DUMP_POSIX_IPP -#define BOOST_STACKTRACE_DETAIL_SAFE_DUMP_POSIX_IPP - -#include -#ifdef BOOST_HAS_PRAGMA_ONCE -# pragma once -#endif - -#include - -#include // ::write -#include // ::open -#include // S_IWUSR and friends - - -namespace boost { namespace stacktrace { namespace detail { - -std::size_t dump(int fd, const native_frame_ptr_t* frames, std::size_t frames_count) BOOST_NOEXCEPT { - // We do not retry, because this function must be typically called from signal handler so it's: - // * to scary to continue in case of EINTR - // * EAGAIN or EWOULDBLOCK may occur only in case of O_NONBLOCK is set for fd, - // so it seems that user does not want to block - if (::write(fd, frames, sizeof(native_frame_ptr_t) * frames_count) == -1) { - return 0; - } - - return frames_count; -} - -std::size_t dump(const char* file, const native_frame_ptr_t* frames, std::size_t frames_count) BOOST_NOEXCEPT { - const int fd = ::open( - file, - O_CREAT | O_WRONLY | O_TRUNC, -#if defined(S_IWUSR) && defined(S_IRUSR) // Workarounds for some Android OSes - S_IWUSR | S_IRUSR -#elif defined(S_IWRITE) && defined(S_IREAD) - S_IWRITE | S_IREAD -#else - 0 -#endif - ); - if (fd == -1) { - return 0; - } - - const std::size_t size = boost::stacktrace::detail::dump(fd, frames, frames_count); - ::close(fd); - return size; -} - -}}} // namespace boost::stacktrace::detail - -#endif // BOOST_STACKTRACE_DETAIL_SAFE_DUMP_POSIX_IPP diff --git a/third_party/boost_stacktrace/include/boost/stacktrace/detail/safe_dump_win.ipp b/third_party/boost_stacktrace/include/boost/stacktrace/detail/safe_dump_win.ipp deleted file mode 100644 index 23e81aab483a..000000000000 --- a/third_party/boost_stacktrace/include/boost/stacktrace/detail/safe_dump_win.ipp +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright Antony Polukhin, 2016-2018. -// -// 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 BOOST_STACKTRACE_DETAIL_SAFE_DUMP_WIN_IPP -#define BOOST_STACKTRACE_DETAIL_SAFE_DUMP_WIN_IPP - -#include -#ifdef BOOST_HAS_PRAGMA_ONCE -# pragma once -#endif - -#include - -#include - -#include -#include -#include -#include - -namespace boost { namespace stacktrace { namespace detail { - -std::size_t dump(void* /*fd*/, const native_frame_ptr_t* /*frames*/, std::size_t /*frames_count*/) BOOST_NOEXCEPT { -#if 0 // This code potentially could cause deadlocks (according to the MSDN). Disabled - boost::winapi::DWORD_ written; - const boost::winapi::DWORD_ bytes_to_write = static_cast( - sizeof(native_frame_ptr_t) * frames_count - ); - if (!boost::winapi::WriteFile(fd, frames, bytes_to_write, &written, 0)) { - return 0; - } - - return frames_count; -#endif - return 0; -} - -std::size_t dump(const char* /*file*/, const native_frame_ptr_t* /*frames*/, std::size_t /*frames_count*/) BOOST_NOEXCEPT { -#if 0 // This code causing deadlocks on some platforms. Disabled - void* const fd = boost::winapi::CreateFileA( - file, - boost::winapi::GENERIC_WRITE_, - 0, - 0, - boost::winapi::CREATE_ALWAYS_, - boost::winapi::FILE_ATTRIBUTE_NORMAL_, - 0 - ); - - if (fd == boost::winapi::invalid_handle_value) { - return 0; - } - - const std::size_t size = boost::stacktrace::detail::dump(fd, frames, frames_count); - boost::winapi::CloseHandle(fd); - return size; -#endif - return 0; -} - -}}} // namespace boost::stacktrace::detail - -#endif // BOOST_STACKTRACE_DETAIL_SAFE_DUMP_WIN_IPP diff --git a/third_party/boost_stacktrace/include/boost/stacktrace/detail/to_dec_array.hpp b/third_party/boost_stacktrace/include/boost/stacktrace/detail/to_dec_array.hpp deleted file mode 100644 index 5f025490fcf2..000000000000 --- a/third_party/boost_stacktrace/include/boost/stacktrace/detail/to_dec_array.hpp +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright Antony Polukhin, 2016-2018. -// -// 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 BOOST_STACKTRACE_DETAIL_TO_DEC_ARRAY_HPP -#define BOOST_STACKTRACE_DETAIL_TO_DEC_ARRAY_HPP - -#include -#ifdef BOOST_HAS_PRAGMA_ONCE -# pragma once -#endif - -#include - -namespace boost { namespace stacktrace { namespace detail { - -// We do not use boost::lexical_cast in this function to reduce module dependencies -inline boost::array to_dec_array(std::size_t value) BOOST_NOEXCEPT { - boost::array ret; - if (!value) { - ret[0] = '0'; - ret[1] = '\0'; - return ret; - } - - std::size_t digits = 0; - for (std::size_t value_copy = value; value_copy; value_copy /= 10) { - ++ digits; - } - - for (std::size_t i = 1; i <= digits; ++i) { - ret[digits - i] = '0' + (value % 10); - value /= 10; - } - - ret[digits] = '\0'; - - return ret; -} - - -}}} // namespace boost::stacktrace::detail - -#endif // BOOST_STACKTRACE_DETAIL_TO_DEC_ARRAY_HPP diff --git a/third_party/boost_stacktrace/include/boost/stacktrace/detail/to_hex_array.hpp b/third_party/boost_stacktrace/include/boost/stacktrace/detail/to_hex_array.hpp deleted file mode 100644 index 20bba9005b71..000000000000 --- a/third_party/boost_stacktrace/include/boost/stacktrace/detail/to_hex_array.hpp +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright Antony Polukhin, 2016-2018. -// -// 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 BOOST_STACKTRACE_DETAIL_TO_HEX_ARRAY_HPP -#define BOOST_STACKTRACE_DETAIL_TO_HEX_ARRAY_HPP - -#include -#ifdef BOOST_HAS_PRAGMA_ONCE -# pragma once -#endif - -#include -#include -#include -#include - -namespace boost { namespace stacktrace { namespace detail { - -BOOST_STATIC_CONSTEXPR char to_hex_array_bytes[] = "0123456789ABCDEF"; - -template -inline boost::array to_hex_array(T addr) BOOST_NOEXCEPT { - boost::array ret = {"0x"}; - ret.back() = '\0'; - BOOST_STATIC_ASSERT_MSG(!boost::is_pointer::value, ""); - - const std::size_t s = sizeof(T); - - char* out = ret.data() + s * 2 + 1; - - for (std::size_t i = 0; i < s; ++i) { - const unsigned char tmp_addr = (addr & 0xFFu); - *out = to_hex_array_bytes[tmp_addr & 0xF]; - -- out; - *out = to_hex_array_bytes[tmp_addr >> 4]; - -- out; - addr >>= 8; - } - - return ret; -} - -inline boost::array to_hex_array(const void* addr) BOOST_NOEXCEPT { - return to_hex_array( - reinterpret_cast< boost::make_unsigned::type >(addr) - ); -} - -}}} // namespace boost::stacktrace::detail - -#endif // BOOST_STACKTRACE_DETAIL_TO_HEX_ARRAY_HPP diff --git a/third_party/boost_stacktrace/include/boost/stacktrace/detail/try_dec_convert.hpp b/third_party/boost_stacktrace/include/boost/stacktrace/detail/try_dec_convert.hpp deleted file mode 100644 index af619bcf6488..000000000000 --- a/third_party/boost_stacktrace/include/boost/stacktrace/detail/try_dec_convert.hpp +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright Antony Polukhin, 2016-2018. -// -// 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 BOOST_STACKTRACE_DETAIL_TRY_DEC_CONVERT_HPP -#define BOOST_STACKTRACE_DETAIL_TRY_DEC_CONVERT_HPP - -#include -#ifdef BOOST_HAS_PRAGMA_ONCE -# pragma once -#endif - -#include - -namespace boost { namespace stacktrace { namespace detail { - -// We do not use boost::lexical_cast in this function to reduce module dependencies -inline bool try_dec_convert(const char* s, std::size_t& res) BOOST_NOEXCEPT { - char* end_ptr = 0; - res = std::strtoul(s, &end_ptr, 10); - return *end_ptr == '\0'; -} - - -}}} // namespace boost::stacktrace::detail - -#endif // BOOST_STACKTRACE_DETAIL_TRY_DEC_CONVERT_HPP diff --git a/third_party/boost_stacktrace/include/boost/stacktrace/detail/unwind_base_impls.hpp b/third_party/boost_stacktrace/include/boost/stacktrace/detail/unwind_base_impls.hpp deleted file mode 100644 index 2f72a15dbc74..000000000000 --- a/third_party/boost_stacktrace/include/boost/stacktrace/detail/unwind_base_impls.hpp +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright Antony Polukhin, 2016-2018. -// -// 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 BOOST_STACKTRACE_DETAIL_UNWIND_BASE_IMPLS_HPP -#define BOOST_STACKTRACE_DETAIL_UNWIND_BASE_IMPLS_HPP - -#include -#ifdef BOOST_HAS_PRAGMA_ONCE -# pragma once -#endif - -#include - -namespace boost { namespace stacktrace { namespace detail { - -struct to_string_using_nothing { - std::string res; - - void prepare_function_name(const void* addr) { - res = boost::stacktrace::frame(addr).name(); - } - - bool prepare_source_location(const void* /*addr*/) const BOOST_NOEXCEPT { - return false; - } -}; - -template class to_string_impl_base; -typedef to_string_impl_base to_string_impl; - -inline std::string name_impl(const void* /*addr*/) { - return std::string(); -} - -} // namespace detail - -std::string frame::source_file() const { - return std::string(); -} - -std::size_t frame::source_line() const { - return 0; -} - -}} // namespace boost::stacktrace - -#endif // BOOST_STACKTRACE_DETAIL_UNWIND_BASE_IMPLS_HPP diff --git a/third_party/boost_stacktrace/include/boost/stacktrace/detail/void_ptr_cast.hpp b/third_party/boost_stacktrace/include/boost/stacktrace/detail/void_ptr_cast.hpp deleted file mode 100644 index 88e6916c3a9f..000000000000 --- a/third_party/boost_stacktrace/include/boost/stacktrace/detail/void_ptr_cast.hpp +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2014 Renato Tegon Forti, Antony Polukhin. -// Copyright 2015-2018 Antony Polukhin. -// -// 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 BOOST_STACKTRACE_DETAIL_VOID_PTR_CAST_HPP -#define BOOST_STACKTRACE_DETAIL_VOID_PTR_CAST_HPP - -#include -#ifdef BOOST_HAS_PRAGMA_ONCE -# pragma once -#endif - -#include -#include - -#if defined(__GNUC__) && defined(__GNUC_MINOR__) && (__GNUC__ * 100 + __GNUC_MINOR__ > 301) -# pragma GCC system_header -#endif - -namespace boost { namespace stacktrace { namespace detail { - -// GCC warns when reinterpret_cast between function pointer and object pointer occur. -// This functionsuppress the warnings and ensures that such casts are safe. -template -To void_ptr_cast(From* v) BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT_MSG( - boost::is_pointer::value, - "`void_ptr_cast` function must be used only for casting to or from void pointers." - ); - - BOOST_STATIC_ASSERT_MSG( - sizeof(From*) == sizeof(To), - "Pointer to function and pointer to object differ in size on your platform." - ); - - return reinterpret_cast(v); -} - - -}}} // boost::stacktrace::detail - -#endif // BOOST_STACKTRACE_DETAIL_VOID_PTR_CAST_HPP - diff --git a/third_party/boost_stacktrace/include/boost/stacktrace/frame.hpp b/third_party/boost_stacktrace/include/boost/stacktrace/frame.hpp deleted file mode 100644 index 4161a44a47d5..000000000000 --- a/third_party/boost_stacktrace/include/boost/stacktrace/frame.hpp +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright Antony Polukhin, 2016-2017. -// -// 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 BOOST_STACKTRACE_FRAME_HPP -#define BOOST_STACKTRACE_FRAME_HPP - -#include -#ifdef BOOST_HAS_PRAGMA_ONCE -# pragma once -#endif - -#include -#include - -#include // boost::stacktrace::detail::native_frame_ptr_t - -#include -#include - -namespace boost { namespace stacktrace { - -/// Comparison operators that provide platform dependant ordering and have O(1) complexity; are Async-Handler-Safe. -BOOST_CONSTEXPR inline bool operator< (const frame& lhs, const frame& rhs) BOOST_NOEXCEPT { return lhs.address() < rhs.address(); } -BOOST_CONSTEXPR inline bool operator> (const frame& lhs, const frame& rhs) BOOST_NOEXCEPT { return rhs < lhs; } -BOOST_CONSTEXPR inline bool operator<=(const frame& lhs, const frame& rhs) BOOST_NOEXCEPT { return !(lhs > rhs); } -BOOST_CONSTEXPR inline bool operator>=(const frame& lhs, const frame& rhs) BOOST_NOEXCEPT { return !(lhs < rhs); } -BOOST_CONSTEXPR inline bool operator==(const frame& lhs, const frame& rhs) BOOST_NOEXCEPT { return lhs.address() == rhs.address(); } -BOOST_CONSTEXPR inline bool operator!=(const frame& lhs, const frame& rhs) BOOST_NOEXCEPT { return !(lhs == rhs); } - -/// Fast hashing support, O(1) complexity; Async-Handler-Safe. -inline std::size_t hash_value(const frame& f) BOOST_NOEXCEPT { - return reinterpret_cast(f.address()); -} - -/// Outputs stacktrace::frame in a human readable format to string; unsafe to use in async handlers. -BOOST_STACKTRACE_FUNCTION std::string to_string(const frame& f); - -/// Outputs stacktrace::frame in a human readable format to output stream; unsafe to use in async handlers. -template -std::basic_ostream& operator<<(std::basic_ostream& os, const frame& f) { - return os << boost::stacktrace::to_string(f); -} - -}} // namespace boost::stacktrace - -/// @cond - -#include - -#ifndef BOOST_STACKTRACE_LINK -# if defined(BOOST_STACKTRACE_USE_NOOP) -# include -# elif defined(BOOST_MSVC) || defined(BOOST_STACKTRACE_USE_WINDBG) || defined(BOOST_STACKTRACE_USE_WINDBG_CACHED) -# include -# else -# include -# endif -#endif -/// @endcond - - -#endif // BOOST_STACKTRACE_FRAME_HPP diff --git a/third_party/boost_stacktrace/include/boost/stacktrace/safe_dump_to.hpp b/third_party/boost_stacktrace/include/boost/stacktrace/safe_dump_to.hpp deleted file mode 100644 index ded0036e8454..000000000000 --- a/third_party/boost_stacktrace/include/boost/stacktrace/safe_dump_to.hpp +++ /dev/null @@ -1,222 +0,0 @@ -// Copyright Antony Polukhin, 2016-2017. -// -// 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 BOOST_STACKTRACE_SAFE_DUMP_TO_HPP -#define BOOST_STACKTRACE_SAFE_DUMP_TO_HPP - -#include -#ifdef BOOST_HAS_PRAGMA_ONCE -# pragma once -#endif - -#if defined(BOOST_WINDOWS) -#include -#endif - -#include - -#ifdef BOOST_INTEL -# pragma warning(push) -# pragma warning(disable:2196) // warning #2196: routine is both "inline" and "noinline" -#endif - -/// @file safe_dump_to.hpp This header contains low-level async-signal-safe functions for dumping call stacks. Dumps are binary serialized arrays of `void*`, -/// so you could read them by using 'od -tx8 -An stacktrace_dump_failename' Linux command or using boost::stacktrace::stacktrace::from_dump functions. - -namespace boost { namespace stacktrace { - -/// @cond -namespace detail { - - typedef const void* native_frame_ptr_t; // TODO: change to `typedef void(*native_frame_ptr_t)();` - enum helper{ max_frames_dump = 128 }; - - BOOST_STACKTRACE_FUNCTION std::size_t from_dump(const char* filename, native_frame_ptr_t* out_frames); - BOOST_STACKTRACE_FUNCTION std::size_t dump(const char* file, const native_frame_ptr_t* frames, std::size_t frames_count) BOOST_NOEXCEPT; -#if defined(BOOST_WINDOWS) - BOOST_STACKTRACE_FUNCTION std::size_t dump(void* fd, const native_frame_ptr_t* frames, std::size_t frames_count) BOOST_NOEXCEPT; -#else - // POSIX - BOOST_STACKTRACE_FUNCTION std::size_t dump(int fd, const native_frame_ptr_t* frames, std::size_t frames_count) BOOST_NOEXCEPT; -#endif - - -struct this_thread_frames { // struct is required to avoid warning about usage of inline+BOOST_NOINLINE - BOOST_NOINLINE BOOST_STACKTRACE_FUNCTION static std::size_t collect(native_frame_ptr_t* out_frames, std::size_t max_frames_count, std::size_t skip) BOOST_NOEXCEPT; - - BOOST_NOINLINE static std::size_t safe_dump_to_impl(void* memory, std::size_t size, std::size_t skip) BOOST_NOEXCEPT { - typedef boost::stacktrace::detail::native_frame_ptr_t native_frame_ptr_t; - - if (size < sizeof(native_frame_ptr_t)) { - return 0; - } - - native_frame_ptr_t* mem = static_cast(memory); - const std::size_t frames_count = boost::stacktrace::detail::this_thread_frames::collect(mem, size / sizeof(native_frame_ptr_t) - 1, skip + 1); - mem[frames_count] = 0; - return frames_count + 1; - } - - template - BOOST_NOINLINE static std::size_t safe_dump_to_impl(T file, std::size_t skip, std::size_t max_depth) BOOST_NOEXCEPT { - typedef boost::stacktrace::detail::native_frame_ptr_t native_frame_ptr_t; - - native_frame_ptr_t buffer[boost::stacktrace::detail::max_frames_dump + 1]; - if (max_depth > boost::stacktrace::detail::max_frames_dump) { - max_depth = boost::stacktrace::detail::max_frames_dump; - } - - const std::size_t frames_count = boost::stacktrace::detail::this_thread_frames::collect(buffer, max_depth, skip + 1); - buffer[frames_count] = 0; - return boost::stacktrace::detail::dump(file, buffer, frames_count + 1); - } -}; - -} // namespace detail -/// @endcond - -/// @brief Stores current function call sequence into the memory. -/// -/// @b Complexity: O(N) where N is call sequence length, O(1) if BOOST_STACKTRACE_USE_NOOP is defined. -/// -/// @b Async-Handler-Safety: Safe. -/// -/// @returns Stored call sequence depth including terminating zero frame. -/// -/// @param memory Preallocated buffer to store current function call sequence into. -/// -/// @param size Size of the preallocated buffer. -BOOST_FORCEINLINE std::size_t safe_dump_to(void* memory, std::size_t size) BOOST_NOEXCEPT { - return boost::stacktrace::detail::this_thread_frames::safe_dump_to_impl(memory, size, 0); -} - -/// @brief Stores current function call sequence into the memory. -/// -/// @b Complexity: O(N) where N is call sequence length, O(1) if BOOST_STACKTRACE_USE_NOOP is defined. -/// -/// @b Async-Handler-Safety: Safe. -/// -/// @returns Stored call sequence depth including terminating zero frame. -/// -/// @param skip How many top calls to skip and do not store. -/// -/// @param memory Preallocated buffer to store current function call sequence into. -/// -/// @param size Size of the preallocated buffer. -BOOST_FORCEINLINE std::size_t safe_dump_to(std::size_t skip, void* memory, std::size_t size) BOOST_NOEXCEPT { - return boost::stacktrace::detail::this_thread_frames::safe_dump_to_impl(memory, size, skip); -} - - -/// @brief Opens a file and rewrites its content with current function call sequence if such operations are async signal safe. -/// -/// @b Complexity: O(N) where N is call sequence length, O(1) if BOOST_STACKTRACE_USE_NOOP is defined. -/// -/// @b Async-Handler-Safety: Safe. -/// -/// @returns Stored call sequence depth including terminating zero frame. -/// -/// @param file File to store current function call sequence. -BOOST_FORCEINLINE std::size_t safe_dump_to(const char* file) BOOST_NOEXCEPT { - return boost::stacktrace::detail::this_thread_frames::safe_dump_to_impl(file, 0, boost::stacktrace::detail::max_frames_dump); -} - -/// @brief Opens a file and rewrites its content with current function call sequence if such operations are async signal safe. -/// -/// @b Complexity: O(N) where N is call sequence length, O(1) if BOOST_STACKTRACE_USE_NOOP is defined. -/// -/// @b Async-Handler-Safety: Safe. -/// -/// @returns Stored call sequence depth including terminating zero frame. -/// -/// @param skip How many top calls to skip and do not store. -/// -/// @param max_depth Max call sequence depth to collect. -/// -/// @param file File to store current function call sequence. -BOOST_FORCEINLINE std::size_t safe_dump_to(std::size_t skip, std::size_t max_depth, const char* file) BOOST_NOEXCEPT { - return boost::stacktrace::detail::this_thread_frames::safe_dump_to_impl(file, skip, max_depth); -} - -#ifdef BOOST_STACKTRACE_DOXYGEN_INVOKED - -/// @brief Writes into the provided file descriptor the current function call sequence if such operation is async signal safe. -/// -/// @b Complexity: O(N) where N is call sequence length, O(1) if BOOST_STACKTRACE_USE_NOOP is defined. -/// -/// @b Async-Handler-Safety: Safe. -/// -/// @returns Stored call sequence depth including terminating zero frame. -/// -/// @param file File to store current function call sequence. -BOOST_FORCEINLINE std::size_t safe_dump_to(platform_specific_descriptor fd) BOOST_NOEXCEPT; - -/// @brief Writes into the provided file descriptor the current function call sequence if such operation is async signal safe. -/// -/// @b Complexity: O(N) where N is call sequence length, O(1) if BOOST_STACKTRACE_USE_NOOP is defined. -/// -/// @b Async-Handler-Safety: Safe. -/// -/// @returns Stored call sequence depth including terminating zero frame. -/// -/// @param skip How many top calls to skip and do not store. -/// -/// @param max_depth Max call sequence depth to collect. -/// -/// @param file File to store current function call sequence. -BOOST_FORCEINLINE std::size_t safe_dump_to(std::size_t skip, std::size_t max_depth, platform_specific_descriptor fd) BOOST_NOEXCEPT; - -#elif defined(BOOST_WINDOWS) - -BOOST_FORCEINLINE std::size_t safe_dump_to(void* fd) BOOST_NOEXCEPT { - return boost::stacktrace::detail::this_thread_frames::safe_dump_to_impl(fd, 0, boost::stacktrace::detail::max_frames_dump); -} - -BOOST_FORCEINLINE std::size_t safe_dump_to(std::size_t skip, std::size_t max_depth, void* fd) BOOST_NOEXCEPT { - return boost::stacktrace::detail::this_thread_frames::safe_dump_to_impl(fd, skip, max_depth); -} - -#else - -// POSIX -BOOST_FORCEINLINE std::size_t safe_dump_to(int fd) BOOST_NOEXCEPT { - return boost::stacktrace::detail::this_thread_frames::safe_dump_to_impl(fd, 0, boost::stacktrace::detail::max_frames_dump); -} - -BOOST_FORCEINLINE std::size_t safe_dump_to(std::size_t skip, std::size_t max_depth, int fd) BOOST_NOEXCEPT { - return boost::stacktrace::detail::this_thread_frames::safe_dump_to_impl(fd, skip, max_depth); -} - -#endif - - -}} // namespace boost::stacktrace - -#ifdef BOOST_INTEL -# pragma warning(pop) -#endif - -#include - -#if !defined(BOOST_STACKTRACE_LINK) || defined(BOOST_STACKTRACE_INTERNAL_BUILD_LIBS) -# if defined(BOOST_STACKTRACE_USE_NOOP) -# include -# include -# else -# if defined(BOOST_WINDOWS) -# include -# else -# include -# endif -# if defined(BOOST_WINDOWS) && !defined(BOOST_WINAPI_IS_MINGW) // MinGW does not provide RtlCaptureStackBackTrace. MinGW-w64 does. -# include -# else -# include -# endif -# endif -#endif - -#endif // BOOST_STACKTRACE_SAFE_DUMP_TO_HPP diff --git a/third_party/boost_stacktrace/include/boost/stacktrace/stacktrace.hpp b/third_party/boost_stacktrace/include/boost/stacktrace/stacktrace.hpp deleted file mode 100644 index f4cf447dda68..000000000000 --- a/third_party/boost_stacktrace/include/boost/stacktrace/stacktrace.hpp +++ /dev/null @@ -1,424 +0,0 @@ -// Copyright Antony Polukhin, 2016-2017. -// -// 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 BOOST_STACKTRACE_STACKTRACE_HPP -#define BOOST_STACKTRACE_STACKTRACE_HPP - -#include -#ifdef BOOST_HAS_PRAGMA_ONCE -# pragma once -#endif - -#include - -#include -#include -#include - -#ifndef BOOST_NO_CXX11_HDR_TYPE_TRAITS -# include -#endif - -#include -#include -#include - -#ifdef BOOST_INTEL -# pragma warning(push) -# pragma warning(disable:2196) // warning #2196: routine is both "inline" and "noinline" -#endif - -namespace boost { namespace stacktrace { - -/// Class that on construction copies minimal information about call stack into its internals and provides access to that information. -/// @tparam Allocator Allocator to use during stack capture. -template -class basic_stacktrace { - std::vector impl_; - typedef boost::stacktrace::detail::native_frame_ptr_t native_frame_ptr_t; - - /// @cond - void fill(native_frame_ptr_t* begin, std::size_t size) { - if (!size) { - return; - } - - impl_.reserve(static_cast(size)); - for (std::size_t i = 0; i < size; ++i) { - if (!begin[i]) { - return; - } - impl_.push_back( - frame(begin[i]) - ); - } - } - - static std::size_t frames_count_from_buffer_size(std::size_t buffer_size) BOOST_NOEXCEPT { - const std::size_t ret = (buffer_size > sizeof(native_frame_ptr_t) ? buffer_size / sizeof(native_frame_ptr_t) : 0); - return (ret > 1024 ? 1024 : ret); // Dealing with suspiciously big sizes - } - - BOOST_NOINLINE void init(std::size_t frames_to_skip, std::size_t max_depth) { - BOOST_CONSTEXPR_OR_CONST std::size_t buffer_size = 128; - if (!max_depth) { - return; - } - - try { - { // Fast path without additional allocations - native_frame_ptr_t buffer[buffer_size]; - const std::size_t frames_count = boost::stacktrace::detail::this_thread_frames::collect(buffer, buffer_size, frames_to_skip + 1); - if (buffer_size > frames_count || frames_count >= max_depth) { - const std::size_t size = (max_depth < frames_count ? max_depth : frames_count); - fill(buffer, size); - return; - } - } - - // Failed to fit in `buffer_size`. Allocating memory: -#ifdef BOOST_NO_CXX11_ALLOCATOR - typedef typename Allocator::template rebind::other allocator_void_t; -#else - typedef typename std::allocator_traits::template rebind_alloc allocator_void_t; -#endif - std::vector buf(buffer_size * 2, 0, impl_.get_allocator()); - do { - const std::size_t frames_count = boost::stacktrace::detail::this_thread_frames::collect(&buf[0], buf.size(), frames_to_skip + 1); - if (buf.size() > frames_count || frames_count >= max_depth) { - const std::size_t size = (max_depth < frames_count ? max_depth : frames_count); - fill(&buf[0], size); - return; - } - - buf.resize(buf.size() * 2); - } while (buf.size() < buf.max_size()); // close to `true`, but suppresses `C4127: conditional expression is constant`. - } catch (...) { - // ignore exception - } - } - /// @endcond - -public: - typedef typename std::vector::value_type value_type; - typedef typename std::vector::allocator_type allocator_type; - typedef typename std::vector::const_pointer pointer; - typedef typename std::vector::const_pointer const_pointer; - typedef typename std::vector::const_reference reference; - typedef typename std::vector::const_reference const_reference; - typedef typename std::vector::size_type size_type; - typedef typename std::vector::difference_type difference_type; - typedef typename std::vector::const_iterator iterator; - typedef typename std::vector::const_iterator const_iterator; - typedef typename std::vector::const_reverse_iterator reverse_iterator; - typedef typename std::vector::const_reverse_iterator const_reverse_iterator; - - /// @brief Stores the current function call sequence inside *this without any decoding or any other heavy platform specific operations. - /// - /// @b Complexity: O(N) where N is call sequence length, O(1) if BOOST_STACKTRACE_USE_NOOP is defined. - /// - /// @b Async-Handler-Safety: Safe if Allocator construction, copying, Allocator::allocate and Allocator::deallocate are async signal safe. - BOOST_FORCEINLINE basic_stacktrace() BOOST_NOEXCEPT - : impl_() - { - init(0 , static_cast(-1)); - } - - /// @brief Stores the current function call sequence inside *this without any decoding or any other heavy platform specific operations. - /// - /// @b Complexity: O(N) where N is call sequence length, O(1) if BOOST_STACKTRACE_USE_NOOP is defined. - /// - /// @b Async-Handler-Safety: Safe if Allocator construction, copying, Allocator::allocate and Allocator::deallocate are async signal safe. - /// - /// @param a Allocator that would be passed to underlying storeage. - BOOST_FORCEINLINE explicit basic_stacktrace(const allocator_type& a) BOOST_NOEXCEPT - : impl_(a) - { - init(0 , static_cast(-1)); - } - - /// @brief Stores [skip, skip + max_depth) of the current function call sequence inside *this without any decoding or any other heavy platform specific operations. - /// - /// @b Complexity: O(N) where N is call sequence length, O(1) if BOOST_STACKTRACE_USE_NOOP is defined. - /// - /// @b Async-Handler-Safety: Safe if Allocator construction, copying, Allocator::allocate and Allocator::deallocate are async signal safe. - /// - /// @param skip How many top calls to skip and do not store in *this. - /// - /// @param max_depth Max call sequence depth to collect. - /// - /// @param a Allocator that would be passed to underlying storeage. - /// - /// @throws Nothing. Note that default construction of allocator may throw, however it is - /// performed outside the constructor and exception in `allocator_type()` would not result in calling `std::terminate`. - BOOST_FORCEINLINE basic_stacktrace(std::size_t skip, std::size_t max_depth, const allocator_type& a = allocator_type()) BOOST_NOEXCEPT - : impl_(a) - { - init(skip , max_depth); - } - - /// @b Complexity: O(st.size()) - /// - /// @b Async-Handler-Safety: Safe if Allocator construction, copying, Allocator::allocate and Allocator::deallocate are async signal safe. - basic_stacktrace(const basic_stacktrace& st) - : impl_(st.impl_) - {} - - /// @b Complexity: O(st.size()) - /// - /// @b Async-Handler-Safety: Safe if Allocator construction, copying, Allocator::allocate and Allocator::deallocate are async signal safe. - basic_stacktrace& operator=(const basic_stacktrace& st) { - impl_ = st.impl_; - return *this; - } - -#ifdef BOOST_STACKTRACE_DOXYGEN_INVOKED - /// @b Complexity: O(1) - /// - /// @b Async-Handler-Safety: Safe if Allocator::deallocate is async signal safe. - ~basic_stacktrace() BOOST_NOEXCEPT = default; -#endif - -#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) - /// @b Complexity: O(1) - /// - /// @b Async-Handler-Safety: Safe if Allocator construction and copying are async signal safe. - basic_stacktrace(basic_stacktrace&& st) BOOST_NOEXCEPT - : impl_(std::move(st.impl_)) - {} - - /// @b Complexity: O(st.size()) - /// - /// @b Async-Handler-Safety: Safe if Allocator construction and copying are async signal safe. - basic_stacktrace& operator=(basic_stacktrace&& st) -#ifndef BOOST_NO_CXX11_HDR_TYPE_TRAITS - BOOST_NOEXCEPT_IF(( std::is_nothrow_move_assignable< std::vector >::value )) -#else - BOOST_NOEXCEPT -#endif - { - impl_ = std::move(st.impl_); - return *this; - } -#endif - - /// @returns Number of function names stored inside the class. - /// - /// @b Complexity: O(1) - /// - /// @b Async-Handler-Safety: Safe. - size_type size() const BOOST_NOEXCEPT { - return impl_.size(); - } - - /// @param frame_no Zero based index of frame to return. 0 - /// is the function index where stacktrace was constructed and - /// index close to this->size() contains function `main()`. - /// @returns frame that references the actual frame info, stored inside *this. - /// - /// @b Complexity: O(1). - /// - /// @b Async-Handler-Safety: Safe. - const_reference operator[](std::size_t frame_no) const BOOST_NOEXCEPT { - return impl_[frame_no]; - } - - /// @b Complexity: O(1) - /// - /// @b Async-Handler-Safety: Safe. - const_iterator begin() const BOOST_NOEXCEPT { return impl_.begin(); } - /// @b Complexity: O(1) - /// - /// @b Async-Handler-Safety: Safe. - const_iterator cbegin() const BOOST_NOEXCEPT { return impl_.begin(); } - /// @b Complexity: O(1) - /// - /// @b Async-Handler-Safety: Safe. - const_iterator end() const BOOST_NOEXCEPT { return impl_.end(); } - /// @b Complexity: O(1) - /// - /// @b Async-Handler-Safety: Safe. - const_iterator cend() const BOOST_NOEXCEPT { return impl_.end(); } - - /// @b Complexity: O(1) - /// - /// @b Async-Handler-Safety: Safe. - const_reverse_iterator rbegin() const BOOST_NOEXCEPT { return impl_.rbegin(); } - /// @b Complexity: O(1) - /// - /// @b Async-Handler-Safety: Safe. - const_reverse_iterator crbegin() const BOOST_NOEXCEPT { return impl_.rbegin(); } - /// @b Complexity: O(1) - /// - /// @b Async-Handler-Safety: Safe. - const_reverse_iterator rend() const BOOST_NOEXCEPT { return impl_.rend(); } - /// @b Complexity: O(1) - /// - /// @b Async-Handler-Safety: Safe. - const_reverse_iterator crend() const BOOST_NOEXCEPT { return impl_.rend(); } - - - /// @brief Allows to check that stack trace capturing was successful. - /// @returns `true` if `this->size() != 0` - /// - /// @b Complexity: O(1) - /// - /// @b Async-Handler-Safety: Safe. - explicit operator bool() const BOOST_NOEXCEPT { - return !!*this; - } - - /// @brief Allows to check that stack trace failed. - /// @returns `true` if `this->size() == 0` - /// - /// @b Complexity: O(1) - /// - /// @b Async-Handler-Safety: Safe. - bool empty() const BOOST_NOEXCEPT { return !size(); } - - /// @cond - bool operator!() const BOOST_NOEXCEPT { return !size(); } - /// @endcond - - const std::vector& as_vector() const BOOST_NOEXCEPT { - return impl_; - } - - /// Constructs stacktrace from basic_istreamable that references the dumped stacktrace. Terminating zero frame is discarded. - /// - /// @b Complexity: O(N) - template - static basic_stacktrace from_dump(std::basic_istream& in, const allocator_type& a = allocator_type()) { - typedef typename std::basic_istream::pos_type pos_type; - basic_stacktrace ret(0, 0, a); - - // reserving space - const pos_type pos = in.tellg(); - in.seekg(0, in.end); - const std::size_t frames_count = frames_count_from_buffer_size(static_cast(in.tellg())); - in.seekg(pos); - - if (!frames_count) { - return ret; - } - - native_frame_ptr_t ptr = 0; - ret.impl_.reserve(frames_count); - while (in.read(reinterpret_cast(&ptr), sizeof(ptr))) { - if (!ptr) { - break; - } - - ret.impl_.push_back(frame(ptr)); - } - - return ret; - } - - /// Constructs stacktrace from raw memory dump. Terminating zero frame is discarded. - /// - /// @b Complexity: O(size) in worst case - static basic_stacktrace from_dump(const void* begin, std::size_t buffer_size_in_bytes, const allocator_type& a = allocator_type()) { - basic_stacktrace ret(0, 0, a); - const native_frame_ptr_t* first = static_cast(begin); - const std::size_t frames_count = frames_count_from_buffer_size(buffer_size_in_bytes); - if (!frames_count) { - return ret; - } - - const native_frame_ptr_t* const last = first + frames_count; - ret.impl_.reserve(frames_count); - for (; first != last; ++first) { - if (!*first) { - break; - } - - ret.impl_.push_back(frame(*first)); - } - - return ret; - } -}; - -/// @brief Compares stacktraces for less, order is platform dependent. -/// -/// @b Complexity: Amortized O(1); worst case O(size()) -/// -/// @b Async-Handler-Safety: Safe. -template -bool operator< (const basic_stacktrace& lhs, const basic_stacktrace& rhs) BOOST_NOEXCEPT { - return lhs.size() < rhs.size() || (lhs.size() == rhs.size() && lhs.as_vector() < rhs.as_vector()); -} - -/// @brief Compares stacktraces for equality. -/// -/// @b Complexity: Amortized O(1); worst case O(size()) -/// -/// @b Async-Handler-Safety: Safe. -template -bool operator==(const basic_stacktrace& lhs, const basic_stacktrace& rhs) BOOST_NOEXCEPT { - return lhs.as_vector() == rhs.as_vector(); -} - - -/// Comparison operators that provide platform dependant ordering and have amortized O(1) complexity; O(size()) worst case complexity; are Async-Handler-Safe. -template -bool operator> (const basic_stacktrace& lhs, const basic_stacktrace& rhs) BOOST_NOEXCEPT { - return rhs < lhs; -} - -template -bool operator<=(const basic_stacktrace& lhs, const basic_stacktrace& rhs) BOOST_NOEXCEPT { - return !(lhs > rhs); -} - -template -bool operator>=(const basic_stacktrace& lhs, const basic_stacktrace& rhs) BOOST_NOEXCEPT { - return !(lhs < rhs); -} - -template -bool operator!=(const basic_stacktrace& lhs, const basic_stacktrace& rhs) BOOST_NOEXCEPT { - return !(lhs == rhs); -} - -/// Fast hashing support, O(st.size()) complexity; Async-Handler-Safe. -template -std::size_t hash_value(const basic_stacktrace& st) BOOST_NOEXCEPT { - return boost::hash_range(st.as_vector().begin(), st.as_vector().end()); -} - -/// Outputs stacktrace in a human readable format to output stream; unsafe to use in async handlers. -template -std::basic_ostream& operator<<(std::basic_ostream& os, const basic_stacktrace& bt) { - if (bt) { - os << boost::stacktrace::detail::to_string(&bt.as_vector()[0], bt.size()); - } - - return os; -} - -/// Outputs stacktrace in a human readable format to std::string; unsafe to use in async handlers. -template -std::string to_string(const basic_stacktrace& bt) { - if (bt) { - return boost::stacktrace::detail::to_string(&bt.as_vector()[0], bt.size()); - } else { - return std::string(); - } -} - - -/// This is the typedef to use unless you'd like to provide a specific allocator to boost::stacktrace::basic_stacktrace. -typedef basic_stacktrace<> stacktrace; - -}} // namespace boost::stacktrace - -#ifdef BOOST_INTEL -# pragma warning(pop) -#endif - -#endif // BOOST_STACKTRACE_STACKTRACE_HPP diff --git a/third_party/boost_stacktrace/include/boost/stacktrace/stacktrace_fwd.hpp b/third_party/boost_stacktrace/include/boost/stacktrace/stacktrace_fwd.hpp deleted file mode 100644 index ec131564c0fd..000000000000 --- a/third_party/boost_stacktrace/include/boost/stacktrace/stacktrace_fwd.hpp +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright Antony Polukhin, 2016-2017. -// -// 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 BOOST_STACKTRACE_STACKTRACE_FWD_HPP -#define BOOST_STACKTRACE_STACKTRACE_FWD_HPP - -#include -#include - -/// @file stacktrace_fwd.hpp This header contains only forward declarations of -/// boost::stacktrace::frame, boost::stacktrace::basic_stacktrace, boost::stacktrace::stacktrace -/// and does not include any other Boost headers. - -/// @cond -namespace boost { namespace stacktrace { - -class frame; -template > class basic_stacktrace; -typedef basic_stacktrace<> stacktrace; - -}} // namespace boost::stacktrace -/// @endcond - - -#endif // BOOST_STACKTRACE_STACKTRACE_FWD_HPP diff --git a/third_party/boost_stacktrace/src/addr2line.cpp b/third_party/boost_stacktrace/src/addr2line.cpp deleted file mode 100644 index 9a64dd310c0e..000000000000 --- a/third_party/boost_stacktrace/src/addr2line.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright Antony Polukhin, 2016-2017. -// -// 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) - -#define BOOST_STACKTRACE_INTERNAL_BUILD_LIBS -#define BOOST_STACKTRACE_USE_ADDR2LINE -#define BOOST_STACKTRACE_LINK - -#ifndef _GNU_SOURCE -# define _GNU_SOURCE -#endif - -#include -#include diff --git a/third_party/boost_stacktrace/src/backtrace.cpp b/third_party/boost_stacktrace/src/backtrace.cpp deleted file mode 100644 index 8ac9ec0cd51f..000000000000 --- a/third_party/boost_stacktrace/src/backtrace.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright Antony Polukhin, 2016-2017. -// -// 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) - -#define BOOST_STACKTRACE_INTERNAL_BUILD_LIBS -#define BOOST_STACKTRACE_USE_BACKTRACE -#define BOOST_STACKTRACE_LINK - -#ifndef _GNU_SOURCE -# define _GNU_SOURCE -#endif - -#include -#include diff --git a/third_party/boost_stacktrace/src/basic.cpp b/third_party/boost_stacktrace/src/basic.cpp deleted file mode 100644 index 5ae71ba246c1..000000000000 --- a/third_party/boost_stacktrace/src/basic.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright Antony Polukhin, 2016-2017. -// -// 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) - -#define BOOST_STACKTRACE_INTERNAL_BUILD_LIBS -#define BOOST_STACKTRACE_LINK - -#ifndef _GNU_SOURCE -# define _GNU_SOURCE -#endif - -#include -#include diff --git a/third_party/boost_stacktrace/src/noop.cpp b/third_party/boost_stacktrace/src/noop.cpp deleted file mode 100644 index e895eb22cfd4..000000000000 --- a/third_party/boost_stacktrace/src/noop.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright Antony Polukhin, 2016-2017. -// -// 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) - -#define BOOST_STACKTRACE_INTERNAL_BUILD_LIBS -#define BOOST_STACKTRACE_LINK -#define BOOST_STACKTRACE_USE_NOOP -#include -#include diff --git a/third_party/boost_stacktrace/src/windbg.cpp b/third_party/boost_stacktrace/src/windbg.cpp deleted file mode 100644 index ea1cf906444d..000000000000 --- a/third_party/boost_stacktrace/src/windbg.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright Antony Polukhin, 2016-2017. -// -// 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) - -#define BOOST_STACKTRACE_INTERNAL_BUILD_LIBS -#define BOOST_STACKTRACE_LINK -#include -#include diff --git a/third_party/boost_stacktrace/src/windbg_cached.cpp b/third_party/boost_stacktrace/src/windbg_cached.cpp deleted file mode 100644 index fdf3a5dec72d..000000000000 --- a/third_party/boost_stacktrace/src/windbg_cached.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright Antony Polukhin, 2016-2017. -// -// 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) - -#define BOOST_STACKTRACE_INTERNAL_BUILD_LIBS -#define BOOST_STACKTRACE_LINK -#define BOOST_STACKTRACE_USE_WINDBG_CACHED -#include -#include diff --git a/universal/CMakeLists.txt b/universal/CMakeLists.txt index 1fe6be5b0042..3644dfbb4ea3 100644 --- a/universal/CMakeLists.txt +++ b/universal/CMakeLists.txt @@ -28,7 +28,13 @@ list(REMOVE_ITEM SOURCES ${UNIT_TEST_SOURCES} ${BENCH_SOURCES} ${INTERNAL_SOURCE set(CMAKE_THREAD_PREFER_PTHREAD ON) set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) -find_package(Boost REQUIRED COMPONENTS program_options filesystem regex) +find_package(Boost REQUIRED COMPONENTS + program_options + filesystem + regex + stacktrace_basic + stacktrace_backtrace +) include(UserverRequireDWCAS) # Should be called after `find_package(Boost REQUIRED)` message(STATUS "boost: ${Boost_VERSION_STRING}") @@ -225,7 +231,6 @@ target_link_libraries(${PROJECT_NAME} ) if (USERVER_CONAN) - find_package(Boost COMPONENTS stacktrace REQUIRED) target_link_libraries(${PROJECT_NAME} PUBLIC fmt::fmt @@ -237,7 +242,10 @@ if (USERVER_CONAN) rapidjson ) else() - add_subdirectory("${USERVER_THIRD_PARTY_DIRS}/boost_stacktrace" boost_stacktrace_build) + include(Stacktrace) + _make_stacktrace_target(userver-stacktrace "${Boost_VERSION_STRING}") + userver_install_targets(TARGETS userver-stacktrace) + target_link_libraries(${PROJECT_NAME} PUBLIC fmt