public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Hans-Peter Nilsson <hp@bitrange.com>
To: Richard Henderson <rth@redhat.com>
Cc: gcc-patches@gcc.gnu.org
Subject: [RFA:] Take 2 (was: Re: RFC: --enable-checking=valgrind.)
Date: Mon, 18 Nov 2002 18:24:00 -0000	[thread overview]
Message-ID: <Pine.BSF.4.44.0211182022110.61397-100000@dair.pair.com> (raw)
In-Reply-To: <20021119012026.GM4209@redhat.com>

On Mon, 18 Nov 2002, Richard Henderson wrote:
> On Mon, Nov 11, 2002 at 04:55:17AM -0500, Hans-Peter Nilsson wrote:
        [Patch for --enable-checking=valgrind take 1]
>
> Ok.

Thanks for the review (that patch did work as far as I ran it).

But I have an updated, polished patch which after 53.75 hours on
an Athlon model 4 1GHz finally finished bootstrapping (phew!).
Just have to finish bootstrap&check without
--enable-checking=valgrind and without the patch too.  FWIW,
testing also included patches for annotations for the ggc memory
management; none trigged AFAICT.  (Will follow as separate
patch.)

Summary of changes to previous patch:
- Only DRIVER_DEFINES needs the path to valgrind.
- I thought better name the prefix $(RUN_GEN) as there may be
other uses for prepending stuff when executing the ./gen*
helpers (and since it's slightly shorter; helps when reading
Makefile.in).
- All the compiler tests are moved together, before
--enable-checking, not just the necessary AC_PROG_CC and
AC_PROG_CPP.
- As Zack pointed out, the mmap+1 annotation in cppfiles.c
should be removed when the page is munmapped.
- I renamed ENABLE_VALGRIND to ENABLE_VALGRIND_CHECKING for
consistency and to avoid confusion if someone wants to
add use of some other valgrind feature e.g.
ENABLE_VALGRIND_CACHE_PROFILING.


Bootstrapped i686-pc-linux-gnu with
--enable-checking=misc,tree,gc,rtlflag,valgrind which
corresponds to the default but adding valgrind.  No Ada.

Will bootstrap and check with default --enable-checking,
comparing with and without the patch before checking in.
Note I have Honza's patch at
<URL:http://gcc.gnu.org/ml/gcc-patches/2002-11/msg00767.html> in
the tree.  Yes, there *are* test-suite "regressions" when adding
--enable-checking=valgrind. :-)  I'll report the findings
separately.

	* Makefile.in (RUN_GEN, VALGRIND_DRIVER_DEFINES): New variables.
	(DRIVER_DEFINES): Add $(VALGRIND_DRIVER_DEFINES).
	(executing gencheck, genconfigs, genconditions, genflags,
	gencodes, genconstants, genemit, genrecog, genopinit, genextract,
	genpeep, genattr, genattrtab, genoutput, gengenrtl, genpreds,
	gengtype, genprotos): Prepend $(RUN_GEN).
	* configure.in: Move host compiler tests before --enable-checking
	tests.
	(--enable-checking=valgrind): New.
	* config.in, configure: Regenerate.
	* cppfiles.c (read_include_file) [ENABLE_VALGRIND_CHECKING]: When
	doing the mmap+1 trick, annotate the byte after the mmap:ed area
	as readable.
	(purge_cache) [ENABLE_VALGRIND_CHECKING]: Remove above annotation.
	* gcc.c (execute) [ENABLE_VALGRIND_CHECKING]: Arrange to prepend
	VALGRIND_PATH -q to each command.

Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.956
diff -p -c -r1.956 Makefile.in
*** Makefile.in	12 Nov 2002 00:27:31 -0000	1.956
--- Makefile.in	19 Nov 2002 01:35:33 -0000
*************** STRICT2_WARN = -Wtraditional -pedantic -
*** 96,101 ****
--- 96,105 ----
  # "extern" tags in header files.
  NOCOMMON_FLAG = @nocommon_flag@

+ # These are set by --enable-checking=valgrind.
+ RUN_GEN = @valgrind_command@
+ VALGRIND_DRIVER_DEFINES = @valgrind_path_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)
*************** DRIVER_DEFINES = \
*** 1260,1265 ****
--- 1264,1270 ----
    -DDEFAULT_TARGET_MACHINE=\"$(target_alias)\" \
    -DSTANDARD_BINDIR_PREFIX=\"$(bindir)/\" \
    -DTOOLDIR_BASE_PREFIX=\"$(unlibsubdir)/../\" \
+   $(VALGRIND_DRIVER_DEFINES) \
    `test "X$${SHLIB_LINK}" = "X" || test "@enable_shared@" != "yes" || echo "-DENABLE_SHARED_LIBGCC"` \
    `test "X$${SHLIB_MULTILIB}" = "X" || echo "-DNO_SHARED_LIBGCC_MULTILIB"`

*************** 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
! 	$(RUN_GEN) ./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)
*** 1690,1702 ****

  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

--- 1695,1707 ----

  insn-config.h: s-config ; @true
  s-config : $(md_file) genconfig$(build_exeext) $(srcdir)/move-if-change
! 	$(RUN_GEN) ./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
! 	$(RUN_GEN) ./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
*** 1711,1729 ****

  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

--- 1716,1734 ----

  insn-flags.h: s-flags ; @true
  s-flags : $(md_file) genflags$(build_exeext) $(srcdir)/move-if-change
! 	$(RUN_GEN) ./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
! 	$(RUN_GEN) ./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
! 	$(RUN_GEN) ./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) $(
*** 1735,1741 ****

  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

--- 1740,1746 ----

  insn-emit.c: s-emit ; @true
  s-emit : $(md_file) genemit$(build_exeext) $(srcdir)/move-if-change
! 	$(RUN_GEN) ./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)
*** 1747,1753 ****

  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

--- 1752,1758 ----

  insn-recog.c: s-recog ; @true
  s-recog : $(md_file) genrecog$(build_exeext) $(srcdir)/move-if-change
! 	$(RUN_GEN) ./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
*** 1758,1764 ****

  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

--- 1763,1769 ----

  insn-opinit.c: s-opinit ; @true
  s-opinit : $(md_file) genopinit$(build_exeext) $(srcdir)/move-if-change
! 	$(RUN_GEN) ./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
*** 1769,1775 ****

  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

--- 1774,1780 ----

  insn-extract.c: s-extract ; @true
  s-extract : $(md_file) genextract$(build_exeext) $(srcdir)/move-if-change
! 	$(RUN_GEN) ./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) $(
*** 1780,1786 ****

  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

--- 1785,1791 ----

  insn-peep.c: s-peep ; @true
  s-peep : $(md_file) genpeep$(build_exeext) $(srcdir)/move-if-change
! 	$(RUN_GEN) ./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
*** 1792,1804 ****

  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

--- 1797,1809 ----

  insn-attr.h: s-attr ; @true
  s-attr : $(md_file) genattr$(build_exeext) $(srcdir)/move-if-change
! 	$(RUN_GEN) ./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
! 	$(RUN_GEN) ./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
*** 1811,1817 ****

  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

--- 1816,1822 ----

  insn-output.c: s-output ; @true
  s-output : $(md_file) genoutput$(build_exeext) $(srcdir)/move-if-change
! 	$(RUN_GEN) ./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
*** 1820,1835 ****
  	@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

--- 1825,1840 ----
  	@true	# force gnu make to recheck modification times.

  s-genrtl: gengenrtl$(build_exeext) $(srcdir)/move-if-change $(RTL_BASE_H)
! 	$(RUN_GEN) ./gengenrtl$(build_exeext) -h > tmp-genrtl.h
  	$(SHELL) $(srcdir)/move-if-change tmp-genrtl.h genrtl.h
! 	$(RUN_GEN) ./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
! 	$(RUN_GEN) ./genpreds$(build_exeext) > tmp-preds.h
  	$(SHELL) $(srcdir)/move-if-change tmp-preds.h tm-preds.h
  	$(STAMP) s-preds

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

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

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

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

  #
*************** xsys-protos.h: $(GCC_PASSES) $(srcdir)/s
*** 2402,2408 ****
  	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

--- 2407,2413 ----
  	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/( )/()/' \
! 	  | $(RUN_GEN) ./gen-protos >xsys-protos.hT
  	mv xsys-protos.hT xsys-protos.h
  	rm -rf fixtmp.c

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	19 Nov 2002 01:35:37 -0000
*************** changequote([, ])dnl
*** 176,181 ****
--- 176,257 ----
    fi
  fi

+ # Find the native compiler
+ AC_PROG_CC
+ AC_PROG_CC_C_O
+ # autoconf is lame and doesn't give us any substitution variable for this.
+ if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then
+   NO_MINUS_C_MINUS_O=yes
+ else
+   OUTPUT_OPTION='-o $@'
+ fi
+ AC_SUBST(NO_MINUS_C_MINUS_O)
+ AC_SUBST(OUTPUT_OPTION)
+
+ # See if GNAT has been installed
+ gcc_AC_PROG_GNAT
+
+ AC_CACHE_CHECK(whether ${CC-cc} accepts -Wno-long-long,
+ ac_cv_prog_cc_no_long_long,
+ [save_CFLAGS="$CFLAGS"
+ CFLAGS="-Wno-long-long"
+ AC_TRY_COMPILE(,,ac_cv_prog_cc_no_long_long=yes,
+ 	       ac_cv_prog_cc_no_long_long=no)
+ CFLAGS="$save_CFLAGS"])
+
+ if test x$have_gnat != xno ; then
+ AC_CACHE_CHECK(whether ${ADAC} accepts -Wno-long-long,
+ ac_cv_prog_adac_no_long_long,
+ [cat >conftest.adb <<EOF
+ procedure conftest is begin null; end conftest;
+ EOF
+ if $ADAC -Wno-long-long -c conftest.adb 1>&5 2>&5 ; then
+   ac_cv_prog_adac_no_long_long=yes
+ else
+   ac_cv_prog_adac_no_long_long=no
+ fi
+ rm -f conftest*])
+ else
+   ac_cv_prog_adac_no_long_long=yes
+ fi
+
+ strict1_warn=
+ if test $ac_cv_prog_cc_no_long_long = yes && \
+     test $ac_cv_prog_adac_no_long_long = yes ; then
+   strict1_warn="-pedantic -Wno-long-long"
+ fi
+ AC_SUBST(strict1_warn)
+
+ AC_PROG_CPP
+ AC_C_INLINE
+ gcc_AC_C_VOLATILE
+
+ gcc_AC_C_LONG_DOUBLE
+ gcc_AC_C_LONG_LONG
+ gcc_AC_C__BOOL
+
+ # sizeof(char) is 1 by definition.
+ gcc_AC_COMPILE_CHECK_SIZEOF(short)
+ gcc_AC_COMPILE_CHECK_SIZEOF(int)
+ gcc_AC_COMPILE_CHECK_SIZEOF(long)
+ if test $ac_cv_c_long_long = yes; then
+   gcc_AC_COMPILE_CHECK_SIZEOF(long long)
+ fi
+ if test $ac_cv_c___int64 = yes; then
+   gcc_AC_COMPILE_CHECK_SIZEOF(__int64)
+ fi
+
+ gcc_AC_C_CHARSET
+
+ # If the native compiler is GCC, we can enable warnings even in stage1.
+ # That's useful for people building cross-compilers, or just running a
+ # quick `make'.
+ warn_cflags=
+ if test "x$GCC" = "xyes"; then
+   warn_cflags='$(GCC_WARN_CFLAGS)'
+ fi
+ AC_SUBST(warn_cflags)
+
  # Determine whether or not multilibs are enabled.
  AC_ARG_ENABLE(multilib,
  [  --enable-multilib       enable library support for multiple ABIs],
*************** no)	;;
*** 211,216 ****
--- 287,293 ----
  		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 ****
--- 333,357 ----
     paranoid mode, validating the entire heap and collecting garbage at
     every opportunity.  This is extremely expensive.])
  fi
+ valgrind_path_defines=
+ valgrind_command=
+ if test x$ac_checking_valgrind != x ; then
+   # It is certainly possible that there's valgrind but no valgrind.h.
+   # GCC relies on making annotations so we must have both.
+   AC_CHECK_HEADER(valgrind.h, have_valgrind_h=yes, have_valgrind_h=no)
+   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" || test $have_valgrind_h = no; then
+ 	AC_MSG_ERROR([*** Can't find both valgrind and valgrind.h])
+   fi
+   valgrind_path_defines=-DVALGRIND_PATH='\"'$valgrind_path'\"'
+   valgrind_command="$valgrind_path -q"
+   AC_DEFINE(ENABLE_VALGRIND_CHECKING, 1,
+ [Define if you want to run subprograms and generated programs
+    through valgrind (a memory checker).  This is extremely expensive.])
+ fi
+ AC_SUBST(valgrind_path_defines)
+ AC_SUBST(valgrind_command)

  # Enable code coverage collection
  AC_ARG_ENABLE(coverage,
*************** AC_CANONICAL_SYSTEM
*** 378,459 ****

  # Set program_transform_name
  AC_ARG_PROGRAM
-
- # Find the native compiler
- AC_PROG_CC
- AC_PROG_CC_C_O
- # autoconf is lame and doesn't give us any substitution variable for this.
- if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then
-   NO_MINUS_C_MINUS_O=yes
- else
-   OUTPUT_OPTION='-o $@'
- fi
- AC_SUBST(NO_MINUS_C_MINUS_O)
- AC_SUBST(OUTPUT_OPTION)
-
- # See if GNAT has been installed
- gcc_AC_PROG_GNAT
-
- AC_CACHE_CHECK(whether ${CC-cc} accepts -Wno-long-long,
- ac_cv_prog_cc_no_long_long,
- [save_CFLAGS="$CFLAGS"
- CFLAGS="-Wno-long-long"
- AC_TRY_COMPILE(,,ac_cv_prog_cc_no_long_long=yes,
- 	       ac_cv_prog_cc_no_long_long=no)
- CFLAGS="$save_CFLAGS"])
-
- if test x$have_gnat != xno ; then
- AC_CACHE_CHECK(whether ${ADAC} accepts -Wno-long-long,
- ac_cv_prog_adac_no_long_long,
- [cat >conftest.adb <<EOF
- procedure conftest is begin null; end conftest;
- EOF
- if $ADAC -Wno-long-long -c conftest.adb 1>&5 2>&5 ; then
-   ac_cv_prog_adac_no_long_long=yes
- else
-   ac_cv_prog_adac_no_long_long=no
- fi
- rm -f conftest*])
- else
-   ac_cv_prog_adac_no_long_long=yes
- fi
-
- strict1_warn=
- if test $ac_cv_prog_cc_no_long_long = yes && \
-     test $ac_cv_prog_adac_no_long_long = yes ; then
-   strict1_warn="-pedantic -Wno-long-long"
- fi
- AC_SUBST(strict1_warn)
-
- AC_PROG_CPP
- AC_C_INLINE
- gcc_AC_C_VOLATILE
-
- gcc_AC_C_LONG_DOUBLE
- gcc_AC_C_LONG_LONG
- gcc_AC_C__BOOL
-
- # sizeof(char) is 1 by definition.
- gcc_AC_COMPILE_CHECK_SIZEOF(short)
- gcc_AC_COMPILE_CHECK_SIZEOF(int)
- gcc_AC_COMPILE_CHECK_SIZEOF(long)
- if test $ac_cv_c_long_long = yes; then
-   gcc_AC_COMPILE_CHECK_SIZEOF(long long)
- fi
- if test $ac_cv_c___int64 = yes; then
-   gcc_AC_COMPILE_CHECK_SIZEOF(__int64)
- fi
-
- gcc_AC_C_CHARSET
-
- # If the native compiler is GCC, we can enable warnings even in stage1.
- # That's useful for people building cross-compilers, or just running a
- # quick `make'.
- warn_cflags=
- if test "x$GCC" = "xyes"; then
-   warn_cflags='$(GCC_WARN_CFLAGS)'
- fi
- AC_SUBST(warn_cflags)

  # Stage specific cflags for build.
  stage1_cflags=
--- 474,479 ----
Index: cppfiles.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cppfiles.c,v
retrieving revision 1.156
diff -p -c -r1.156 cppfiles.c
*** cppfiles.c	22 Sep 2002 02:03:16 -0000	1.156
--- cppfiles.c	19 Nov 2002 01:35:38 -0000
*************** Foundation, 59 Temple Place - Suite 330,
*** 27,32 ****
--- 27,35 ----
  #include "intl.h"
  #include "mkdeps.h"
  #include "splay-tree.h"
+ #ifdef ENABLE_VALGRIND_CHECKING
+ #include <valgrind.h>
+ #endif

  #ifdef HAVE_MMAP_FILE
  # include <sys/mman.h>
*************** read_include_file (pfile, inc)
*** 418,423 ****
--- 421,433 ----
  	  buf = (uchar *) mmap (0, size, PROT_READ, MAP_PRIVATE, inc->fd, 0);
  	  if (buf == (uchar *)-1)
  	    goto perror_fail;
+
+ #ifdef ENABLE_VALGRIND_CHECKING
+ 	  /* We must tell Valgrind that the byte at buf[size] is actually
+ 	     readable.  Discard the handle to avoid handle leak.  */
+ 	  VALGRIND_DISCARD (VALGRIND_MAKE_READABLE (buf + size, 1));
+ #endif
+
  	  inc->mapped = 1;
  	}
        else
*************** purge_cache (inc)
*** 498,504 ****
      {
  #if MMAP_THRESHOLD
        if (inc->mapped)
! 	munmap ((PTR) inc->buffer, inc->st.st_size);
        else
  #endif
  	free ((PTR) inc->buffer);
--- 508,523 ----
      {
  #if MMAP_THRESHOLD
        if (inc->mapped)
! 	{
! #ifdef ENABLE_VALGRIND_CHECKING
! 	  /* Undo the previous annotation for the
! 	     known-zero-byte-after-mmap.  Discard the handle to avoid
! 	     handle leak.  */
! 	  VALGRIND_DISCARD (VALGRIND_MAKE_NOACCESS (inc->buffer
! 						    + inc->st.st_size, 1));
! #endif
! 	  munmap ((PTR) inc->buffer, inc->st.st_size);
! 	}
        else
  #endif
  	free ((PTR) inc->buffer);
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	19 Nov 2002 01:35:45 -0000
*************** execute ()
*** 2843,2848 ****
--- 2843,2875 ----
  #endif /* DEBUG */
      }

+ #ifdef ENABLE_VALGRIND_CHECKING
+   /* Run the each command through valgrind.  To simplifiy prepending the
+      path to valgrind and the option "-q" (for quiet operation unless
+      something triggers), we allocate a separate argv array.  */
+
+   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";
+       for (j = 2; j < argc + 2; j++)
+ 	argv[j] = commands[i].argv[j - 2];
+       argv[j] = NULL;
+
+       commands[i].argv = argv;
+       commands[i].prog = argv[0];
+     }
+ #endif
+
    /* Run each piped subprocess.  */

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

brgds, H-P

  reply	other threads:[~2002-11-19  2:24 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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       ` Hans-Peter Nilsson [this message]
2002-11-18 20:37         ` [RFA:] Take 2 (was: Re: RFC: --enable-checking=valgrind.) 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.BSF.4.44.0211182022110.61397-100000@dair.pair.com \
    --to=hp@bitrange.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=rth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).