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

Link boost stacktrace appropriately for line information. #4771

Open
wants to merge 2 commits into
base: develop
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
23 changes: 11 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,6 @@ set(NANO_ROCKSDB_TOOLS
OFF
CACHE BOOL "")

option(NANO_STACKTRACE_BACKTRACE
"Use BOOST_STACKTRACE_USE_BACKTRACE in stacktraces, for POSIX" OFF)

if(NANO_STACKTRACE_BACKTRACE)
add_definitions(-DNANO_STACKTRACE_BACKTRACE)
add_definitions(-DBOOST_STACKTRACE_USE_BACKTRACE)
if(NANO_BACKTRACE_INCLUDE)
add_definitions(
-DBOOST_STACKTRACE_BACKTRACE_INCLUDE_FILE=${NANO_BACKTRACE_INCLUDE})
endif()
endif()

# Enable NANO_TRACING by default in Debug builds
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
option(NANO_TRACING "Enable trace logging" ON)
Expand Down Expand Up @@ -497,6 +485,17 @@ include_directories(${BOOST_LIBRARY_INCLUDES})
add_library(Boost::stacktrace ALIAS boost_stacktrace_basic)
add_definitions(-DBOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED)

if(WIN32)
# Windows-specific configuration
target_link_libraries(boost_stacktrace_basic PRIVATE dbghelp)
else()
# Unix-like systems (Linux, macOS)
target_link_libraries(boost_stacktrace_basic PRIVATE dl)

# Add -rdynamic linker flag for better symbol resolution
target_link_options(boost_stacktrace_basic PRIVATE -rdynamic)
endif()

# Workaround for missing reference errata in the boost property_tree module
target_link_libraries(boost_property_tree INTERFACE Boost::any)
target_link_libraries(boost_property_tree INTERFACE Boost::format)
Expand Down
11 changes: 0 additions & 11 deletions ci/build-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,6 @@ fi

ulimit -S -n 8192

if [[ "$OS" == 'Linux' ]]; then
if clang --version && [ ${LCOV:-0} == 0 ]; then
BACKTRACE="-DNANO_STACKTRACE_BACKTRACE=ON \
-DNANO_BACKTRACE_INCLUDE=</tmp/backtrace.h>"
else
BACKTRACE="-DNANO_STACKTRACE_BACKTRACE=ON"
fi
else
BACKTRACE=""
fi

cmake \
-G'Unix Makefiles' \
-DACTIVE_NETWORK=nano_dev_network \
Expand Down
9 changes: 0 additions & 9 deletions ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,6 @@ fi
SRC=${SRC:-${PWD}}
OS=$(uname)

CMAKE_BACKTRACE=""
if [[ ${OS} == 'Linux' ]]; then
CMAKE_BACKTRACE="-DNANO_STACKTRACE_BACKTRACE=ON"

if [[ ${COMPILER:-} == 'clang' ]]; then
CMAKE_BACKTRACE="${CMAKE_BACKTRACE} -DNANO_BACKTRACE_INCLUDE=</tmp/backtrace.h>"
fi
fi

CMAKE_QT_DIR=""
if [[ ${QT_DIR:-} ]]; then
CMAKE_QT_DIR="-DQt5_DIR=${QT_DIR}"
Expand Down
4 changes: 0 additions & 4 deletions ci/prepare/linux/prepare-clang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,3 @@ curl -O https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && ./llvm.sh $CLANG_VER
update-alternatives --install /usr/bin/cc cc /usr/bin/clang-$CLANG_VERSION 100
update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++-$CLANG_VERSION 100
update-alternatives --install /usr/bin/lldb lldb /usr/bin/lldb-$CLANG_VERSION 100

# Workaround to get a path that can be easily passed into cmake for BOOST_STACKTRACE_BACKTRACE_INCLUDE_FILE
# See https://www.boost.org/doc/libs/1_70_0/doc/html/stacktrace/configuration_and_build.html#stacktrace.configuration_and_build.f3
backtrace_file=$(find /usr/lib/gcc/ -name 'backtrace.h' | head -n 1) && test -f $backtrace_file && ln -s $backtrace_file /tmp/backtrace.h
1 change: 1 addition & 0 deletions nano/core_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ add_executable(
request_aggregator.cpp
signal_manager.cpp
socket.cpp
stacktrace.cpp
system.cpp
telemetry.cpp
throttle.cpp
Expand Down
13 changes: 13 additions & 0 deletions nano/core_test/stacktrace.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <nano/lib/stacktrace.hpp>

#include <gtest/gtest.h>

// Check that the stacktrace contains the current function name
// This depends on the way testcase names are compiled by gtest
// Current name: "stacktrace_human_readable_Test::TestBody()"
TEST (stacktrace, human_readable)
{
auto stacktrace = nano::generate_stacktrace ();
ASSERT_FALSE (stacktrace.empty ());
ASSERT_TRUE (stacktrace.find ("stacktrace_human_readable_Test") != std::string::npos);
}
4 changes: 0 additions & 4 deletions nano/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,6 @@ target_link_libraries(
Boost::property_tree
Boost::stacktrace)

if(NANO_STACKTRACE_BACKTRACE)
target_link_libraries(nano_lib backtrace)
endif()

target_compile_definitions(
nano_lib
PRIVATE -DMAJOR_VERSION_STRING=${CPACK_PACKAGE_VERSION_MAJOR}
Expand Down
Loading