From abe71bded5ae04532b9a9a47d942cd860df8deeb Mon Sep 17 00:00:00 2001 From: Florian Krohm Date: Tue, 17 Sep 2013 20:15:36 +0000 Subject: [PATCH] Followup to r13553 which caused some build failures. (1) Detect availability of pthread_setname_np. Ignore testcases memcheck/tests/threadname[_xml] if not available. (2) Enable _GNU_SOURCE to avold compiler warnings. (3) In threadname_xml filter out stackframes referring to system libraries. Added tests/filter_xml_frames to do that. (4) Adjust .exp files as needed (5) Do not ship stdout.exp for memcheck/tests/threadname[_xml]. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13557 --- configure.ac | 3 ++ drd/tests/annotate_barrier_xml.stderr.exp | 5 --- memcheck/tests/Makefile.am | 12 +++--- memcheck/tests/filter_xml | 3 ++ memcheck/tests/threadname.c | 2 +- memcheck/tests/threadname.vgtest | 1 + memcheck/tests/threadname_xml.stderr.exp | 48 ----------------------- memcheck/tests/threadname_xml.vgtest | 1 + tests/Makefile.am | 1 + tests/filter_xml_frames | 40 +++++++++++++++++++ 10 files changed, 57 insertions(+), 59 deletions(-) create mode 100755 tests/filter_xml_frames diff --git a/configure.ac b/configure.ac index d32d03b63c..22c98be1fc 100644 --- a/configure.ac +++ b/configure.ac @@ -2201,6 +2201,7 @@ AC_CHECK_FUNCS([ \ pthread_rwlock_timedwrlock \ pthread_spin_lock \ pthread_yield \ + pthread_setname_np \ readlinkat \ semtimedop \ signalfd \ @@ -2227,6 +2228,8 @@ AM_CONDITIONAL([HAVE_PTHREAD_MUTEX_TIMEDLOCK], [test x$ac_cv_func_pthread_mutex_timedlock = xyes]) AM_CONDITIONAL([HAVE_PTHREAD_SPINLOCK], [test x$ac_cv_func_pthread_spin_lock = xyes]) +AM_CONDITIONAL([HAVE_PTHREAD_SETNAME_NP], + [test x$ac_cv_func_pthread_setname_np = xyes]) if test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \ -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX ; then diff --git a/drd/tests/annotate_barrier_xml.stderr.exp b/drd/tests/annotate_barrier_xml.stderr.exp index 52e49506d9..b34c787e8e 100644 --- a/drd/tests/annotate_barrier_xml.stderr.exp +++ b/drd/tests/annotate_barrier_xml.stderr.exp @@ -185,11 +185,6 @@ drd_pthread_intercepts.c ... - - 0x........ - ... - start_thread - Address 0x........ is at offset 0 from 0x......... diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am index 2951423dd8..f66e76b934 100644 --- a/memcheck/tests/Makefile.am +++ b/memcheck/tests/Makefile.am @@ -261,9 +261,8 @@ EXTRA_DIST = \ wrap8.stdout.exp2 wrap8.stderr.exp2 \ writev1.stderr.exp writev1.vgtest \ xml1.stderr.exp xml1.stdout.exp xml1.vgtest xml1.stderr.exp-s390x-mvc \ - threadname.vgtest threadname.stdout.exp threadname.stderr.exp \ - threadname_xml.vgtest threadname_xml.stdout.exp \ - threadname_xml.stderr.exp + threadname.vgtest threadname.stderr.exp \ + threadname_xml.vgtest threadname_xml.stderr.exp check_PROGRAMS = \ accounting \ @@ -338,8 +337,7 @@ check_PROGRAMS = \ wcs \ xml1 \ wrap1 wrap2 wrap3 wrap4 wrap5 wrap6 wrap7 wrap7so.so wrap8 \ - writev1 \ - threadname + writev1 if DWARF4 check_PROGRAMS += dw4 @@ -349,6 +347,10 @@ if HAVE_GNU_STPNCPY check_PROGRAMS += stpncpy endif +if HAVE_PTHREAD_SETNAME_NP +check_PROGRAMS += threadname +endif + AM_CFLAGS += $(AM_FLAG_M3264_PRI) AM_CXXFLAGS += $(AM_FLAG_M3264_PRI) diff --git a/memcheck/tests/filter_xml b/memcheck/tests/filter_xml index c26b138c71..6de4e930b5 100755 --- a/memcheck/tests/filter_xml +++ b/memcheck/tests/filter_xml @@ -1,6 +1,9 @@ #! /bin/sh +dir=`dirname $0` + ./filter_stderr "$@" | +$dir/../../tests/filter_xml_frames | sed "s/[0-9]*<\/tid>/...<\/tid>/" | sed "s/[0-9]*<\/pid>/...<\/pid>/" | sed "s/[0-9]*<\/ppid>/...<\/ppid>/" | diff --git a/memcheck/tests/threadname.c b/memcheck/tests/threadname.c index 2eabfd5e70..69d8b22238 100644 --- a/memcheck/tests/threadname.c +++ b/memcheck/tests/threadname.c @@ -1,4 +1,4 @@ -//#define _GNU_SOURCE +#define _GNU_SOURCE #include #include #include diff --git a/memcheck/tests/threadname.vgtest b/memcheck/tests/threadname.vgtest index 4cffb8edd8..2692bd0784 100644 --- a/memcheck/tests/threadname.vgtest +++ b/memcheck/tests/threadname.vgtest @@ -1,2 +1,3 @@ prog: threadname +prereq: test -e ./threadname vgopts: -q diff --git a/memcheck/tests/threadname_xml.stderr.exp b/memcheck/tests/threadname_xml.stderr.exp index 7ecc850861..067b2ff13b 100644 --- a/memcheck/tests/threadname_xml.stderr.exp +++ b/memcheck/tests/threadname_xml.stderr.exp @@ -102,14 +102,6 @@ threadname.c ... - - 0x........ - ... - start_thread - ... - pthread_create.c - ... - Address 0x........ is 0 bytes after a block of size 2 alloc'd @@ -137,14 +129,6 @@ threadname.c ... - - 0x........ - ... - start_thread - ... - pthread_create.c - ... - @@ -171,14 +155,6 @@ threadname.c ... - - 0x........ - ... - start_thread - ... - pthread_create.c - ... - Address 0x........ is 0 bytes after a block of size 3 alloc'd @@ -206,14 +182,6 @@ threadname.c ... - - 0x........ - ... - start_thread - ... - pthread_create.c - ... - @@ -240,14 +208,6 @@ threadname.c ... - - 0x........ - ... - start_thread - ... - pthread_create.c - ... - Address 0x........ is 0 bytes after a block of size 4 alloc'd @@ -275,14 +235,6 @@ threadname.c ... - - 0x........ - ... - start_thread - ... - pthread_create.c - ... - diff --git a/memcheck/tests/threadname_xml.vgtest b/memcheck/tests/threadname_xml.vgtest index 730fe72a57..7796ac2c8e 100644 --- a/memcheck/tests/threadname_xml.vgtest +++ b/memcheck/tests/threadname_xml.vgtest @@ -1,3 +1,4 @@ prog: threadname +prereq: test -e ./threadname vgopts: --xml=yes --xml-fd=2 --log-file=/dev/null stderr_filter: filter_xml diff --git a/tests/Makefile.am b/tests/Makefile.am index 0303a61759..e323374e81 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -12,6 +12,7 @@ dist_noinst_SCRIPTS = \ filter_numbers \ filter_stderr_basic \ filter_sink \ + filter_xml_frames \ platform_test \ vg_regtest diff --git a/tests/filter_xml_frames b/tests/filter_xml_frames new file mode 100755 index 0000000000..fc92542a4d --- /dev/null +++ b/tests/filter_xml_frames @@ -0,0 +1,40 @@ +#! /usr/bin/env perl + +# Remove ..... containing an poining to +# some system library. + +use strict; +use warnings; + +my $in_frame = 0; +my $frame = ""; +my $ignore_frame = 0; + +while (my $line = <>) +{ + if (! $in_frame) { + if ($line =~ //) { + $frame = $line; + $in_frame = 1; + $ignore_frame = 0 + } else { + print $line; + } + next; + } + +# We're in a frame + $frame .= $line; + if ($line =~ /<\/frame>/) { + if (! $ignore_frame) { + print $frame; + } + $in_frame = 0; + } else { +# The may require tweaking; currently /lib and /usr/lib are matched + $ignore_frame = 1 if ($line =~ /\/lib/); + $ignore_frame = 1 if ($line =~ /\/usr\/lib/); + } +} + +exit 0; -- 2.47.2