Created
February 9, 2021 16:26
-
-
Save Estecka/45a369c4a139c3b67f36148215548c29 to your computer and use it in GitHub Desktop.
Valgrind for 42 projects.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
EXEC=./a.out # Put your executable's path here. | |
LOG=valgrind | |
valgrind \ | |
--tool=memcheck \ | |
--leak-check=full \ | |
--leak-resolution=high \ | |
--track-origins=yes \ | |
--show-reachable=yes \ | |
--log-file=${LOG}.log \ | |
$EXEC $@ \ | |
; | |
# Separate the logs from multiple processes into multiple log files. | |
grep '==[0-9]*==' <valgrind.log --only-matching | sort --unique | tr -d = | | |
while read -r pid; | |
do \ | |
pidlog=${LOG}.${pid}.log; | |
echo $pidlog; | |
grep "$pid" <${LOG}.log >$pidlog; | |
grep -A1 "valgrind" $pidlog | grep $EXEC; | |
done; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment