From b128b20e66adbf00e87cf43e00e07ffe04f2ba8b Mon Sep 17 00:00:00 2001 From: Paul Floyd Date: Wed, 6 Oct 2021 22:58:15 +0200 Subject: [PATCH] FreeBSD support, patch 7 tests directory configure.ac to generate tests/filter_discards and tests/filter_stderr_basic .gitignore to ignore these generated filters --- .gitignore | 2 ++ configure.ac | 4 ++++ tests/arch_test.c | 4 ++-- tests/filter_discards | 8 ------- tests/filter_discards.in | 11 +++++++++ tests/filter_libc | 6 ++++- ...er_stderr_basic => filter_stderr_basic.in} | 24 ++++++++++--------- tests/malloc.h | 10 +++++--- tests/platform_test | 1 + 9 files changed, 45 insertions(+), 25 deletions(-) delete mode 100755 tests/filter_discards create mode 100755 tests/filter_discards.in rename tests/{filter_stderr_basic => filter_stderr_basic.in} (72%) diff --git a/.gitignore b/.gitignore index 05b0b040b2..bb8578d680 100644 --- a/.gitignore +++ b/.gitignore @@ -2084,6 +2084,8 @@ # /tests/ /tests/*.dSYM +/tests/filter_discards +/tests/filter_stderr_basic /tests/.deps /tests/Makefile /tests/Makefile.in diff --git a/configure.ac b/configure.ac index 27400ad1e5..0398aafa1c 100755 --- a/configure.ac +++ b/configure.ac @@ -5060,6 +5060,10 @@ AC_CONFIG_FILES([coregrind/link_tool_exe_darwin], [chmod +x coregrind/link_tool_exe_darwin]) AC_CONFIG_FILES([coregrind/link_tool_exe_solaris], [chmod +x coregrind/link_tool_exe_solaris]) +AC_CONFIG_FILES([tests/filter_stderr_basic], + [chmod +x tests/filter_stderr_basic]) +AC_CONFIG_FILES([tests/filter_discards], + [chmod +x tests/filter_discards]) AC_OUTPUT cat< [0-9]\+) translations in range/discard ... (... -> ...) translations in range/" | - -$dir/filter_addresses diff --git a/tests/filter_discards.in b/tests/filter_discards.in new file mode 100755 index 0000000000..05e823687c --- /dev/null +++ b/tests/filter_discards.in @@ -0,0 +1,11 @@ +#! /bin/sh + +dir=`dirname $0` + +SED=@SED@ + + +# Remove number and position of discards +$SED "s/discard [0-9]\+ ([0-9]\+ -> [0-9]\+) translations in range/discard ... (... -> ...) translations in range/" | + +$dir/filter_addresses diff --git a/tests/filter_libc b/tests/filter_libc index 8eb9911cb0..4f097903a3 100755 --- a/tests/filter_libc +++ b/tests/filter_libc @@ -1,6 +1,7 @@ -#! /usr/bin/perl -w +#!/usr/bin/env perl use strict; +use warnings; while (<>) { @@ -20,6 +21,9 @@ while (<>) # libc, on some (eg. Darwin) it will be in the main executable. s/\(below main\) \(.+\)$/(below main)/; + # libc on x86 FreeBSD + s#_start1 \(src/lib/csu/i386/crt1_c.c.*#(below main)#; + # filter out the exact libc-start.c:### line number. (ppc64*) s/\(libc-start.c:[0-9]*\)$/(in \/...libc...)/; diff --git a/tests/filter_stderr_basic b/tests/filter_stderr_basic.in similarity index 72% rename from tests/filter_stderr_basic rename to tests/filter_stderr_basic.in index 4b6e4806be..fc1d19b35b 100755 --- a/tests/filter_stderr_basic +++ b/tests/filter_stderr_basic.in @@ -1,5 +1,7 @@ #! /bin/sh +SED=@SED@ + # This filter should be applied to *every* stderr result. It removes # Valgrind startup stuff and pid numbers. # @@ -18,14 +20,14 @@ perl -p -e 's/(==|--|\*\*)[0-9]{1,7}\1 //' | # Remove "Command: line". (If wrapping occurs, it won't remove the # subsequent lines...) -sed "/^Command: .*$/d" | +$SED "/^Command: .*$/d" | # Remove "WARNING: assuming toc 0x.." strings -sed "/^WARNING: assuming toc 0x*/d" | +$SED "/^WARNING: assuming toc 0x*/d" | # Remove "Using Valgrind-$VERSION and LibVEX..." line. # Tools have to filter their own line themselves. -sed "/^Using Valgrind-.* and LibVEX; rerun with -h for copyright info/ d" | +$SED "/^Using Valgrind-.* and LibVEX; rerun with -h for copyright info/ d" | # Anonymise line numbers in vg_replace_malloc.c, remove dirname if present perl -p -e "s/(m_replacemalloc\/)?vg_replace_malloc.c:\d+\)/vg_replace_malloc.c:...\)/" | @@ -34,13 +36,13 @@ perl -p -e "s/(m_replacemalloc\/)?vg_replace_malloc.c:\d+\)/vg_replace_malloc.c: perl -p -e "s/valgrind\.h:\d+\)/valgrind\.h:...\)/" | # Hide suppressed error counts -sed "s/^\(ERROR SUMMARY[^(]*(suppressed: \)[0-9]*\( from \)[0-9]*)$/\10\20)/" | +$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" | +$SED "/warning: line info addresses out of order/d" | # Older bash versions print abnormal termination messages on the stderr # of the bash process. Newer bash versions redirect such messages properly. @@ -53,20 +55,20 @@ perl -n -e 'print if !/^(Memory fault|Killed) $/' | # Translate intercepted glibc functions back to their canonical name perl -p -e "s/: memcpy\@\@?GLIBC_[.1-9]+ \(vg_replace_strmem.c:.*?\)/: memcpy \(vg_replace_strmem.c:...\)/" | -sed -e "s/: \(__GI_\|__\|\)\(memcmp\|memcpy\|strcpy\|strncpy\|strchr\|strrchr\)\(\|_sse4_1\|_sse42\|_sse2_unaligned\|_sse2\) (vg_replace_strmem.c:/: \2 (vg_replace_strmem.c:/" | +$SED -e "s/: \(__GI_\|__\|\)\(memcmp\|memcpy\|strcpy\|strncpy\|strchr\|strrchr\)\(\|_sse4_1\|_sse42\|_sse2_unaligned\|_sse2\) (vg_replace_strmem.c:/: \2 (vg_replace_strmem.c:/" | # 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/" | +$SED "s/\(signal [0-9]* (SIG[A-Z]*)\): dumping core/\1/" | # Remove the size in "The main thread stack size..." message. -sed "s/The main thread stack size used in this run was [0-9]*/The main thread stack size used in this run was .../" | +$SED "s/The main thread stack size used in this run was [0-9]*/The main thread stack size used in this run was .../" | # Remove the size in "10482464 bytes below stack pointer" message. -sed "s/[0-9][0-9]* bytes below stack pointer/.... bytes below stack pointer/" | +$SED "s/[0-9][0-9]* bytes below stack pointer/.... bytes below stack pointer/" | # Suppress warnings from incompatible debug info -sed '/warning: the debug information found in "[^"]*" does not match/d' | +$SED '/warning: the debug information found in "[^"]*" does not match/d' | # Suppress warnings from Dwarf reader -sed '/warning: evaluate_Dwarf3_Expr: unhandled DW_OP_/d' +$SED '/warning: evaluate_Dwarf3_Expr: unhandled DW_OP_/d' diff --git a/tests/malloc.h b/tests/malloc.h index 146790e3c7..a64abbf2d7 100644 --- a/tests/malloc.h +++ b/tests/malloc.h @@ -1,8 +1,12 @@ // Replacement for malloc.h which factors out platform differences. #include +#include "config.h" #if defined(VGO_darwin) # include +#elif defined(VGO_freebsd) +# include +# include #else # include #endif @@ -14,7 +18,7 @@ __attribute__((unused)) static void* memalign16(size_t szB) { void* x; -#if defined(VGO_darwin) +#if defined(VGO_darwin) || defined(VGO_freebsd) // Darwin lacks memalign, but its malloc is always 16-aligned anyway. posix_memalign((void **)&x, 16, szB); #else @@ -30,7 +34,7 @@ __attribute__((unused)) static void* memalign32(size_t szB) { void* x; -#if defined(VGO_darwin) +#if defined(VGO_darwin) || defined(VGO_freebsd) // Darwin lacks memalign posix_memalign((void **)&x, 32, szB); #else @@ -46,7 +50,7 @@ __attribute__((unused)) static void* memalign64(size_t szB) { void* x; -#if defined(VGO_darwin) +#if defined(VGO_darwin) || defined(VGO_freebsd) // Darwin lacks memalign posix_memalign((void **)&x, 64, szB); #else diff --git a/tests/platform_test b/tests/platform_test index 376f62eb41..c23a4f6453 100644 --- a/tests/platform_test +++ b/tests/platform_test @@ -16,6 +16,7 @@ all_platforms="$all_platforms arm-linux arm64-linux" all_platforms="$all_platforms s390x-linux mips32-linux mips64-linux" all_platforms="$all_platforms x86-darwin amd64-darwin" all_platforms="$all_platforms x86-solaris amd64-solaris" +all_platforms="$all_platforms x86-freebsd amd64-freebsd" if [ $# -ne 2 ] ; then echo "usage: platform_test " -- 2.47.2