diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /libmudflap/testsuite | |
download | cbb-gcc-4.6.4-upstream.tar.bz2 cbb-gcc-4.6.4-upstream.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig;
imported gcc-4.6.4 source tree from verified upstream tarball.
downloading a git-generated archive based on the 'upstream' tag
should provide you with a source tree that is binary identical
to the one extracted from the above tarball.
if you have obtained the source via the command 'git clone',
however, do note that line-endings of files in your working
directory might differ from line-endings of the respective
files in the upstream repository.
Diffstat (limited to 'libmudflap/testsuite')
128 files changed, 3905 insertions, 0 deletions
diff --git a/libmudflap/testsuite/Makefile.am b/libmudflap/testsuite/Makefile.am new file mode 100644 index 000000000..a2c1e9f4e --- /dev/null +++ b/libmudflap/testsuite/Makefile.am @@ -0,0 +1,11 @@ +## Process this with automake to create Makefile.in + +AUTOMAKE_OPTIONS = foreign dejagnu + +EXPECT = `if [ -f ../../expect/expect ] ; then \ + echo ../../expect/expect ; \ + else echo expect ; fi` + +RUNTEST = `if [ -f ${srcdir}/../../dejagnu/runtest ] ; then \ + echo ${srcdir}/../../dejagnu/runtest ; \ + else echo runtest ; fi` diff --git a/libmudflap/testsuite/Makefile.in b/libmudflap/testsuite/Makefile.in new file mode 100644 index 000000000..73411bdd1 --- /dev/null +++ b/libmudflap/testsuite/Makefile.in @@ -0,0 +1,392 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +subdir = testsuite +DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ + $(srcdir)/mfconfig.exp.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \ + $(top_srcdir)/../config/depstand.m4 \ + $(top_srcdir)/../config/enable.m4 \ + $(top_srcdir)/../config/lead-dot.m4 \ + $(top_srcdir)/../config/multi.m4 \ + $(top_srcdir)/../config/override.m4 \ + $(top_srcdir)/../config/tls.m4 $(top_srcdir)/../ltoptions.m4 \ + $(top_srcdir)/../ltsugar.m4 $(top_srcdir)/../ltversion.m4 \ + $(top_srcdir)/../lt~obsolete.m4 $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/../libtool.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = mfconfig.exp +CONFIG_CLEAN_VPATH_FILES = +SOURCES = +DEJATOOL = $(PACKAGE) +RUNTESTDEFAULTFLAGS = --tool $$tool --srcdir $$srcdir +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MF_HAVE_STDINT_H = @MF_HAVE_STDINT_H@ +MF_HAVE_UINTPTR_T = @MF_HAVE_UINTPTR_T@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +RANLIB = @RANLIB@ +SECTION_FLAGS = @SECTION_FLAGS@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_libmudflapth = @build_libmudflapth@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +enable_shared = @enable_shared@ +enable_static = @enable_static@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +multi_basedir = @multi_basedir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_noncanonical = @target_noncanonical@ +target_os = @target_os@ +target_vendor = @target_vendor@ +toolexecdir = @toolexecdir@ +toolexeclibdir = @toolexeclibdir@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +AUTOMAKE_OPTIONS = foreign dejagnu +EXPECT = `if [ -f ../../expect/expect ] ; then \ + echo ../../expect/expect ; \ + else echo expect ; fi` + +RUNTEST = `if [ -f ${srcdir}/../../dejagnu/runtest ] ; then \ + echo ${srcdir}/../../dejagnu/runtest ; \ + else echo runtest ; fi` + +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign testsuite/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign testsuite/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +mfconfig.exp: $(top_builddir)/config.status $(srcdir)/mfconfig.exp.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + + +check-DEJAGNU: site.exp + srcdir=`$(am__cd) $(srcdir) && pwd`; export srcdir; \ + EXPECT=$(EXPECT); export EXPECT; \ + runtest=$(RUNTEST); \ + if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \ + exit_status=0; l='$(DEJATOOL)'; for tool in $$l; do \ + if $$runtest $(AM_RUNTESTFLAGS) $(RUNTESTDEFAULTFLAGS) $(RUNTESTFLAGS); \ + then :; else exit_status=1; fi; \ + done; \ + else echo "WARNING: could not find \`runtest'" 1>&2; :;\ + fi; \ + exit $$exit_status +site.exp: Makefile + @echo 'Making a new site.exp file...' + @echo '## these variables are automatically generated by make ##' >site.tmp + @echo '# Do not edit here. If you wish to override these values' >>site.tmp + @echo '# edit the last section' >>site.tmp + @echo 'set srcdir $(srcdir)' >>site.tmp + @echo "set objdir `pwd`" >>site.tmp + @echo 'set build_alias "$(build_alias)"' >>site.tmp + @echo 'set build_triplet $(build_triplet)' >>site.tmp + @echo 'set host_alias "$(host_alias)"' >>site.tmp + @echo 'set host_triplet $(host_triplet)' >>site.tmp + @echo 'set target_alias "$(target_alias)"' >>site.tmp + @echo 'set target_triplet $(target_triplet)' >>site.tmp + @echo '## All variables above are generated by configure. Do Not Edit ##' >>site.tmp + @test ! -f site.exp || \ + sed '1,/^## All variables above are.*##/ d' site.exp >> site.tmp + @-rm -f site.bak + @test ! -f site.exp || mv site.exp site.bak + @mv site.tmp site.exp + +distclean-DEJAGNU: + -rm -f site.exp site.bak + -l='$(DEJATOOL)'; for tool in $$l; do \ + rm -f $$tool.sum $$tool.log; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) check-DEJAGNU +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-DEJAGNU distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: check-am install-am install-strip + +.PHONY: all all-am check check-DEJAGNU check-am clean clean-generic \ + clean-libtool distclean distclean-DEJAGNU distclean-generic \ + distclean-libtool dvi dvi-am html html-am info info-am install \ + install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + uninstall uninstall-am + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/libmudflap/testsuite/config/default.exp b/libmudflap/testsuite/config/default.exp new file mode 100644 index 000000000..0dafaa123 --- /dev/null +++ b/libmudflap/testsuite/config/default.exp @@ -0,0 +1,3 @@ +load_lib standard.exp +load_lib libmudflap.exp +load_lib mfconfig.exp diff --git a/libmudflap/testsuite/lib/libmudflap.exp b/libmudflap/testsuite/lib/libmudflap.exp new file mode 100644 index 000000000..a09eb959a --- /dev/null +++ b/libmudflap/testsuite/lib/libmudflap.exp @@ -0,0 +1,306 @@ +# Copyright (C) 2001, 2002, 2003, 2004, 2009, 2010 +# Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING3. If not see +# <http://www.gnu.org/licenses/>. + +# Define libmudflap callbacks for dg.exp. +# This file is a copy of libstdc++-v3's dejagnu driver, with minor changes. + +# Useful hook: if ${hostname}_init exists, it will be called, almost +# the last thing before testing begins. This can be defined in, e.g., +# ~/.dejagnurc or $DEJAGNU. + +proc load_gcc_lib { filename } { + global srcdir + load_file $srcdir/../../gcc/testsuite/lib/$filename +} + +load_lib mfdg.exp +load_lib libgloss.exp +load_gcc_lib target-libpath.exp +load_gcc_lib timeout.exp +load_gcc_lib timeout-dg.exp + +proc libmudflap-init { language } { + global env + global srcdir outdir blddir objdir tool_root_dir + global cxx cxxflags + global includes + global libs + global gluefile wrap_flags + global ld_library_path + + switch $language { + "c" { set cxx [find_gcc] } + "c++" { set cxx [find_g++] } + default { error "bad language code $language"; return } + } + + verbose -log "libmudflap-init $cxx" + + set blddir [lookfor_file [get_multilibs] libmudflap] + set cxxblddir [lookfor_file [get_multilibs] libstdc++-v3] + set cxxflags_file "${cxxblddir}/scripts/testsuite_flags" + + # By default, we assume we want to run program images. + global dg-do-what-default + set dg-do-what-default run + + # set LD_LIBRARY_PATH so that libgcc_s, libstdc++ binaries can be found. + # locate libgcc.a so we don't need to account for different values of + # SHLIB_EXT on different platforms + set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a] + if {$gccdir != ""} { + set gccdir [file dirname $gccdir] + } + + set ld_library_path "." + append ld_library_path ":${gccdir}" + append ld_library_path ":${cxxblddir}/src/.libs" + if {[is_remote host] == 0} { + foreach i "[exec ${gccdir}/xgcc --print-multi-lib]" { + set mldir "" + regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir + set mldir [string trimright $mldir "\;@"] + if { "$mldir" == "." } { + continue + } + if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } { + append ld_library_path ":${gccdir}/${mldir}" + } + } + } + append ld_library_path ":${blddir}/.libs" + + set libs "-L${blddir}/.libs" + set cxxflags "-ggdb3 -DDEBUG_ASSERT" + set includes "-I${srcdir} -I${srcdir}/.. -I.." + + if {$language == "c++"} { + if {[file exists $cxxflags_file]} then { + set includes "${includes} [exec sh $cxxflags_file --build-includes]" + set cxxflags "${cxxflags} [exec sh $cxxflags_file --cxxflags]" + # c++ libs are included by --build-cxx below + set cxx "[exec sh $cxxflags_file --build-cxx]" + } else { + lappend libs "-L${cxxblddir}src/.libs" + lappend includes "-I../../libstdc++-v3/include" + } + } + + global mfconfig_libs + global add_flags + append add_flags " $mfconfig_libs" + + set_ld_library_path_env_vars + if [info exists env(LD_LIBRARY_PATH)] { + verbose -log "LD_LIBRARY_PATH = $env(LD_LIBRARY_PATH)" + } + + if { [target_info needs_status_wrapper]!=""} { + file delete ${objdir}/testglue.o; + set gluefile ${objdir}/testglue.o; + set result [build_wrapper $gluefile]; + if { $result != "" } { + set gluefile [lindex $result 0]; + set wrap_flags [lindex $result 1]; + } else { + unset gluefile + } + } + + # If there is no static library then don't run tests with -static. + global tool + set opts "additional_flags=-static" + lappend opts "additional_flags=-fmudflap" + lappend opts "additional_flags=-lmudflap" + set src stlm[pid].c + set exe stlm[pid].x + + set f [open $src "w"] + puts $f "int main () { }" + close $f + set lines [${tool}_target_compile $src $exe executable "$opts"] + file delete $src + remote_file build delete $exe + + if { ![string match "" $lines] } { + # Compilation failed; assume static library is not available. + global MUDFLAP_FLAGS + set i [lsearch $MUDFLAP_FLAGS "*static*"] + set MUDFLAP_FLAGS [lreplace $MUDFLAP_FLAGS $i $i] + } +} + +proc libmudflap-dg-test { prog do_what extra_tool_flags } { + # Set up the compiler flags, based on what we're going to do. + + switch $do_what { + "preprocess" { + set compile_type "preprocess" + set output_file "[file rootname [file tail $prog]].i" + } + "compile" { + set compile_type "assembly" + set output_file "[file rootname [file tail $prog]].s" + } + "assemble" { + set compile_type "object" + set output_file "[file rootname [file tail $prog]].o" + } + "link" { + set compile_type "executable" + set output_file "./[file rootname [file tail $prog]].exe" + } + "run" { + set compile_type "executable" + # FIXME: "./" is to cope with "." not being in $PATH. + # Should this be handled elsewhere? + # YES. + set output_file "./[file rootname [file tail $prog]].exe" + # This is the only place where we care if an executable was + # created or not. If it was, dg.exp will try to run it. + remote_file build delete $output_file; + } + default { + perror "$do_what: not a valid dg-do keyword" + return "" + } + } + set options "" + if { $extra_tool_flags != "" } { + lappend options "additional_flags=$extra_tool_flags" + } + + global mfconfig_libs + lappend options "libs=$mfconfig_libs" + + set comp_output [libmudflap_target_compile "$prog" "$output_file" "$compile_type" $options]; + + return [list $comp_output $output_file] +} + + +proc libmudflap_target_compile { source dest type options } { + global gluefile + global wrap_flags + global cxx + global cxxflags + global includes + global libs + global blddir + + if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } { + lappend options "libs=${gluefile}" + lappend options "ldflags=${wrap_flags}" + } + + set cxx_final $cxx + set cxxlibglossflags [libgloss_link_flags] + set cxx_final [concat $cxx_final $cxxlibglossflags] + set cxx_final [concat $cxx_final $cxxflags] + set cxx_final [concat $cxx_final $includes] + set cxx_final [concat $cxx_final $libs] + + lappend options "compiler=$cxx_final" + lappend options "timeout=[timeout_value]" + + # Picks up the freshly-built testsuite library corresponding to the + # multilib under test. + lappend options "ldflags=-L${blddir}/testsuite" + + return [target_compile $source $dest $type $options] +} + + +# A bit sloppy... Returns a list of source files (full pathnames) to +# compile. We mimic the mkcheck script in that the first time this is run, +# all existing files are listed in "testsuite_files" in the output +# directory. Subsequent runs pull the list from that file, allowing users +# to trim the list down to problematic tests. +### This is supposed to be done via RUNTESTFLAGS, but that doesn't work. +proc libmudflap-list-sourcefiles { } { + global srcdir + global outdir + + set files_file "${outdir}/testsuite_files" + set sfiles "" + if { [file exists $files_file] } { + set f [open $files_file] + while { ! [eof $f] } { + set t [gets $f] + if { [string length "$t"] != 0 } { + lappend sfiles ${srcdir}/${t} + } + } + } else { + set f [open $files_file "w"] + set where_we_were [pwd] + cd $srcdir + foreach s [lsort [glob -nocomplain "*/*.cc" "*/*/*.cc" "{,*/}*/*/*/*.cc" ]] { + lappend sfiles ${srcdir}/${s} + puts $f $s + } + cd $where_we_were + } + close $f + + # Disable wchar_t tests if library not configured to support + # wchar_t testing. + set wchar_file "${outdir}/testsuite_wchar_t" + if { [file exists $wchar_file] } { + return $sfiles + } else { + # Remove wchar_t tests files from list. + set res {} + foreach w $sfiles { + if [regexp "wchar_t" $w] { + verbose -log "element out list is $w" + } else { + verbose -log "element in list is $w" + lappend res $w + } + } + return $res + } +} + + +proc libmudflap-dg-prune { system text } { + global additional_prunes + + set text [prune_gcc_output $text] + + foreach p $additional_prunes { + if { [string length $p] > 0 } { + # Following regexp matches a complete line containing $p. + regsub -all "(^|\n)\[^\n\]*$p\[^\n\]*" $text "" text + } + } + + return $text +} + + +proc prune_gcc_output { text } { + regsub -all {(^|\n)[^\n]*ld: warning: libgcc_s[^\n]*not found[^\n]*try using[^\n]*} $text "" text + regsub -all {(^|\n)[^\n]*In function.*pthread_create[^\n]*} $text "" text + regsub -all {(^|\n)[^\n]*the use of .pthread.*is deprecated[^\n]*} $text "" text + regsub -all {(^|\n)[^\n]*Dwarf Error:.*FORM value: 14[^\n]*} $text "" text + regsub -all {(^|\n)[^\n]*In function[^\n]*} $text "" text + regsub -all {(^|\n)[^\n]*Using.*in statically linked applications requires[^\n]*} $text "" text + + return $text +} diff --git a/libmudflap/testsuite/lib/mfdg.exp b/libmudflap/testsuite/lib/mfdg.exp new file mode 100644 index 000000000..9e340c0bd --- /dev/null +++ b/libmudflap/testsuite/lib/mfdg.exp @@ -0,0 +1,365 @@ +# `mfdg' - overrides parts of general purpose testcase driver. +# Copyright (C) 1994 - 2001, 2003, 2009, 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING3. If not see +# <http://www.gnu.org/licenses/>. + + +# This is a modified excerpt of dejagnu/lib/dg.exp. + +load_lib dg.exp + + +# dg-test -- runs a new style DejaGnu test +# +# Syntax: dg-test [-keep-output] prog tool_flags default_extra_tool_flags +# +# PROG is the full path name of the file to pass to the tool (eg: compiler). +# TOOL_FLAGS is a set of options to always pass. +# DEFAULT_EXTRA_TOOL_FLAGS are additional options if the testcase has none. + +#proc dg-test { prog tool_flags default_extra_tool_flags } { +proc dg-test { args } { + global dg-do-what-default dg-interpreter-batch-mode dg-linenum-format + global errorCode errorInfo + global additional_prunes + global tool + global srcdir ;# eg: /calvin/dje/build/gcc/./testsuite/ + global host_triplet target_triplet + + set keep 0 + set i 0 + set dg-repetitions 1 ;# may be overridden by { dg-repetitions N } + unset_timeout_vars + + if { [string index [lindex $args 0] 0] == "-" } { + for { set i 0 } { $i < [llength $args] } { incr i } { + if { [lindex $args $i] == "--" } { + incr i + break + } elseif { [lindex $args $i] == "-keep-output" } { + set keep 1 + } elseif { [string index [lindex $args $i] 0] == "-" } { + clone_output "ERROR: dg-test: illegal argument: [lindex $args $i]" + return + } else { + break + } + } + } + + if { $i + 3 != [llength $args] } { + clone_output "ERROR: dg-test: missing arguments in call" + return + } + set prog [lindex $args $i] + set tool_flags [lindex $args [expr $i + 1]] + set default_extra_tool_flags [lindex $args [expr $i + 2]] + + set text "\[- A-Za-z0-9\.\;\"\_\:\'\`\(\)\!\#\=\+\?\&\*]*" + + set name [dg-trim-dirname $srcdir $prog] + # If we couldn't rip $srcdir out of `prog' then just do the best we can. + # The point is to reduce the unnecessary noise in the logs. Don't strip + # out too much because different testcases with the same name can confuse + # `test-tool'. + if [string match "/*" $name] { + set name "[file tail [file dirname $prog]]/[file tail $prog]" + } + + if {$tool_flags != ""} { + append name " ($tool_flags)" + } + + # Process any embedded dg options in the testcase. + + # Use "" for the second element of dg-do-what so we can tell if it's been + # explicitly set to "S". + set dg-do-what [list ${dg-do-what-default} "" P] + set dg-excess-errors-flag 0 + set dg-messages "" + set dg-extra-tool-flags $default_extra_tool_flags + set dg-final-code "" + + set additional_prunes "" + + # `dg-output-text' is a list of two elements: pass/fail and text. + # Leave second element off for now (indicates "don't perform test") + set dg-output-text "P" + + # Define our own "special function" `unknown' so we catch spelling errors. + # But first rename the existing one so we can restore it afterwards. + catch {rename dg-save-unknown ""} + rename unknown dg-save-unknown + proc unknown { args } { + return -code error "unknown dg option: $args" + } + + set tmp [dg-get-options $prog] + foreach op $tmp { + verbose "Processing option: $op" 3 + set status [catch "$op" errmsg] + if { $status != 0 } { + if { 0 && [info exists errorInfo] } { + # This also prints a backtrace which will just confuse + # testcase writers, so it's disabled. + perror "$name: $errorInfo\n" + } else { + perror "$name: $errmsg for \"$op\"\n" + } + # ??? The call to unresolved here is necessary to clear `errcnt'. + # What we really need is a proc like perror that doesn't set errcnt. + # It should also set exit_status to 1. + unresolved "$name: $errmsg for \"$op\"" + return + } + } + + # Restore normal error handling. + rename unknown "" + rename dg-save-unknown unknown + + # If we're not supposed to try this test on this target, we're done. + if { [lindex ${dg-do-what} 1] == "N" } { + unsupported "$name" + verbose "$name not supported on this target, skipping it" 3 + return + } + + # Run the tool and analyze the results. + # The result of ${tool}-dg-test is in a bit of flux. + # Currently it is the name of the output file (or "" if none). + # If we need more than this it will grow into a list of things. + # No intention is made (at this point) to preserve upward compatibility + # (though at some point we'll have to). + + set results [${tool}-dg-test $prog [lindex ${dg-do-what} 0] "$tool_flags ${dg-extra-tool-flags}"]; + + set comp_output [lindex $results 0]; + set output_file [lindex $results 1]; + + #send_user "\nold_dejagnu.exp: comp_output1 = :$comp_output:\n\n" + #send_user "\nold_dejagnu.exp: message = :$message:\n\n" + #send_user "\nold_dejagnu.exp: message length = [llength $message]\n\n" + + foreach i ${dg-messages} { + verbose "Scanning for message: $i" 4 + + # Remove all error messages for the line [lindex $i 0] + # in the source file. If we find any, success! + set line [lindex $i 0] + set pattern [lindex $i 2] + set comment [lindex $i 3] + #send_user "Before:\n$comp_output\n" + if [regsub -all "(^|\n)(\[^\n\]+$line\[^\n\]*($pattern)\[^\n\]*\n?)+" $comp_output "\n" comp_output] { + set comp_output [string trimleft $comp_output] + set ok pass + set uhoh fail + } else { + set ok fail + set uhoh pass + } + #send_user "After:\n$comp_output\n" + + # $line will either be a formatted line number or a number all by + # itself. Delete the formatting. + scan $line ${dg-linenum-format} line + switch [lindex $i 1] { + "ERROR" { + $ok "$name $comment (test for errors, line $line)" + } + "XERROR" { + x$ok "$name $comment (test for errors, line $line)" + } + "WARNING" { + $ok "$name $comment (test for warnings, line $line)" + } + "XWARNING" { + x$ok "$name $comment (test for warnings, line $line)" + } + "BOGUS" { + $uhoh "$name $comment (test for bogus messages, line $line)" + } + "XBOGUS" { + x$uhoh "$name $comment (test for bogus messages, line $line)" + } + "BUILD" { + $uhoh "$name $comment (test for build failure, line $line)" + } + "XBUILD" { + x$uhoh "$name $comment (test for build failure, line $line)" + } + "EXEC" { } + "XEXEC" { } + } + #send_user "\nold_dejagnu.exp: comp_output2= :$comp_output:\n\n" + } + #send_user "\nold_dejagnu.exp: comp_output3 = :$comp_output:\n\n" + + # Remove messages from the tool that we can ignore. + #send_user "comp_output: $comp_output\n" + set comp_output [prune_warnings $comp_output] + + if { [info proc ${tool}-dg-prune] != "" } { + set comp_output [${tool}-dg-prune $target_triplet $comp_output] + switch -glob $comp_output { + "::untested::*" { + regsub "::untested::" $comp_output "" message + untested "$name: $message" + return + } + "::unresolved::*" { + regsub "::unresolved::" $comp_output "" message + unresolved "$name: $message" + return + } + "::unsupported::*" { + regsub "::unsupported::" $comp_output "" message + unsupported "$name: $message" + return + } + } + } + + # See if someone forgot to delete the extra lines. + regsub -all "\n+" $comp_output "\n" comp_output + regsub "^\n+" $comp_output "" comp_output + #send_user "comp_output: $comp_output\n" + + # Don't do this if we're testing an interpreter. + # FIXME: why? + if { ${dg-interpreter-batch-mode} == 0 } { + # Catch excess errors (new bugs or incomplete testcases). + if ${dg-excess-errors-flag} { + setup_xfail "*-*-*" + } + if ![string match "" $comp_output] { + fail "$name (test for excess errors)" + send_log "Excess errors:\n$comp_output\n" + } else { + pass "$name (test for excess errors)" + } + } + + # Run the executable image if asked to do so. + # FIXME: This is the only place where we assume a standard meaning to + # the `keyword' argument of dg-do. This could be cleaned up. + if { [lindex ${dg-do-what} 0] == "run" } { + if ![file exists $output_file] { + warning "$name compilation failed to produce executable" + } else { + set testname $name + for {set rep 0} {$rep < ${dg-repetitions}} {incr rep} { + # include repetition number in test name + if {$rep > 0} { set name "$testname (rerun $rep)" } + + set status -1 + set result [${tool}_load $output_file] + set status [lindex $result 0]; + set output [lindex $result 1]; + #send_user "After exec, status: $status\n" + + if { "$status" == "pass" } { + verbose "Exec succeeded." 3 + } elseif { "$status" == "fail" } { + # It would be nice to get some info out of errorCode. + if [info exists errorCode] { + verbose "Exec failed, errorCode: $errorCode" 3 + } else { + verbose "Exec failed, errorCode not defined!" 3 + } + } + + if { [lindex ${dg-do-what} 2] == "F" } { + # Instead of modelling this as an xfail (via setup_xfail), + # treat an expected crash as a success. + if { $status == "pass" } then { set status fail } else { set status pass } + set testtype "crash" + } else { set testtype "execution" } + + $status "$name $testtype test" + + if { [llength ${dg-output-text}] > 1 } { + #send_user "${dg-output-text}\n" + if { [lindex ${dg-output-text} 0] == "F" } { + setup_xfail "*-*-*" + } + set texttmp [lindex ${dg-output-text} 1] + if { ![regexp $texttmp ${output}] } { + fail "$name output pattern test" + } else { + pass "$name output pattern test" + } + verbose -log "Output pattern $texttmp" + unset texttmp + } + } + } + } + + # Are there any further tests to perform? + # Note that if the program has special run-time requirements, running + # of the program can be delayed until here. Ditto for other situations. + # It would be a bit cumbersome though. + + if ![string match ${dg-final-code} ""] { + regsub -all "\\\\(\[{}\])" ${dg-final-code} "\\1" dg-final-code + # Note that the use of `args' here makes this a varargs proc. + proc dg-final-proc { args } ${dg-final-code} + verbose "Running dg-final tests." 3 + verbose "dg-final-proc:\n[info body dg-final-proc]" 4 + if [catch "dg-final-proc $prog" errmsg] { + perror "$name: error executing dg-final: $errmsg" + # ??? The call to unresolved here is necessary to clear `errcnt'. + # What we really need is a proc like perror that doesn't set errcnt. + # It should also set exit_status to 1. + unresolved "$name: error executing dg-final: $errmsg" + } + } + + # Do some final clean up. + # When testing an interpreter, we don't compile something and leave an + # output file. + if { ! ${keep} && ${dg-interpreter-batch-mode} == 0 } { + catch "exec rm -f $output_file" + } +} + + +# +# Indicate that this test case is to be rerun several times. This +# is useful if it is nondeterministic. This applies to rerunning the +# test program only, not rebuilding it. +# The embedded format is "{ dg-repetitions N }", where N is the number +# of repetitions. It better be greater than zero. +# +proc dg-repetitions { line value } { + upvar dg-repetitions repetitions + set repetitions $value +} + + +# Prune any messages matching ARGS[1] (a regexp) from test output. +proc dg-prune-output { args } { + global additional_prunes + + if { [llength $args] != 2 } { + error "[lindex $args 1]: need one argument" + return + } + + lappend additional_prunes [lindex $args 1] +} + +set additional_prunes "" diff --git a/libmudflap/testsuite/libmudflap.c++/c++frags.exp b/libmudflap/testsuite/libmudflap.c++/c++frags.exp new file mode 100644 index 000000000..eb900d799 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c++/c++frags.exp @@ -0,0 +1,22 @@ +global MUDFLAP_FLAGS +set MUDFLAP_FLAGS [list {} {-static} { -O} {-O2} {-O3}] + +libmudflap-init c++ +if {$cxx == "g++"} then { + unsupported "g++ not found" + return +} + +dg-init + +global srcdir + +foreach flags $MUDFLAP_FLAGS { + foreach srcfile [lsort [glob -nocomplain ${srcdir}/libmudflap.c++/*frag.cxx]] { + set bsrc [file tail $srcfile] + setenv MUDFLAP_OPTIONS "-viol-segv" + dg-runtest $srcfile $flags "-fmudflap -lmudflap" + } +} + +dg-finish diff --git a/libmudflap/testsuite/libmudflap.c++/ctors-1.cxx b/libmudflap/testsuite/libmudflap.c++/ctors-1.cxx new file mode 100644 index 000000000..7717c805c --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c++/ctors-1.cxx @@ -0,0 +1,20 @@ +#include <iostream> + + +extern char k []; + +class foo +{ + public: + foo (char *m) { m [40] = 20; } +}; + + +foo f1 (k); +foo f2 (k); +foo f3 (k); + +int main () +{ + return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c++/ctors-2.cxx b/libmudflap/testsuite/libmudflap.c++/ctors-2.cxx new file mode 100644 index 000000000..c1a501979 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c++/ctors-2.cxx @@ -0,0 +1 @@ +char k [500]; diff --git a/libmudflap/testsuite/libmudflap.c++/ctors.exp b/libmudflap/testsuite/libmudflap.c++/ctors.exp new file mode 100644 index 000000000..b3dda8fd6 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c++/ctors.exp @@ -0,0 +1,48 @@ +global MUDFLAP_FLAGS +set MUDFLAP_FLAGS [list {} {-static} {-O2} {-O3}] + +libmudflap-init c++ +if {$cxx == "g++"} then { + unsupported "g++ not found" + return +} + +dg-init + +global srcdir subdir + +foreach flags $MUDFLAP_FLAGS { + set l1 [libmudflap_target_compile "$srcdir/$subdir/ctors-1.cxx" "ctors-1.o" object {additional_flags=-fmudflap}] + set test "ctors-1 compilation ${flags}" + if [string match "*mudflap cannot track unknown size extern *k*" $l1] { pass $test } { fail $test } + + set l2 [libmudflap_target_compile "$srcdir/$subdir/ctors-2.cxx" "ctors-2.o" object {additional_flags=-fmudflap}] + set test "ctors-2 compilation ${flags}" + if [string match "" $l2] { pass $test } { fail $test } + + set l3 [libmudflap_target_compile "ctors-1.o ctors-2.o" "ctors-12.exe" executable {additional_flags=-fmudflap additional_flags=-lmudflap additional_flags=-lstdc++}] + set test "ctors-12 linkage ${flags}" + if [string match "" $l3] { pass $test } { fail $test } + + set l4 [libmudflap_target_compile "ctors-2.o ctors-1.o" "ctors-21.exe" executable {additional_flags=-fmudflap additional_flags=-lmudflap additional_flags=-lstdc++}] + set test "ctors-21 linkage ${flags}" + if [string match "" $l3] { pass $test } { fail $test } + + setenv MUDFLAP_OPTIONS "-viol-segv" + + remote_spawn host "./ctors-12.exe" + set l5 [remote_wait host 10] + set test "ctors-12 execution ${flags}" + if {[lindex $l5 0] == 0} { pass $test } { fail $test } + + remote_spawn host "./ctors-21.exe" + set l6 [remote_wait host 10] + set test "ctors-21 execution ${flags}" + if {[lindex $l6 0] == 0} { pass $test } { fail $test } + + foreach f [glob -nocomplain "ctors-*"] { + remote_file build delete $f + } +} + +dg-finish diff --git a/libmudflap/testsuite/libmudflap.c++/error1-frag.cxx b/libmudflap/testsuite/libmudflap.c++/error1-frag.cxx new file mode 100644 index 000000000..8bfe85328 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c++/error1-frag.cxx @@ -0,0 +1,5 @@ +// PR 26789 +// { dg-do compile } + +struct A; +A a; // { dg-error "incomplete" } diff --git a/libmudflap/testsuite/libmudflap.c++/error2-frag.cxx b/libmudflap/testsuite/libmudflap.c++/error2-frag.cxx new file mode 100644 index 000000000..0e89e117f --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c++/error2-frag.cxx @@ -0,0 +1,10 @@ +// PR 26790 +// { dg-do compile } + +struct A; + +A foo() // { dg-error "incomplete" } +{ + A a; // { dg-error "incomplete" } + return a; +} diff --git a/libmudflap/testsuite/libmudflap.c++/fail24-frag.cxx b/libmudflap/testsuite/libmudflap.c++/fail24-frag.cxx new file mode 100644 index 000000000..e3467ddaf --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c++/fail24-frag.cxx @@ -0,0 +1,16 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +char zoo [10]; + +int main () +{ +int i = strlen ("twelve") + strlen ("zero") + strlen ("seventeen"); +zoo[i] = 'a'; +return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object.*" } */ +/* { dg-output "mudflap object.*zoo.*static.*" } */ +/* { dg-do run { xfail *-*-* } } */ diff --git a/libmudflap/testsuite/libmudflap.c++/pass27-frag.cxx b/libmudflap/testsuite/libmudflap.c++/pass27-frag.cxx new file mode 100644 index 000000000..aca2ea3a3 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c++/pass27-frag.cxx @@ -0,0 +1,12 @@ +class foo { + char z [10]; +public: + char *get_z () { return & this->z[0]; } +}; + +int main () +{ +foo x; +x.get_z()[9] = 'a'; +return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c++/pass28-frag.cxx b/libmudflap/testsuite/libmudflap.c++/pass28-frag.cxx new file mode 100644 index 000000000..75e14ba14 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c++/pass28-frag.cxx @@ -0,0 +1,20 @@ +class foo { + char z [10]; +public: + virtual char *get_z () { return & this->z[0]; } +}; + +class bar: public foo { + char q [20]; +public: + char *get_z () { return & this->q[0]; } +}; + +int main () { +foo *x = new bar (); + +x->get_z()[9] = 'a'; + +delete x; +return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c++/pass31-frag.cxx b/libmudflap/testsuite/libmudflap.c++/pass31-frag.cxx new file mode 100644 index 000000000..6c4b9f9a7 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c++/pass31-frag.cxx @@ -0,0 +1,12 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +char zoo [10]; + +int main () +{ +int i = strlen ("eight") + strlen ("one"); +zoo[i] = 'a'; +return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c++/pass41-frag.cxx b/libmudflap/testsuite/libmudflap.c++/pass41-frag.cxx new file mode 100644 index 000000000..06896c7f6 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c++/pass41-frag.cxx @@ -0,0 +1,13 @@ +#include <string> +#include <iostream> + +int +main (int argc, char *argv[]) +{ + std::string myStr = "Hello, World!"; + std::cout << myStr << std::endl; + return 0; +} + +/* Ignore a warning that is irrelevant to the purpose of this test. */ +/* { dg-prune-output ".*mudflap cannot track unknown size extern.*" } */ diff --git a/libmudflap/testsuite/libmudflap.c++/pass55-frag.cxx b/libmudflap/testsuite/libmudflap.c++/pass55-frag.cxx new file mode 100644 index 000000000..e83c12461 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c++/pass55-frag.cxx @@ -0,0 +1,7 @@ +#include <vector> + +int main() { + std::vector<int> v; + v.push_back(1); + return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c++/pass57-frag.cxx b/libmudflap/testsuite/libmudflap.c++/pass57-frag.cxx new file mode 100644 index 000000000..8be1a2d11 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c++/pass57-frag.cxx @@ -0,0 +1,28 @@ +#include <vector> +#include <string> + +class fitscolumn + { + private: + std::string name_, unit_; + int i, t; + public: + fitscolumn (const std::string &nm, const std::string &un,int i1,int t1) + : name_(nm), unit_(un), i(i1), t(t1){} + }; + +void init_bintab(std::vector<fitscolumn> & columns_) +{ + char ttype[81], tunit[81], tform[81]; + long repc; + int typecode; + columns_.push_back (fitscolumn (ttype,tunit,1,typecode)); +} + +int main () +{ + return 0; +} + +/* Ignore a warning that is irrelevant to the purpose of this test. */ +/* { dg-prune-output ".*mudflap cannot track unknown size extern.*" } */ diff --git a/libmudflap/testsuite/libmudflap.c++/pass58-frag.cxx b/libmudflap/testsuite/libmudflap.c++/pass58-frag.cxx new file mode 100644 index 000000000..96da05fca --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c++/pass58-frag.cxx @@ -0,0 +1,12 @@ +// PR 19319 +struct k { + int data; + k(int j): data(j) {} +}; +k make_k () { return k(1); } + +int main () +{ + k foo = make_k (); + return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c++/pass60-frag.cxx b/libmudflap/testsuite/libmudflap.c++/pass60-frag.cxx new file mode 100644 index 000000000..35989d122 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c++/pass60-frag.cxx @@ -0,0 +1,13 @@ +// PR 26442 + +struct A +{ + A(); +}; + +int main() +{ + if (0) + A(); + return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c++/pass61-frag.cxx b/libmudflap/testsuite/libmudflap.c++/pass61-frag.cxx new file mode 100644 index 000000000..03046112c --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c++/pass61-frag.cxx @@ -0,0 +1,20 @@ +// PR c++/34619 +// { dg-do compile } + +template <typename> struct A +{ + typedef int X; + static const int N = 1; +}; + +template <typename T> struct B +{ + typedef typename A <int [A <T>::N]>::X Y; + template <typename U> B (Y, U) {} +}; + +int main () +{ +} + +B <int>b (0, 0); diff --git a/libmudflap/testsuite/libmudflap.c++/pass66-frag.cxx b/libmudflap/testsuite/libmudflap.c++/pass66-frag.cxx new file mode 100644 index 000000000..989c7ca6f --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c++/pass66-frag.cxx @@ -0,0 +1,17 @@ +// PR c++/37568 +// { dg-do compile } +// { dg-options "-fmudflap -O" } + +struct A +{ + int i; +}; + +A +foo () +{ + A a = { 1 }; + return a; +} + +A a = foo (); diff --git a/libmudflap/testsuite/libmudflap.c/cfrags.exp b/libmudflap/testsuite/libmudflap.c/cfrags.exp new file mode 100644 index 000000000..bdaf2196c --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/cfrags.exp @@ -0,0 +1,21 @@ +global MUDFLAP_FLAGS +set MUDFLAP_FLAGS [list {} {-static} {-O2} {-O3}] + +libmudflap-init c + +dg-init + +global srcdir +foreach flags $MUDFLAP_FLAGS { + foreach srcfile [lsort [glob -nocomplain \ + ${srcdir}/libmudflap.c/*frag.c \ + ${srcdir}/libmudflap.c/heap*.c \ + ${srcdir}/libmudflap.c/hook*.c \ + ${srcdir}/libmudflap.c/pass*.c]] { + set bsrc [file tail $srcfile] + setenv MUDFLAP_OPTIONS "-viol-segv" + dg-runtest $srcfile $flags "-fmudflap -lmudflap" + } +} + +dg-finish diff --git a/libmudflap/testsuite/libmudflap.c/externs-1.c b/libmudflap/testsuite/libmudflap.c/externs-1.c new file mode 100644 index 000000000..028f5eb5a --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/externs-1.c @@ -0,0 +1,16 @@ +typedef struct { char *name; } dummy; +extern dummy d[]; + +int +main (void) +{ + dummy *pd = d; + + while (pd->name) + { + printf ("%s\n", pd->name); + pd++; + } + + return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c/externs-2.c b/libmudflap/testsuite/libmudflap.c/externs-2.c new file mode 100644 index 000000000..cecf6253a --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/externs-2.c @@ -0,0 +1,2 @@ +typedef struct { char *name; } dummy; +dummy d[] = { {"a"}, {0} }; diff --git a/libmudflap/testsuite/libmudflap.c/externs.exp b/libmudflap/testsuite/libmudflap.c/externs.exp new file mode 100644 index 000000000..773f80cc1 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/externs.exp @@ -0,0 +1,43 @@ +global MUDFLAP_FLAGS +set MUDFLAP_FLAGS [list {} {-static} {-O2} {-O3}] + +libmudflap-init c +dg-init + +global srcdir subdir + +foreach flags $MUDFLAP_FLAGS { + set l1 [libmudflap_target_compile "$srcdir/$subdir/externs-1.c" "externs-1.o" object {additional_flags=-fmudflap}] + set test "externs-1 compilation ${flags}" + if [string match "*mudflap cannot track unknown size extern *d*" $l1] { pass $test } { fail $test } + + set l2 [libmudflap_target_compile "$srcdir/$subdir/externs-2.c" "externs-2.o" object {additional_flags=-fmudflap}] + set test "externs-2 compilation ${flags}" + if [string match "" $l2] { pass $test } { fail $test } + + set l3 [libmudflap_target_compile "externs-1.o externs-2.o" "externs-12.exe" executable {additional_flags=-fmudflap additional_flags=-lmudflap}] + set test "externs-12 linkage ${flags}" + if [string match "" $l3] { pass $test } { fail $test } + + set l4 [libmudflap_target_compile "externs-2.o externs-1.o" "externs-21.exe" executable {additional_flags=-fmudflap additional_flags=-lmudflap}] + set test "externs-21 linkage ${flags}" + if [string match "" $l3] { pass $test } { fail $test } + + setenv MUDFLAP_OPTIONS "-viol-segv" + + remote_spawn host "./externs-12.exe" + set l5 [remote_wait host 10] + set test "externs-12 execution ${flags}" + if {[lindex $l5 0] == 0} { pass $test } { fail $test } + + remote_spawn host "./externs-21.exe" + set l6 [remote_wait host 10] + set test "externs-21 execution ${flags}" + if {[lindex $l6 0] == 0} { pass $test } { fail $test } + + foreach f [glob -nocomplain "externs-*"] { + remote_file build delete $f + } +} + +dg-finish diff --git a/libmudflap/testsuite/libmudflap.c/fail1-frag.c b/libmudflap/testsuite/libmudflap.c/fail1-frag.c new file mode 100644 index 000000000..1e48fff87 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/fail1-frag.c @@ -0,0 +1,13 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ +volatile int foo [10]; +foo[10] = 0; +return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap object.*.main. foo.*" } */ +/* { dg-do run { xfail *-*-* } } */ diff --git a/libmudflap/testsuite/libmudflap.c/fail10-frag.c b/libmudflap/testsuite/libmudflap.c/fail10-frag.c new file mode 100644 index 000000000..db135d5c4 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/fail10-frag.c @@ -0,0 +1,16 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ +volatile int foo[10]; +int sz = sizeof (int); + +volatile char *bar = (char *)foo; +bar [sz * 10] = 0; +return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap object.*.main. foo.*" } */ +/* { dg-do run { xfail *-*-* } } */ diff --git a/libmudflap/testsuite/libmudflap.c/fail11-frag.c b/libmudflap/testsuite/libmudflap.c/fail11-frag.c new file mode 100644 index 000000000..ebd1db967 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/fail11-frag.c @@ -0,0 +1,20 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +char *y; +int main () +{ +int i = 10; +char *x = (char *) malloc (i * sizeof (char)); +y = x; +while (i--) +{ + ++x; + *x = 0; +} +return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap object.*malloc region.*" } */ +/* { dg-do run { xfail *-*-* } } */ diff --git a/libmudflap/testsuite/libmudflap.c/fail12-frag.c b/libmudflap/testsuite/libmudflap.c/fail12-frag.c new file mode 100644 index 000000000..46dbdb236 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/fail12-frag.c @@ -0,0 +1,20 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int *y; +int main () +{ +int i = 10; +int *x = (int *) malloc (i * sizeof (int)); +y = x; +while (i--) +{ + ++x; + *x = 0; +} +return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap object.*malloc region.*" } */ +/* { dg-do run { xfail *-*-* } } */ diff --git a/libmudflap/testsuite/libmudflap.c/fail13-frag.c b/libmudflap/testsuite/libmudflap.c/fail13-frag.c new file mode 100644 index 000000000..9fd3e2557 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/fail13-frag.c @@ -0,0 +1,26 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ +struct a { + int x; + int y; + char z; +}; + +struct b { + int x; + int y; +}; + +struct b k; + +(*((volatile struct a *) &k)).z = 'q'; + +return 0; +} +/* { dg-output "mudflap violation 1..check/write.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap object.*.main. k.*" } */ +/* { dg-do run { xfail *-*-* } } */ diff --git a/libmudflap/testsuite/libmudflap.c/fail14-frag.c b/libmudflap/testsuite/libmudflap.c/fail14-frag.c new file mode 100644 index 000000000..e66cc94c4 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/fail14-frag.c @@ -0,0 +1,29 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ +struct a { + int x; + int y; + char z; +}; + +struct b { + int x; + int y; +}; + +volatile struct b k; +volatile struct a *p; + +p = (struct a*) &k; + +p->z = 'q'; + +return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap object.*.main. k.*" } */ +/* { dg-do run { xfail *-*-* } } */ diff --git a/libmudflap/testsuite/libmudflap.c/fail15-frag.c b/libmudflap/testsuite/libmudflap.c/fail15-frag.c new file mode 100644 index 000000000..5d7ae7449 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/fail15-frag.c @@ -0,0 +1,27 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ +struct base { + int basic; +}; + +struct derived { + struct base common; + char extra; +}; + +volatile struct base b; +volatile struct base *bp; + +bp = (struct base *)&b; + +bp->basic = 10; +((struct derived volatile *)bp)->extra = 'x'; +return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap object.*.main. b.*" } */ +/* { dg-do run { xfail *-*-* } } */ diff --git a/libmudflap/testsuite/libmudflap.c/fail16-frag.c b/libmudflap/testsuite/libmudflap.c/fail16-frag.c new file mode 100644 index 000000000..6ac6187e2 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/fail16-frag.c @@ -0,0 +1,27 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +void *p; +int main () +{ +struct base { + int basic; +}; + +struct derived { + struct base common; + char extra; +}; + +struct base *bp; + +bp = (struct base *) malloc (sizeof (struct base));; +p = bp; +bp->basic = 10; +((struct derived *)bp)->extra = 'x'; +return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap object.*.malloc region.*" } */ +/* { dg-do run { xfail *-*-* } } */ diff --git a/libmudflap/testsuite/libmudflap.c/fail17-frag.c b/libmudflap/testsuite/libmudflap.c/fail17-frag.c new file mode 100644 index 000000000..5af67f138 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/fail17-frag.c @@ -0,0 +1,18 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ + +char * x; +int foo; +x = (char *) malloc (10); +strcpy (x, "123456789"); +foo = strlen (x+10); +x [foo] = 1; /* we just just use foo to force execution of strlen */ +return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap object.*.malloc region.*" } */ +/* { dg-do run { xfail *-*-* } } */ diff --git a/libmudflap/testsuite/libmudflap.c/fail18-frag.c b/libmudflap/testsuite/libmudflap.c/fail18-frag.c new file mode 100644 index 000000000..a7b62ddb7 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/fail18-frag.c @@ -0,0 +1,16 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ +/* One cannot redeclare __mf_lc_mask in proper C from instrumented + code, because of the way the instrumentation code emits its decls. */ +extern unsigned foo __asm__ ("__mf_lc_mask"); +unsigned * volatile bar = &foo; +*bar = 4; +return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap object.*.__mf_lc_mask.*no-access.*" } */ +/* { dg-do run { xfail *-*-* } } */ diff --git a/libmudflap/testsuite/libmudflap.c/fail19-frag.c b/libmudflap/testsuite/libmudflap.c/fail19-frag.c new file mode 100644 index 000000000..7e446b405 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/fail19-frag.c @@ -0,0 +1,18 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ +struct foo { + int bar [10]; +}; + +struct foo *k = (struct foo *) malloc (2 * sizeof(int)); +k->bar[5] = 9; +free (k); +return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap object.*.malloc region.*" } */ +/* { dg-do run { xfail *-*-* } } */ diff --git a/libmudflap/testsuite/libmudflap.c/fail2-frag.c b/libmudflap/testsuite/libmudflap.c/fail2-frag.c new file mode 100644 index 000000000..7672e60c6 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/fail2-frag.c @@ -0,0 +1,13 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ +volatile int foo [10][10]; +foo[10][0] = 0; +return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap object.*.main. foo.*" } */ +/* { dg-do run { xfail *-*-* } } */ diff --git a/libmudflap/testsuite/libmudflap.c/fail20-frag.c b/libmudflap/testsuite/libmudflap.c/fail20-frag.c new file mode 100644 index 000000000..0dd8bb7f9 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/fail20-frag.c @@ -0,0 +1,13 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ +volatile char *p = (char *) 0; +*p = 5; +return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap object.*.NULL.*" } */ +/* { dg-do run { xfail *-*-* } } */ diff --git a/libmudflap/testsuite/libmudflap.c/fail21-frag.c b/libmudflap/testsuite/libmudflap.c/fail21-frag.c new file mode 100644 index 000000000..4ab4a09f3 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/fail21-frag.c @@ -0,0 +1,18 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ + int *bar = (int *) malloc (sizeof (int)); +/* Make an access here to get &foo into the lookup cache. */ +*bar = 5; +__mf_watch (bar, sizeof(int)); +/* This access should trigger the watch violation. */ +*bar = 10; +/* NOTREACHED */ +return 0; +} +/* { dg-output "mudflap violation 1.*watch.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap object.*malloc region.*" } */ +/* { dg-do run { xfail *-*-* } } */ diff --git a/libmudflap/testsuite/libmudflap.c/fail22-frag.c b/libmudflap/testsuite/libmudflap.c/fail22-frag.c new file mode 100644 index 000000000..7dd7103d3 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/fail22-frag.c @@ -0,0 +1,17 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ +struct boo { int a; }; +int c; +struct boo *b = malloc (sizeof (struct boo)); +__mf_set_options ("-check-initialization"); +c = b->a; +(void) malloc (c); /* some dummy use of c */ +return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap object.*.malloc region.*1r/0w.*" } */ +/* { dg-do run { xfail *-*-* } } */ diff --git a/libmudflap/testsuite/libmudflap.c/fail23-frag.c b/libmudflap/testsuite/libmudflap.c/fail23-frag.c new file mode 100644 index 000000000..bb1b52ec7 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/fail23-frag.c @@ -0,0 +1,16 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +char zoo [10]; + +int main () +{ +int i = strlen ("012345") + strlen ("6789") + strlen ("01"); /* 11 */ +zoo[i] = 'a'; +return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object.*" } */ +/* { dg-output "mudflap object.*zoo.*static.*" } */ +/* { dg-do run { xfail *-*-* } } */ diff --git a/libmudflap/testsuite/libmudflap.c/fail25-frag.c b/libmudflap/testsuite/libmudflap.c/fail25-frag.c new file mode 100644 index 000000000..acac5236b --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/fail25-frag.c @@ -0,0 +1,18 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ +char *foo; +char *bar; +__mf_set_options ("-check-initialization"); +foo = (char *)malloc (10); +bar = (char *)malloc (10); +/* bar[2] = 'z'; */ /* don't touch memcpy source */ +memcpy(foo+1, bar+1, 9); +return 0; +} +/* { dg-output "mudflap violation 1.*check.read.*memcpy source.*" } */ +/* { dg-output "Nearby object.*" } */ +/* { dg-output "mudflap object.*malloc region.*alloc time.*" } */ +/* { dg-do run { xfail *-*-* } } */ diff --git a/libmudflap/testsuite/libmudflap.c/fail26-frag.c b/libmudflap/testsuite/libmudflap.c/fail26-frag.c new file mode 100644 index 000000000..88484d6ad --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/fail26-frag.c @@ -0,0 +1,24 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ +char *foo; + +__mf_set_options ("-check-initialization"); +foo = (char *)malloc (1); + +/* These two operations each expand to a read-modify-write. + * Even though the end result is that every bit of foo[0] is + * eventually written to deterministically, the first read + * triggers an uninit error. Ideally, it shouldn't, so this + * should be treated more like a regular XFAIL. */ +foo[0] &= 0xfe; +foo[0] |= 0x01; + +return foo[0]; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object.*" } */ +/* { dg-output "mudflap object.*malloc region.*1r/0w.*" } */ +/* { dg-do run { xfail *-*-* } } */ diff --git a/libmudflap/testsuite/libmudflap.c/fail27-frag.c b/libmudflap/testsuite/libmudflap.c/fail27-frag.c new file mode 100644 index 000000000..547c5e7a6 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/fail27-frag.c @@ -0,0 +1,24 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +char volatile * +__attribute__((noinline)) +foo (unsigned i) +{ + char volatile buffer[10]; + char volatile *k = i ? & buffer[i] : NULL; /* defeat addr-of-local-returned warning */ + return k; +} + +int main () +{ +char volatile *f = foo (5); +f[0] = 'b'; + +return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object.*" } */ +/* { dg-output "mudflap dead object.*buffer.*alloc.*dealloc" } */ +/* { dg-do run { xfail *-*-* } } */ diff --git a/libmudflap/testsuite/libmudflap.c/fail28-frag.c b/libmudflap/testsuite/libmudflap.c/fail28-frag.c new file mode 100644 index 000000000..7d61c57f3 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/fail28-frag.c @@ -0,0 +1,18 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +int foo (int *u, int i) +{ + return u[i]; /* this dereference should be instrumented */ +} + +int main () +{ +int *k = malloc (6); +return foo (k, 8); +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object.*" } */ +/* { dg-output "mudflap object.*malloc region.*alloc" } */ +/* { dg-do run { xfail *-*-* } } */ diff --git a/libmudflap/testsuite/libmudflap.c/fail29-frag.c b/libmudflap/testsuite/libmudflap.c/fail29-frag.c new file mode 100644 index 000000000..2024064dc --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/fail29-frag.c @@ -0,0 +1,17 @@ +#include <stdio.h> +#include <stdlib.h> + +int foo (int u[10]) +{ + return u[8]; /* this dereference should be instrumented */ +} + +int main () +{ +int *k = malloc (6); +return foo (k); +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object.*" } */ +/* { dg-output "mudflap object.*malloc region.*alloc" } */ +/* { dg-do run { xfail *-*-* } } */ diff --git a/libmudflap/testsuite/libmudflap.c/fail3-frag.c b/libmudflap/testsuite/libmudflap.c/fail3-frag.c new file mode 100644 index 000000000..98c1dbae1 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/fail3-frag.c @@ -0,0 +1,13 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ +volatile int foo [10][10][10]; +foo[9][10][0] = 0; +return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap object.*.main. foo.*" } */ +/* { dg-do run { xfail *-*-* } } */ diff --git a/libmudflap/testsuite/libmudflap.c/fail30-frag.c b/libmudflap/testsuite/libmudflap.c/fail30-frag.c new file mode 100644 index 000000000..8bfea61cb --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/fail30-frag.c @@ -0,0 +1,18 @@ +#include <stdio.h> +#include <stdlib.h> + +int foo (int u) +{ + return u*u; +} + +int main () +{ +int *k = malloc(5); +int j = foo (k[8]); /* this call argument should be instrumented */ +return j; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object.*" } */ +/* { dg-output "mudflap object.*malloc region.*alloc" } */ +/* { dg-do run { xfail *-*-* } } */ diff --git a/libmudflap/testsuite/libmudflap.c/fail31-frag.c b/libmudflap/testsuite/libmudflap.c/fail31-frag.c new file mode 100644 index 000000000..bd9a903cc --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/fail31-frag.c @@ -0,0 +1,23 @@ +#include <stdio.h> +#include <stdlib.h> + +extern int h (int i, int j); + +int main () +{ + int z = h (4, 10); + return 0; +} +int *p; +int h (int i, int j) +{ + int k[i]; + k[j] = i; + p = k; + return j; +} + +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object.*" } */ +/* { dg-output "mudflap object.*\(h\).*k" } */ +/* { dg-do run { xfail *-*-* } } */ diff --git a/libmudflap/testsuite/libmudflap.c/fail32-frag.c b/libmudflap/testsuite/libmudflap.c/fail32-frag.c new file mode 100644 index 000000000..2a38237b6 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/fail32-frag.c @@ -0,0 +1,16 @@ +void foo (int k) +{ + volatile int *b = & k; + b++; + *b = 5; +} + +int main () +{ + foo (5); + return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object.*" } */ +/* { dg-output "mudflap object.*k" } */ +/* { dg-do run { xfail *-*-* } } */ diff --git a/libmudflap/testsuite/libmudflap.c/fail33-frag.c b/libmudflap/testsuite/libmudflap.c/fail33-frag.c new file mode 100644 index 000000000..ac7c617a4 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/fail33-frag.c @@ -0,0 +1,25 @@ +#include <stdlib.h> + +#define SIZE 16 + +char b[SIZE]; +char a[SIZE]; + +int main () +{ + int i, j=0, k; + int a_before_b = (& a[0] < & b[0]); + /* Rather than iterating linearly, which would allow loop unrolling + and mapping to pointer manipulation, we traverse the "joined" + arrays in some random order. */ + for (i=0; i<SIZE*2; i++) + { + k = rand() % (SIZE*2); + j += (a_before_b ? a[k] : b[k]); + } + return j; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object.*" } */ +/* { dg-output "mudflap object.*\[ab\]" } */ +/* { dg-do run { xfail *-*-* } } */ diff --git a/libmudflap/testsuite/libmudflap.c/fail34-frag.c b/libmudflap/testsuite/libmudflap.c/fail34-frag.c new file mode 100644 index 000000000..f6572b019 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/fail34-frag.c @@ -0,0 +1,22 @@ +#include <stdlib.h> + +struct s +{ + int a1[4]; +}; + +struct s a, b; +int idx = 7; /* should pass to the next object */ + +int +main () +{ + int i, j=0; + int a_before_b = (& a < & b); + j = (a_before_b ? a.a1[idx] : b.a1[idx]); + return j; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object.*" } */ +/* { dg-output "mudflap object.*\[ab\]" } */ +/* { dg-do run { xfail *-*-* } } */ diff --git a/libmudflap/testsuite/libmudflap.c/fail35-frag.c b/libmudflap/testsuite/libmudflap.c/fail35-frag.c new file mode 100644 index 000000000..101fe293b --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/fail35-frag.c @@ -0,0 +1,23 @@ +#include <stdlib.h> + +struct k +{ + int p; + struct { + int m; + } q; +}; + +int +main () +{ + volatile struct k *l = malloc (sizeof (int)); /* make it only big enough for k.p */ + /* Confirm that we instrument this nested construct + COMPONENT_REF(COMPONENT_REF(INDIRECT_REF)). */ + l->q.m = 5; + return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object.*" } */ +/* { dg-output "mudflap object.*" } */ +/* { dg-do run { xfail *-*-* } } */ diff --git a/libmudflap/testsuite/libmudflap.c/fail36-frag.c b/libmudflap/testsuite/libmudflap.c/fail36-frag.c new file mode 100644 index 000000000..af6851c1d --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/fail36-frag.c @@ -0,0 +1,23 @@ +#include <stdlib.h> + +struct k +{ + int p; + struct { + int m : 31; + } q; +}; + +int +main () +{ + volatile struct k *l = malloc (sizeof (int)); /* make it only big enough for k.p */ + /* Confirm that we instrument this nested construct + BIT_FIELD_REF(COMPONENT_REF(INDIRECT_REF)). */ + l->q.m = 5; + return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object.*" } */ +/* { dg-output "mudflap object.*" } */ +/* { dg-do run { xfail *-*-* } } */ diff --git a/libmudflap/testsuite/libmudflap.c/fail37-frag.c b/libmudflap/testsuite/libmudflap.c/fail37-frag.c new file mode 100644 index 000000000..41ce4b91e --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/fail37-frag.c @@ -0,0 +1,22 @@ +typedef struct +{ + short f : 3; +} small; + +struct +{ + int i; + small s[4]; +} x; + +main () +{ + int i; + for (i = 0; i < 5; i++) + x.s[i].f = 0; + exit (0); +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object.*" } */ +/* { dg-output "mudflap object.* x.*" } */ +/* { dg-do run { xfail *-*-* } } */ diff --git a/libmudflap/testsuite/libmudflap.c/fail38-frag.c b/libmudflap/testsuite/libmudflap.c/fail38-frag.c new file mode 100644 index 000000000..9667e2134 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/fail38-frag.c @@ -0,0 +1,29 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ +struct a { + int x; + int y; + int z : 10; +}; + +struct b { + int x; + int y; +}; + +volatile struct b k; +volatile struct a *p; + +p = (struct a*) &k; + +p->z = 'q'; + +return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap object.*.main. k.*" } */ +/* { dg-do run { xfail *-*-* } } */ diff --git a/libmudflap/testsuite/libmudflap.c/fail39-frag.c b/libmudflap/testsuite/libmudflap.c/fail39-frag.c new file mode 100644 index 000000000..4e74ea5cd --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/fail39-frag.c @@ -0,0 +1,20 @@ +#include <stdio.h> +#include <stdlib.h> + +int main () +{ + volatile int *k = (int *) malloc (sizeof (int)); + volatile int l; + if (k == NULL) abort (); + *k = 5; + free ((void *) k); + __mf_set_options ("-ignore-reads"); + l = *k; /* Should not trip, even though memory region just freed. */ + __mf_set_options ("-no-ignore-reads"); + l = *k; /* Should trip now. */ + return 0; +} +/* { dg-output "mudflap violation 1.*check/read.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap dead object.*malloc region.*" } */ +/* { dg-do run { xfail *-*-* } } */ diff --git a/libmudflap/testsuite/libmudflap.c/fail4-frag.c b/libmudflap/testsuite/libmudflap.c/fail4-frag.c new file mode 100644 index 000000000..a3423e6c3 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/fail4-frag.c @@ -0,0 +1,13 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ +char foo [10]; +strcpy(foo, "1234567890"); +return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap object.*.main. foo.*" } */ +/* { dg-do run { xfail *-*-* } } */ diff --git a/libmudflap/testsuite/libmudflap.c/fail40-frag.c b/libmudflap/testsuite/libmudflap.c/fail40-frag.c new file mode 100644 index 000000000..fbeb6fd21 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/fail40-frag.c @@ -0,0 +1,59 @@ +/* Test proper lookup-uncaching of large objects */ +#include "../config.h" + +#include <unistd.h> +#include <string.h> +#include <stdio.h> +#include <stdlib.h> +#ifdef HAVE_SYS_MMAN_H +#include <sys/mman.h> +#endif + +int main () +{ +#ifndef MAP_ANONYMOUS +#define MAP_ANONYMOUS MAP_ANON +#endif +#ifndef MAP_FAILED +#define MAP_FAILED ((void *)-1) +#endif +#ifdef HAVE_MMAP + volatile unsigned char *p; + unsigned num = getpagesize (); + unsigned i; + int rc; + + /* Get a bit of usable address space. We really want an 2**N+1-sized object, + so the low/high addresses wrap when hashed into the lookup cache. So we + will manually unregister the entire mmap, then re-register a slice. */ + p = mmap (NULL, num, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); + if (p == MAP_FAILED) + return 1; + /* Now unregister it, as if munmap was called. But don't actually munmap, so + we can write into the memory. */ + __mf_unregister ((void *) p, num, __MF_TYPE_HEAP_I); + + /* Now register it under a slightly inflated, 2**N+1 size. */ + __mf_register ((void *) p, num+1, __MF_TYPE_HEAP_I, "fake mmap registration"); + + /* Traverse array to ensure that entire lookup cache is made to point at it. */ + for (i=0; i<num; i++) + p[i] = 0; + + /* Unregister it. This should clear the entire lookup cache, even though + hash(low) == hash (high) (and probably == 0) */ + __mf_unregister ((void *) p, num+1, __MF_TYPE_HEAP_I); + + /* Now touch the middle portion of the ex-array. If the lookup cache was + well and truly cleaned, then this access should trap. */ + p[num/2] = 1; + + return 0; +#else + return 1; +#endif +} +/* { dg-output "mudflap violation 1.*check/write.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap dead object.*fake mmap registration.*" } */ +/* { dg-do run { xfail *-*-* } } */ diff --git a/libmudflap/testsuite/libmudflap.c/fail5-frag.c b/libmudflap/testsuite/libmudflap.c/fail5-frag.c new file mode 100644 index 000000000..a08569fe7 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/fail5-frag.c @@ -0,0 +1,14 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ +char foo [15]; +char bar [10]; +memcpy(foo, bar, 11); +return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap object.*.main. bar.*" } */ +/* { dg-do run { xfail *-*-* } } */ diff --git a/libmudflap/testsuite/libmudflap.c/fail6-frag.c b/libmudflap/testsuite/libmudflap.c/fail6-frag.c new file mode 100644 index 000000000..1904a8871 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/fail6-frag.c @@ -0,0 +1,17 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ +char *foo; +char *bar; +foo = (char *)malloc (10); +bar = (char *)malloc (15); + +memcpy(foo, bar, 11); +return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap object.*malloc region.*" } */ +/* { dg-do run { xfail *-*-* } } */ diff --git a/libmudflap/testsuite/libmudflap.c/fail68-frag.c b/libmudflap/testsuite/libmudflap.c/fail68-frag.c new file mode 100644 index 000000000..7b2f8cf2c --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/fail68-frag.c @@ -0,0 +1,27 @@ +/* PR libmudflap/40778 */ + +char p[32]; +static int j; + +__attribute__((noinline)) +static void foo (int i) +{ + if (j++ == 0) + p[i + 4] = 12; + else + p[i - 4] = 13; +} + +int +main () +{ + foo (30); + foo (30); + foo (30); + return 0; +} + +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap object.*name.*p" } */ +/* { dg-do run { xfail *-*-* } } */ diff --git a/libmudflap/testsuite/libmudflap.c/fail7-frag.c b/libmudflap/testsuite/libmudflap.c/fail7-frag.c new file mode 100644 index 000000000..580d04538 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/fail7-frag.c @@ -0,0 +1,17 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ +char *foo; +char *bar; +foo = (char *)malloc (12); +bar = (char *)malloc (10); + +memcpy(foo+1, bar+1, 10); +return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap object.*malloc region.*" } */ +/* { dg-do run { xfail *-*-* } } */ diff --git a/libmudflap/testsuite/libmudflap.c/fail8-frag.c b/libmudflap/testsuite/libmudflap.c/fail8-frag.c new file mode 100644 index 000000000..8309068df --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/fail8-frag.c @@ -0,0 +1,19 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ +char *foo; +char *bar; +foo = (char *)malloc (10); +bar = (char *)malloc (10); + +free(bar); + +memcpy(foo, bar, 10); +return 0; +} +/* { dg-output "mudflap violation 1.*memcpy source.*" } */ +/* { dg-output "Nearby object.*" } */ +/* { dg-output "mudflap dead object.*malloc region.*alloc time.*dealloc time.*" } */ +/* { dg-do run { xfail *-*-* } } */ diff --git a/libmudflap/testsuite/libmudflap.c/fail9-frag.c b/libmudflap/testsuite/libmudflap.c/fail9-frag.c new file mode 100644 index 000000000..9bbd860a8 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/fail9-frag.c @@ -0,0 +1,21 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ +char *foo; +char *bar; +foo = (char *)malloc (10); +bar = (char *)malloc (10); + +free(foo); + +bar[4] = 'a'; /* touch source buffer */ +memcpy(foo, bar, 10); +return 0; +} + +/* { dg-output "mudflap violation 1.*memcpy dest.*" } */ +/* { dg-output "Nearby object.*" } */ +/* { dg-output "mudflap dead object.*malloc region.*alloc time.*dealloc time.*" } */ +/* { dg-do run { xfail *-*-* } } */ diff --git a/libmudflap/testsuite/libmudflap.c/heap-scalestress.c b/libmudflap/testsuite/libmudflap.c/heap-scalestress.c new file mode 100644 index 000000000..2d51731d6 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/heap-scalestress.c @@ -0,0 +1,79 @@ +/* zz30 + * + * demonstrate a splay-tree depth problem +*/ + +#include <stdlib.h> +#include <stdio.h> +#include <unistd.h> + +#ifndef SCALE +#define SCALE 100000 +#endif + + +struct list +{ + struct list *next; +}; + + +int +main () +{ + struct list *head = NULL; + struct list *tail = NULL; + struct list *p; + long n; + int direction; + + for (direction = 0; direction < 2; direction++) + { + fprintf (stdout, "allocating\n"); + fflush (stdout); + + for (n = 0; n < SCALE; ++n) + { + p = malloc (sizeof *p); + if (NULL == p) + { + fprintf (stdout, "malloc failed\n"); + break; + } + if (direction == 0) + { /* add at tail */ + p->next = NULL; + if (NULL != tail) + tail->next = p; + else + head = p; + tail = p; + } + else + { /* add at head */ + p->next = head; + if (NULL == tail) + tail = p; + head = p; + } + } + + fprintf (stdout, "freeing\n"); + fflush (stdout); + + while (NULL != head) + { + p = head; + head = head->next; + free (p); + } + + } + + fprintf (stdout, "done\n"); + fflush (stdout); + + return (0); +} + +/* { dg-output "allocating.*freeing.*allocating.*freeing.*done" } */ diff --git a/libmudflap/testsuite/libmudflap.c/hook-allocstuff.c b/libmudflap/testsuite/libmudflap.c/hook-allocstuff.c new file mode 100644 index 000000000..dc2537548 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/hook-allocstuff.c @@ -0,0 +1,16 @@ +#include <stdio.h> +#include <stdlib.h> + +int main () +{ + char *foo = (char *) malloc (10); + strcpy (foo, "hello"); + foo = (char *) realloc (foo, 20); + printf ("%s", foo); + if (strcmp (foo, "hello")) + abort (); + free (foo); + printf (" world\n"); + return 0; +} +/* { dg-output "hello world" } */ diff --git a/libmudflap/testsuite/libmudflap.c/hook2-allocstuff.c b/libmudflap/testsuite/libmudflap.c/hook2-allocstuff.c new file mode 100644 index 000000000..d8fbec467 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/hook2-allocstuff.c @@ -0,0 +1,9 @@ +/* Generates recursive malloc call on i386-freebsd4.10 with -fmudflap. */ +#include <stdlib.h> + +int +main (void) +{ + char *p = malloc (1<<24); + return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass-stratcliff.c b/libmudflap/testsuite/libmudflap.c/pass-stratcliff.c new file mode 100644 index 000000000..baaf8a9f3 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass-stratcliff.c @@ -0,0 +1,319 @@ +/* Test for string function add boundaries of usable memory. + Copyright (C) 1996,1997,1999,2000,2001,2002 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301 USA. */ + +#define _GNU_SOURCE 1 +#define __USE_GNU + +/* Make sure we don't test the optimized inline functions if we want to + test the real implementation. */ +#undef __USE_STRING_INLINES + +#include <errno.h> +#include <stdio.h> +#include <string.h> +#include <unistd.h> +#include <sys/mman.h> +#include <sys/param.h> + +#ifndef MAX +#define MAX(a, b) ((a) > (b) ? (a) : (b)) +#endif + +int +main (int argc, char *argv[]) +{ + int size = sysconf (_SC_PAGESIZE); + char *adr, *dest; + int result = 0; + + adr = (char *) mmap (NULL, 3 * size, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANON, -1, 0); + dest = (char *) mmap (NULL, 3 * size, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANON, -1, 0); + if (adr == MAP_FAILED || dest == MAP_FAILED) + { + if (errno == ENOSYS) + puts ("No test, mmap not available."); + else + { + printf ("mmap failed: %m"); + result = 1; + } + } + else + { + int inner, middle, outer; + + mprotect(adr, size, PROT_NONE); + mprotect(adr + 2 * size, size, PROT_NONE); + adr += size; + + mprotect(dest, size, PROT_NONE); + mprotect(dest + 2 * size, size, PROT_NONE); + dest += size; + + memset (adr, 'T', size); + + /* strlen test */ + for (outer = size - 1; outer >= MAX (0, size - 128); --outer) + { + for (inner = MAX (outer, size - 64); inner < size; ++inner) + { + adr[inner] = '\0'; + + if (strlen (&adr[outer]) != (size_t) (inner - outer)) + { + printf ("strlen flunked for outer = %d, inner = %d\n", + outer, inner); + result = 1; + } + + adr[inner] = 'T'; + } + } + + /* strchr test */ + for (outer = size - 1; outer >= MAX (0, size - 128); --outer) + { + for (middle = MAX (outer, size - 64); middle < size; ++middle) + { + for (inner = middle; inner < size; ++inner) + { + char *cp; + adr[middle] = 'V'; + adr[inner] = '\0'; + + cp = strchr (&adr[outer], 'V'); + + if ((inner == middle && cp != NULL) + || (inner != middle + && (cp - &adr[outer]) != middle - outer)) + { + printf ("strchr flunked for outer = %d, middle = %d, " + "inner = %d\n", outer, middle, inner); + result = 1; + } + + adr[inner] = 'T'; + adr[middle] = 'T'; + } + } + } + + /* Special test. */ + adr[size - 1] = '\0'; + if (strchr (&adr[size - 1], '\n') != NULL) + { + puts ("strchr flunked for test of empty string at end of page"); + result = 1; + } + + /* strrchr test */ + for (outer = size - 1; outer >= MAX (0, size - 128); --outer) + { + for (middle = MAX (outer, size - 64); middle < size; ++middle) + { + for (inner = middle; inner < size; ++inner) + { + char *cp; + adr[middle] = 'V'; + adr[inner] = '\0'; + + cp = strrchr (&adr[outer], 'V'); + + if ((inner == middle && cp != NULL) + || (inner != middle + && (cp - &adr[outer]) != middle - outer)) + { + printf ("strrchr flunked for outer = %d, middle = %d, " + "inner = %d\n", outer, middle, inner); + result = 1; + } + + adr[inner] = 'T'; + adr[middle] = 'T'; + } + } + } + +#ifndef __FreeBSD__ + /* rawmemchr test */ + for (outer = size - 1; outer >= MAX (0, size - 128); --outer) + { + for (middle = MAX (outer, size - 64); middle < size; ++middle) + { + char *cp; + adr[middle] = 'V'; + + cp = (char *) rawmemchr (&adr[outer], 'V'); + + if (cp - &adr[outer] != middle - outer) + { + printf ("rawmemchr flunked for outer = %d, middle = %d\n", + outer, middle); + result = 1; + } + + adr[middle] = 'T'; + } + } +#endif + + /* strcpy test */ + for (outer = size - 1; outer >= MAX (0, size - 128); --outer) + { + for (inner = MAX (outer, size - 64); inner < size; ++inner) + { + adr[inner] = '\0'; + + if (strcpy (dest, &adr[outer]) != dest + || strlen (dest) != (size_t) (inner - outer)) + { + printf ("strcpy flunked for outer = %d, inner = %d\n", + outer, inner); + result = 1; + } + + adr[inner] = 'T'; + } + } + + /* strncpy tests */ + adr[size-1] = 'T'; + for (outer = size - 1; outer >= MAX (0, size - 128); --outer) + { + size_t len; + + for (len = 0; len < size - outer; ++len) + { + if (strncpy (dest, &adr[outer], len) != dest + || memcmp (dest, &adr[outer], len) != 0) + { + printf ("outer strncpy flunked for outer = %d, len = %Zd\n", + outer, len); + result = 1; + } + } + } + adr[size-1] = '\0'; + + for (outer = size - 1; outer >= MAX (0, size - 128); --outer) + { + for (inner = MAX (outer, size - 64); inner < size; ++inner) + { + size_t len; + + adr[inner] = '\0'; + + for (len = 0; len < size - outer + 64; ++len) + { + if (strncpy (dest, &adr[outer], len) != dest + || memcmp (dest, &adr[outer], + MIN (inner - outer, len)) != 0 + || (inner - outer < len + && strlen (dest) != (inner - outer))) + { + printf ("strncpy flunked for outer = %d, inner = %d, len = %Zd\n", + outer, inner, len); + result = 1; + } + if (strncpy (dest + 1, &adr[outer], len) != dest + 1 + || memcmp (dest + 1, &adr[outer], + MIN (inner - outer, len)) != 0 + || (inner - outer < len + && strlen (dest + 1) != (inner - outer))) + { + printf ("strncpy+1 flunked for outer = %d, inner = %d, len = %Zd\n", + outer, inner, len); + result = 1; + } + } + + adr[inner] = 'T'; + } + } + +#ifndef __FreeBSD__ + /* stpcpy test */ + for (outer = size - 1; outer >= MAX (0, size - 128); --outer) + { + for (inner = MAX (outer, size - 64); inner < size; ++inner) + { + adr[inner] = '\0'; + + if ((stpcpy (dest, &adr[outer]) - dest) != inner - outer) + { + printf ("stpcpy flunked for outer = %d, inner = %d\n", + outer, inner); + result = 1; + } + + adr[inner] = 'T'; + } + } + + /* stpncpy test */ + for (outer = size - 1; outer >= MAX (0, size - 128); --outer) + { + for (middle = MAX (outer, size - 64); middle < size; ++middle) + { + adr[middle] = '\0'; + + for (inner = 0; inner < size - outer; ++ inner) + { + if ((stpncpy (dest, &adr[outer], inner) - dest) + != MIN (inner, middle - outer)) + { + printf ("stpncpy flunked for outer = %d, middle = %d, " + "inner = %d\n", outer, middle, inner); + result = 1; + } + } + + adr[middle] = 'T'; + } + } +#endif + + /* memcpy test */ + for (outer = size - 1; outer >= MAX (0, size - 128); --outer) + for (inner = 0; inner < size - outer; ++inner) + if (memcpy (dest, &adr[outer], inner) != dest) + { + printf ("memcpy flunked for outer = %d, inner = %d\n", + outer, inner); + result = 1; + } + +#ifndef __FreeBSD__ + /* mempcpy test */ + for (outer = size - 1; outer >= MAX (0, size - 128); --outer) + for (inner = 0; inner < size - outer; ++inner) + if (mempcpy (dest, &adr[outer], inner) != dest + inner) + { + printf ("mempcpy flunked for outer = %d, inner = %d\n", + outer, inner); + result = 1; + } +#endif + } + + return result; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass1-frag.c b/libmudflap/testsuite/libmudflap.c/pass1-frag.c new file mode 100644 index 000000000..40f629b56 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass1-frag.c @@ -0,0 +1,9 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ +int foo [10]; +foo[9] = 0; +return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass10-frag.c b/libmudflap/testsuite/libmudflap.c/pass10-frag.c new file mode 100644 index 000000000..f05650da5 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass10-frag.c @@ -0,0 +1,12 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ +int foo[10]; +int sz = sizeof (int); + +char *bar = (char *)foo; +bar [sz * 9] = 0; +return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass11-frag.c b/libmudflap/testsuite/libmudflap.c/pass11-frag.c new file mode 100644 index 000000000..ab7ee38c4 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass11-frag.c @@ -0,0 +1,15 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ +int i = 10; +char *x = (char *) malloc (i * sizeof (char)); + +while (--i) +{ + ++x; + *x = 0; +} +return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass12-frag.c b/libmudflap/testsuite/libmudflap.c/pass12-frag.c new file mode 100644 index 000000000..53630d997 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass12-frag.c @@ -0,0 +1,15 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ +int i = 10; +int *x = (int *) malloc (i * sizeof (int)); + +while (--i) +{ + ++x; + *x = 0; +} +return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass13-frag.c b/libmudflap/testsuite/libmudflap.c/pass13-frag.c new file mode 100644 index 000000000..c2b820d0f --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass13-frag.c @@ -0,0 +1,17 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ +struct a { + int x; + int y; + char z; +}; + +struct a k; + +k.z = 'q'; + +return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass14-frag.c b/libmudflap/testsuite/libmudflap.c/pass14-frag.c new file mode 100644 index 000000000..264564329 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass14-frag.c @@ -0,0 +1,20 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ +struct a { + int x; + int y; + char z; +}; + +struct a k; +struct a *p; + +p = &k; + +p->z = 'q'; + +return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass15-frag.c b/libmudflap/testsuite/libmudflap.c/pass15-frag.c new file mode 100644 index 000000000..5e1fee8eb --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass15-frag.c @@ -0,0 +1,23 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ +struct base { + int basic; +}; + +struct derived { + struct base common; + char extra; +}; + +struct derived d; +struct base *bp; + +bp = (struct base *)&d; + +bp->basic = 10; +((struct derived *)bp)->extra = 'x'; +return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass16-frag.c b/libmudflap/testsuite/libmudflap.c/pass16-frag.c new file mode 100644 index 000000000..99ede3f21 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass16-frag.c @@ -0,0 +1,22 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ +struct base { + int basic; +}; + +struct derived { + struct base common; + char extra; +}; + +struct base *bp; + +bp = (struct base *) malloc (sizeof (struct derived)); + +bp->basic = 10; +((struct derived *)bp)->extra = 'x'; +return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass17-frag.c b/libmudflap/testsuite/libmudflap.c/pass17-frag.c new file mode 100644 index 000000000..b840dc987 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass17-frag.c @@ -0,0 +1,9 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ + +strlen("123456789"); +return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass18-frag.c b/libmudflap/testsuite/libmudflap.c/pass18-frag.c new file mode 100644 index 000000000..c5d5af0fe --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass18-frag.c @@ -0,0 +1,27 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ +int t; +char foo[3] = { 'b', 'c', 'd' }; +int bar[3] = {1, 2, 0}; +t = 1; + +/* These tests check expression evaluation rules, such as + ensuring that side-effect expression (++) get executed the + right number of times; that array lookup checks nest correctly. */ +foo[t++] = 'a'; +if (foo[0] != 'b' || foo[1] != 'a' || foo[2] != 'd' || t != 2) abort (); +if (bar[0] != 1 || bar[1] != 2 || bar[2] != 0) abort(); + +foo[bar[t--]] = 'e'; +if (foo[0] != 'e' || foo[1] != 'a' || foo[2] != 'd' || t != 1) abort (); +if (bar[0] != 1 || bar[1] != 2 || bar[2] != 0) abort(); + +foo[bar[++t]--] = 'g'; +if (foo[0] != 'g' || foo[1] != 'a' || foo[2] != 'd' || t != 2) abort (); +if (bar[0] != 1 || bar[1] != 2 || bar[2] != -1) abort(); + +return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass19-frag.c b/libmudflap/testsuite/libmudflap.c/pass19-frag.c new file mode 100644 index 000000000..0b00845d4 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass19-frag.c @@ -0,0 +1,11 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ +struct foo {int base; char variable[1]; }; /* a common idiom for variable-size structs */ + +struct foo * b = (struct foo *) malloc (sizeof (int)); /* enough for base */ +b->base = 4; +return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass2-frag.c b/libmudflap/testsuite/libmudflap.c/pass2-frag.c new file mode 100644 index 000000000..7e71e0cd7 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass2-frag.c @@ -0,0 +1,9 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ +int foo [10][10]; +foo[9][0] = 0; +return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass20-frag.c b/libmudflap/testsuite/libmudflap.c/pass20-frag.c new file mode 100644 index 000000000..984311685 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass20-frag.c @@ -0,0 +1,13 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ +struct bar {int stuff; int array[10]; }; + +struct bar *foo = (struct bar *) malloc (sizeof (struct bar)); +foo->array[5] = 4; +free (foo); + +return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass21-frag.c b/libmudflap/testsuite/libmudflap.c/pass21-frag.c new file mode 100644 index 000000000..231055a23 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass21-frag.c @@ -0,0 +1,15 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#ifndef __FreeBSD__ +#include <alloca.h> +#endif +int main () +{ +char *boo, *foo; +boo = (char *) alloca (100); +boo[99] = 'a'; +foo = (char *) __builtin_alloca (200); +foo[44] = 'b'; +return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass22-frag.c b/libmudflap/testsuite/libmudflap.c/pass22-frag.c new file mode 100644 index 000000000..b092ea0b2 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass22-frag.c @@ -0,0 +1,23 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ +struct foo { + unsigned base:8; + unsigned flag1:1; + unsigned flag2:3; + unsigned flag3:4; + char nothing[0]; +}; + +#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *) 0)->MEMBER) + +struct foo* f = (struct foo *) malloc (offsetof (struct foo, nothing)); +f->base = 1; +f->flag1 = 1; +free (f); + + +return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass23-frag.c b/libmudflap/testsuite/libmudflap.c/pass23-frag.c new file mode 100644 index 000000000..f27c22361 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass23-frag.c @@ -0,0 +1,29 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ +struct foo { + int part1: 8; + int nothing : 1; + int part2 : 5; + int lots_more_nothing : 3; + int some_padding; /* for 64-bit hosts */ + float some_more_nothing; + double yet_more_nothing; +}; + +#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *) 0)->MEMBER) + +struct foo* q = (struct foo *) malloc (offsetof (struct foo, some_more_nothing)); +q->nothing = 1; /* touch q */ +/* The RHS of the following expression is meant to trigger a + fold-const.c mapping the expression to a BIT_FIELD_REF. It glues + together the accesses to the two non-neighbouring bitfields into a + single bigger boolean test. */ +q->lots_more_nothing = (q->part1 == 13 && q->part2 == 7); +free (q); + + +return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass24-frag.c b/libmudflap/testsuite/libmudflap.c/pass24-frag.c new file mode 100644 index 000000000..003858221 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass24-frag.c @@ -0,0 +1,18 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ +struct foo { + int zoo; + int bar [10]; + float baz; +}; + +#define offsetof(S,F) ((size_t) & (((S *) 0)->F)) + +struct foo *k = (struct foo *) malloc (offsetof (struct foo, bar[4])); +k->bar[1] = 9; +free (k); +return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass25-frag.c b/libmudflap/testsuite/libmudflap.c/pass25-frag.c new file mode 100644 index 000000000..c5a75e333 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass25-frag.c @@ -0,0 +1,15 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ +int *foo = malloc (10 * sizeof(int)); +int *bar = & foo[3]; +/* Watching occurs at the object granularity, which is in this case + the entire array. */ +__mf_watch (& foo[1], sizeof(foo[1])); +__mf_unwatch (& foo[6], sizeof(foo[6])); +*bar = 10; +free (foo); +return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass26-frag.c b/libmudflap/testsuite/libmudflap.c/pass26-frag.c new file mode 100644 index 000000000..5a72f5b79 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass26-frag.c @@ -0,0 +1,52 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ +volatile int *p; + +__mf_set_options ("-wipe-stack -no-check-initialization"); + +{ + volatile int array [10]; + p = & array[0]; + + array[0] = 2; + array[9] = 5; + + /* Array[] should be wiped clean at this point. */ +} + +__mf_set_options ("-no-wipe-stack"); + +{ + volatile int array2[10]; + + /* hope that this is allocated on top of old array[] */ + if (p != & array2[0]) + exit (0); /* Test is not applicable. */ + + array2[5] = 6; + + /* Old values shouldn't still be around; the new one should. */ + if (p[0] == 2 || p[9] == 5 || p[5] != 6) + abort() ; + + /* array2[] should not be wiped at this point! */ +} + +{ + volatile int array3[10]; + + /* hope that this is allocated on top of old array[] and array2[]*/ + if (p != & array3[0]) + exit (0); /* Test is not applicable. */ + + array3[1] = 2; + + /* Check that old assignment is still around. */ + if (p[5] != 6 || p[1] != 2) + abort() ; +} +return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass29-frag.c b/libmudflap/testsuite/libmudflap.c/pass29-frag.c new file mode 100644 index 000000000..97bed6eb3 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass29-frag.c @@ -0,0 +1,15 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ +struct boo { int a; }; +int c; +struct boo *b = malloc (sizeof (struct boo)); +__mf_set_options ("-check-initialization"); +b->a = 0; +/* That __mf_set_options call could be here instead. */ +c = b->a; +(void) malloc (c); /* some dummy use of c */ +return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass3-frag.c b/libmudflap/testsuite/libmudflap.c/pass3-frag.c new file mode 100644 index 000000000..4e950a2c5 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass3-frag.c @@ -0,0 +1,9 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ +int foo [10][10][10]; +foo[9][9][0] = 0; +return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass30-frag.c b/libmudflap/testsuite/libmudflap.c/pass30-frag.c new file mode 100644 index 000000000..6c4b9f9a7 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass30-frag.c @@ -0,0 +1,12 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +char zoo [10]; + +int main () +{ +int i = strlen ("eight") + strlen ("one"); +zoo[i] = 'a'; +return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass32-frag.c b/libmudflap/testsuite/libmudflap.c/pass32-frag.c new file mode 100644 index 000000000..d7f223279 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass32-frag.c @@ -0,0 +1,18 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +struct foo { char z[10]; }; + +char * get_z (struct foo *this) +{ + return & this->z[0] /* the `this' pointer is not dereferenced! */; +} + +int main () +{ +struct foo k; +char *n = get_z (& k); +srand ((int)(__mf_uintptr_t) n); /* use the pointer value */ +return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass33-frag.c b/libmudflap/testsuite/libmudflap.c/pass33-frag.c new file mode 100644 index 000000000..95d762cc1 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass33-frag.c @@ -0,0 +1,17 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +void test (int *k) +{ + if (*k > 5) { *k --; } +} + +int main () +{ +int z; +/* z is initialized, but not via a pointer, so not instrumented */ +z = rand (); +test (& z); +return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass34-frag.c b/libmudflap/testsuite/libmudflap.c/pass34-frag.c new file mode 100644 index 000000000..2dfd0ca21 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass34-frag.c @@ -0,0 +1,18 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +void test (int *k) +{ + if (*k > 5) { *k --; } +} + +int z; + +int main () +{ +/* z is initialized, but not via a pointer, so not instrumented */ +z = rand (); +test (& z); +return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass35-frag.c b/libmudflap/testsuite/libmudflap.c/pass35-frag.c new file mode 100644 index 000000000..14d2c94a9 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass35-frag.c @@ -0,0 +1,14 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +extern char end []; /* Any old symbol we're sure will be defined. */ +/* { dg-warning "cannot track unknown size extern" "cannot track unknown size extern" { target *-*-* } 0 } */ + +int main () +{ +/* dummy register */ +__mf_register ((void *) end, 1, __MF_TYPE_GUESS, "end"); +char z = end[0]; +return z & 0; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass36-frag.c b/libmudflap/testsuite/libmudflap.c/pass36-frag.c new file mode 100644 index 000000000..68d1a7f80 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass36-frag.c @@ -0,0 +1,15 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <signal.h> + +int main () +{ +char *k; +__mf_set_options ("-sigusr1-report -print-leaks"); +k = (char *) malloc (100); +raise (SIGUSR1); +free (k); +return 0; +} +/* { dg-output "Leaked object.*name=.malloc region.*objects: 1" } */ diff --git a/libmudflap/testsuite/libmudflap.c/pass38-frag.c b/libmudflap/testsuite/libmudflap.c/pass38-frag.c new file mode 100644 index 000000000..a250234da --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass38-frag.c @@ -0,0 +1,9 @@ +/* Test an odd construct for compilability. */ +static void *fwd; +void *bwd = &fwd; +static void *fwd = &bwd; + +int main () +{ + return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass4-frag.c b/libmudflap/testsuite/libmudflap.c/pass4-frag.c new file mode 100644 index 000000000..0a40d1c42 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass4-frag.c @@ -0,0 +1,9 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ +char foo[10]; +strcpy (foo, "123456789"); +return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass42-frag.c b/libmudflap/testsuite/libmudflap.c/pass42-frag.c new file mode 100644 index 000000000..1045c47c3 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass42-frag.c @@ -0,0 +1,17 @@ +#include <stdio.h> + +void +foo () +{ + putc ('h', stdout); + putc ('i', stdout); + putc ('\n', stdout); +} + +int +main (int argc, char *argv[]) +{ + foo (); + return 0; +} +/* { dg-output "hi" } */ diff --git a/libmudflap/testsuite/libmudflap.c/pass43-frag.c b/libmudflap/testsuite/libmudflap.c/pass43-frag.c new file mode 100644 index 000000000..4fec3306e --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass43-frag.c @@ -0,0 +1,11 @@ +void +foo () +{ +} + +int +main (int argc, char *argv[]) +{ + foo (); + return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass44-frag.c b/libmudflap/testsuite/libmudflap.c/pass44-frag.c new file mode 100644 index 000000000..338d6da63 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass44-frag.c @@ -0,0 +1,14 @@ +#include <stdio.h> + +void +foo () +{ + return; /* accept value-less return statement */ +} + +int +main (int argc, char *argv[]) +{ + foo (); + return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass45-frag.c b/libmudflap/testsuite/libmudflap.c/pass45-frag.c new file mode 100644 index 000000000..c6bfeb504 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass45-frag.c @@ -0,0 +1,31 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +extern void h (const char *p, const char *f); +int +main (void) +{ + h (0, "foo"); + return 0; +} + +void +h (const char *p, const char *f) +{ + size_t pl = p == NULL ? 0 : strlen (p); + size_t fl = strlen (f) + 1; + char a[pl + 1 + fl]; + char *cp = a; + char b[pl + 5 + fl * 2]; + char *cccp = b; + if (p != NULL) + { + cp = memcpy (cp, p, pl); + *cp++ = ':'; + } + memcpy (cp, f, fl); + strcpy (b, a); + puts (a); +} +/* { dg-output "foo" } */ diff --git a/libmudflap/testsuite/libmudflap.c/pass46-frag.c b/libmudflap/testsuite/libmudflap.c/pass46-frag.c new file mode 100644 index 000000000..904868af0 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass46-frag.c @@ -0,0 +1,18 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +int foo (int *u, int i) +{ + return u[i]; /* this dereference should not be instrumented */ +} + +int main () +{ + int *k = malloc (6); + int l = foo (k, 8); + int boo [8]; + int m = boo [l % 2 + 12]; /* should not be instrumented */ + return m & strlen (""); /* a fancy way of saying "0" */ +} +/* { dg-options "-fmudflap -fmudflapir -lmudflap" } */ diff --git a/libmudflap/testsuite/libmudflap.c/pass47-frag.c b/libmudflap/testsuite/libmudflap.c/pass47-frag.c new file mode 100644 index 000000000..9e4ac50ef --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass47-frag.c @@ -0,0 +1,10 @@ +#include <stdlib.h> +#include <ctype.h> + +int main () +{ + char* buf = "hello"; + return ! ((toupper (buf[0]) == 'H' && toupper ('z') == 'Z' && + tolower (buf[4]) == 'o' && tolower ('X') == 'x' && + isdigit (buf[3])) == 0 && isalnum ('4')); +} diff --git a/libmudflap/testsuite/libmudflap.c/pass48-frag.c b/libmudflap/testsuite/libmudflap.c/pass48-frag.c new file mode 100644 index 000000000..3059762a8 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass48-frag.c @@ -0,0 +1,11 @@ +void foo (int k) +{ + volatile int *b = & k; + *b = 5; +} + +int main () +{ + foo (5); + return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass49-frag.c b/libmudflap/testsuite/libmudflap.c/pass49-frag.c new file mode 100644 index 000000000..db7453079 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass49-frag.c @@ -0,0 +1,35 @@ +#include <stdlib.h> +#include <ctype.h> +#include <stdarg.h> + +int foo (int a, ...) +{ + va_list args; + char *a1; + int a2; + int k; + + va_start (args, a); + for (k = 0; k < a; k++) + { + if ((k % 2) == 0) + { + char *b = va_arg (args, char *); + printf ("%s", b); + } + else + { + int b = va_arg (args, int); + printf ("%d", b); + } + } + va_end (args); + return a; +} + +int main () +{ + foo (7, "hello ", 5, " ", 3, " world ", 9, "\n"); + return 0; +} +/* { dg-output "hello 5 3 world 9" } */ diff --git a/libmudflap/testsuite/libmudflap.c/pass5-frag.c b/libmudflap/testsuite/libmudflap.c/pass5-frag.c new file mode 100644 index 000000000..6d3408a4e --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass5-frag.c @@ -0,0 +1,11 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ +char foo [10]; +char bar [10]; +bar[4] = 'k'; /* touch memcpy source */ +memcpy(foo, bar, 10); +return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass50-frag.c b/libmudflap/testsuite/libmudflap.c/pass50-frag.c new file mode 100644 index 000000000..ac9ee0909 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass50-frag.c @@ -0,0 +1,29 @@ +#include <stdlib.h> + +struct a +{ + int a1[5]; + union + { + int b1[5]; + struct + { + int c1; + int c2; + } b2[4]; + } a2[8]; +}; + +int i1 = 5; +int i2 = 2; +int i3 = 6; +int i4 = 0; + +int +main () +{ + volatile struct a *k = calloc (1, sizeof (struct a)); + k->a2[i1].b1[i2] = k->a2[i3].b2[i4].c2; + free ((void *) k); + return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass51-frag.c b/libmudflap/testsuite/libmudflap.c/pass51-frag.c new file mode 100644 index 000000000..2780ffd72 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass51-frag.c @@ -0,0 +1,44 @@ +/* Test object-spanning accesses. This is most conveniently done with + mmap, thus the config.h specificity here. */ +#include "../config.h" + +#include <unistd.h> +#include <string.h> +#ifdef HAVE_SYS_MMAN_H +#include <sys/mman.h> +#endif + +int main () +{ +#ifndef MAP_ANONYMOUS +#define MAP_ANONYMOUS MAP_ANON +#endif +#ifndef MAP_FAILED +#define MAP_FAILED ((void *)-1) +#endif +#ifdef HAVE_MMAP + void *p; + unsigned pg = getpagesize (); + int rc; + + p = mmap (NULL, 4 * pg, PROT_READ|PROT_WRITE, + MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); + if (p == MAP_FAILED) + return 1; + + memset (p, 0, 4*pg); + rc = munmap (p, pg); + if (rc < 0) return 1; + memset (p+pg, 0, 3*pg); + rc = munmap (p+pg, pg); + if (rc < 0) return 1; + memset (p+2*pg, 0, 2*pg); + rc = munmap (p+2*pg, pg); + if (rc < 0) return 1; + memset (p+3*pg, 0, pg); + rc = munmap (p+3*pg, pg); + if (rc < 0) return 1; +#endif + + return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass52-frag.c b/libmudflap/testsuite/libmudflap.c/pass52-frag.c new file mode 100644 index 000000000..7ff9d577b --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass52-frag.c @@ -0,0 +1,36 @@ +#include <stdio.h> + + +void writestuff (FILE *f) +{ + fprintf (f, "hello world\n"); + fputc ('y', f); + putc ('e', f); +} + +void readstuff (FILE *f) +{ + int c, d; + char stuff[100], *s; + c = fgetc (f); + ungetc (c, f); + d = fgetc (f); + s = fgets (stuff, sizeof(stuff), f); +} + +int main () +{ + FILE *f; + writestuff (stdout); + writestuff (stderr); + f = fopen ("/dev/null", "w"); + writestuff (f); + fclose (f); + f = fopen ("/dev/zero", "r"); + readstuff (f); + f = freopen ("/dev/null", "w", f); + writestuff (f); + fclose (f); + + return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass53-frag.c b/libmudflap/testsuite/libmudflap.c/pass53-frag.c new file mode 100644 index 000000000..6afb2931e --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass53-frag.c @@ -0,0 +1,41 @@ +int foo1 () +{ + union { int l; char c[sizeof (int)]; } k1; + char *m; + k1.l = 0; + /* This test variant triggers ADDR_EXPR of k explicitly in order to + ensure it's registered with the runtime. */ + m = k1.c; + k1.c [sizeof (int)-1] = m[sizeof (int)-2]; +} + +int foo2 () +{ + union { int l; char c[sizeof (int)]; } k2; + k2.l = 0; + /* Since this access is known-in-range, k need not be registered + with the runtime, but then this access better not be instrumented + either. */ + k2.c [sizeof (int)-1] ++; + return k2.l; +} + +int foo3idx = sizeof (int)-1; + +int foo3 () +{ + union { int l; char c[sizeof (int)]; } k3; + k3.l = 0; + /* NB this test uses foo3idx, an extern variable, to defeat mudflap + known-in-range-index optimizations. */ + k3.c [foo3idx] ++; + return k3.l; +} + +int main () +{ + foo1 (); + foo2 (); + foo3 (); + return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass54-frag.c b/libmudflap/testsuite/libmudflap.c/pass54-frag.c new file mode 100644 index 000000000..5eebb4515 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass54-frag.c @@ -0,0 +1,34 @@ +struct k +{ + struct { + int b; + int c; + } a; +}; + +static struct k l; +static struct k m; + +void foo () +{ + /* This should not be instrumented. */ + l.a.b = 5; +} + +void bar () +{ + /* This should not be instrumented. */ + m.a.b = 5; +} + +int main () +{ + /* Force TREE_ADDRESSABLE on "l" only. */ + volatile int *k = & l.a.c; + *k = 8; + __mf_set_options ("-mode-violate"); + foo (); + bar (); + __mf_set_options ("-mode-check"); + return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass56-frag.c b/libmudflap/testsuite/libmudflap.c/pass56-frag.c new file mode 100644 index 000000000..e22fc8dbf --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass56-frag.c @@ -0,0 +1,14 @@ +#include <stdio.h> +#include <stdlib.h> + +int main () +{ + volatile int *k = (int *) malloc (sizeof (int)); + volatile int l; + if (k == NULL) abort (); + *k = 5; + free ((void *) k); + __mf_set_options ("-ignore-reads"); + l = *k; /* Should not trip, even though memory region just freed. */ + return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass6-frag.c b/libmudflap/testsuite/libmudflap.c/pass6-frag.c new file mode 100644 index 000000000..9b07fe2de --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass6-frag.c @@ -0,0 +1,14 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ +char *foo; +char *bar; + +foo = (char *)malloc (10); +bar = (char *)malloc (10); +bar[2] = 'z'; /* touch memcpy source */ +memcpy(foo, bar, 10); +return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass62-frag.c b/libmudflap/testsuite/libmudflap.c/pass62-frag.c new file mode 100644 index 000000000..8e64b2b0e --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass62-frag.c @@ -0,0 +1,13 @@ +/* PR tree-optimization/34618 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -fmudflap" } */ + +int a[16]; + +void +foo () +{ + int i; + for (i = 0; i < 16; i++) + a[i] = i; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass63-frag.c b/libmudflap/testsuite/libmudflap.c/pass63-frag.c new file mode 100644 index 000000000..a5ad8f26b --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass63-frag.c @@ -0,0 +1,6 @@ +/* Check -Wno-mudflap flag */ +/* { dg-do compile } */ +/* { dg-options "-fmudflap -Wno-mudflap" } */ + +extern char x[]; +int main() { return x[3]; } /* { dg-bogus "mudflap cannot track" } */ diff --git a/libmudflap/testsuite/libmudflap.c/pass64-frag.c b/libmudflap/testsuite/libmudflap.c/pass64-frag.c new file mode 100644 index 000000000..856eec0fa --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass64-frag.c @@ -0,0 +1,38 @@ +/* PR libmudflap/36397 */ +/* { dg-do run } */ +/* { dg-options "-O -fmudflap -fno-strict-aliasing -lmudflap" } */ + +struct A +{ + int a[2]; +}; + +long long int x; + +int __attribute__ ((noinline)) +baz (long long int *x) +{ + return *x; +} + +int __attribute__ ((noinline)) +foo (int i) +{ + if (i > 10) + return baz (&x); + return ((struct A *) &x)->a[i]; +} + +int +main (void) +{ + if (sizeof (long long) == 2 * sizeof (int) + && sizeof (long long) == sizeof (struct A)) + { + struct A a = { .a[0] = 10, .a[1] = 20 }; + __builtin_memcpy (&x, &a, sizeof (x)); + if (foo (0) != 10 || foo (1) != 20) + __builtin_abort (); + } + return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass67-frag.c b/libmudflap/testsuite/libmudflap.c/pass67-frag.c new file mode 100644 index 000000000..0c2f81a17 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass67-frag.c @@ -0,0 +1,14 @@ +/* PR middle-end/35314 */ +/* { dg-do compile } */ +/* { dg-options "-fmudflap" } */ + +#include <setjmp.h> + +jmp_buf buf; + +void +foo (volatile char *p) +{ + if (__builtin_setjmp (buf)) + *p; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass7-frag.c b/libmudflap/testsuite/libmudflap.c/pass7-frag.c new file mode 100644 index 000000000..36197339e --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass7-frag.c @@ -0,0 +1,13 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ +char *foo; +char *bar; +foo = (char *)malloc (10); +bar = (char *)malloc (10); +bar[2] = 'z'; /* touch memcpy source */ +memcpy(foo+1, bar+1, 9); +return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass8-frag.c b/libmudflap/testsuite/libmudflap.c/pass8-frag.c new file mode 100644 index 000000000..6be4e93f0 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass8-frag.c @@ -0,0 +1,16 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ +char *foo; +char *bar; +foo = (char *)malloc (10); +bar = (char *)malloc (10); + +free(bar); +bar = (char *)malloc (10); +bar[6] = 'k'; /* touch memcpy source */ +memcpy(foo, bar, 10); +return 0; +} diff --git a/libmudflap/testsuite/libmudflap.c/pass9-frag.c b/libmudflap/testsuite/libmudflap.c/pass9-frag.c new file mode 100644 index 000000000..9186e062f --- /dev/null +++ b/libmudflap/testsuite/libmudflap.c/pass9-frag.c @@ -0,0 +1,16 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int main () +{ +char *foo; +char *bar; +foo = (char *)malloc (10); +bar = (char *)malloc (10); + +free(foo); +foo = (char *)malloc (10); +bar[3] = 'w'; /* touch memcpy source */ +memcpy(foo, bar, 10); +return 0; +} diff --git a/libmudflap/testsuite/libmudflap.cth/cthfrags.exp b/libmudflap/testsuite/libmudflap.cth/cthfrags.exp new file mode 100644 index 000000000..e5a7de843 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.cth/cthfrags.exp @@ -0,0 +1,25 @@ +global MUDFLAP_FLAGS +set MUDFLAP_FLAGS [list {} {-static -DSTATIC} {-O2} {-O3}] + +libmudflap-init c + +dg-init + +global srcdir +foreach flags $MUDFLAP_FLAGS { + foreach srcfile [lsort [glob -nocomplain ${srcdir}/libmudflap.cth/*.c]] { + set bsrc [file tail $srcfile] + setenv MUDFLAP_OPTIONS "-viol-segv" + if {$libmudflapth} then { + # --noinhibit-exec works around a ld problem that causes + # "Dwarf Error: Invalid or unhandled FORM value: 14" + # to fail builds unnecessarily. + dg-runtest $srcfile $flags "-fmudflapth -lmudflapth -lpthread -Wl,--noinhibit-exec" + } else { + if {$flags != ""} {set f " ($flags)"} {set f ""} + untested "libmudflap.cth/$bsrc$f" + } + } +} + +dg-finish diff --git a/libmudflap/testsuite/libmudflap.cth/pass37-frag.c b/libmudflap/testsuite/libmudflap.cth/pass37-frag.c new file mode 100644 index 000000000..877803c1e --- /dev/null +++ b/libmudflap/testsuite/libmudflap.cth/pass37-frag.c @@ -0,0 +1,58 @@ +#include <stdlib.h> +#include <stdio.h> +#include <pthread.h> +#include <sched.h> + +static void * +func (void *p) +{ + int *counter = (int *) p; + unsigned i; + + for (i=0; i<100; i++) + { + (*counter) ++; + { + int array[17]; + unsigned x = i % (sizeof(array)/sizeof(array[0])); + /* VRP could prove that x is within [0,16], but until then, the + following access will ensure that array[] is registered to + libmudflap. */ + array[x] = i; + } + sched_yield (); /* sleep (1); */ + } + + return (NULL); +} + + +int main () +{ + int rc; + unsigned i; + enum foo { NT=10 }; + pthread_t threads[NT]; + int counts[NT]; + + + for (i=0; i<NT; i++) + { + counts[i] = 0; + rc = pthread_create (& threads[i], NULL, func, (void *) & counts[i]); + if (rc) abort(); + } + + for (i=0; i<NT; i++) + { + rc = pthread_join (threads[i], NULL); + if (rc) abort(); + printf ("%d%s", counts[i], (i==NT-1) ? "\n" : " "); + } + + return 0; +} + +/* { dg-output "100 100 100 100 100 100 100 100 100 100" } */ +/* { dg-repetitions 20 } */ +/* { dg-timeout 10 } */ diff --git a/libmudflap/testsuite/libmudflap.cth/pass39-frag.c b/libmudflap/testsuite/libmudflap.cth/pass39-frag.c new file mode 100644 index 000000000..cd3eb5abd --- /dev/null +++ b/libmudflap/testsuite/libmudflap.cth/pass39-frag.c @@ -0,0 +1,57 @@ +#include <stdlib.h> +#include <stdio.h> +#include <pthread.h> +#include <sched.h> +#include <assert.h> + +static void * +func (void *p) +{ + int *counter = (int *) p; + unsigned i; + enum { numarrays = 100, numels = 17 }; + char *arrays [numarrays]; + + for (i=0; i<numarrays; i++) + { + (*counter) ++; + unsigned x = i % numels; + arrays[i] = calloc (numels, sizeof(arrays[i][0])); + assert (arrays[i] != NULL); + arrays[i][x] = i; + free (arrays[i]); + sched_yield (); /* sleep (1); */ + } + + return (NULL); +} + + +int main () +{ + int rc; + unsigned i; + enum foo { NT=10 }; + pthread_t threads[NT]; + int counts[NT]; + + + for (i=0; i<NT; i++) + { + counts[i] = 0; + rc = pthread_create (& threads[i], NULL, func, (void *) & counts[i]); + if (rc) abort(); + } + + for (i=0; i<NT; i++) + { + rc = pthread_join (threads[i], NULL); + if (rc) abort(); + printf ("%d%s", counts[i], (i==NT-1) ? "\n" : " "); + } + + return 0; +} +/* { dg-output "100 100 100 100 100 100 100 100 100 100" } */ +/* { dg-repetitions 20 } */ +/* { dg-timeout 10 } */ diff --git a/libmudflap/testsuite/libmudflap.cth/pass40-frag.c b/libmudflap/testsuite/libmudflap.cth/pass40-frag.c new file mode 100644 index 000000000..007cb1607 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.cth/pass40-frag.c @@ -0,0 +1,59 @@ +#include <stdlib.h> +#include <stdio.h> +#include <pthread.h> + +static void * +func (void *p) +{ + return (NULL); +} + +static void +test (void) +{ + int rc; + pthread_attr_t my_pthread_attr; + pthread_t h; + long i; + + rc = pthread_attr_init (&my_pthread_attr); + + for (i = 1; i <= 10000; ++i) { + if (i%100 == 0) fprintf (stderr, "%i ", i); + if (i%1000 == 0) fprintf (stderr, "\n"); +#ifndef STATIC + /* Some glibc versions don't like static multithreaded programs doing this. */ + if (i==5000) __mf_set_options ("-thread-stack=192"); +#endif + rc = pthread_create (&h, &my_pthread_attr, + func, NULL); + if (rc) + break; + + rc = pthread_join (h, NULL); + if (rc) + break; + } + + rc = pthread_attr_destroy (&my_pthread_attr); +} + +int main () +{ + test (); + + return (0); +} + +/* { dg-timeout 30 } */ +/* { dg-output "100 200 300 400 500 600 700 800 900 1000 \n" } */ +/* { dg-output "1100 1200 1300 1400 1500 1600 1700 1800 1900 2000 \n" } */ +/* { dg-output "2100 2200 2300 2400 2500 2600 2700 2800 2900 3000 \n" } */ +/* { dg-output "3100 3200 3300 3400 3500 3600 3700 3800 3900 4000 \n" } */ +/* { dg-output "4100 4200 4300 4400 4500 4600 4700 4800 4900 5000 \n" } */ +/* { dg-output "5100 5200 5300 5400 5500 5600 5700 5800 5900 6000 \n" } */ +/* { dg-output "6100 6200 6300 6400 6500 6600 6700 6800 6900 7000 \n" } */ +/* { dg-output "7100 7200 7300 7400 7500 7600 7700 7800 7900 8000 \n" } */ +/* { dg-output "8100 8200 8300 8400 8500 8600 8700 8800 8900 9000 \n" } */ +/* { dg-output "9100 9200 9300 9400 9500 9600 9700 9800 9900 10000 \n" } */ + diff --git a/libmudflap/testsuite/libmudflap.cth/pass59-frag.c b/libmudflap/testsuite/libmudflap.cth/pass59-frag.c new file mode 100644 index 000000000..490130677 --- /dev/null +++ b/libmudflap/testsuite/libmudflap.cth/pass59-frag.c @@ -0,0 +1,39 @@ +#include <stdio.h> +#include <pthread.h> + +/* PR 28578 */ + +void* test_thread(void* arg) +{ + printf("Hello from thread!\n"); + pthread_exit(NULL); + return 0; +} + +int main() +{ + pthread_t thread; + void *arg = NULL; + pthread_create(&thread, NULL, test_thread, arg); + pthread_join(thread, NULL); + pthread_exit(NULL); + return 0; +} + +/* { dg-output "Hello from thread!\n" } */ + +#if 0 + +/* Even this test case replicates the problem. However, when built in + static mode, it blows up during __mf_init (?!?!?!) with a + pthread_mutex_lock deadlock error. */ + +#include <stdio.h> +#include <pthread.h> + +int main () +{ + pthread_exit(NULL); + return 0; +} +#endif diff --git a/libmudflap/testsuite/mfconfig.exp.in b/libmudflap/testsuite/mfconfig.exp.in new file mode 100644 index 000000000..bed16542c --- /dev/null +++ b/libmudflap/testsuite/mfconfig.exp.in @@ -0,0 +1,4 @@ +global mfconfig_libs +set mfconfig_libs "@LIBS@" +global libmudflapth +set libmudflapth "@build_libmudflapth@" |