]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Followup to r13553 which caused some build failures.
authorFlorian Krohm <florian@eich-krohm.de>
Tue, 17 Sep 2013 20:15:36 +0000 (20:15 +0000)
committerFlorian Krohm <florian@eich-krohm.de>
Tue, 17 Sep 2013 20:15:36 +0000 (20:15 +0000)
(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
drd/tests/annotate_barrier_xml.stderr.exp
memcheck/tests/Makefile.am
memcheck/tests/filter_xml
memcheck/tests/threadname.c
memcheck/tests/threadname.vgtest
memcheck/tests/threadname_xml.stderr.exp
memcheck/tests/threadname_xml.vgtest
tests/Makefile.am
tests/filter_xml_frames [new file with mode: 0755]

index d32d03b63c404e21ef5c48c19b6c641aa2a16df0..22c98be1fc28755bb720c035012e8022d6faea8f 100644 (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
index 52e49506d9c88897ed56f7b3a9e1a8297203adb9..b34c787e8ebd07e0e7339475ff124fcae0e0ddc7 100644 (file)
       <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>
index 2951423dd867a41b63b914c72d709de8905b7c36..f66e76b9345c652b2d66116f71950de9178a53d8 100644 (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)
 
index c26b138c719c36c9b33332af2978d6f04433daaa..6de4e930b5ebfce46ad557be0918f59a7c91fc6c 100755 (executable)
@@ -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>/" |
index 2eabfd5e70459f9c62c19bc3084ece0ef6c0051f..69d8b22238f3e69549eeaf8255b9e15529dd7667 100644 (file)
@@ -1,4 +1,4 @@
-//#define _GNU_SOURCE
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <pthread.h>
 #include <string.h>
index 4cffb8edd829a57f5c15023b021e27a5e5b86349..2692bd078491fc0e87fec67b0b1ecde27b78c2f1 100644 (file)
@@ -1,2 +1,3 @@
 prog: threadname
+prereq: test -e ./threadname
 vgopts: -q
index 7ecc850861181863bfd2e4d35fb26627710c5c40..067b2ff13bb4ab6e73f80c549d63c4d0693d41e3 100644 (file)
       <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>
       <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>
 
       <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>
       <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>
 
       <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>
       <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>
 
index 730fe72a57bc28494c0e5239a9979a98da5c35d6..7796ac2c8ef0cf144dafb12acfc772e5260764e8 100644 (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
index 0303a617590041100580becb6c8b14d1011dd97b..e323374e81cabcb913a6bd69618f4d290f022a79 100644 (file)
@@ -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 (executable)
index 0000000..fc92542
--- /dev/null
@@ -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;