#! /bin/sh

# This filter should be applied to *every* stderr result.  It removes
# Valgrind startup stuff and pid numbers.

dir=`dirname $0`

# Remove ==pid== and --pid-- and ++pid++ and **pid** strings 
sed "s/\(==\|--\|\+\+\|\*\*\)[0-9]\{1,5\}\1 //"             |

# Remove "Using valgrind..." line and the following
# copyright notice line.  Tools have to filter their own line themselves.
sed "/^Using valgrind-.*, a dynamic binary instrumentation framework/ , /./ d" |

# ... and also remove the "Using LibVEX..." line and the one after it.
sed "/^Using LibVEX rev .*, a library for dynamic binary translation/ , /./ d" |

# Remove other introductory lines
sed "/Estimated CPU clock rate is [0-9]* MHz/d"                       |
sed "/For more details, rerun with: -v/d"                             |

# Anonymise line numbers in vg_replace_malloc.c, remove dirname if present
sed "s/\(m_replacemalloc\/\)\?vg_replace_malloc.c:[0-9]*/vg_replace_malloc.c:.../"           |

# Anonymise vg_intercept lines
#sed "s/vg_intercept.c:[0-9]*/vg_intercept.c:.../"                     |

# Hide suppressed error counts
sed "s/^\(ERROR SUMMARY[^(]*(suppressed: \)[0-9]*\( from \)[0-9]*)$/\10\20)/" |


# Reduce some libc incompatibility
$dir/filter_libc                                                       |

# Remove line info out of order warnings
sed "/warning: line info addresses out of order/d"                     |

# Remove any ": dumping core" message as the user might have a
# limit set that prevents the core dump
sed "s/\(signal [0-9]* (SIG[A-Z]*)\): dumping core/\1/"
