Skip to content

Commit

Permalink
re-enable ultimate stack traces for backward-cpp on linux (#67)
Browse files Browse the repository at this point in the history
During the transition to Conan and CMake, we lost the configuration necessary
for ultimate stack traces to be recorded on Linux platforms. This only works
on Linux, so we need to conditionally link the extra libraries.
  • Loading branch information
copperlight authored Aug 21, 2023
1 parent 6922cde commit 01712fd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
18 changes: 17 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ include(CTest)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

if (UNIX AND NOT APPLE)
message(STATUS "platform is linux")
set(BACKWARD_LIBS "-lbfd -ldl")
else()
message(STATUS "platform is NOT linux")
set(BACKWARD_LIBS "")
endif()

add_subdirectory(admin)
add_subdirectory(bench)
add_subdirectory(server)
Expand All @@ -32,6 +40,7 @@ target_link_libraries(spectator_test
sample_cfg
spectator
util
${BACKWARD_LIBS}
${CONAN_LIBS}
)
add_test(
Expand All @@ -50,7 +59,12 @@ add_executable(spectatord_test
"spectator/test_utils.h"
)
target_include_directories(spectatord_test PRIVATE ${CMAKE_SOURCE_DIR})
target_link_libraries(spectatord_test admin_server spectatord ${CONAN_LIBS})
target_link_libraries(spectatord_test
admin_server
spectatord
${BACKWARD_LIBS}
${CONAN_LIBS}
)
add_test(
NAME spectatord_test
COMMAND spectatord_test
Expand All @@ -70,6 +84,7 @@ if(NFLX_INTERNAL)
netflix_cfg
spectatord
admin_server
${BACKWARD_LIBS}
${CONAN_LIBS}
)
else()
Expand All @@ -78,6 +93,7 @@ else()
sample_cfg
spectatord
admin_server
${BACKWARD_LIBS}
${CONAN_LIBS}
)
endif()
Expand Down
3 changes: 3 additions & 0 deletions bin/spectatord_main.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#ifdef __linux__
#define BACKWARD_HAS_BFD 1
#endif
#include "backward.hpp"
#include "util/logger.h"
#include "spectatord.h"
Expand Down
3 changes: 3 additions & 0 deletions bin/test_main.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#ifdef __linux__
#define BACKWARD_HAS_BFD 1
#endif
#include "backward.hpp"
#include <gtest/gtest.h>

Expand Down

0 comments on commit 01712fd

Please sign in to comment.