Created
May 22, 2024 23:06
-
-
Save tueda/a33934738300771664e9699a27c7b3df to your computer and use it in GitHub Desktop.
Generate Valgrind suppression file.
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 | |
# Save Valgrind output to a temporary file | |
valgrind_output=$(mktemp) | |
# Run Valgrind and save its output to the temporary file | |
# Capture only standard error output | |
valgrind --leak-check=full --gen-suppressions=all "$@" 2> "$valgrind_output" 1>/dev/null | |
# Output the suppression entries to standard output | |
awk ' | |
/^{/ {brace_count++} | |
brace_count > 0 { | |
if ($0 ~ /<insert_a_suppression_name_here>/) { | |
suppression_count++ | |
sub(/<insert_a_suppression_name_here>/, "my_suppression_" suppression_count) | |
} | |
} | |
/^}/ {brace_count--} | |
' "$valgrind_output" | |
# Delete the temporary file | |
rm "$valgrind_output" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment