Warning, file /education/labplot/admin/parse_valgrind_suppressions.sh was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 #! /usr/bin/awk -f 0002 # A script to extract the actual suppression info from the output of (for example) valgrind --leak-check=full --show-reachable=yes --error-limit=no --gen-suppressions=all ./minimal 0003 # The desired bits are between ^{ and ^} (including the braces themselves). 0004 # The combined output should either be appended to /usr/lib/valgrind/default.supp, or placed in a .supp of its own 0005 # If the latter, either tell valgrind about it each time with --suppressions=<filename>, or add that line to ~/.valgrindrc 0006 0007 # NB This script uses the |& operator, which I believe is gawk-specific. In case of failure, check that you're using gawk rather than some other awk 0008 0009 # The script looks for suppressions. When it finds one it stores it temporarily in an array, 0010 # and also feeds it line by line to the external app 'md5sum' which generates a unique checksum for it. 0011 # The checksum is used as an index in a different array. If an item with that index already exists the suppression must be a duplicate and is discarded. 0012 0013 BEGIN { suppression=0; md5sum = "md5sum" } 0014 # If the line begins with '{', it's the start of a supression; so set the var and initialise things 0015 /^{/ { 0016 suppression=1; i=0; next 0017 } 0018 # If the line begins with '}' its the end of a suppression 0019 /^}/ { 0020 if (suppression) 0021 { suppression=0; 0022 close(md5sum, "to") # We've finished sending data to md5sum, so close that part of the pipe 0023 ProcessInput() # Do the slightly-complicated stuff in functions 0024 delete supparray # We don't want subsequent suppressions to append to it! 0025 } 0026 } 0027 # Otherwise, it's a normal line. If we're inside a supression, store it, and pipe it to md5sum. Otherwise it's cruft, so ignore it 0028 { if (suppression) 0029 { 0030 supparray[++i] = $0 0031 print |& md5sum 0032 } 0033 } 0034 0035 0036 function ProcessInput() 0037 { 0038 # Pipe the result from md5sum, then close it 0039 md5sum |& getline result 0040 close(md5sum) 0041 # gawk can't cope with enormous ints like $result would be, so stringify it first by prefixing a definite string 0042 resultstring = "prefix"result 0043 0044 if (! (resultstring in chksum_array) ) 0045 { chksum_array[resultstring] = 0; # This checksum hasn't been seen before, so add it to the array 0046 OutputSuppression() # and output the contents of the suppression 0047 } 0048 } 0049 0050 function OutputSuppression() 0051 { 0052 # A suppression is surrounded by '{' and '}'. Its data was stored line by line in the array 0053 print "{" 0054 for (n=1; n <= i; ++n) 0055 { print supparray[n] } 0056 print "}" 0057 }