From 98e62646c6cb11311f661353b384f1bb159d99ab Mon Sep 17 00:00:00 2001 From: dnzbk Date: Thu, 12 Dec 2024 12:24:48 +0300 Subject: [PATCH] Fix: stacktrace --- cmake/common.cmake | 2 ++ cmake/config.h.in | 3 +++ cmake/windows.cmake | 4 ++++ daemon/main/StackTrace.cpp | 4 ++-- lib/regex/regex.c | 2 +- 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/cmake/common.cmake b/cmake/common.cmake index cbeb9f6ef..1a73f4eb5 100644 --- a/cmake/common.cmake +++ b/cmake/common.cmake @@ -15,6 +15,8 @@ if (CMAKE_SYSTEM_PROCESSOR MATCHES "riscv32|rv32") endif() if(CMAKE_BUILD_TYPE STREQUAL "Debug") + set(DEBUG 1) + if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang") add_compile_options(-Weverything -Wno-c++98-compat) elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") diff --git a/cmake/config.h.in b/cmake/config.h.in index 6225fa2ea..2aa98f632 100644 --- a/cmake/config.h.in +++ b/cmake/config.h.in @@ -1,3 +1,6 @@ +/* Define to 1 to include debug-code */ +#cmakedefine DEBUG + /* Name of package */ #cmakedefine PACKAGE "@PACKAGE@" diff --git a/cmake/windows.cmake b/cmake/windows.cmake index c6f786227..bc6cfcd52 100644 --- a/cmake/windows.cmake +++ b/cmake/windows.cmake @@ -16,6 +16,10 @@ find_package(Threads REQUIRED) find_package(LibXml2 REQUIRED) find_package(Boost REQUIRED COMPONENTS json) +if(CMAKE_BUILD_TYPE STREQUAL "Debug") + set(LIBS ${LIBS} dbghelp.lib) +endif() + set(LIBS ${LIBS} Threads::Threads Boost::json LibXml2::LibXml2 winmm.lib) set(INCLUDES ${INCLUDES} ${Boost_INCLUDE_DIR} ${LIBXML2_INCLUDE_DIR}) diff --git a/daemon/main/StackTrace.cpp b/daemon/main/StackTrace.cpp index 3b720a02b..072d1b2dc 100644 --- a/daemon/main/StackTrace.cpp +++ b/daemon/main/StackTrace.cpp @@ -128,7 +128,7 @@ void PrintBacktrace(PCONTEXT context) srcFileName = ""; } - info("%s (%i) : %s", *srcFileName, lineNumber, *symName); + error("Stacktrace: %s (%i) : %s", *srcFileName, lineNumber, *symName); if (sfStackFrame.AddrReturn.Offset == 0) { @@ -209,7 +209,7 @@ void PrintBacktrace() error("Obtained %zd stack frames", size); for (i = 0; i < size; i++) { - error("%s", strings[i]); + error("Stacktrace: %s", strings[i]); } free(strings); diff --git a/lib/regex/regex.c b/lib/regex/regex.c index c60ddbfd0..7500e2883 100644 --- a/lib/regex/regex.c +++ b/lib/regex/regex.c @@ -1465,7 +1465,7 @@ re_string_reconstruct(re_string_t* pstr, int idx, int eflags) pstr->valid_len - offset); pstr->valid_len -= offset; pstr->valid_raw_len -= offset; -#if DEBUG +#ifdef DEBUG assert(pstr->valid_len > 0); #endif }