public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [tree-ssa mudflap] more on initialization checking
@ 2003-03-10 22:29 Frank Ch. Eigler
  0 siblings, 0 replies; only message in thread
From: Frank Ch. Eigler @ 2003-03-10 22:29 UTC (permalink / raw)
  To: gcc-patches

Hi -

Checking for uninitialized reads is more complex than I had
expected.  The attached patch further limits the scope of
what libmudflap attempts to catch, and adds some test cases
that subtly point out problems.  There are also some minor
cleanups and build tweaks.

- FChE


[gcc]
2003-03-10  Frank Ch. Eigler  <fche@redhat.com>

	* tree-mudflap.c (mx_xfn_indirect_ref): Allow unfolded "& ptr->field"
	constructs to pass uninstrumented.  Remove TREE_ADDRESSABLE settings.
	Keep array accesses to non-ADDRESSABLE objects uninstrumented.  Update
	__MF_TYPE_* constants for __mf_register calls.

[libmudflap]
2003-03-10  Frank Ch. Eigler  <fche@redhat.com>

	* Makefile.am: Reorganize hook file building.  Add auto dependencies.
	* configure.in: Tweak generation of mf-runtime.h.
	* mf-runtime.h.in: Add new __MF_TYPE_HEAP_I.
	* mf-hooks.c (*): Adapt to initialized-heap object type.
	* mf-impl.h: Tweak cemetary boundaries.
	* mf-runtime.c (__mf_check): Adapt to new initialized-heap object
	type.
	(__mf_insert_new_object, __mf_register, __mf_unregister): Ditto.
	(__mf_describe_object, __mf_report_leaks, __mf_violation): Ditto.
	* testsuite/lib/libmudflap.exp (includes): Include build tree.
	* testsuite/libmudflap.c/pass{26,5}: Further adapt to initialization
	checking.
	* testsuite/.../fail{25,26}-frag.c: New tests.
	* testsuite/.../pass{32,33,34,35}-frag.c: New tests.
	* Makefile.in, configure: Regenerated.



Index: tree-mudflap.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-mudflap.c,v
retrieving revision 1.1.2.37
diff -u -p -r1.1.2.37 tree-mudflap.c
--- tree-mudflap.c	28 Feb 2003 20:00:43 -0000	1.1.2.37
+++ tree-mudflap.c	10 Mar 2003 21:09:16 -0000
@@ -768,6 +768,21 @@ mx_xfn_indirect_ref (t, continue_p, data
       ; /* Continue traversal.  */
       break;
 
+      /* Catch unfolded "& ptr->field" constructs that come from the
+	 C++ front-end. */
+    case ADDR_EXPR:
+      {
+	tree arg = TREE_OPERAND (*t, 0);
+	if (TREE_CODE (arg) == COMPONENT_REF
+	    && TREE_CODE (TREE_OPERAND (arg, 0)) == INDIRECT_REF)
+	  {
+	    mx_flag (TREE_OPERAND (arg, 0));
+	    mx_flag (arg);
+	    mx_flag (*t);
+	  }
+      }
+      break;
+
     case ARRAY_REF:
       {
 	tree base_array, base_obj_type, base_ptr_type;
@@ -791,9 +806,6 @@ mx_xfn_indirect_ref (t, continue_p, data
 	base_obj_type = TREE_TYPE (TREE_TYPE (TREE_OPERAND (*t,0)));
 	base_ptr_type = build_pointer_type (base_obj_type);
 
-	TREE_ADDRESSABLE (base_array) = 1;
-
-
 	/* Maybe we have an expression like ptr->array[4].  In this
 	   case, we don't want to check (*ptr), since ptr+sizeof(*ptr)
 	   might be well beyond &(ptr->array[4]).  */
@@ -840,26 +852,18 @@ mx_xfn_indirect_ref (t, continue_p, data
 				     base_ptr_type,
 				     mx_flag (*t)));
 	walk_tree (& value_ptr, mf_mostly_copy_tree_r, NULL, NULL);
-	TREE_ADDRESSABLE (*t) = 1;
 
 	/* As an optimization, omit checking if the base object is
 	   known to be large enough.  Only certain kinds of
 	   declarations and indexes/sizes are trustworthy.  */
-	if (TREE_CODE (check_size) == INTEGER_CST && /* constant offset */
-	    TREE_CODE (base_array) == VAR_DECL && /* not a PARM_DECL */
-	    ! DECL_EXTERNAL (base_array) && /* has known size */
-	    TREE_CODE (TREE_TYPE (base_array)) == ARRAY_TYPE && /* an array */
-	    ((size_t) int_size_in_bytes (TREE_TYPE (base_array)) >= (size_t) TREE_INT_CST_LOW (check_size) &&
-	     TREE_INT_CST_HIGH (check_size) == 0)) /* offset within bounds */
+	if (TREE_CODE (check_size) == INTEGER_CST /* constant offset */
+	    && TREE_CODE (base_array) == VAR_DECL /* not a PARM_DECL */
+	    && ! DECL_EXTERNAL (base_array) /* has known size */
+	    && TREE_CODE (TREE_TYPE (base_array)) == ARRAY_TYPE /* an array */
+	    && ! TREE_ADDRESSABLE (base_array) /* ought not to be __mf_registered */
+	    && ((size_t) int_size_in_bytes (TREE_TYPE (base_array)) >= (size_t) TREE_INT_CST_LOW (check_size)
+	    && TREE_INT_CST_HIGH (check_size) == 0)) /* offset within bounds */
 	  {
-#if 0
-	    warning ("mudflap is omitting array bounds checks");
-	    fprintf (stderr, "  for expression: ");
-	    print_generic_expr (stderr, *t, 0);
-	    fprintf (stderr, " array-size=%u", int_size_in_bytes (TREE_TYPE (base_array)));
-	    fprintf (stderr, " check-size=%u", TREE_INT_CST_LOW (check_size));
-	    fprintf (stderr, "\n");
-#endif
 	    if (check_decls != NULL_TREE) abort();
 	    break;
 	  }
@@ -1026,7 +1030,7 @@ mx_register_decls (decl, compound_expr)
 	    build_function_call (mf_unregister_fndecl,
 				 unregister_fncall_params);
 
-	  /* (& VARIABLE, sizeof (VARIABLE), __MF_LIFETIME_STACK=2) */
+	  /* (& VARIABLE, sizeof (VARIABLE), __MF_TYPE_STACK) */
 	  tree variable_name = mf_varname_tree (decl);
 	  tree register_fncall_params =
 	    tree_cons (NULL_TREE,
@@ -1038,10 +1042,11 @@ mx_register_decls (decl, compound_expr)
 				  convert (size_type_node, 
 					   TYPE_SIZE_UNIT (TREE_TYPE (decl))),
 				  tree_cons (NULL_TREE,
-					     build_int_2 (2, 0),
+					     build_int_2 (3, 0), /* __MF_TYPE_STACK */
 					     tree_cons (NULL_TREE,
 							variable_name,
 							NULL_TREE))));
+
 	  /* __mf_register (...) */
 	  tree register_fncall =
 	    build_function_call (mf_register_fndecl,
@@ -1052,8 +1057,6 @@ mx_register_decls (decl, compound_expr)
 	  add_tree (unregister_fncall, & finally_stmts);
 	  
 	  mx_flag (decl);
-	  /* Hint to inhibit any fancy register optimizations on this variable. */
-	  TREE_ADDRESSABLE (decl) = 1;
 	}
 
       decl = TREE_CHAIN (decl);
@@ -1177,10 +1180,6 @@ mudflap_enqueue_decl (obj, label)
   */
   if (DECL_P (obj) && DECL_EXTERNAL (obj) && DECL_ARTIFICIAL (obj))
     {
-#if 0
-	warning_with_decl (obj, "ignoring system extern decl `%s'",
-			   IDENTIFIER_POINTER (DECL_NAME (obj)));
-#endif
       return;
     }
 
@@ -1199,7 +1198,7 @@ mudflap_enqueue_decl (obj, label)
       tree call_stmt =
 	mflang_register_call (label,
 			      size_in_bytes (TREE_TYPE (obj)),
-			      build_int_2 (3, 0), /* __MF_TYPE_STATIC */
+			      build_int_2 (4, 0), /* __MF_TYPE_STATIC */
 			      mf_varname_tree (obj));
 
       /* Link this call into the chain. */
@@ -1225,8 +1224,7 @@ mudflap_enqueue_decl (obj, label)
 	  found_p = 1;
       
       if (found_p)
-	warning_with_decl (obj, "mudflap cannot track lifetime of `%s'", 
-			   IDENTIFIER_POINTER (DECL_NAME (obj)));
+	warning ("mudflap cannot track lifetime of `%D'", obj);
       else
 	{
 	  VARRAY_PUSH_TREE (deferred_static_decls, obj);
@@ -1250,12 +1248,12 @@ mudflap_enqueue_constant (obj, label)
     (TREE_CODE (obj) == STRING_CST)
     ? mflang_register_call (label,
 			    build_int_2 (TREE_STRING_LENGTH (obj), 0),
-			    build_int_2 (3, 0), /* __MF_TYPE_STATIC */
+			    build_int_2 (4, 0), /* __MF_TYPE_STATIC */
 			    mx_flag (fix_string_type
 				     (build_string (15, "string literal"))))
     : mflang_register_call (label,
 			    size_in_bytes (TREE_TYPE (obj)),
-			    build_int_2 (3, 0), /* __MF_TYPE_STATIC */
+			    build_int_2 (4, 0), /* __MF_TYPE_STATIC */
 			    mx_flag (fix_string_type
 				     (build_string (9, "constant"))));
     



Index: Makefile.am
===================================================================
RCS file: /cvs/gcc/gcc/libmudflap/Attic/Makefile.am,v
retrieving revision 1.1.2.22
diff -u -p -r1.1.2.22 Makefile.am
--- Makefile.am	27 Feb 2003 15:23:23 -0000	1.1.2.22
+++ Makefile.am	10 Mar 2003 21:36:14 -0000
@@ -1,10 +1,10 @@
 ## Makefile for the toplevel directory of the mudflap library.
 ##
-## Copyright (C) 2002
+## Copyright (C) 2002, 2003
 ## Free Software Foundation, Inc.
 ##
 
-AUTOMAKE_OPTIONS = 1.3 cygnus
+AUTOMAKE_OPTIONS = 1.3 foreign
 MAINT_CHARSET = latin1
 SUBDIRS = testsuite
 
@@ -13,9 +13,9 @@ AM_CFLAGS = -ansi -Wall -O3 -g -freorder
 lib_LTLIBRARIES = libmudflap.la
 include_HEADERS = mf-runtime.h
 
-mf-runtime.o: mf-runtime.h mf-impl.h
-mf-hooks.o: mf-runtime.h mf-impl.h
-mf-heuristics.o: mf-runtime.h mf-impl.h
+mf-runtime.h: mf-runtime.h.in $(top_builddir)/config.status
+	cd $(top_builddir) \
+	  && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status
 
 libmudflap_la_SOURCES = \
 	mf-runtime.c \
@@ -58,14 +58,10 @@ HOOKOBJS = \
  munmap-hook.lo \
  alloca-hook.lo
 
-
-.NOTPARALLEL:
+#.NOTPARALLEL: # Otherwise the following loop will be executed in parallel!
 $(HOOKOBJS): mf-hooks.c mf-runtime.h mf-impl.h
-	set -e; \
-	for i in $(HOOKOBJS); do \
-	     hook=`basename $$i -hook.lo`; \
-	     $(LTCOMPILE) -DWRAP_$$hook -c $(srcdir)/mf-hooks.c -o $$i; \
-	done
+	hook=`basename $@ -hook.lo`; \
+	$(LTCOMPILE) -DWRAP_$$hook -c $(srcdir)/mf-hooks.c -o $@
 
 libmudflap_la_LDFLAGS = 
 libmudflap_la_LIBADD = $(HOOKOBJS)
Index: configure.in
===================================================================
RCS file: /cvs/gcc/gcc/libmudflap/Attic/configure.in,v
retrieving revision 1.1.2.8
diff -u -p -r1.1.2.8 configure.in
--- configure.in	26 Feb 2003 19:00:37 -0000	1.1.2.8
+++ configure.in	10 Mar 2003 21:36:14 -0000
@@ -37,12 +37,12 @@ else
 fi
 AC_SUBST(LIBMUDFLAP_PICFLAGS)
 
-AC_OUTPUT([testsuite/Makefile Makefile], [
+AC_OUTPUT([Makefile testsuite/Makefile], [
 (
  echo '#ifndef __MF_RUNTIME_H'
  echo '#define __MF_RUNTIME_H'
  egrep 'HAVE_(STDINT|UINTPTR)' < config.h
- cat $srcdir/mf-runtime.h.in
+ cat $top_srcdir/mf-runtime.h.in
  echo '#endif'
 ) > mf-runtime.h
 echo creating mf-runtime.h
Index: mf-hooks.c
===================================================================
RCS file: /cvs/gcc/gcc/libmudflap/Attic/mf-hooks.c,v
retrieving revision 1.1.2.25
diff -u -p -r1.1.2.25 mf-hooks.c
--- mf-hooks.c	5 Mar 2003 19:08:04 -0000	1.1.2.25
+++ mf-hooks.c	10 Mar 2003 21:36:14 -0000
@@ -82,8 +82,7 @@ WRAPPER(void *, malloc, size_t c)
   if (LIKELY(result))
     {
       result += __mf_opts.crumple_zone;
-      __mf_register (result, c,
-		     __MF_TYPE_HEAP, "malloc region");
+      __mf_register (result, c, __MF_TYPE_HEAP, "malloc region");
     }
 
   return result;
@@ -115,8 +114,7 @@ WRAPPER(void *, calloc, size_t c, size_t
   if (LIKELY(result))
     {
       result += __mf_opts.crumple_zone;
-      __mf_register (result, c*n, /* XXX: CLAMPMUL */
-		     __MF_TYPE_HEAP, "calloc region");
+      __mf_register (result, c*n /* XXX: clamp */, __MF_TYPE_HEAP_I, "calloc region");
     }
   
   return result;
@@ -155,8 +153,7 @@ WRAPPER(void *, realloc, void *buf, size
   if (LIKELY(result))
     {
       result += __mf_opts.crumple_zone;
-      __mf_register (result, c, 
-		     __MF_TYPE_HEAP, "realloc region");
+      __mf_register (result, c, __MF_TYPE_HEAP_I, "realloc region");
     }
 
   /* Restore previous setting.  */
@@ -293,7 +290,7 @@ WRAPPER(void *, mmap, 
 	  /* XXX: Unaccassed HEAP pages are reported as leaks.  Is this
 	     appropriate for unaccessed mmap pages? */
 	  __mf_register ((void *) CLAMPADD (base, offset), ps,
-			 __MF_TYPE_HEAP, "mmap page");
+			 __MF_TYPE_HEAP_I, "mmap page");
 	}
     }
 
@@ -620,8 +617,7 @@ WRAPPER2(char *, strdup, const char *s)
   memcpy (result, s, n);
   result[n] = '\0';
 
-  __mf_register (result, CLAMPADD(n,1), 
-		 __MF_TYPE_HEAP, "strdup region");
+  __mf_register (result, CLAMPADD(n,1), __MF_TYPE_HEAP_I, "strdup region");
   return result;
 }
 #endif
@@ -647,7 +643,7 @@ WRAPPER2(char *, strndup, const char *s,
   memcpy (result, s, n);
   result[n] = '\0';
 
-  __mf_register (result, CLAMPADD(n,1), __MF_TYPE_HEAP, "strndup region");
+  __mf_register (result, CLAMPADD(n,1), __MF_TYPE_HEAP_I, "strndup region");
   return result;
 }
 #endif
Index: mf-impl.h
===================================================================
RCS file: /cvs/gcc/gcc/libmudflap/Attic/mf-impl.h,v
retrieving revision 1.1.2.13
diff -u -p -r1.1.2.13 mf-impl.h
--- mf-impl.h	5 Mar 2003 19:08:04 -0000	1.1.2.13
+++ mf-impl.h	10 Mar 2003 21:36:14 -0000
@@ -20,7 +20,7 @@
 
 /* Private definitions related to mf-runtime.h  */
 
-#define __MF_TYPE_MAX_CEM  3  /* the largest type stored in the cemetary */
+#define __MF_TYPE_MAX_CEM  __MF_TYPE_STACK  /* largest type# for the cemetary */
 #define __MF_TYPE_MAX __MF_TYPE_GUESS
 
 
Index: mf-runtime.c
===================================================================
RCS file: /cvs/gcc/gcc/libmudflap/Attic/mf-runtime.c,v
retrieving revision 1.1.2.27
diff -u -p -r1.1.2.27 mf-runtime.c
--- mf-runtime.c	5 Mar 2003 20:21:19 -0000	1.1.2.27
+++ mf-runtime.c	10 Mar 2003 21:36:15 -0000
@@ -637,9 +637,13 @@ void __mf_check (void *ptr, size_t sz, i
 		      judgement = -1;
 		    else if (UNLIKELY (obj->watching_p))
 		      judgement = -2; /* trigger VIOL_WATCH */
-		    else if (UNLIKELY (__mf_opts.check_initialization &&
-				       type == __MF_CHECK_READ &&
-				       obj->write_count == 0))
+		    else if (UNLIKELY (__mf_opts.check_initialization
+				       /* reading */
+				       && type == __MF_CHECK_READ
+				       /* not written */
+				       && obj->write_count == 0
+				       /* uninitialized (heap) */
+				       && obj->type == __MF_TYPE_HEAP))
 		      judgement = -1;
 		    else
 		      {
@@ -724,8 +728,14 @@ void __mf_check (void *ptr, size_t sz, i
 			unsigned written_count = 0;
 
 			for (i=0; i<obj_count; i++)
-			  if (all_ovr_objs[i]->data.write_count)
-			    written_count ++;
+			  {
+			    __mf_object_t *obj = & all_ovr_objs[i]->data;
+
+			    if (obj->write_count
+				|| obj->type == __MF_TYPE_HEAP_I
+				|| obj->type == __MF_TYPE_GUESS)
+			      written_count ++;
+			  }
 			
 			/* Check for ALL pieces having been written-to.
 			   XXX: should this be ANY instead?  */
@@ -806,13 +816,9 @@ __mf_insert_new_object (uintptr_t low, u
   new_obj->data.type = type;
   new_obj->data.name = name;
   new_obj->data.alloc_pc = pc;
-  if (type == __MF_TYPE_STATIC || 
-      type == __MF_TYPE_STACK || /* XXX */
-      type == __MF_TYPE_GUESS)
-    new_obj->data.write_count = 1; /* assume initialized */
   gettimeofday (& new_obj->data.alloc_time, NULL);
   
-  if (__mf_opts.backtrace > 0 && type == __MF_TYPE_HEAP)
+  if (__mf_opts.backtrace > 0 && (type == __MF_TYPE_HEAP || type == __MF_TYPE_HEAP_I))
     new_obj->data.alloc_backtrace_size = 
       __mf_backtrace (& new_obj->data.alloc_backtrace,
 		      (void *) pc, 2);
@@ -857,7 +863,7 @@ __mf_register (void *ptr, size_t sz, int
 {
   /* if (UNLIKELY (!(__mf_state == active || __mf_state == starting))) return; */
 
-  TRACE ("mf: register ptr=%08lx size=%lu type=%d name='%s'\n", ptr, sz, 
+  TRACE ("mf: register ptr=%08lx size=%lu type=%x name='%s'\n", ptr, sz, 
 	type, name ? name : "");
 
   if (__mf_opts.collect_stats)
@@ -909,10 +915,10 @@ __mf_register (void *ptr, size_t sz, int
 	    /* Quietly accept a single duplicate registration for
 	       static objects, since these may come from distinct
 	       compilation units.  */
-	    if (type == __MF_TYPE_STATIC &&
-		ovr_obj->data.type == __MF_TYPE_STATIC &&
-		ovr_obj->data.low == low &&
-		ovr_obj->data.high == high)
+	    if (type == __MF_TYPE_STATIC
+		&& ovr_obj->data.type == __MF_TYPE_STATIC
+		&& ovr_obj->data.low == low
+		&& ovr_obj->data.high == high)
 	      {
 		/* do nothing */
 		VERBOSE_TRACE ("mf: duplicate static reg %08lx-%08lx `%s'\n", 
@@ -1098,8 +1104,9 @@ __mf_unregister (void *ptr, size_t sz)
 	__mf_uncache_object (& old_obj->data);
 
 	/* Wipe buffer contents if desired.  */
-	if ((__mf_opts.wipe_stack && old_obj->data.type == __MF_TYPE_STACK) ||
-	    (__mf_opts.wipe_heap && old_obj->data.type == __MF_TYPE_HEAP))
+	if ((__mf_opts.wipe_stack && old_obj->data.type == __MF_TYPE_STACK)
+	    || (__mf_opts.wipe_heap && (old_obj->data.type == __MF_TYPE_HEAP 
+					|| old_obj->data.type == __MF_TYPE_HEAP_I)))
 	  {
 	    memset ((void *) old_obj->data.low,
 		    0,
@@ -1147,7 +1154,8 @@ __mf_unregister (void *ptr, size_t sz)
 	if (__mf_opts.print_leaks)
 	  {
 	    if ((old_obj->data.read_count + old_obj->data.write_count) == 0 &&
-		old_obj->data.type == __MF_TYPE_HEAP)
+		(old_obj->data.type == __MF_TYPE_HEAP 
+		 || old_obj->data.type == __MF_TYPE_HEAP_I))
 	      {
 		fprintf (stderr, 
 			 "*******\n"
@@ -1639,11 +1647,13 @@ __mf_describe_object (__mf_object_t *obj
 	   "alloc time=%lu.%06lu pc=%08lx\n",
 	   (uintptr_t) obj, (obj->name ? obj->name : ""), 
 	   obj->low, obj->high, (obj->high - obj->low + 1),
-	   (obj->type == __MF_TYPE_HEAP ? "heap" :
+	   (obj->type == __MF_TYPE_NOACCESS ? "no-access" :
+	    obj->type == __MF_TYPE_HEAP ? "heap" :
+	    obj->type == __MF_TYPE_HEAP_I ? "heap-init" :
 	    obj->type == __MF_TYPE_STACK ? "stack" :
 	    obj->type == __MF_TYPE_STATIC ? "static" :
 	    obj->type == __MF_TYPE_GUESS ? "guess" :
-	    "no-access"),
+	    "unknown"),
 	   obj->read_count, obj->write_count, obj->liveness, obj->watching_p,
 	   obj->alloc_time.tv_sec, obj->alloc_time.tv_usec, obj->alloc_pc);
 
@@ -1681,7 +1691,8 @@ __mf_report_leaks (__mf_object_tree_t *n
 
   /* Inorder traversal. */
   __mf_report_leaks (node->left);
-  if (node->data.type == __MF_TYPE_HEAP)
+  if (node->data.type == __MF_TYPE_HEAP
+      || node->data.type == __MF_TYPE_HEAP_I)
     {
       count ++;
       fprintf (stderr, "Leaked object %u:\n", count);
@@ -1847,7 +1858,7 @@ __mf_backtrace (char ***symbols, void *g
     for (i = 0; i < remaining_size; i++)
       {
 	pointers[i] = chars;
-	sprintf (chars, "[%08lx]", pc_array [omitted_size + i]);
+	sprintf (chars, "[0x%08lx]", pc_array [omitted_size + i]);
 	chars = chars + perline;
       }
     *symbols = pointers;
@@ -1896,8 +1907,7 @@ __mf_violation (void *ptr, size_t sz, ui
 	      (type == __MF_VIOL_WRITE) ? "check/write" :
 	      (type == __MF_VIOL_REGISTER) ? "register" :
 	      (type == __MF_VIOL_UNREGISTER) ? "unregister" :
-	      (type == __MF_VIOL_WATCH) ? "watch" :
-	      "unknown"),
+	      (type == __MF_VIOL_WATCH) ? "watch" : "unknown"),
 	     now.tv_sec, now.tv_usec, 
 	     ptr, sz, pc,
 	     (location != NULL ? " location=`" : ""),
Index: mf-runtime.h.in
===================================================================
RCS file: /cvs/gcc/gcc/libmudflap/Attic/mf-runtime.h.in,v
retrieving revision 1.1.2.8
diff -u -p -r1.1.2.8 mf-runtime.h.in
--- mf-runtime.h.in	5 Mar 2003 19:08:05 -0000	1.1.2.8
+++ mf-runtime.h.in	10 Mar 2003 21:36:15 -0000
@@ -35,9 +35,10 @@ extern unsigned char __mf_lc_shift;
 
 #define __MF_TYPE_NOACCESS 0
 #define __MF_TYPE_HEAP 1
-#define __MF_TYPE_STACK 2
-#define __MF_TYPE_STATIC 3
-#define __MF_TYPE_GUESS 4
+#define __MF_TYPE_HEAP_I 2
+#define __MF_TYPE_STACK 3
+#define __MF_TYPE_STATIC 4
+#define __MF_TYPE_GUESS 5
 
 
 /* The public mudflap API */
Index: testsuite/lib/libmudflap.exp
===================================================================
RCS file: /cvs/gcc/gcc/libmudflap/testsuite/lib/Attic/libmudflap.exp,v
retrieving revision 1.1.2.1
diff -u -p -r1.1.2.1 libmudflap.exp
--- testsuite/lib/libmudflap.exp	26 Feb 2003 19:00:37 -0000	1.1.2.1
+++ testsuite/lib/libmudflap.exp	10 Mar 2003 21:36:15 -0000
@@ -71,7 +71,7 @@ proc libmudflap-init { compiler } {
     set cxx $compiler
     set libs "-L../.libs -L../../libstdc++-v3/src/.libs -L../../../gcc"
     set cxxflags "-ggdb3 -DDEBUG_ASSERT"
-    set includes "-I${srcdir}"
+    set includes "-I${srcdir} -I.."
 
     verbose "ld_library_path=$ld_library_path"
     setenv  LD_LIBRARY_PATH     $ld_library_path
Index: testsuite/libmudflap.c/fail25-frag.c
===================================================================
RCS file: testsuite/libmudflap.c/fail25-frag.c
diff -N testsuite/libmudflap.c/fail25-frag.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/libmudflap.c/fail25-frag.c	10 Mar 2003 21:36:15 -0000
@@ -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 (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 *-*-* } } */
Index: testsuite/libmudflap.c/fail26-frag.c
===================================================================
RCS file: testsuite/libmudflap.c/fail26-frag.c
diff -N testsuite/libmudflap.c/fail26-frag.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/libmudflap.c/fail26-frag.c	10 Mar 2003 21:36:15 -0000
@@ -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 *-*-* } } */
Index: testsuite/libmudflap.c/pass26-frag.c
===================================================================
RCS file: /cvs/gcc/gcc/libmudflap/testsuite/libmudflap.c/Attic/pass26-frag.c,v
retrieving revision 1.1.2.1
diff -u -p -r1.1.2.1 pass26-frag.c
--- testsuite/libmudflap.c/pass26-frag.c	26 Feb 2003 19:00:38 -0000	1.1.2.1
+++ testsuite/libmudflap.c/pass26-frag.c	10 Mar 2003 21:36:15 -0000
@@ -5,7 +5,7 @@ int main ()
 {
 int *p;
 
-__mf_set_options ("-wipe-stack");
+__mf_set_options ("-wipe-stack -no-check-initialization");
 
 {
   int array [10];
Index: testsuite/libmudflap.c/pass32-frag.c
===================================================================
RCS file: testsuite/libmudflap.c/pass32-frag.c
diff -N testsuite/libmudflap.c/pass32-frag.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/libmudflap.c/pass32-frag.c	10 Mar 2003 21:36:15 -0000
@@ -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)(uintptr_t) n); /* use the pointer value */
+return 0;
+}
Index: testsuite/libmudflap.c/pass33-frag.c
===================================================================
RCS file: testsuite/libmudflap.c/pass33-frag.c
diff -N testsuite/libmudflap.c/pass33-frag.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/libmudflap.c/pass33-frag.c	10 Mar 2003 21:36:15 -0000
@@ -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;
+}
Index: testsuite/libmudflap.c/pass34-frag.c
===================================================================
RCS file: testsuite/libmudflap.c/pass34-frag.c
diff -N testsuite/libmudflap.c/pass34-frag.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/libmudflap.c/pass34-frag.c	10 Mar 2003 21:36:15 -0000
@@ -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;
+}
Index: testsuite/libmudflap.c/pass35-frag.c
===================================================================
RCS file: testsuite/libmudflap.c/pass35-frag.c
diff -N testsuite/libmudflap.c/pass35-frag.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/libmudflap.c/pass35-frag.c	10 Mar 2003 21:36:15 -0000
@@ -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 lifetime of `end'" "cannot track lifetime" { target *-*-* } 0 } */
+
+int main ()
+{
+/* dummy register */
+__mf_register ((void *) end, 1, __MF_TYPE_GUESS, "end");
+char z = end[0];
+return z & 0;
+}
Index: testsuite/libmudflap.c/pass5-frag.c
===================================================================
RCS file: /cvs/gcc/gcc/libmudflap/testsuite/libmudflap.c/Attic/pass5-frag.c,v
retrieving revision 1.1.2.1
diff -u -p -r1.1.2.1 pass5-frag.c
--- testsuite/libmudflap.c/pass5-frag.c	26 Feb 2003 19:00:38 -0000	1.1.2.1
+++ testsuite/libmudflap.c/pass5-frag.c	10 Mar 2003 21:36:15 -0000
@@ -5,6 +5,7 @@ int main ()
 {
 char foo [10];
 char bar [10];
+bar[4] = 'k'; /* touch memcpy source */
 memcpy(foo, bar, 10);
 return 0;
 }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-03-10 22:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-10 22:29 [tree-ssa mudflap] more on initialization checking Frank Ch. Eigler

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