From 28a9a289e0ff9c159bd1293edc6e0294df61cf26 Mon Sep 17 00:00:00 2001 From: Tobin Baker Date: Wed, 7 Jul 2021 21:40:25 -0700 Subject: [PATCH] Enable stack traces by default in all SDK and test executables (#768) --- production/CMakeLists.txt | 9 +++++++-- production/catalog/gaiac/CMakeLists.txt | 4 ++++ production/cmake/gaia_internal.cmake | 4 ++++ production/db/core/CMakeLists.txt | 8 ++------ .../core/src => inc/gaia_internal/common}/backward.cpp | 0 production/tools/gaia_translate/CMakeLists.txt | 4 ++++ 6 files changed, 21 insertions(+), 8 deletions(-) rename production/{db/core/src => inc/gaia_internal/common}/backward.cpp (100%) diff --git a/production/CMakeLists.txt b/production/CMakeLists.txt index dbb0bbd1bfd0..f7242dc58093 100644 --- a/production/CMakeLists.txt +++ b/production/CMakeLists.txt @@ -14,7 +14,7 @@ project(production VERSION 0.1.0) option(EXECUTE_FDW_TESTS "Execute FDW tests" OFF) -option(ENABLE_STACKTRACE "Enable stack traces in debug builds" ON) +option(ENABLE_STACKTRACE "Enable stack traces" ON) option(BUILD_GAIA_RELEASE "Build Gaia Release packages and binaries" OFF) include(GNUInstallDirs) @@ -255,8 +255,13 @@ add_subdirectory(${FLATBUFFERS} flatbuffers) include(ExternalProject) # Backward. -if(CMAKE_BUILD_TYPE STREQUAL "Debug") +if(ENABLE_STACKTRACE) + message(VERBOSE "ENABLE_STACKTRACE=${ENABLE_STACKTRACE}") add_subdirectory("${GAIA_REPO}/third_party/production/backward" backward) + add_library(gaia_stack_trace INTERFACE) + target_sources(gaia_stack_trace INTERFACE "${GAIA_INC}/gaia_internal/common/backward.cpp") + target_compile_options(gaia_stack_trace INTERFACE -g -funwind-tables -fno-omit-frame-pointer) + target_link_libraries(gaia_stack_trace INTERFACE backward) endif() # Cpptoml. add_subdirectory("${GAIA_REPO}/third_party/production/cpptoml" cpptoml) diff --git a/production/catalog/gaiac/CMakeLists.txt b/production/catalog/gaiac/CMakeLists.txt index 8b7839247141..c72b421318ef 100644 --- a/production/catalog/gaiac/CMakeLists.txt +++ b/production/catalog/gaiac/CMakeLists.txt @@ -30,4 +30,8 @@ target_include_directories(gaiac PRIVATE ${GAIA_CATALOG_TOOL_INCLUDES}) add_dependencies(gaiac gaia_db_server) target_link_libraries(gaiac PRIVATE rt gaia_common gaia_catalog gaia_parser flatbuffers tabulate Threads::Threads) +if(ENABLE_STACKTRACE) + target_link_libraries(gaiac PRIVATE gaia_stack_trace) +endif() + install(TARGETS gaiac DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/production/cmake/gaia_internal.cmake b/production/cmake/gaia_internal.cmake index e0e8c31cdbd1..6c762c785dce 100644 --- a/production/cmake/gaia_internal.cmake +++ b/production/cmake/gaia_internal.cmake @@ -57,6 +57,10 @@ function(add_gtest TARGET SOURCES INCLUDES LIBRARIES) endif() target_link_libraries(${TARGET} PRIVATE ${LIBRARIES} ${GTEST_LIB}) + if(ENABLE_STACKTRACE) + target_link_libraries(${TARGET} PRIVATE gaia_stack_trace) + endif() + if(NOT ("${ARGV6}" STREQUAL "")) set(ENV "${ARGV6}") else() diff --git a/production/db/core/CMakeLists.txt b/production/db/core/CMakeLists.txt index c8fae856002c..68c9379e653b 100644 --- a/production/db/core/CMakeLists.txt +++ b/production/db/core/CMakeLists.txt @@ -122,10 +122,6 @@ set(GAIA_DB_SERVER_SOURCES src/gaia_ptr.cpp src/gaia_ptr_server.cpp) -if(ENABLE_STACKTRACE AND (CMAKE_BUILD_TYPE STREQUAL "Debug")) - list(APPEND GAIA_DB_SERVER_SOURCES src/backward.cpp) -endif() - add_executable(gaia_db_server ${GAIA_DB_SERVER_SOURCES}) add_dependencies(gaia_db_server "messages.fbs") target_link_libraries(gaia_db_server PUBLIC gaia_build_options) @@ -139,8 +135,8 @@ target_include_directories(gaia_db_server SYSTEM PRIVATE "${GEN_DIR}") # Suppress spurious warnings about zero-initialized structs. target_link_libraries(gaia_db_server PRIVATE gaia_common Threads::Threads rocks_wrapper gaia_memory_manager ${LIB_EXPLAIN} ${LIB_CAP} dl) -if(ENABLE_STACKTRACE AND (CMAKE_BUILD_TYPE STREQUAL "Debug")) - target_link_libraries(gaia_db_server PUBLIC backward) +if(ENABLE_STACKTRACE) + target_link_libraries(gaia_db_server PRIVATE gaia_stack_trace) endif() install(TARGETS gaia_db_server DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/production/db/core/src/backward.cpp b/production/inc/gaia_internal/common/backward.cpp similarity index 100% rename from production/db/core/src/backward.cpp rename to production/inc/gaia_internal/common/backward.cpp diff --git a/production/tools/gaia_translate/CMakeLists.txt b/production/tools/gaia_translate/CMakeLists.txt index ea31f59d0557..3930910f2913 100644 --- a/production/tools/gaia_translate/CMakeLists.txt +++ b/production/tools/gaia_translate/CMakeLists.txt @@ -42,6 +42,10 @@ target_link_libraries(gaiat dl ) +if(ENABLE_STACKTRACE) + target_link_libraries(gaiat PRIVATE gaia_stack_trace) +endif() + install(TARGETS gaiat DESTINATION ${CMAKE_INSTALL_BINDIR}) set(TEST_INCLUDES