public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* RFC: --enable-checking=valgrind.
@ 2002-11-10 17:35 Hans-Peter Nilsson
  2002-11-10 19:34 ` Zack Weinberg
  0 siblings, 1 reply; 25+ messages in thread
From: Hans-Peter Nilsson @ 2002-11-10 17:35 UTC (permalink / raw)
  To: gcc-patches

A conceptual patch.  Bootstrap still in progress on
i686-pc-linux-gnu.  Lots of bug indications so far...

Valgrind also has memory management instrumentation that
could be useful in marking what GC-allocated memory chunks
are actually not supposed to be accessed and similar.  This
first step runs valgrind on ./gen* and for the subprograms
called from gcc.

Thoughts?

gcc:
	* configure.in (--enable-checking=valgrind): New.
	* Makefile.in (VALGRIND_PATH, VALGRIND_CMD, VALGRIND_DEFINES):
	New variables.
	(HOST_CFLAGS, ALL_CFLAGS): Add $(VALGRIND_DEFINES).
	(executing gencheck, genconfigs, genconditions, genflags,
	gencodes, genconstants, genemit, genrecog, genopinit, genextract,
	genpeep, genattr, genattrtab, genoutput, gengenrtl, genpreds,
	gengtype, genprotos): Prepend $(VALGRIND_CMD).
	* gcc.c (execute): Arrange to prepend $(VALGRIND_PATH) -q to each
	command.
	* configure, config.in: Regenerate.

Index: configure.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/configure.in,v
retrieving revision 1.622
diff -p -c -r1.622 configure.in
*** configure.in	7 Nov 2002 22:48:09 -0000	1.622
--- configure.in	11 Nov 2002 01:11:04 -0000
*************** no)	;;
*** 211,216 ****
--- 211,217 ----
  		rtl)	ac_rtl_checking=1 ;;
  		gc)	ac_gc_checking=1 ;;
  		gcac)	ac_gc_always_collect=1 ;;
+ 		valgrind)	ac_checking_valgrind=1 ;;
  		*)	AC_MSG_ERROR(unknown check category $check) ;;
  		esac
  	done
*************** if test x$ac_gc_always_collect != x ; th
*** 256,261 ****
--- 257,280 ----
     paranoid mode, validating the entire heap and collecting garbage at
     every opportunity.  This is extremely expensive.])
  fi
+ valgrind_defines=
+ valgrind_path=
+ valgrind_cmd=
+ if test x$ac_checking_valgrind != x ; then
+   AM_PATH_PROG_WITH_TEST(valgrind_path, valgrind,
+ 	[$ac_dir/$ac_word --version | grep valgrind- >/dev/null 2>&1])
+   if test "x$valgrind_path" = "x" ; then
+ 	AC_MSG_ERROR([*** Can't find valgrind])
+   fi
+   valgrind_defines=-DVALGRIND_PATH='\"'$valgrind_path'\"'
+   valgrind_cmd="$valgrind_path -q"
+   AC_DEFINE(ENABLE_VALGRIND, 1,
+ [Define if you want to run subprograms and generated programs
+    through valgrind (a memory checker).  This is rather expensive.])
+ fi
+ AC_SUBST(valgrind_defines)
+ AC_SUBST(valgrind_path)
+ AC_SUBST(valgrind_cmd)

  # Enable code coverage collection
  AC_ARG_ENABLE(coverage,
Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.955
diff -p -c -r1.955 Makefile.in
*** Makefile.in	29 Oct 2002 21:37:13 -0000	1.955
--- Makefile.in	11 Nov 2002 01:11:07 -0000
*************** STRICT2_WARN = -Wtraditional -pedantic -
*** 96,101 ****
--- 96,106 ----
  # "extern" tags in header files.
  NOCOMMON_FLAG = @nocommon_flag@

+ # These are set by --enable-checking=valgrind.
+ VALGRIND_PATH = @valgrind_path@
+ VALGRIND_CMD = @valgrind_cmd@
+ VALGRIND_DEFINES = @valgrind_defines@
+
  # This is how we control whether or not the additional warnings are applied.
  .-warn = $(STRICT_WARN)
  GCC_WARN_CFLAGS = $(LOOSE_WARN) $($(@D)-warn) $(NOCOMMON_FLAG)
*************** BUILD_PREFIX = @BUILD_PREFIX@
*** 483,489 ****
  BUILD_PREFIX_1 = @BUILD_PREFIX_1@
  # Native compiler for the build machine and its switches.
  HOST_CC = @HOST_CC@
! HOST_CFLAGS= @HOST_CFLAGS@ -DGENERATOR_FILE

  # Native linker and preprocessor flags.  For x-fragment overrides.
  HOST_LDFLAGS=$(LDFLAGS)
--- 488,494 ----
  BUILD_PREFIX_1 = @BUILD_PREFIX_1@
  # Native compiler for the build machine and its switches.
  HOST_CC = @HOST_CC@
! HOST_CFLAGS= @HOST_CFLAGS@ -DGENERATOR_FILE $(VALGRIND_DEFINES)

  # Native linker and preprocessor flags.  For x-fragment overrides.
  HOST_LDFLAGS=$(LDFLAGS)
*************** INTERNAL_CFLAGS = -DIN_GCC @CROSS@
*** 602,608 ****
  # This is the variable actually used when we compile.
  # If you change this line, you probably also need to change the definition
  # of HOST_CFLAGS in build-make to match.
! ALL_CFLAGS = $(X_CFLAGS) $(T_CFLAGS) \
    $(CFLAGS) $(INTERNAL_CFLAGS) $(COVERAGE_FLAGS) $(WARN_CFLAGS) $(XCFLAGS) @DEFS@

  # Likewise.
--- 607,613 ----
  # This is the variable actually used when we compile.
  # If you change this line, you probably also need to change the definition
  # of HOST_CFLAGS in build-make to match.
! ALL_CFLAGS = $(X_CFLAGS) $(T_CFLAGS) $(VALGRIND_DEFINES) \
    $(CFLAGS) $(INTERNAL_CFLAGS) $(COVERAGE_FLAGS) $(WARN_CFLAGS) $(XCFLAGS) @DEFS@

  # Likewise.
*************** cppspec.o: cppspec.c $(CONFIG_H) $(SYSTE
*** 1282,1288 ****

  tree-check.h: s-check ; @true
  s-check : gencheck$(build_exeext) $(srcdir)/move-if-change
! 	./gencheck$(build_exeext) > tmp-check.h
  	$(SHELL) $(srcdir)/move-if-change tmp-check.h tree-check.h
  	$(STAMP) s-check

--- 1287,1293 ----

  tree-check.h: s-check ; @true
  s-check : gencheck$(build_exeext) $(srcdir)/move-if-change
! 	$(VALGRIND_CMD) ./gencheck$(build_exeext) > tmp-check.h
  	$(SHELL) $(srcdir)/move-if-change tmp-check.h tree-check.h
  	$(STAMP) s-check

*************** mips-tdump.o : mips-tdump.c $(CONFIG_H)
*** 1689,1701 ****

  insn-config.h: s-config ; @true
  s-config : $(md_file) genconfig$(build_exeext) $(srcdir)/move-if-change
! 	./genconfig$(build_exeext) $(md_file) > tmp-config.h
  	$(SHELL) $(srcdir)/move-if-change tmp-config.h insn-config.h
  	$(STAMP) s-config

  insn-conditions.c: s-conditions ; @true
  s-conditions : $(md_file) genconditions$(build_exeext) $(srcdir)/move-if-change
! 	./genconditions$(build_exeext) $(md_file) > tmp-conditions.c
  	$(SHELL) $(srcdir)/move-if-change tmp-conditions.c insn-conditions.c
  	$(STAMP) s-conditions

--- 1694,1706 ----

  insn-config.h: s-config ; @true
  s-config : $(md_file) genconfig$(build_exeext) $(srcdir)/move-if-change
! 	$(VALGRIND_CMD) ./genconfig$(build_exeext) $(md_file) > tmp-config.h
  	$(SHELL) $(srcdir)/move-if-change tmp-config.h insn-config.h
  	$(STAMP) s-config

  insn-conditions.c: s-conditions ; @true
  s-conditions : $(md_file) genconditions$(build_exeext) $(srcdir)/move-if-change
! 	$(VALGRIND_CMD) ./genconditions$(build_exeext) $(md_file) > tmp-conditions.c
  	$(SHELL) $(srcdir)/move-if-change tmp-conditions.c insn-conditions.c
  	$(STAMP) s-conditions

*************** dummy-conditions.o : dummy-conditions.c
*** 1710,1728 ****

  insn-flags.h: s-flags ; @true
  s-flags : $(md_file) genflags$(build_exeext) $(srcdir)/move-if-change
! 	./genflags$(build_exeext) $(md_file) > tmp-flags.h
  	$(SHELL) $(srcdir)/move-if-change tmp-flags.h insn-flags.h
  	$(STAMP) s-flags

  insn-codes.h: s-codes ; @true
  s-codes : $(md_file) gencodes$(build_exeext) $(srcdir)/move-if-change
! 	./gencodes$(build_exeext) $(md_file) > tmp-codes.h
  	$(SHELL) $(srcdir)/move-if-change tmp-codes.h insn-codes.h
  	$(STAMP) s-codes

  insn-constants.h: s-constants ; @true
  s-constants : $(md_file) genconstants$(build_exeext) $(srcdir)/move-if-change
! 	./genconstants$(build_exeext) $(md_file) > tmp-constants.h
  	$(SHELL) $(srcdir)/move-if-change tmp-constants.h insn-constants.h
  	$(STAMP) s-constants

--- 1715,1733 ----

  insn-flags.h: s-flags ; @true
  s-flags : $(md_file) genflags$(build_exeext) $(srcdir)/move-if-change
! 	$(VALGRIND_CMD) ./genflags$(build_exeext) $(md_file) > tmp-flags.h
  	$(SHELL) $(srcdir)/move-if-change tmp-flags.h insn-flags.h
  	$(STAMP) s-flags

  insn-codes.h: s-codes ; @true
  s-codes : $(md_file) gencodes$(build_exeext) $(srcdir)/move-if-change
! 	$(VALGRIND_CMD) ./gencodes$(build_exeext) $(md_file) > tmp-codes.h
  	$(SHELL) $(srcdir)/move-if-change tmp-codes.h insn-codes.h
  	$(STAMP) s-codes

  insn-constants.h: s-constants ; @true
  s-constants : $(md_file) genconstants$(build_exeext) $(srcdir)/move-if-change
! 	$(VALGRIND_CMD) ./genconstants$(build_exeext) $(md_file) > tmp-constants.h
  	$(SHELL) $(srcdir)/move-if-change tmp-constants.h insn-constants.h
  	$(STAMP) s-constants

*************** insn-emit.o : insn-emit.c $(CONFIG_H) $(
*** 1734,1740 ****

  insn-emit.c: s-emit ; @true
  s-emit : $(md_file) genemit$(build_exeext) $(srcdir)/move-if-change
! 	./genemit$(build_exeext) $(md_file) > tmp-emit.c
  	$(SHELL) $(srcdir)/move-if-change tmp-emit.c insn-emit.c
  	$(STAMP) s-emit

--- 1739,1745 ----

  insn-emit.c: s-emit ; @true
  s-emit : $(md_file) genemit$(build_exeext) $(srcdir)/move-if-change
! 	$(VALGRIND_CMD) ./genemit$(build_exeext) $(md_file) > tmp-emit.c
  	$(SHELL) $(srcdir)/move-if-change tmp-emit.c insn-emit.c
  	$(STAMP) s-emit

*************** insn-recog.o : insn-recog.c $(CONFIG_H)
*** 1746,1752 ****

  insn-recog.c: s-recog ; @true
  s-recog : $(md_file) genrecog$(build_exeext) $(srcdir)/move-if-change
! 	./genrecog$(build_exeext) $(md_file) > tmp-recog.c
  	$(SHELL) $(srcdir)/move-if-change tmp-recog.c insn-recog.c
  	$(STAMP) s-recog

--- 1751,1757 ----

  insn-recog.c: s-recog ; @true
  s-recog : $(md_file) genrecog$(build_exeext) $(srcdir)/move-if-change
! 	$(VALGRIND_CMD) ./genrecog$(build_exeext) $(md_file) > tmp-recog.c
  	$(SHELL) $(srcdir)/move-if-change tmp-recog.c insn-recog.c
  	$(STAMP) s-recog

*************** insn-opinit.o : insn-opinit.c $(CONFIG_H
*** 1757,1763 ****

  insn-opinit.c: s-opinit ; @true
  s-opinit : $(md_file) genopinit$(build_exeext) $(srcdir)/move-if-change
! 	./genopinit$(build_exeext) $(md_file) > tmp-opinit.c
  	$(SHELL) $(srcdir)/move-if-change tmp-opinit.c insn-opinit.c
  	$(STAMP) s-opinit

--- 1762,1768 ----

  insn-opinit.c: s-opinit ; @true
  s-opinit : $(md_file) genopinit$(build_exeext) $(srcdir)/move-if-change
! 	$(VALGRIND_CMD) ./genopinit$(build_exeext) $(md_file) > tmp-opinit.c
  	$(SHELL) $(srcdir)/move-if-change tmp-opinit.c insn-opinit.c
  	$(STAMP) s-opinit

*************** insn-extract.o : insn-extract.c $(CONFIG
*** 1768,1774 ****

  insn-extract.c: s-extract ; @true
  s-extract : $(md_file) genextract$(build_exeext) $(srcdir)/move-if-change
! 	./genextract$(build_exeext) $(md_file) > tmp-extract.c
  	$(SHELL) $(srcdir)/move-if-change tmp-extract.c insn-extract.c
  	$(STAMP) s-extract

--- 1773,1779 ----

  insn-extract.c: s-extract ; @true
  s-extract : $(md_file) genextract$(build_exeext) $(srcdir)/move-if-change
! 	$(VALGRIND_CMD) ./genextract$(build_exeext) $(md_file) > tmp-extract.c
  	$(SHELL) $(srcdir)/move-if-change tmp-extract.c insn-extract.c
  	$(STAMP) s-extract

*************** insn-peep.o : insn-peep.c $(CONFIG_H) $(
*** 1779,1785 ****

  insn-peep.c: s-peep ; @true
  s-peep : $(md_file) genpeep$(build_exeext) $(srcdir)/move-if-change
! 	./genpeep$(build_exeext) $(md_file) > tmp-peep.c
  	$(SHELL) $(srcdir)/move-if-change tmp-peep.c insn-peep.c
  	$(STAMP) s-peep

--- 1784,1790 ----

  insn-peep.c: s-peep ; @true
  s-peep : $(md_file) genpeep$(build_exeext) $(srcdir)/move-if-change
! 	$(VALGRIND_CMD) ./genpeep$(build_exeext) $(md_file) > tmp-peep.c
  	$(SHELL) $(srcdir)/move-if-change tmp-peep.c insn-peep.c
  	$(STAMP) s-peep

*************** insn-attrtab.o : insn-attrtab.c $(CONFIG
*** 1791,1803 ****

  insn-attr.h: s-attr ; @true
  s-attr : $(md_file) genattr$(build_exeext) $(srcdir)/move-if-change
! 	./genattr$(build_exeext) $(md_file) > tmp-attr.h
  	$(SHELL) $(srcdir)/move-if-change tmp-attr.h insn-attr.h
  	$(STAMP) s-attr

  insn-attrtab.c: s-attrtab ; @true
  s-attrtab : $(md_file) genattrtab$(build_exeext) $(srcdir)/move-if-change
! 	./genattrtab$(build_exeext) $(md_file) > tmp-attrtab.c
  	$(SHELL) $(srcdir)/move-if-change tmp-attrtab.c insn-attrtab.c
  	$(STAMP) s-attrtab

--- 1796,1808 ----

  insn-attr.h: s-attr ; @true
  s-attr : $(md_file) genattr$(build_exeext) $(srcdir)/move-if-change
! 	$(VALGRIND_CMD) ./genattr$(build_exeext) $(md_file) > tmp-attr.h
  	$(SHELL) $(srcdir)/move-if-change tmp-attr.h insn-attr.h
  	$(STAMP) s-attr

  insn-attrtab.c: s-attrtab ; @true
  s-attrtab : $(md_file) genattrtab$(build_exeext) $(srcdir)/move-if-change
! 	$(VALGRIND_CMD) ./genattrtab$(build_exeext) $(md_file) > tmp-attrtab.c
  	$(SHELL) $(srcdir)/move-if-change tmp-attrtab.c insn-attrtab.c
  	$(STAMP) s-attrtab

*************** insn-output.o : insn-output.c $(CONFIG_H
*** 1810,1816 ****

  insn-output.c: s-output ; @true
  s-output : $(md_file) genoutput$(build_exeext) $(srcdir)/move-if-change
! 	./genoutput$(build_exeext) $(md_file) > tmp-output.c
  	$(SHELL) $(srcdir)/move-if-change tmp-output.c insn-output.c
  	$(STAMP) s-output

--- 1815,1821 ----

  insn-output.c: s-output ; @true
  s-output : $(md_file) genoutput$(build_exeext) $(srcdir)/move-if-change
! 	$(VALGRIND_CMD) ./genoutput$(build_exeext) $(md_file) > tmp-output.c
  	$(SHELL) $(srcdir)/move-if-change tmp-output.c insn-output.c
  	$(STAMP) s-output

*************** genrtl.c genrtl.h : s-genrtl
*** 1819,1834 ****
  	@true	# force gnu make to recheck modification times.

  s-genrtl: gengenrtl$(build_exeext) $(srcdir)/move-if-change $(RTL_BASE_H)
! 	./gengenrtl$(build_exeext) -h > tmp-genrtl.h
  	$(SHELL) $(srcdir)/move-if-change tmp-genrtl.h genrtl.h
! 	./gengenrtl$(build_exeext) > tmp-genrtl.c
  	$(SHELL) $(srcdir)/move-if-change tmp-genrtl.c genrtl.c
  	$(STAMP) s-genrtl

  tm-preds.h: s-preds; @true

  s-preds: genpreds$(build_exeext) $(srcdir)/move-if-change
! 	./genpreds$(build_exeext) > tmp-preds.h
  	$(SHELL) $(srcdir)/move-if-change tmp-preds.h tm-preds.h
  	$(STAMP) s-preds

--- 1824,1839 ----
  	@true	# force gnu make to recheck modification times.

  s-genrtl: gengenrtl$(build_exeext) $(srcdir)/move-if-change $(RTL_BASE_H)
! 	$(VALGRIND_CMD) ./gengenrtl$(build_exeext) -h > tmp-genrtl.h
  	$(SHELL) $(srcdir)/move-if-change tmp-genrtl.h genrtl.h
! 	$(VALGRIND_CMD) ./gengenrtl$(build_exeext) > tmp-genrtl.c
  	$(SHELL) $(srcdir)/move-if-change tmp-genrtl.c genrtl.c
  	$(STAMP) s-genrtl

  tm-preds.h: s-preds; @true

  s-preds: genpreds$(build_exeext) $(srcdir)/move-if-change
! 	$(VALGRIND_CMD) ./genpreds$(build_exeext) > tmp-preds.h
  	$(SHELL) $(srcdir)/move-if-change tmp-preds.h tm-preds.h
  	$(STAMP) s-preds

*************** gtyp-gen.h: Makefile
*** 1893,1899 ****
  	$(SHELL) $(srcdir)/move-if-change tmp-gtyp.h gtyp-gen.h

  s-gtype: gengtype$(build_exeext) $(GTFILES)
! 	./gengtype
  	$(STAMP) s-gtype

  #
--- 1898,1904 ----
  	$(SHELL) $(srcdir)/move-if-change tmp-gtyp.h gtyp-gen.h

  s-gtype: gengtype$(build_exeext) $(GTFILES)
! 	$(VALGRIND_CMD) ./gengtype
  	$(STAMP) s-gtype

  #
*************** xsys-protos.h: $(GCC_PASSES) $(srcdir)/s
*** 2401,2407 ****
  	mv tmp-fixtmp.c fixtmp.c
  	$(GCC_FOR_TARGET) fixtmp.c -w -U__SIZE_TYPE__ -U__PTRDIFF_TYPE__ -U__WCHAR_TYPE__ -E \
  	  | sed -e 's/	/ /g' -e 's/ *(/ (/g' -e 's/ [ ]*/ /g' -e 's/( )/()/' \
! 	  | ./gen-protos >xsys-protos.hT
  	mv xsys-protos.hT xsys-protos.h
  	rm -rf fixtmp.c

--- 2406,2412 ----
  	mv tmp-fixtmp.c fixtmp.c
  	$(GCC_FOR_TARGET) fixtmp.c -w -U__SIZE_TYPE__ -U__PTRDIFF_TYPE__ -U__WCHAR_TYPE__ -E \
  	  | sed -e 's/	/ /g' -e 's/ *(/ (/g' -e 's/ [ ]*/ /g' -e 's/( )/()/' \
! 	  | $(VALGRIND_CMD) ./gen-protos >xsys-protos.hT
  	mv xsys-protos.hT xsys-protos.h
  	rm -rf fixtmp.c

Index: gcc.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcc.c,v
retrieving revision 1.344
diff -p -c -r1.344 gcc.c
*** gcc.c	14 Oct 2002 07:15:38 -0000	1.344
--- gcc.c	11 Nov 2002 01:11:09 -0000
*************** execute ()
*** 2843,2848 ****
--- 2843,2874 ----
  #endif /* DEBUG */
      }

+ #ifdef ENABLE_VALGRIND
+   /* Run the each command through valgrind.  Allocate a separate argv
+      array to prepend the path to valgrind and "-q" for quiet operation.  */
+
+   for (i = 0; i < n_commands; i++)
+     {
+       const char **argv;
+       int argc;
+       int j;
+
+       for (argc = 0; commands[i].argv[argc] != NULL; argc++)
+ 	;
+
+       argv = alloca ((argc + 3) * sizeof (char *));
+
+       argv[0] = VALGRIND_PATH;
+       argv[1] = "-q";
+       argv[argc + 2] = NULL;
+       for (j = 0; j < argc; j++)
+ 	argv[j + 2] = commands[i].argv[j];
+
+       commands[i].argv = argv;
+       commands[i].prog = argv[0];
+     }
+ #endif
+
    /* Run each piped subprocess.  */

    for (i = 0; i < n_commands; i++)

brgds, H-P

^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2002-11-27 23:08 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-10 17:35 RFC: --enable-checking=valgrind Hans-Peter Nilsson
2002-11-10 19:34 ` Zack Weinberg
2002-11-11  1:55   ` Hans-Peter Nilsson
2002-11-11 16:53     ` Zack Weinberg
2002-11-11 17:48       ` Hans-Peter Nilsson
2002-11-12  6:02       ` Jan Hubicka
2002-11-12 17:11         ` Hans-Peter Nilsson
2002-11-12 17:21           ` Zack Weinberg
2002-11-13  5:32           ` Jan Hubicka
2002-11-13 13:38             ` Hans-Peter Nilsson
2002-11-18 17:20     ` Richard Henderson
2002-11-18 18:24       ` [RFA:] Take 2 (was: Re: RFC: --enable-checking=valgrind.) Hans-Peter Nilsson
2002-11-18 20:37         ` Richard Henderson
2002-11-20 11:57           ` Hans-Peter Nilsson
2002-11-18 22:12         ` Neil Booth
2002-11-19  4:37           ` Hans-Peter Nilsson
2002-11-18 22:33         ` Andreas Jaeger
2002-11-19  4:33           ` Hans-Peter Nilsson
2002-11-19  7:31             ` Andreas Jaeger
2002-11-19  9:07               ` Hans-Peter Nilsson
2002-11-19  9:15                 ` [RFA:] Take 2 Andreas Jaeger
2002-11-26  5:42         ` [PATCH] Fix configure (was Re: [RFA:] Take 2 (was: Re: RFC: --enable-checking=valgrind.)) Jakub Jelinek
2002-11-26  9:59           ` Richard Henderson
2002-11-28  7:34           ` Hans-Peter Nilsson
2002-11-28  8:08             ` Hans-Peter Nilsson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).