Skip to contentSkip to conversation

LVM2 ./Makefile.in ./configure.in libdm/mm/dbg ...

PATCH [email protected] 1 participant 1 message Aug 9, 2010 Kbuild

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: thornber at sourceware.org 2010-08-09 10:56:03

Modified files:
. : Makefile.in configure.in
libdm/mm : dbg_malloc.c pool-fast.c
Added files:
unit-tests/mm : Makefile.in TESTS check_results
pool_valgrind_t.c

Log message:
[MM] Make valgrind aware of the pool allocators

./configure with --enable-valgrind-pool to enable this.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/Makefile.in.diff?cvsroot=lvm2&r1=1.61&r2=1.62
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/configure.in.diff?cvsroot=lvm2&r1=1.151&r2=1.152
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/mm/dbg_malloc.c.diff?cvsroot=lvm2&r1=1.19&r2=1.20
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/mm/pool-fast.c.diff?cvsroot=lvm2&r1=1.8&r2=1.9
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/unit-tests/mm/Makefile.in.diff?cvsroot=lvm2&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/unit-tests/mm/TESTS.diff?cvsroot=lvm2&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/unit-tests/mm/check_results.diff?cvsroot=lvm2&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/unit-tests/mm/pool_valgrind_t.c.diff?cvsroot=lvm2&r1=NONE&r2=1.1

Makefile.in +2 -0
@@ -137,9 +137,11 @@
 
 .PHONEY: unit-test ruby-test test-programs
 
+# FIXME: put dependencies on libdm and liblvm
 test-programs:
 	cd unit-tests/regex && $(MAKE)
 	cd unit-tests/datastruct && $(MAKE)
+	cd unit-tests/mm && $(MAKE)
 
 unit-test: test-programs
 	$(RUBY) report-generators/unit_test.rb $(shell find . -name TESTS)
configure.in +14 -0
@@ -717,6 +717,19 @@
 fi
 
 ################################################################################
+dnl -- Enable valgrind awareness of memory pools
+AC_MSG_CHECKING(whether to enable valgrind awareness of pools)
+AC_ARG_ENABLE(valgrind_pool,
+              AC_HELP_STRING(--enable-valgrind-pool, [enable valgrind awareness of pools]),
+	      VALGRIND_POOL=$enableval, VALGRIND_POOL=no)
+AC_MSG_RESULT($VALGRIND_POOL)
+
+if test "$VALGRIND_POOL" = yes; then
+    AC_CHECK_HEADERS([valgrind/memcheck.h], , [AC_MSG_ERROR(bailing out)])
+    AC_DEFINE([VALGRIND_POOL], 1, [Enable a valgrind aware build of pool])
+fi
+
+################################################################################
 dnl -- Disable devmapper
 AC_MSG_CHECKING(whether to use device-mapper)
 AC_ARG_ENABLE(devmapper,
@@ -1343,6 +1356,7 @@
 udev/Makefile
 unit-tests/datastruct/Makefile
 unit-tests/regex/Makefile
+unit-tests/mm/Makefile
 ])
 AC_OUTPUT
 
libdm/mm/dbg_malloc.c +8 -0
@@ -193,6 +193,13 @@
 		log_very_verbose("You have a memory leak:");
 
 	for (mb = _head; mb; mb = mb->next) {
+#ifdef VALGRIND_POOL
+		/*
+		 * We can't look at the memory in case it has had
+		 * VALGRIND_MAKE_MEM_NOACCESS called on it.
+		 */
+		str[0] = '\0';
+#else
 		for (c = 0; c < sizeof(str) - 1; c++) {
 			if (c >= mb->length)
 				str[c] = ' ';
@@ -204,6 +211,7 @@
 				str[c] = ((char *)mb->magic)[c];
 		}
 		str[sizeof(str) - 1] = '\0';
+#endif
 
 		LOG_MESG(_LOG_INFO, mb->file, mb->line, 0,
 			 "block %d at %p, size %" PRIsize_t "\t [%s]",
libdm/mm/pool-fast.c +55 -8

130 lines not on this page · raw message

/cvs/lvm2/LVM2/unit-tests/mm/Makefile.in,v --> standard output revision 1.1

- renamed from unit-tests/mm/Makefile.in +31 -0
@@ -0,0 +1,31 @@
+#
+# Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
+# Copyright (C) 2004 Red Hat, Inc. All rights reserved.
+#
+# This file is part of LVM2.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+top_builddir = @top_builddir@
+VPATH = @srcdir@
+
+SOURCES=\
+	pool_valgrind_t.c
+
+TARGETS=\
+	pool_valgrind_t
+
+include $(top_builddir)/make.tmpl
+DM_LIBS = -ldevmapper $(LIBS)
+
+pool_valgrind_t: pool_valgrind_t.o
+	$(CC) $(CFLAGS) -o $@ pool_valgrind_t.o $(LDFLAGS) $(DM_LIBS)
+

/cvs/lvm2/LVM2/unit-tests/mm/TESTS,v --> standard output revision 1.1

- renamed from unit-tests/mm/TESTS +1 -0
@@ -0,0 +1 @@
+valgrind pool awareness:valgrind ./pool_valgrind_t 2>&1 | ./check_results

/cvs/lvm2/LVM2/unit-tests/mm/check_results,v --> standard output revision 1.1

- renamed from unit-tests/mm/check_results +31 -0
@@ -0,0 +1,31 @@
+#!/usr/bin/env ruby1.9
+
+require 'pp'
+
+patterns = [
+            /Invalid read of size 1/,
+            /Invalid write of size 1/,
+            /Invalid read of size 1/,
+            /still reachable: [0-9,]+ bytes in 3 blocks/
+           ]
+
+lines = STDIN.readlines
+pp lines
+
+result = catch(:done) do
+  patterns.each do |pat|
+    loop do
+      throw(:done, false) if lines.size == 0
+
+      line = lines.shift
+      if line =~ pat
+        STDERR.puts "matched #{pat}"
+        break;
+      end
+    end
+  end
+
+  throw(:done, true)
+end
+
+exit(result ? 0 : 1)

/cvs/lvm2/LVM2/unit-tests/mm/pool_valgrind_t.c,v --> standard output revision 1.1

- renamed from unit-tests/mm/pool_valgrind_t.c +183 -0

183 lines not on this page · raw message