From 5e23ef8156a85a981d60152990bde53d6e8eefe9 Mon Sep 17 00:00:00 2001 From: Timerix22 Date: Fri, 19 May 2023 23:42:12 +0600 Subject: [PATCH] force valgrind output on crash --- default.config | 5 ++--- default_tasks/valgrind.sh | 9 ++++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/default.config b/default.config index 27cb089..2ed0a53 100644 --- a/default.config +++ b/default.config @@ -50,8 +50,7 @@ case "$TASK" in # -fprofile-use enables compiler to use profiling info files to optimize executable # -fprofile-prefix-path sets path where profiling info about objects are be saved # -fdata-sections -ffunction-sections -Wl,--gc-sections removes unused code - C_ARGS="-O2 -flto=auto -fuse-linker-plugin -fprofile-use -fprofile-prefix-path=$(realpath $OBJDIR)/objects \ --fdata-sections -ffunction-sections -Wl,--gc-sections" + C_ARGS="-O2 -flto=auto -fuse-linker-plugin -fprofile-use -fprofile-prefix-path=$(realpath $OBJDIR)/objects -fdata-sections -ffunction-sections -Wl,--gc-sections" CPP_ARGS="$C_ARGS" LINKER_ARGS="$CPP_ARGS" PRE_TASK_SCRIPT= @@ -107,7 +106,7 @@ case "$TASK" in ;; # executes $EXEC_FILE with valgrind memory checker valgrind) - VALGRIND_ARGS="-s --log-file=valgrind.log --read-var-info=yes --track-origins=yes --fullpath-after=$PROJECT/ --leak-check=full --show-leak-kinds=all" + VALGRIND_ARGS="-s --read-var-info=yes --track-origins=yes --fullpath-after=$PROJECT/ --leak-check=full --show-leak-kinds=all" TASK_SCRIPT=cbuild/default_tasks/valgrind.sh ;; # generates profiling info diff --git a/default_tasks/valgrind.sh b/default_tasks/valgrind.sh index f82fdac..57c6892 100755 --- a/default_tasks/valgrind.sh +++ b/default_tasks/valgrind.sh @@ -1,7 +1,10 @@ #!/bin/bash cd "$OUTDIR" -valgrind $VALGRIND_ARGS ./$EXEC_FILE -cat "valgrind.log" -myprint "${GREEN}valgrind log saved to ${CYAN}$OUTDIR/exec.log" +rm -f "valgrind.log" +set +e +valgrind --log-file=valgrind.log $VALGRIND_ARGS ./$EXEC_FILE +set -e +[ -f "valgrind.log" ] && cat "valgrind.log" || error "valgrind exited with errors" +myprint "${GREEN}valgrind log saved to ${CYAN}$OUTDIR/valgrind.log" cd ..