Bladeren bron

Use old dwarf version for valgrind with clang, add suppression

Kajetan Johannes Hammerle 10 maanden geleden
bovenliggende
commit
787ab4bb39
3 gewijzigde bestanden met toevoegingen van 28 en 14 verwijderingen
  1. 5 5
      CMakeLists.txt
  2. 13 9
      tasks
  3. 10 0
      valgrind.supp

+ 5 - 5
CMakeLists.txt

@@ -63,7 +63,7 @@ else()
         set(COMPILE_OPTIONS --coverage)
         set(LINK_OPTIONS gcov)
     elseif(CMAKE_C_COMPILER_ID STREQUAL "Clang")
-        set(COMPILE_OPTIONS -fprofile-instr-generate -fcoverage-mapping)
+        set(COMPILE_OPTIONS -fprofile-instr-generate -fcoverage-mapping -gdwarf-4)
         set(LINK_OPTIONS ${COMPILE_OPTIONS})
     endif()
     set(LOG_LEVEL 4)
@@ -89,17 +89,17 @@ target_compile_options(core PUBLIC
     ${WARNINGS}
     -fdiagnostics-color=always
 )
-target_compile_definitions(core 
+target_compile_definitions(core
     PUBLIC CORE_LOG_LEVEL=${LOG_LEVEL}
     PRIVATE ${DEFINITIONS}
 )
-target_link_libraries(core 
+target_link_libraries(core
     PRIVATE m ${LINK_OPTIONS}
 )
-target_sources(core PUBLIC 
+target_sources(core PUBLIC
     FILE_SET HEADERS
     BASE_DIRS include
-    FILES 
+    FILES
         ./include/core/BitArray.h
         ./include/core/Box.h
         ./include/core/Buffer.h

+ 13 - 9
tasks

@@ -18,7 +18,7 @@ printHelpExit() {
     echo "$0 coverage        | generate code coverage"
     echo "$0 performance     | run the performance tests"
     echo "$0 stats           | run the performance tests with stats"
-    echo "$0 macro           | find macros without CORE" 
+    echo "$0 macro           | find macros without CORE"
     echo "$0 time            | check build time"
     exit 0
 }
@@ -102,7 +102,11 @@ elif [ "$task" = "valgrind" ]; then
         echo "Valid valgrind types are: debug, release, all"
         printHelpExit
     fi
-    valgrind="valgrind"
+    valgrind="valgrind \
+        --leak-check=full \
+        --show-leak-kinds=all \
+        --suppressions=../valgrind.supp
+        "
 elif [ "$task" = "performance" ]; then
     build_profile=true
     performance=true
@@ -125,7 +129,7 @@ fi
 buildProfile() {
     folder=$1
     shift 1
-    if [ ! -e "$folder" ]; then 
+    if [ ! -e "$folder" ]; then
         cmake -B "$folder" -S . -G Ninja -DCMAKE_C_COMPILER=${compiler} -DCMAKE_INSTALL_PREFIX=../install $@
     fi
     ninja -C "$folder"
@@ -146,15 +150,15 @@ fi
 
 function runTests() {
     echo "--------------Invalid alloc exit----------------"
-    LLVM_PROFILE_FILE="alloc.profraw" $valgrind ./test alloc $valgrind || true
+    LLVM_PROFILE_FILE="alloc.profraw" ./test alloc || true
     echo "--------------Invalid realloc exit--------------"
-    LLVM_PROFILE_FILE="realloc.profraw" $valgrind ./test realloc $valgrind || true
+    LLVM_PROFILE_FILE="realloc.profraw" ./test realloc || true
     echo "--------------Pre canary detection--------------"
-    LLVM_PROFILE_FILE="pre_canary.profraw" $valgrind ./test pre_canary $valgrind || true
+    LLVM_PROFILE_FILE="pre_canary.profraw" ./test pre_canary || true
     echo "--------------Post canary detection-------------"
-    LLVM_PROFILE_FILE="post_canary.profraw" $valgrind ./test post_canary $valgrind || true
+    LLVM_PROFILE_FILE="post_canary.profraw" ./test post_canary || true
     echo "--------------Test Fails------------------------"
-    LLVM_PROFILE_FILE="test.profraw" $valgrind ./test test $valgrind || true
+    LLVM_PROFILE_FILE="test.profraw" ./test test || true
     echo "--------------Default run-----------------------"
     LLVM_PROFILE_FILE="default.profraw" $valgrind ./test light $valgrind < ../readLineTest || true
 }
@@ -213,4 +217,4 @@ if $coverage; then
         llvm-profdata-16 merge -sparse $files -o build_debug/default.profdata
         llvm-cov-16 show ./build_debug/test -instr-profile=build_debug/default.profdata --ignore-filename-regex="test/" -line-coverage-lt=100
     fi
-fi 
+fi

+ 10 - 0
valgrind.supp

@@ -0,0 +1,10 @@
+{
+  glfwInit 1
+  Memcheck:Leak
+  match-leak-kinds: reachable
+  fun:malloc
+  ...
+  fun:__llvm_profile_initialize
+  ...
+  fun:call_init
+}