switch to backward-cpp

This commit is contained in:
Scott E. Graves 2024-07-27 09:13:43 -05:00
parent 42b67a7b61
commit ca799298f4
5 changed files with 4544 additions and 25 deletions

View File

@ -45,6 +45,7 @@ decmult_gen_prec_bits
decmult_window_size
degl
denable_threaded_resolver
deps
devent__disable_openssl
devent__disable_tests
devent__library_type

4496
deps/include/backward.hpp vendored Normal file

File diff suppressed because it is too large Load Diff

42
deps/src/backward.cpp vendored Normal file
View File

@ -0,0 +1,42 @@
// Pick your poison.
//
// On GNU/Linux, you have few choices to get the most out of your stack trace.
//
// By default you get:
// - object filename
// - function name
//
// In order to add:
// - source filename
// - line and column numbers
// - source code snippet (assuming the file is accessible)
// Install one of the following libraries then uncomment one of the macro (or
// better, add the detection of the lib and the macro definition in your build
// system)
// - apt-get install libdw-dev ...
// - g++/clang++ -ldw ...
// #define BACKWARD_HAS_DW 1
// - apt-get install binutils-dev ...
// - g++/clang++ -lbfd ...
// #define BACKWARD_HAS_BFD 1
// - apt-get install libdwarf-dev ...
// - g++/clang++ -ldwarf ...
// #define BACKWARD_HAS_DWARF 1
// Regardless of the library you choose to read the debug information,
// for potentially more detailed stack traces you can use libunwind
// - apt-get install libunwind-dev
// - g++/clang++ -lunwind
// #define BACKWARD_HAS_LIBUNWIND 1
#include "backward.hpp"
namespace backward {
backward::SignalHandling sh;
} // namespace backward

View File

@ -1,29 +1,9 @@
if (NOT PROJECT_STATIC_LINK)
if(PROJECT_IS_MINGW)
add_definitions(-DCPPTRACE_UNWIND_WITH_DBGHELP)
else()
add_definitions(-DCPPTRACE_UNWIND_WITH_UNWIND)
endif()
include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/deps/include)
include(FetchContent)
FetchContent_Declare(
cpptrace
GIT_REPOSITORY https://github.com/jeremy-rifkin/cpptrace.git
GIT_TAG v0.6.3
list(APPEND PROJECT_ADDITIONAL_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/deps/src/backward.cpp
)
FetchContent_MakeAvailable(cpptrace)
if(WIN32)
add_custom_command(
TARGET ${PROJECT_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:cpptrace::cpptrace>
$<TARGET_FILE_DIR:your_target>
)
endif()
link_libraries(cpptrace::cpptrace)
endif()
set(CMAKE_CXX_FLAGS "-include common.hpp ${CMAKE_CXX_FLAGS}")

View File

@ -20,7 +20,7 @@
SOFTWARE.
*/
#if !defined(PROJECT_STATIC_LINK)
#include "cpptrace/cpptrace.hpp"
#include "backward.hpp"
#endif
#include "cli/actions.hpp"
@ -33,7 +33,7 @@ using namespace repertory;
auto main(int argc, char **argv) -> int {
#if !defined(PROJECT_STATIC_LINK)
cpptrace::register_terminate_handler();
static backward::SignalHandling sh;
#endif
if (not repertory::project_initialize()) {