Skip to content

Commit

Permalink
Use cmake find_library result to switch
Browse files Browse the repository at this point in the history
  • Loading branch information
at-wat committed Feb 18, 2023
1 parent 2eb80dd commit 30518b6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions rtloader/rtloader/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ add_library(datadog-agent-rtloader SHARED
find_library(EXECINFO execinfo)
if(EXECINFO)
target_link_libraries(datadog-agent-rtloader execinfo)
add_compile_definitions(HAS_BACKTRACE_LIB)
endif()
endif()

Expand Down
6 changes: 3 additions & 3 deletions rtloader/rtloader/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#ifndef _WIN32
// clang-format off
// handler stuff
#ifdef __GLIBC__
#ifdef HAS_BACKTRACE_LIB
#include <execinfo.h>
#endif
#include <csignal>
Expand Down Expand Up @@ -373,14 +373,14 @@ static inline void core(int sig)
# define STACKTRACE_SIZE 500
void signalHandler(int sig, siginfo_t *, void *)
{
# ifdef __GLIBC__
# ifdef HAS_BACKTRACE_LIB
void *buffer[STACKTRACE_SIZE];
char **symbols;

size_t nptrs = backtrace(buffer, STACKTRACE_SIZE);
# endif
std::cerr << "HANDLER CAUGHT signal Error: signal " << sig << std::endl;
# ifdef __GLIBC__
# ifdef HAS_BACKTRACE_LIB
symbols = backtrace_symbols(buffer, nptrs);
if (symbols == NULL) {
std::cerr << "Error getting backtrace symbols" << std::endl;
Expand Down

0 comments on commit 30518b6

Please sign in to comment.