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
This commit is contained in:
Florian Krohm 2013-09-17 20:15:36 +00:00
parent 2ffd73f178
commit abe71bded5
10 changed files with 57 additions and 59 deletions

View File

@ -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

View File

@ -185,11 +185,6 @@
<file>drd_pthread_intercepts.c</file>
<line>...</line>
</frame>
<frame>
<ip>0x........</ip>
<obj>...</obj>
<fn>start_thread</fn>
</frame>
</stack>
<auxwhat>Address 0x........ is at offset 0 from 0x.........</auxwhat>
<allocation_context>

View File

@ -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)

View File

@ -1,6 +1,9 @@
#! /bin/sh
dir=`dirname $0`
./filter_stderr "$@" |
$dir/../../tests/filter_xml_frames |
sed "s/<tid>[0-9]*<\/tid>/<tid>...<\/tid>/" |
sed "s/<pid>[0-9]*<\/pid>/<pid>...<\/pid>/" |
sed "s/<ppid>[0-9]*<\/ppid>/<ppid>...<\/ppid>/" |

View File

@ -1,4 +1,4 @@
//#define _GNU_SOURCE
#define _GNU_SOURCE
#include <stdio.h>
#include <pthread.h>
#include <string.h>

View File

@ -1,2 +1,3 @@
prog: threadname
prereq: test -e ./threadname
vgopts: -q

View File

@ -102,14 +102,6 @@
<file>threadname.c</file>
<line>...</line>
</frame>
<frame>
<ip>0x........</ip>
<obj>...</obj>
<fn>start_thread</fn>
<dir>...</dir>
<file>pthread_create.c</file>
<line>...</line>
</frame>
</stack>
<auxwhat>Address 0x........ is 0 bytes after a block of size 2 alloc'd</auxwhat>
<stack>
@ -137,14 +129,6 @@
<file>threadname.c</file>
<line>...</line>
</frame>
<frame>
<ip>0x........</ip>
<obj>...</obj>
<fn>start_thread</fn>
<dir>...</dir>
<file>pthread_create.c</file>
<line>...</line>
</frame>
</stack>
</error>
@ -171,14 +155,6 @@
<file>threadname.c</file>
<line>...</line>
</frame>
<frame>
<ip>0x........</ip>
<obj>...</obj>
<fn>start_thread</fn>
<dir>...</dir>
<file>pthread_create.c</file>
<line>...</line>
</frame>
</stack>
<auxwhat>Address 0x........ is 0 bytes after a block of size 3 alloc'd</auxwhat>
<stack>
@ -206,14 +182,6 @@
<file>threadname.c</file>
<line>...</line>
</frame>
<frame>
<ip>0x........</ip>
<obj>...</obj>
<fn>start_thread</fn>
<dir>...</dir>
<file>pthread_create.c</file>
<line>...</line>
</frame>
</stack>
</error>
@ -240,14 +208,6 @@
<file>threadname.c</file>
<line>...</line>
</frame>
<frame>
<ip>0x........</ip>
<obj>...</obj>
<fn>start_thread</fn>
<dir>...</dir>
<file>pthread_create.c</file>
<line>...</line>
</frame>
</stack>
<auxwhat>Address 0x........ is 0 bytes after a block of size 4 alloc'd</auxwhat>
<stack>
@ -275,14 +235,6 @@
<file>threadname.c</file>
<line>...</line>
</frame>
<frame>
<ip>0x........</ip>
<obj>...</obj>
<fn>start_thread</fn>
<dir>...</dir>
<file>pthread_create.c</file>
<line>...</line>
</frame>
</stack>
</error>

View File

@ -1,3 +1,4 @@
prog: threadname
prereq: test -e ./threadname
vgopts: --xml=yes --xml-fd=2 --log-file=/dev/null
stderr_filter: filter_xml

View File

@ -12,6 +12,7 @@ dist_noinst_SCRIPTS = \
filter_numbers \
filter_stderr_basic \
filter_sink \
filter_xml_frames \
platform_test \
vg_regtest

40
tests/filter_xml_frames Executable file
View File

@ -0,0 +1,40 @@
#! /usr/bin/env perl
# Remove <frame>.....</frame> containing an <obj> 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>/) {
$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 =~ /<obj>\/lib/);
$ignore_frame = 1 if ($line =~ /<obj>\/usr\/lib/);
}
}
exit 0;