From 38fc51c3b6c6deb7799cd0a7dfeee482213d1384 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Wed, 7 Aug 2019 14:51:28 +0200 Subject: [PATCH] CMakeLists.txt: add compil option KICAD_STDLIB_LIGHT_DEBUG, useful when KICAD_STDLIB_DEBUG cannot be used. KICAD_STDLIB_DEBUG option generate intrusive tests and asserts, and on Windows, generate crashed not captured by GDB. KICAD_STDLIB_LIGHT_DEBUG generate less intrusive tests and asserts. it adds only -Wp,-D_GLIBCXX_ASSERTIONS and that generate less asserts. Add also the new build options in dialog about. --- CMakeLists.txt | 14 +++++++++++++- common/dialog_about/dialog_about.cpp | 22 ++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 474f4ba1e8..61c49b1381 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,6 +108,7 @@ option( KICAD_SPICE "Build KiCad with internal Spice simulator." ON ) +# Not supported by all platforms (for instance mingw) option( KICAD_SANITIZE "Build KiCad with sanitizer options. WARNING: Not compatible with gold linker" OFF ) @@ -116,6 +117,10 @@ option( KICAD_STDLIB_DEBUG "Build KiCad with libstdc++ debug flags enabled." OFF ) +option( KICAD_STDLIB_LIGHT_DEBUG + "Build KiCad with libstdc++ with -Wp,-D_GLIBCXX_ASSERTIONS flag enabled. Not as intrusive as KICAD_STDLIB_DEBUG" + OFF ) + option( KICAD_BUILD_PARALLEL_CL_MP "Build in parallel using the /MP compiler option (default OFF for safety reasons)" OFF ) @@ -329,13 +334,20 @@ if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" ) set( CMAKE_C_FLAGS_DEBUG "-g3 -ggdb3 -DDEBUG" ) set( CMAKE_CXX_FLAGS_DEBUG "-g3 -ggdb3 -DDEBUG -Wno-deprecated-declarations" ) endif() - + if( KICAD_SANITIZE ) + add_definitions( -DKICAD_SANITIZE ) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_SANITIZE_VECTOR -fsanitize=address -fno-optimize-sibling-calls -fsanitize-address-use-after-scope -fno-omit-frame-pointer" ) endif() if( KICAD_STDLIB_DEBUG ) + add_definitions( -DKICAD_STDLIB_DEBUG ) set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_GLIBCXX_DEBUG" ) + elseif( KICAD_STDLIB_LIGHT_DEBUG ) + # useless if KICAD_STDLIB_DEBUG is ON. + # this option makes some controls to trap out of bound memory access. + add_definitions( -DKICAD_STDLIB_LIGHT_DEBUG ) + set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wp,-D_GLIBCXX_ASSERTIONS" ) endif() if( MINGW ) diff --git a/common/dialog_about/dialog_about.cpp b/common/dialog_about/dialog_about.cpp index 4e09054d56..9e716b7cf9 100644 --- a/common/dialog_about/dialog_about.cpp +++ b/common/dialog_about/dialog_about.cpp @@ -589,6 +589,28 @@ void DIALOG_ABOUT::buildVersionInfoData( wxString& aMsg, bool aFormatHtml ) #else aMsg << OFF; #endif + +#ifndef NDEBUG + aMsg << indent4 << "KICAD_STDLIB_DEBUG="; + #ifdef KICAD_STDLIB_DEBUG + aMsg << ON; + #else + aMsg << OFF; + aMsg << indent4 << "KICAD_STDLIB_LIGHT_DEBUG="; + #ifdef KICAD_STDLIB_LIGHT_DEBUG + aMsg << ON; + #else + aMsg << OFF; + #endif + #endif + + aMsg << indent4 << "KICAD_SANITIZE="; + #ifdef KICAD_SANITIZE + aMsg << ON; + #else + aMsg << OFF; + #endif +#endif }