#! /bin/sh

dir=`dirname $0`

$dir/../../tests/filter_stderr_basic                    |

# Anonymise addresses
$dir/../../tests/filter_addresses                       |

# Anonymise paths like "(in /foo/bar/libc-baz.so)"
sed "s/(in \/.*libc.*)$/(in \/...libc...)/"             |
sed "s/(in \/.*libpthread.*)$/(in \/...libpthread...)/"             |

# Anonymise paths like "__libc_start_main (../foo/bar/libc-quux.c:129)"
sed "s/__libc_\(.*\) (.*)$/__libc_\1 (...libc...)/" |

# Remove preambly stuff; also postambly stuff
sed \
-e "/^exp-sgcheck, a stack and global array overrun detector$/d" \
-e "/^NOTE: This is an Experimental-Class Valgrind Tool$/d"  \
-e "/^Copyright (C) 2003-201., and GNU GPL'd, by OpenWorks Ltd et al.$/d" \
-e "/^For counts of detected and suppressed errors, rerun with: -v$/d" |

# Tidy up in cases where glibc (+ libdl + libpthread + ld) have
# been built with debugging information, hence source locs are present.
sed \
-e "s/ vfprintf (.*)/ .../" \
-e "s/ vsprintf (.*)/ .../" \
-e "s/ sprintf (.*)/ .../" \
-e "s/ printf (.*)/ .../" \
-e "s/ strdup (.*)/ .../" \
-e "s/(pthread_key_create.c:[0-9]*)/(in \/...libpthread...)/" \
-e "s/(genops.c:[0-9]*)/(in \/...libc...)/" \
-e "s/(syscall-template.S:[0-9]*)/(in \/...libc...)/" |

# Anonymise line numbers in h_intercepts.c.
sed "s/h_intercepts.c:[0-9]*/h_intercepts.c:.../" 

