force valgrind output on crash

This commit is contained in:
Timerix22 2023-05-19 23:42:12 +06:00
parent 9711d8fbb1
commit 5e23ef8156
2 changed files with 8 additions and 6 deletions

View File

@ -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

View File

@ -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 ..