This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[tree-ssa mudflap] cleanup, runtime extensions


Hi -

The following patches tweak the gcc-side instrumentation code, and
provide some extensions for the runtime.


+2002-11-05  Frank Ch. Eigler  <fche@redhat.com>
+
+	* tree-mudflap.c (mudflap_enqueue_decl, _constant): Use
+	size_in_bytes, not c_size_in_bytes.
+	(mf_init_extern_trees): Import uintptr_t typedef node from
+	mf-runtime.h.


Index: tree-mudflap.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-mudflap.c,v
retrieving revision 1.1.2.20
diff -u -p -r1.1.2.20 tree-mudflap.c
--- tree-mudflap.c	26 Oct 2002 20:37:07 -0000	1.1.2.20
+++ tree-mudflap.c	5 Nov 2002 20:44:12 -0000
@@ -148,7 +148,7 @@ mudflap_enqueue_decl (obj, label)
          only used from other compilation units.  XXX: Maybe static
          objects could require those attributes being set.  */
       mf_enqueue_register_call (label,
-				c_size_in_bytes (TREE_TYPE (obj)),
+				size_in_bytes (TREE_TYPE (obj)),
 				build_int_2 (3, 0), /* __MF_TYPE_STATIC */
 				mf_varname_tree (obj));
     }
@@ -201,7 +201,7 @@ mudflap_enqueue_constant (obj, label)
   else
     {
       mf_enqueue_register_call (label,
-				c_size_in_bytes (TREE_TYPE (obj)),
+				size_in_bytes (TREE_TYPE (obj)),
 				build_int_2 (3, 0), /* __MF_TYPE_STATIC */
 				mx_flag (fix_string_type
 					 (build_string (9, "constant"))));
@@ -263,11 +263,7 @@ mf_init_extern_trees ()
   static int done = 0;
   if (done) return;
 
-#if 1
-  mf_uintptr_type = long_unsigned_type_node;
-#else
   mf_uintptr_type = TREE_TYPE (lookup_name (get_identifier ("uintptr_t")));
-#endif
 
   mf_cache_struct_type = xref_tag (RECORD_TYPE, get_identifier ("__mf_cache"));
   mf_cache_structptr_type = build_pointer_type (mf_cache_struct_type);



Index: ChangeLog
+2002-11-05  Frank Ch. Eigler  <fche@redhat.com>
+
+	* test/fail20-frag.c: New test for NULL pointer dereferencing.
+	* Makefile.am (TESTS): Add it.
+	* test/pass-stratcliff.c: Add decls of stpcpy.
+	* configure.in: Test for <stdint.h>.  Generate mf-runtime.h in
+	build tree from config.h and new file mf-runtime.h.in.
+	* mf-runtime.h.in: Renamed from mf-runtime.h.  Tweak uintptr_t decl.
+	* Makefile.in, configure, config.h.in: Regenerated.
+	* mf-hooks.c: Add #undef for wrapped glibc str*/mem* macros.	
+	* mf-runtime.c (options, __mf_set_default_options): Support new 
+	default "abbreviate" option.
+	(__mf_object.description_epoch): New field.
+	(__mf_describe_object): Conditionally abbreviate objects already
+	displayed in current epoch.  Accept NULL input to increment epoch.
+	(__mf_fini, __mf_ini): Reset description epoch.
+	(__mf_register, __mf_unregister, __mf_adapt_cache, __mf_init): Ensure
+	that NULL pointer slot in lookup cache is invalidated.  Register a
+	NOACCESS region around NULL.
+	* mf-impl.h: Corresponding changes.
+

Index: Makefile.am
===================================================================
RCS file: /cvs/gcc/gcc/libmudflap/Attic/Makefile.am,v
retrieving revision 1.1.2.15
diff -u -p -r1.1.2.15 Makefile.am
--- Makefile.am	16 Oct 2002 18:51:57 -0000	1.1.2.15
+++ Makefile.am	5 Nov 2002 20:46:38 -0000
@@ -12,7 +12,7 @@ TESTS_ENVIRONMENT = LD_LIBRARY_PATH='.li
 TESTS = test/fail1.x test/fail2.x test/fail3.x test/fail4.x test/fail5.x \
  test/fail6.x test/fail7.x test/fail8.x test/fail9.x test/fail10.x \
  test/fail11.x test/fail12.x test/fail13.x test/fail14.x test/fail15.x \
- test/fail16.x test/fail17.x test/fail18.x test/fail19.x \
+ test/fail16.x test/fail17.x test/fail18.x test/fail19.x test/fail20.x \
  test/pass1.x test/pass2.x test/pass3.x test/pass4.x test/pass5.x \
  test/pass6.x test/pass7.x test/pass8.x test/pass9.x test/pass10.x \
  test/pass11.x test/pass12.x test/pass13.x test/pass14.x test/pass15.x \
Index: configure.in
===================================================================
RCS file: /cvs/gcc/gcc/libmudflap/Attic/configure.in,v
retrieving revision 1.1.2.2
diff -u -p -r1.1.2.2 configure.in
--- configure.in	26 Aug 2002 23:18:04 -0000	1.1.2.2
+++ configure.in	5 Nov 2002 20:46:39 -0000
@@ -20,15 +20,14 @@ AC_SUBST(target_alias)
 
 AM_CONFIG_HEADER(config.h)
 
-# override for now
-#enable_shared=no
-#disable_shared=yes
-
 AC_LIBTOOL_DLOPEN
 AM_PROG_LIBTOOL
 AC_SUBST(enable_shared)
 AC_SUBST(enable_static)
 
+dnl Should check for this header for the host/target, not the build platform
+AC_CHECK_HEADERS(stdint.h)
+
 if ${CONFIG_SHELL-/bin/sh} ./libtool --tag CC --features |
    grep "enable shared" > /dev/null; then
   LIBMUDFLAP_PICFLAGS=-prefer-pic
@@ -38,3 +37,11 @@ fi
 AC_SUBST(LIBMUDFLAP_PICFLAGS)
 
 AC_OUTPUT(Makefile)
+
+(
+ echo '#ifndef __MF_RUNTIME_H'
+ echo '#define __MF_RUNTIME_H'
+ cat config.h
+ cat $srcdir/mf-runtime.h.in
+ echo '#endif'
+) > mf-runtime.h
Index: mf-hooks.c
===================================================================
RCS file: /cvs/gcc/gcc/libmudflap/Attic/mf-hooks.c,v
retrieving revision 1.1.2.19
diff -u -p -r1.1.2.19 mf-hooks.c
--- mf-hooks.c	22 Oct 2002 18:29:32 -0000	1.1.2.19
+++ mf-hooks.c	5 Nov 2002 20:46:39 -0000
@@ -7,8 +7,6 @@ This file is part of GCC.
 XXX: libgcc license?
 */
 
-#include "mf-runtime.h"
-
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -18,6 +16,7 @@ XXX: libgcc license?
 #include <execinfo.h>
 #include <assert.h>
 
+#include "mf-runtime.h"
 #include "mf-impl.h"
 
 #ifdef _MUDFLAP
@@ -61,6 +60,7 @@ XXX: libgcc license?
 /* malloc/free etc. */
 
 #ifdef WRAP_malloc
+#undef malloc
 WRAPPER(void *, malloc, size_t c)
 {
   size_t size_with_crumple_zones;
@@ -87,6 +87,7 @@ WRAPPER(void *, malloc, size_t c)
 
 
 #ifdef WRAP_calloc
+#undef calloc
 WRAPPER(void *, calloc, size_t c, size_t n)
 {
   size_t size_with_crumple_zones;
@@ -118,6 +119,7 @@ WRAPPER(void *, calloc, size_t c, size_t
 #endif
 
 #ifdef WRAP_realloc
+#undef realloc
 WRAPPER(void *, realloc, void *buf, size_t c)
 {
   DECLARE(void * , realloc, void *, size_t);
@@ -152,6 +154,7 @@ WRAPPER(void *, realloc, void *buf, size
 
 
 #ifdef WRAP_free
+#undef free
 WRAPPER(void, free, void *buf)
 {
   /* Use a circular queue to delay some number (__mf_opts.free_queue_length) of free()s.  */
@@ -226,6 +229,7 @@ WRAPPER(void, free, void *buf)
 
 
 #ifdef WRAP_dlopen
+#undef dlopen
 WRAPPER(void *, dlopen, const char *filename, int flag)
 {
   DECLARE(void * , dlopen, const char *filename, int flag);
@@ -238,6 +242,7 @@ WRAPPER(void *, dlopen, const char *file
 
 
 #ifdef WRAP_mmap
+#undef mmap
 WRAPPER(void *, mmap, 
 	void  *start,  size_t length, int prot, 
 	int flags, int fd, off_t offset)
@@ -285,6 +290,7 @@ WRAPPER(void *, mmap, 
 
 
 #ifdef WRAP_munmap
+#undef munmap
 WRAPPER(int , munmap, void *start, size_t length)
 {
   DECLARE(int, munmap, void *, size_t);
@@ -318,6 +324,7 @@ WRAPPER(int , munmap, void *start, size_
 /* This wrapper is a little different, as it's implemented in terms
    of the wrapped malloc/free functions. */
 #ifdef WRAP_alloca
+#undef alloca
 WRAPPER(void *, alloca, size_t c)
 {
   DECLARE (void *, malloc, size_t);
@@ -384,6 +391,7 @@ WRAPPER(void *, alloca, size_t c)
 /* str*,mem*,b* */
 
 #ifdef WRAP_memcpy
+#undef memcpy
 WRAPPER(void *, memcpy, void *dest, const void *src, size_t n)
 {
   DECLARE(void *, memcpy, void *dest, const void *src, size_t n);
@@ -396,6 +404,7 @@ WRAPPER(void *, memcpy, void *dest, cons
 
 
 #ifdef WRAP_memmove
+#undef memmove
 WRAPPER(void *, memmove, void *dest, const void *src, size_t n)
 {
   DECLARE(void *, memmove, void *dest, const void *src, size_t n);
@@ -407,6 +416,7 @@ WRAPPER(void *, memmove, void *dest, con
 #endif
 
 #ifdef WRAP_memset
+#undef memset
 WRAPPER(void *, memset, void *s, int c, size_t n)
 {
   DECLARE(void *, memset, void *s, int c, size_t n);
@@ -417,6 +427,7 @@ WRAPPER(void *, memset, void *s, int c, 
 #endif
 
 #ifdef WRAP_memcmp
+#undef memcmp
 WRAPPER(int, memcmp, const void *s1, const void *s2, size_t n)
 {
   DECLARE(int , memcmp, const void *s1, const void *s2, size_t n);
@@ -428,6 +439,7 @@ WRAPPER(int, memcmp, const void *s1, con
 #endif
 
 #ifdef WRAP_memchr
+#undef memchr
 WRAPPER(void *, memchr, const void *s, int c, size_t n)
 {
   DECLARE(void *, memchr, const void *s, int c, size_t n);
@@ -438,6 +450,7 @@ WRAPPER(void *, memchr, const void *s, i
 #endif
 
 #ifdef WRAP_memrchr
+#undef memrchr
 WRAPPER(void *, memrchr, const void *s, int c, size_t n)
 {
   DECLARE(void *, memrchr, const void *s, int c, size_t n);
@@ -448,6 +461,7 @@ WRAPPER(void *, memrchr, const void *s, 
 #endif
 
 #ifdef WRAP_strcpy
+#undef strcpy
 WRAPPER(char *, strcpy, char *dest, const char *src)
 {
   DECLARE(size_t, strlen, const char *s);
@@ -468,6 +482,7 @@ WRAPPER(char *, strcpy, char *dest, cons
 #endif
 
 #ifdef WRAP_strncpy
+#undef strncpy
 WRAPPER(char *, strncpy, char *dest, const char *src, size_t n)
 {
   DECLARE(size_t, strnlen, const char *s, size_t n);
@@ -484,6 +499,7 @@ WRAPPER(char *, strncpy, char *dest, con
 #endif
 
 #ifdef WRAP_strcat
+#undef strcat
 WRAPPER(char *, strcat, char *dest, const char *src)
 {
   DECLARE(size_t, strlen, const char *s);
@@ -501,6 +517,7 @@ WRAPPER(char *, strcat, char *dest, cons
 #endif
 
 #ifdef WRAP_strncat
+#undef strncat
 WRAPPER(char *, strncat, char *dest, const char *src, size_t n)
 {
 
@@ -540,6 +557,7 @@ WRAPPER(char *, strncat, char *dest, con
 #endif
 
 #ifdef WRAP_strcmp
+#undef strcmp
 WRAPPER(int, strcmp, const char *s1, const char *s2)
 {
   DECLARE(size_t, strlen, const char *s);
@@ -557,6 +575,7 @@ WRAPPER(int, strcmp, const char *s1, con
 #endif
 
 #ifdef WRAP_strcasecmp
+#undef strcasecmp
 WRAPPER(int, strcasecmp, const char *s1, const char *s2)
 {
   DECLARE(size_t, strlen, const char *s);
@@ -574,6 +593,7 @@ WRAPPER(int, strcasecmp, const char *s1,
 #endif
 
 #ifdef WRAP_strncmp
+#undef strncmp
 WRAPPER(int, strncmp, const char *s1, const char *s2, size_t n)
 {
   DECLARE(size_t, strnlen, const char *s, size_t n);
@@ -591,6 +611,7 @@ WRAPPER(int, strncmp, const char *s1, co
 #endif
 
 #ifdef WRAP_strncasecmp
+#undef strncasecmp
 WRAPPER(int, strncasecmp, const char *s1, const char *s2, size_t n)
 {
   DECLARE(size_t, strnlen, const char *s, size_t n);
@@ -608,6 +629,7 @@ WRAPPER(int, strncasecmp, const char *s1
 #endif
 
 #ifdef WRAP_strdup
+#undef strdup
 WRAPPER(char *, strdup, const char *s)
 {
   DECLARE(size_t, strlen, const char *s);
@@ -643,6 +665,7 @@ WRAPPER(char *, strdup, const char *s)
 #endif
 
 #ifdef WRAP_strndup
+#undef strndup
 WRAPPER(char *, strndup, const char *s, size_t n)
 {
   DECLARE(size_t, strnlen, const char *s, size_t n);
@@ -679,6 +702,7 @@ WRAPPER(char *, strndup, const char *s, 
 #endif
 
 #ifdef WRAP_strchr
+#undef strchr
 WRAPPER(char *, strchr, const char *s, int c)
 {
   DECLARE(size_t, strlen, const char *s);
@@ -693,6 +717,7 @@ WRAPPER(char *, strchr, const char *s, i
 #endif
 
 #ifdef WRAP_strrchr
+#undef strrchr
 WRAPPER(char *, strrchr, const char *s, int c)
 {
   DECLARE(size_t, strlen, const char *s);
@@ -707,6 +732,7 @@ WRAPPER(char *, strrchr, const char *s, 
 #endif
 
 #ifdef WRAP_strstr
+#undef strstr
 WRAPPER(char *, strstr, const char *haystack, const char *needle)
 {
   DECLARE(size_t, strlen, const char *s);
@@ -724,6 +750,7 @@ WRAPPER(char *, strstr, const char *hays
 #endif
 
 #ifdef WRAP_memmem
+#undef memmem
 WRAPPER(void *, memmem, 
 	const void *haystack, size_t haystacklen,
 	const void *needle, size_t needlelen)
@@ -739,6 +766,7 @@ WRAPPER(void *, memmem, 
 #endif
 
 #ifdef WRAP_strlen
+#undef strlen
 WRAPPER(size_t, strlen, const char *s)
 {
   DECLARE(size_t, strlen, const char *s);
@@ -752,6 +780,7 @@ WRAPPER(size_t, strlen, const char *s)
 #endif
 
 #ifdef WRAP_strnlen
+#undef strnlen
 WRAPPER(size_t, strnlen, const char *s, size_t n)
 {
   DECLARE(size_t, strnlen, const char *s, size_t n);
@@ -765,6 +794,7 @@ WRAPPER(size_t, strnlen, const char *s, 
 #endif
 
 #ifdef WRAP_bzero
+#undef bzero
 WRAPPER(void, bzero, void *s, size_t n)
 {
   DECLARE(void , bzero, void *s, size_t n);
@@ -785,6 +815,7 @@ WRAPPER(void, bzero, void *s, size_t n)
 #endif
 
 #ifdef WRAP_bcopy
+#undef bcopy
 WRAPPER(void, bcopy, const void *src, void *dest, size_t n)
 {
   DECLARE(void , bcopy, const void *src, void *dest, size_t n);
@@ -806,6 +837,7 @@ WRAPPER(void, bcopy, const void *src, vo
 #endif
 
 #ifdef WRAP_bcmp
+#undef bcmp
 WRAPPER(int, bcmp, const void *s1, const void *s2, size_t n)
 {
   DECLARE(int , bcmp, const void *s1, const void *s2, size_t n);
@@ -818,6 +850,7 @@ WRAPPER(int, bcmp, const void *s1, const
 #endif
 
 #ifdef WRAP_index
+#undef index
 WRAPPER(char *, index, const char *s, int c)
 {
   DECLARE(size_t, strlen, const char *s);
@@ -832,6 +865,7 @@ WRAPPER(char *, index, const char *s, in
 #endif
 
 #ifdef WRAP_rindex
+#undef rindex
 WRAPPER(char *, rindex, const char *s, int c)
 {
   DECLARE(size_t, strlen, const char *s);
@@ -851,5 +885,6 @@ WRAPPER(char *, rindex, const char *s, i
 /* XXX: *printf,*scanf */
 
 
+/* XXX: setjmp, longjmp */
 
 /* ------------------------------------------------------------------------ */
Index: mf-impl.h
===================================================================
RCS file: /cvs/gcc/gcc/libmudflap/Attic/mf-impl.h,v
retrieving revision 1.1.2.8
diff -u -p -r1.1.2.8 mf-impl.h
--- mf-impl.h	26 Sep 2002 18:59:33 -0000	1.1.2.8
+++ mf-impl.h	5 Nov 2002 20:46:39 -0000
@@ -70,6 +70,9 @@ struct __mf_options
   /* Print verbose description of violations. */
   unsigned verbose_violations;
 
+  /* Abbreviate duplicate object descriptions.  */
+  unsigned abbreviate;
+
   /* Emit internal tracing message. */
   unsigned verbose_trace;
 
Index: mf-runtime.c
===================================================================
RCS file: /cvs/gcc/gcc/libmudflap/Attic/mf-runtime.c,v
retrieving revision 1.1.2.19
diff -u -p -r1.1.2.19 mf-runtime.c
--- mf-runtime.c	16 Oct 2002 18:51:57 -0000	1.1.2.19
+++ mf-runtime.c	5 Nov 2002 20:46:39 -0000
@@ -24,6 +24,8 @@ XXX: libgcc license?
 #include "mf-runtime.h"
 #include "mf-impl.h"
 
+
+
 #ifndef max
 #define max(a,b) ((a) > (b) ? (a) : (b))
 #endif
@@ -88,6 +90,7 @@ __mf_set_default_options ()
   __mf_opts.tree_aging =    13037;
   __mf_opts.adapt_cache = 1000003;
   __mf_opts.print_leaks = 0;
+  __mf_opts.abbreviate = 1;
   __mf_opts.verbose_violations = 0;
   __mf_opts.multi_threaded = 0;
   __mf_opts.free_queue_length = 4;
@@ -162,6 +165,9 @@ options [] =
     {"verbose-violations", 
      "print verbose messages when memory violations occur",
      set_option, 1, &__mf_opts.verbose_violations},
+    {"abbreviate", 
+     "abbreviate repetitive listings",
+     set_option, 1, &__mf_opts.abbreviate},
     /* XXX: this should be sensitive to gcc --enable-threading= setting */
     {"multi-threaded", 
      "support multiple threads",
@@ -405,64 +411,8 @@ resolve_single_dynamic (&__mf_dynamic.dy
 
 #endif /* PIC */
 
-extern void __mf_init () CTOR;
-void __mf_init ()
-{
-  char *ov = 0;
-
-  __mf_state = starting;
 
-#ifdef PIC
-  __mf_resolve_dynamics ();
-#endif
 
-  __mf_set_default_options ();
-
-  ov = getenv ("MUDFLAP_OPTIONS");
-  if (ov)
-    {
-      if (__mf_process_opts (ov) == 0)
-	{
-	  fprintf (stderr, 
-		   "mudflap error: unknown options in "
-		   "environment variable MUDFLAP_OPTIONS\n");
-	  __mf_usage ();
-	  exit (1);
-	}
-    }
-
-  __mf_state = active;
-#define REG_RESERVED(obj) \
-  __mf_register ((uintptr_t) & obj, (uintptr_t) sizeof(obj), __MF_TYPE_NOACCESS, # obj)
-
-  REG_RESERVED (__mf_lookup_cache);
-  REG_RESERVED (__mf_lc_mask);
-  REG_RESERVED (__mf_lc_shift);
-  /* XXX: others of our statics?  */
-
-  /* XXX: bad hack: assumes Linux process layout */
-  if (__mf_opts.heur_argv_environ)
-    {
-      int foo = 0;
-      __mf_register ((uintptr_t) & foo,
-		     (uintptr_t) 0xC0000000 - (uintptr_t) (& foo),
-		     __MF_TYPE_GUESS,
-		     "argv/environ area");
-      /* XXX: separate heuristic? */
-      __mf_register ((uintptr_t) & errno,
-		     (uintptr_t) sizeof (errno),
-		     __MF_TYPE_GUESS,
-		     "errno area");
-    }
-}
-
-
-extern void __mf_fini () DTOR;
-void __mf_fini ()
-{
-  TRACE ("mf: __mf_fini\n");
-  __mf_report ();
-}
 
 /* ------------------------------------------------------------------------ */
 /* stats-related globals.  */
@@ -486,6 +436,7 @@ typedef struct __mf_object
   const char *name;
   unsigned check_count; /* Number of times __mf_check was called on this object.  */
   unsigned liveness; /* A measure of recent checking activity.  */
+  unsigned description_epoch; /* Last epoch __mf_describe_object printed this.  */
 
   uintptr_t alloc_pc;
   struct timeval alloc_time;
@@ -523,6 +474,79 @@ static void __mf_adapt_cache ();
 static void __mf_unlink_object (__mf_object_tree_t *obj);
 static void __mf_describe_object (__mf_object_t *obj);
 
+
+
+/* ------------------------------------------------------------------------ */
+
+extern void __mf_init () CTOR;
+void __mf_init ()
+{
+  char *ov = 0;
+
+  __mf_state = starting;
+
+#ifdef PIC
+  __mf_resolve_dynamics ();
+#endif
+
+  __mf_set_default_options ();
+
+  ov = getenv ("MUDFLAP_OPTIONS");
+  if (ov)
+    {
+      if (__mf_process_opts (ov) == 0)
+	{
+	  fprintf (stderr, 
+		   "mudflap error: unknown options in "
+		   "environment variable MUDFLAP_OPTIONS\n");
+	  __mf_usage ();
+	  exit (1);
+	}
+    }
+
+  __mf_state = active;
+
+  /* Initialize to a non-zero description epoch. */
+  __mf_describe_object (NULL);
+
+#define REG_RESERVED(obj) \
+  __mf_register ((uintptr_t) & obj, (uintptr_t) sizeof(obj), __MF_TYPE_NOACCESS, # obj)
+
+  REG_RESERVED (__mf_lookup_cache);
+  REG_RESERVED (__mf_lc_mask);
+  REG_RESERVED (__mf_lc_shift);
+  /* XXX: others of our statics?  */
+
+  /* Prevent access to *NULL. */
+  __mf_register ((uintptr_t) 0, 1, __MF_TYPE_NOACCESS, "NULL");
+  __mf_lookup_cache[0].low = (uintptr_t) -1;
+
+  /* XXX: bad hack: assumes Linux process layout */
+  if (__mf_opts.heur_argv_environ)
+    {
+      int foo = 0;
+      __mf_register ((uintptr_t) & foo,
+		     (uintptr_t) 0xC0000000 - (uintptr_t) (& foo),
+		     __MF_TYPE_GUESS,
+		     "argv/environ area");
+      /* XXX: separate heuristic? */
+      __mf_register ((uintptr_t) & errno,
+		     (uintptr_t) sizeof (errno),
+		     __MF_TYPE_GUESS,
+		     "errno area");
+    }
+}
+
+
+extern void __mf_fini () DTOR;
+void __mf_fini ()
+{
+  TRACE ("mf: __mf_fini\n");
+  __mf_report ();
+}
+
+
+
 /* ------------------------------------------------------------------------ */
 /* __mf_check */
 
@@ -797,6 +821,8 @@ __mf_register (uintptr_t ptr, uintptr_t 
       /* Clear the cache.  */
       /* XXX: why the entire cache? */
       memset (__mf_lookup_cache, 0, sizeof(__mf_lookup_cache));
+      /* void slot 0 */
+      __mf_lookup_cache[0].low = (uintptr_t) -1;
       break;
 
     case mode_check:
@@ -974,6 +1000,8 @@ __mf_unregister (uintptr_t ptr, uintptr_
     case mode_populate:
       /* Clear the cache.  */
       memset (__mf_lookup_cache, 0, sizeof(__mf_lookup_cache));
+      /* void slot 0 */
+      __mf_lookup_cache[0].low = (uintptr_t) -1;
       break;
 
     case mode_check:
@@ -1018,6 +1046,9 @@ __mf_unregister (uintptr_t ptr, uintptr_
 		__mf_backtrace (& old_obj->data.dealloc_backtrace,
 				NULL, 2);
 
+	    /* Encourage this object to be displayed again in current epoch.  */
+	    old_obj->data.description_epoch --;
+
 	    /* Put this object into the cemetary.  This may require this plot to
 	       be recycled, and the previous resident to be designated del_obj.  */
 	    
@@ -1029,7 +1060,7 @@ __mf_unregister (uintptr_t ptr, uintptr_
 	      
 	      del_obj = __mf_object_cemetary [row][plot];
 	      __mf_object_cemetary [row][plot] = old_obj;
-	      
+
 	      plot ++;
 	      if (plot == __mf_opts.persistent_count) plot = 0;
 	      __mf_object_dead_head [row] = plot;
@@ -1243,7 +1274,7 @@ __mf_adapt_cache ()
     if (shifted > weighted_avg_size)
       break;
     
-  VERBOSE_TRACE ("mf: adapt cache %u/%u/%u/%.0f/%.0f => "
+  VERBOSE_TRACE ("mf: adapt cache %u/%u/%lu/%.0f/%.0f => "
 		 "%.0f/%lu/%lu/%.0f%% => "
 		 "%08lx/%u\n",
 		 s.obj_count, s.live_obj_count, s.total_size,
@@ -1258,6 +1289,8 @@ __mf_adapt_cache ()
       __mf_lc_mask = new_mask;
       __mf_lc_shift = new_shift;
       memset (__mf_lookup_cache, 0, sizeof(__mf_lookup_cache));
+      /* void slot 0 */
+      __mf_lookup_cache[0].low = (uintptr_t) -1;
     }
 }
 
@@ -1507,13 +1540,28 @@ __mf_find_dead_objects (uintptr_t low, u
 static void
 __mf_describe_object (__mf_object_t *obj)
 {
-  /* if (UNLIKELY (__mf_state != active)) return; */
+  static unsigned epoch = 0;
+  if (obj == NULL)
+    {
+      epoch ++;
+      return;
+    }
+
+  if (__mf_opts.abbreviate && obj->description_epoch == epoch)
+    {
+      fprintf (stderr,
+	       "mudflap object %08lx: name=`%s'\n",
+	       (uintptr_t) obj, (obj->name ? obj->name : ""));
+      return;
+    }
+  else
+    obj->description_epoch = epoch;
 
   fprintf (stderr,
 	   "mudflap object %08lx: name=`%s'\n"
 	   "bounds=[%08lx,%08lx] size=%lu area=%s checked=%u liveness=%u\n"
 	   "alloc time=%lu.%06lu pc=%08lx\n",
-	   obj, (obj->name ? obj->name : ""), 
+	   (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_STACK ? "stack" :
@@ -1636,6 +1684,7 @@ __mf_report ()
       unsigned l;
       /* Free up any remaining alloca()'d blocks.  */
       (void) CALL_WRAP (alloca, 0); /* XXX: doesn't work in shared mode. */
+      __mf_describe_object (NULL); /* Reset description epoch.  */
       l = __mf_report_leaks (__mf_object_root);
       fprintf (stderr, "number of leaked objects: %u\n", l);
     }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]