Makefile.in (RUN_GEN, [...]): New variables.

* 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 [!ENABLE_VALGRIND_CHECKING] (VALGRIND_DISCARD):
	Define as empty.
	(read_include_file): When doing the mmap+1 trick,
	valgrind-annotate the byte after the mmap:ed area as readable.
	(purge_cache): Remove above annotation.
	* gcc.c (execute) [ENABLE_VALGRIND_CHECKING]: Arrange to prepend
	VALGRIND_PATH -q to each command.

From-SVN: r59309
This commit is contained in:
Hans-Peter Nilsson 2002-11-20 19:49:53 +00:00 committed by Hans-Peter Nilsson
parent 3ba2436a67
commit 414d23ae18
7 changed files with 1653 additions and 1426 deletions

View File

@ -1,3 +1,23 @@
2002-11-20 Hans-Peter Nilsson <hp@bitrange.com>
* 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 [!ENABLE_VALGRIND_CHECKING] (VALGRIND_DISCARD):
Define as empty.
(read_include_file): When doing the mmap+1 trick,
valgrind-annotate the byte after the mmap:ed area as readable.
(purge_cache): Remove above annotation.
* gcc.c (execute) [ENABLE_VALGRIND_CHECKING]: Arrange to prepend
VALGRIND_PATH -q to each command.
2002-11-20 Ulrich Weigand <uweigand@de.ibm.com>
* recog.c (constrain_operands): Prefer exact match over reloadable

View File

@ -96,6 +96,10 @@ STRICT2_WARN = -Wtraditional -pedantic -Wno-long-long
# "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)
@ -1260,6 +1264,7 @@ DRIVER_DEFINES = \
-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"`
@ -1282,7 +1287,7 @@ cppspec.o: cppspec.c $(CONFIG_H) $(SYSTEM_H) $(GCC_H)
tree-check.h: s-check ; @true
s-check : gencheck$(build_exeext) $(srcdir)/move-if-change
./gencheck$(build_exeext) > tmp-check.h
$(RUN_GEN) ./gencheck$(build_exeext) > tmp-check.h
$(SHELL) $(srcdir)/move-if-change tmp-check.h tree-check.h
$(STAMP) s-check
@ -1690,13 +1695,13 @@ mips-tdump.o : mips-tdump.c $(CONFIG_H) $(RTL_H) $(SYSTEM_H)
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
$(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
./genconditions$(build_exeext) $(md_file) > tmp-conditions.c
$(RUN_GEN) ./genconditions$(build_exeext) $(md_file) > tmp-conditions.c
$(SHELL) $(srcdir)/move-if-change tmp-conditions.c insn-conditions.c
$(STAMP) s-conditions
@ -1711,19 +1716,19 @@ dummy-conditions.o : dummy-conditions.c $(HCONFIG_H) $(SYSTEM_H) gensupport.h
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
$(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
./gencodes$(build_exeext) $(md_file) > tmp-codes.h
$(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
./genconstants$(build_exeext) $(md_file) > tmp-constants.h
$(RUN_GEN) ./genconstants$(build_exeext) $(md_file) > tmp-constants.h
$(SHELL) $(srcdir)/move-if-change tmp-constants.h insn-constants.h
$(STAMP) s-constants
@ -1735,7 +1740,7 @@ insn-emit.o : insn-emit.c $(CONFIG_H) $(RTL_H) $(EXPR_H) real.h output.h \
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
$(RUN_GEN) ./genemit$(build_exeext) $(md_file) > tmp-emit.c
$(SHELL) $(srcdir)/move-if-change tmp-emit.c insn-emit.c
$(STAMP) s-emit
@ -1747,7 +1752,7 @@ insn-recog.o : insn-recog.c $(CONFIG_H) $(RTL_H) insn-config.h $(RECOG_H) \
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
$(RUN_GEN) ./genrecog$(build_exeext) $(md_file) > tmp-recog.c
$(SHELL) $(srcdir)/move-if-change tmp-recog.c insn-recog.c
$(STAMP) s-recog
@ -1758,7 +1763,7 @@ insn-opinit.o : insn-opinit.c $(CONFIG_H) $(RTL_H) \
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
$(RUN_GEN) ./genopinit$(build_exeext) $(md_file) > tmp-opinit.c
$(SHELL) $(srcdir)/move-if-change tmp-opinit.c insn-opinit.c
$(STAMP) s-opinit
@ -1769,7 +1774,7 @@ insn-extract.o : insn-extract.c $(CONFIG_H) $(RTL_H) $(SYSTEM_H) toplev.h \
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
$(RUN_GEN) ./genextract$(build_exeext) $(md_file) > tmp-extract.c
$(SHELL) $(srcdir)/move-if-change tmp-extract.c insn-extract.c
$(STAMP) s-extract
@ -1780,7 +1785,7 @@ insn-peep.o : insn-peep.c $(CONFIG_H) $(RTL_H) $(REGS_H) output.h real.h \
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
$(RUN_GEN) ./genpeep$(build_exeext) $(md_file) > tmp-peep.c
$(SHELL) $(srcdir)/move-if-change tmp-peep.c insn-peep.c
$(STAMP) s-peep
@ -1792,13 +1797,13 @@ insn-attrtab.o : insn-attrtab.c $(CONFIG_H) $(RTL_H) $(REGS_H) real.h \
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
$(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
./genattrtab$(build_exeext) $(md_file) > tmp-attrtab.c
$(RUN_GEN) ./genattrtab$(build_exeext) $(md_file) > tmp-attrtab.c
$(SHELL) $(srcdir)/move-if-change tmp-attrtab.c insn-attrtab.c
$(STAMP) s-attrtab
@ -1811,7 +1816,7 @@ insn-output.o : insn-output.c $(CONFIG_H) $(RTL_H) $(GGC_H) $(REGS_H) real.h \
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
$(RUN_GEN) ./genoutput$(build_exeext) $(md_file) > tmp-output.c
$(SHELL) $(srcdir)/move-if-change tmp-output.c insn-output.c
$(STAMP) s-output
@ -1820,16 +1825,16 @@ genrtl.c genrtl.h : s-genrtl
@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
$(RUN_GEN) ./gengenrtl$(build_exeext) -h > tmp-genrtl.h
$(SHELL) $(srcdir)/move-if-change tmp-genrtl.h genrtl.h
./gengenrtl$(build_exeext) > tmp-genrtl.c
$(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
./genpreds$(build_exeext) > tmp-preds.h
$(RUN_GEN) ./genpreds$(build_exeext) > tmp-preds.h
$(SHELL) $(srcdir)/move-if-change tmp-preds.h tm-preds.h
$(STAMP) s-preds
@ -1894,7 +1899,7 @@ gtyp-gen.h: Makefile
$(SHELL) $(srcdir)/move-if-change tmp-gtyp.h gtyp-gen.h
s-gtype: gengtype$(build_exeext) $(GTFILES)
./gengtype
$(RUN_GEN) ./gengtype
$(STAMP) s-gtype
#
@ -2402,7 +2407,7 @@ xsys-protos.h: $(GCC_PASSES) $(srcdir)/sys-protos.h deduced.h gen-protos$(build_
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
| $(RUN_GEN) ./gen-protos >xsys-protos.hT
mv xsys-protos.hT xsys-protos.h
rm -rf fixtmp.c

View File

@ -279,44 +279,6 @@
/* Define to enable the use of a default assembler. */
#undef DEFAULT_ASSEMBLER
/* Define if you want more run-time sanity checks. This one gets a grab
bag of miscellaneous but relatively cheap checks. */
#undef ENABLE_CHECKING
/* Define if you want all operations on trees (the basic data
structure of the front ends) to be checked for dynamic type safety
at runtime. This is moderately expensive. */
#undef ENABLE_TREE_CHECKING
/* Define if you want all operations on RTL (the basic data structure
of the optimizer and back end) to be checked for dynamic type safety
at runtime. This is quite expensive. */
#undef ENABLE_RTL_CHECKING
/* Define if you want RTL flag accesses to be checked against the RTL
codes that are supported for each access macro. This is relatively
cheap. */
#undef ENABLE_RTL_FLAG_CHECKING
/* Define if you want the garbage collector to do object poisoning and
other memory allocation checks. This is quite expensive. */
#undef ENABLE_GC_CHECKING
/* Define if you want the garbage collector to operate in maximally
paranoid mode, validating the entire heap and collecting garbage at
every opportunity. This is extremely expensive. */
#undef ENABLE_GC_ALWAYS_COLLECT
/* Define if you want to use __cxa_atexit, rather than atexit, to
register C++ destructors for local statics and global objects.
This is essential for fully standards-compliant handling of
destructors, but requires __cxa_atexit in libc. */
#undef DEFAULT_USE_CXA_ATEXIT
/* Define if you want the C and C++ compilers to support multibyte
character sets for source code. */
#undef MULTIBYTE_CHARS
/* Define if your compiler understands volatile. */
#undef HAVE_VOLATILE
@ -350,6 +312,48 @@
/* Define if the host execution character set is EBCDIC. */
#undef HOST_EBCDIC
/* Define if you want more run-time sanity checks. This one gets a grab
bag of miscellaneous but relatively cheap checks. */
#undef ENABLE_CHECKING
/* Define if you want all operations on trees (the basic data
structure of the front ends) to be checked for dynamic type safety
at runtime. This is moderately expensive. */
#undef ENABLE_TREE_CHECKING
/* Define if you want all operations on RTL (the basic data structure
of the optimizer and back end) to be checked for dynamic type safety
at runtime. This is quite expensive. */
#undef ENABLE_RTL_CHECKING
/* Define if you want RTL flag accesses to be checked against the RTL
codes that are supported for each access macro. This is relatively
cheap. */
#undef ENABLE_RTL_FLAG_CHECKING
/* Define if you want the garbage collector to do object poisoning and
other memory allocation checks. This is quite expensive. */
#undef ENABLE_GC_CHECKING
/* Define if you want the garbage collector to operate in maximally
paranoid mode, validating the entire heap and collecting garbage at
every opportunity. This is extremely expensive. */
#undef ENABLE_GC_ALWAYS_COLLECT
/* Define if you want to run subprograms and generated programs
through valgrind (a memory checker). This is extremely expensive. */
#undef ENABLE_VALGRIND_CHECKING
/* Define if you want to use __cxa_atexit, rather than atexit, to
register C++ destructors for local statics and global objects.
This is essential for fully standards-compliant handling of
destructors, but requires __cxa_atexit in libc. */
#undef DEFAULT_USE_CXA_ATEXIT
/* Define if you want the C and C++ compilers to support multibyte
character sets for source code. */
#undef MULTIBYTE_CHARS
/* Always define this when using the GNU C Library */
#undef _GNU_SOURCE

2717
gcc/configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -176,6 +176,82 @@ changequote([, ])dnl
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],
@ -211,6 +287,7 @@ no) ;;
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
@ -256,6 +333,25 @@ if test x$ac_gc_always_collect != x ; then
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,
@ -379,82 +475,6 @@ AC_CANONICAL_SYSTEM
# 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=
case $build in

View File

@ -27,6 +27,12 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "intl.h"
#include "mkdeps.h"
#include "splay-tree.h"
#ifdef ENABLE_VALGRIND_CHECKING
#include <valgrind.h>
#else
/* Avoid #ifdef:s when we can help it. */
#define VALGRIND_DISCARD(x)
#endif
#ifdef HAVE_MMAP_FILE
# include <sys/mman.h>
@ -417,6 +423,11 @@ read_include_file (pfile, inc)
buf = (uchar *) mmap (0, size, PROT_READ, MAP_PRIVATE, inc->fd, 0);
if (buf == (uchar *) -1)
goto perror_fail;
/* 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));
inc->mapped = 1;
}
else
@ -497,7 +508,14 @@ purge_cache (inc)
{
#if MMAP_THRESHOLD
if (inc->mapped)
munmap ((PTR) inc->buffer, inc->st.st_size);
{
/* 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));
munmap ((PTR) inc->buffer, inc->st.st_size);
}
else
#endif
free ((PTR) inc->buffer);

View File

@ -2877,6 +2877,33 @@ execute ()
#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++)