Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore enhanced stacktraces when libbacktrace is not found #192

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 15 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,29 +48,10 @@ endif()
target_include_directories(${PROJECT_NAME} PRIVATE ${CURL_INCLUDE_DIRS})

find_package(Backtrace QUIET)
if (${Backtrace_FOUND})
if (Backtrace_FOUND)
target_link_libraries(${PROJECT_NAME} PRIVATE ${Backtrace_LIBRARIES})

find_library(DW_LIB NAMES dw)
if (NOT DW_LIB STREQUAL DW_LIB-NOTFOUND)
message("-- Enhanced stack-traces are enabled via libdw: ${DW_LIB}")
target_compile_definitions(${PROJECT_NAME} PRIVATE "BACKWARD_HAS_DW=1")
target_link_libraries(${PROJECT_NAME} PUBLIC "${DW_LIB}")
else()
find_library(BFD_LIB NAMES bfd)
if (NOT BFD_LIB STREQUAL BFD_LIB-NOTFOUND)
message("-- Enhanced stack-traces are enabled via libbfd: ${BFD_LIB}")
target_compile_definitions(${PROJECT_NAME} PRIVATE "BACKWARD_HAS_BFD=1")
target_link_libraries(${PROJECT_NAME} PRIVATE "${BFD_LIB}")
endif()
endif()

else()
message("-- libbacktrace was not installed. Stacktracing will be disabled")
add_definitions(-Dno_backtrace)
endif()


target_compile_options(${PROJECT_NAME} PRIVATE
"-fno-exceptions"
"-fno-rtti"
Expand All @@ -82,6 +63,20 @@ target_compile_options(${PROJECT_NAME} PRIVATE
"-Wconversion"
"-Wno-sign-conversion")

find_library(DW_LIB NAMES dw)
if (NOT DW_LIB STREQUAL DW_LIB-NOTFOUND)
message("-- Enhanced stack-traces are enabled via libdw: ${DW_LIB}")
target_compile_definitions(${PROJECT_NAME} PRIVATE "BACKWARD_HAS_DW=1")
target_link_libraries(${PROJECT_NAME} PUBLIC "${DW_LIB}")
else()
find_library(BFD_LIB NAMES bfd)
if (NOT BFD_LIB STREQUAL BFD_LIB-NOTFOUND)
message("-- Enhanced stack-traces are enabled via libbfd: ${BFD_LIB}")
target_compile_definitions(${PROJECT_NAME} PRIVATE "BACKWARD_HAS_BFD=1")
target_link_libraries(${PROJECT_NAME} PRIVATE "${BFD_LIB}")
endif()
endif()

if (LOG_VERBOSITY)
target_compile_definitions(${PROJECT_NAME} PRIVATE "AWS_LAMBDA_LOG=${LOG_VERBOSITY}")
elseif(CMAKE_BUILD_TYPE STREQUAL Debug)
Expand Down
6 changes: 1 addition & 5 deletions src/backward.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,10 @@
// - g++/clang++ -lbfd ...
// #define BACKWARD_HAS_BFD 1

#ifndef no_backtrace

# include "backward.h"
#include "backward.h"

namespace backward {

backward::SignalHandling sh;

} // namespace backward

#endif
6 changes: 0 additions & 6 deletions src/backward.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@
# error "It's not going to compile without a C++ compiler..."
#endif

#ifdef no_backtrace
# pragma message "Disabling stacktracing"
#else

#if defined(BACKWARD_CXX11)
#elif defined(BACKWARD_CXX98)
#else
Expand Down Expand Up @@ -4543,6 +4539,4 @@ class SignalHandling {

} // namespace backward

#endif /* no_backtrace */

#endif /* H_GUARD */