bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

patches to make valgrind-2.0.0 run coreutils `make check'


From: Jim Meyering
Subject: patches to make valgrind-2.0.0 run coreutils `make check'
Date: Mon, 17 Nov 2003 14:57:44 +0100

I had to make some changes to valgrind so that it could be used to
run the `make check' tests in the GNU coreutils package.
Note that to get the test scripts to run the tools via valgrind,
I tweak every Makefile.am under the coreutils/tests/ hierarchy in
order to run each program via its own wrapper script.
Minimal instructions are in coreutils' README-valgrind in CVS.

ChangeLog entries and diffs are below.
Obviously, only the changes to vg_syscalls.c are intended to be
directly useful to you.  The others are mainly for your reference.

Is there some other way to suppress the
"discard syms in %s due to munmap()" warnings?
I confess that I may not have read the documentation carefully enough.

BTW, valgrind detected a free-mem-read bug in csplit.  Thanks!

Jim

P.S., I did register with KDE bugzilla and then tried to report
via that, but when I hit the `commit' button, it failed.  Sigh.
I reported _that_ to the indicated address.

I'm using Debian unstable, linux-2.4.22, libc-2.3.2,
and valgrind-2.0.0 compiled from sources.

FYI, when running the test suite, each of the 90 programs in the
coreutils is invoked through its own wrapper script that exec's valgrind.
Here's the wrapper for `cat' as an example:

  $ cat src/vg/cat
  #!/bin/sh
  export PATH=/work/fetish/cu/src:...
  exec /p/bin/valgrind --suppressions=/tmp/cu-vg --gen-suppressions=yes --quiet 
--num-callers=9 cat "$@"

=========================================================

2003-11-17  Jim Meyering  <address@hidden>

        * coregrind/vg_syscalls.c (perform_assumed_nonblocking_syscall)
        [case __NR_clock_gettime]: Check for `res == 0', not `res > 0'.
        [case __NR_statfs64] (syscall 268): Handle new syscall.
        [case __NR_utimes] (syscall 271): Likewise.

        * coregrind/vg_main.c (process_cmd_line_options): Raise the upper
        bound on the number of command line arguments to 1500.
        Coreutils runs a test case that uses over 1300.  This might
        deserve an option.

        * coregrind/vg_symtab2.c: #if-0'out the code that produces
        diagnostics like these.  Using --quiet doesn't suppress them, and the
        extra output (albeit on stderr) induces many unwarranted failures
        in the coreutils test suite.
          ==10629== discard syms in /lib/libnss_compat-2.3.2.so due to munmap()
          ==10629== discard syms in /lib/libnss_nis-2.3.2.so due to munmap()
          ==10629== discard syms in /lib/libnsl-2.3.2.so due to munmap()
          ==10629== discard syms in /lib/libnss_files-2.3.2.so due to munmap()
        [case __NR_utimes] (syscall 271): Likewise.

        * coregrind/vg_unsafe.h: Include kernel definition of
        `struct list_head', to avoid this sort of compile error:
        In file included from /usr/include/linux/timer.h:5,
                         from /usr/include/linux/isdn/fsm.h:15,
                         from /usr/include/linux/isdn.h:17,
                         from vg_unsafe.h:53,
                         from vg_signals.c:34:
        /usr/include/linux/list.h:576:2: warning: #warning "don't include 
kernel headers in userspace"
        In file included from /usr/include/linux/isdn/fsm.h:15,
                         from /usr/include/linux/isdn.h:17,
                         from vg_unsafe.h:53,
                         from vg_signals.c:34:
        /usr/include/linux/timer.h:11: error: field `entry' has incomplete type
        make[3]: *** [vg_signals.o] Error 1

diff -F '^[_a-zA-Z$]' -ur -x config.status -x config.log -x configure -x 
Makefile -x '*.Po' valgrind-2.0.0/coregrind/vg_syscalls.c 
valgrind-2.0.0-my/coregrind/vg_syscalls.c
--- valgrind-2.0.0/coregrind/vg_syscalls.c      2003-11-03 20:15:04.000000000 
+0100
+++ valgrind-2.0.0-my/coregrind/vg_syscalls.c   2003-11-17 13:52:56.000000000 
+0100
@@ -492,7 +492,7 @@ void VG_(perform_assumed_nonblocking_sys
          SYSCALL_TRACK( pre_mem_write, tid, "clock_gettime(tp)", 
                         arg2, sizeof(struct timespec) );
          KERNEL_DO_SYSCALL(tid,res);
-         if (!VG_(is_kerror)(res) && res > 0)
+         if (!VG_(is_kerror)(res) && res == 0)
             VG_TRACK( post_mem_write, arg2, sizeof(struct timespec) );
          break;
 #     endif
@@ -2961,6 +2961,29 @@ void VG_(perform_assumed_nonblocking_sys
          KERNEL_DO_SYSCALL(tid,res);
          break;
 
+#     if defined(__NR_statfs64)
+      case __NR_statfs64: /* syscall 268 */
+         /* int statfs64(const char *path, struct statfs64 *buf); */
+         MAYBE_PRINTF("statfs64 ( %s, %p )\n", arg1,arg2);
+         SYSCALL_TRACK( pre_mem_read_asciiz, tid, "statfs64(path)", arg1 );
+         KERNEL_DO_SYSCALL(tid,res);
+         if (!VG_(is_kerror)(res) && res == 0)
+            VG_TRACK( post_mem_write,arg2, sizeof(struct statfs) );
+         break;
+#     endif
+
+#     if defined(__NR_utimes)
+      case __NR_utimes: /* syscall 271 */
+         /* int utimes(const char *filename, struct timeval *tvp); */
+         MAYBE_PRINTF("utimes ( %p, %p )\n", arg1,arg2);
+         SYSCALL_TRACK( pre_mem_read_asciiz, tid, "utimes(filename)", arg1 );
+         if (arg2 != (UInt)NULL)
+            SYSCALL_TRACK( pre_mem_read, tid, "utimes(tvp)", arg2,
+                          sizeof(struct timeval) );
+         KERNEL_DO_SYSCALL(tid,res);
+         break;
+#     endif
+
 #     if defined(__NR_setuid32)
       case __NR_setuid32: /* syscall 213 */
 #     endif
diff -F '^[_a-zA-Z$]' -ur -x config.status -x config.log -x configure -x 
Makefile -x '*.Po' valgrind-2.0.0/coregrind/vg_main.c 
valgrind-2.0.0-my/coregrind/vg_main.c
--- valgrind-2.0.0/coregrind/vg_main.c  2003-10-05 02:02:43.000000000 +0200
+++ valgrind-2.0.0-my/coregrind/vg_main.c       2003-11-17 13:44:05.000000000 
+0100
@@ -874,7 +874,7 @@ static void process_cmd_line_options ( v
           if (*sp == VG_(client_argc))
              break;
           VG_(client_argc)++;
-           if (++ctr >= 1000)
+           if (++ctr >= 1500)
               args_grok_error(
                  "suspiciously many (1000) argv[] entries; giving up");
        }
diff -F '^[_a-zA-Z$]' -ur -x config.status -x config.log -x configure -x 
Makefile -x '*.Po' valgrind-2.0.0/coregrind/vg_symtab2.c 
valgrind-2.0.0-my/coregrind/vg_symtab2.c
--- valgrind-2.0.0/coregrind/vg_symtab2.c       2003-10-29 23:52:46.000000000 
+0100
+++ valgrind-2.0.0-my/coregrind/vg_symtab2.c    2003-11-17 13:44:07.000000000 
+0100
@@ -2299,9 +2299,11 @@ void VG_(unload_symbols) ( Addr start, U
    if (curr == NULL) 
       return;
 
+#if 0
    VG_(message)(Vg_UserMsg, 
                 "discard syms in %s due to munmap()", 
                 curr->filename ? curr->filename : (UChar*)"???");
+#endif
 
    vg_assert(prev == NULL || prev->next == curr);
 
diff -F '^[_a-zA-Z$]' -ur -x config.status -x config.log -x configure -x 
Makefile -x '*.Po' valgrind-2.0.0/coregrind/vg_unsafe.h 
valgrind-2.0.0-my/coregrind/vg_unsafe.h
--- valgrind-2.0.0/coregrind/vg_unsafe.h        2003-11-05 00:18:40.000000000 
+0100
+++ valgrind-2.0.0-my/coregrind/vg_unsafe.h     2003-11-17 13:44:12.000000000 
+0100
@@ -50,6 +50,9 @@
 #include <linux/msg.h>    /* for struct msgbuf */
 #include <linux/sem.h>    /* for struct sembuf */
 
+struct list_head {
+       struct list_head *next, *prev;
+};
 #include <linux/isdn.h>   /* for ISDN ioctls */
 #include <scsi/sg.h>      /* for the SG_* ioctls */
 #include <sched.h>        /* for struct sched_param */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]