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]

[libmudflap] __libc_freeres


Hi -

Committing:

+2006-11-06  Frank Ch. Eigler  <fche@redhat.com>
+
+	* configure.ac (__libc_freeres): Look for it.
+	* mf-impl.h (call_libc_freeres): New configuration flag.
+	* mf-runtime.c (__mf_set_default_options): Set it by default.
+	(__mfu_report): Call it if needed.
+	(__mfu_unregister): Remove "unaccessed registered object" warning.
+	* configure, config.h.in: Regenerated.

Index: mf-impl.h
===================================================================
--- mf-impl.h	(revision 118521)
+++ mf-impl.h	(working copy)
@@ -134,6 +134,11 @@ struct __mf_options
   /* Print list of leaked heap objects on shutdown. */
   unsigned print_leaks;
 
+#ifdef HAVE___LIBC_FREERES
+  /* Call __libc_freeres before leak analysis. */
+  unsigned call_libc_freeres;
+#endif
+
   /* Detect reads of uninitialized objects. */
   unsigned check_initialization;
 
 
Index: configure.ac
===================================================================
--- configure.ac	(revision 118521)
+++ configure.ac	(working copy)
@@ -75,6 +75,7 @@ AC_CHECK_FUNCS(getservent getservbyname 
 AC_CHECK_FUNCS(getprotoent getprotobyname getprotobynumber)
 AC_CHECK_FUNCS(getmntent setmntent addmntent)
 AC_CHECK_FUNCS(inet_ntoa mmap munmap)
+AC_CHECK_FUNCS(__libc_freeres)
 
 AC_TRY_COMPILE([#include <sys/types.h>
 #include <sys/ipc.h>
Index: mf-runtime.c
===================================================================
--- mf-runtime.c	(revision 118521)
+++ mf-runtime.c	(working copy)
@@ -1,5 +1,5 @@
 /* Mudflap: narrow-pointer bounds-checking by tree rewriting.
-   Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
    Contributed by Frank Ch. Eigler <fche@redhat.com>
    and Graydon Hoare <graydon@redhat.com>
    Splay Tree code originally by Mark Mitchell <mark@markmitchell.com>,
@@ -300,6 +300,9 @@ __mf_set_default_options ()
   __mf_opts.timestamps = 1;
   __mf_opts.mudflap_mode = mode_check;
   __mf_opts.violation_mode = viol_nop;
+#ifdef HAVE___LIBC_FREERES
+  __mf_opts.call_libc_freeres = 1;
+#endif
   __mf_opts.heur_std_data = 1;
 #ifdef LIBMUDFLAPTH
   __mf_opts.thread_stack = 0;
@@ -365,6 +368,11 @@ options [] =
     {"print-leaks",
      "print any memory leaks at program shutdown",
      set_option, 1, &__mf_opts.print_leaks},
+#ifdef HAVE___LIBC_FREERES
+    {"libc-freeres",
+     "call glibc __libc_freeres at shutdown for better leak data",
+     set_option, 1, &__mf_opts.call_libc_freeres},
+#endif
     {"check-initialization",
      "detect uninitialized object reads",
      set_option, 1, &__mf_opts.check_initialization},
@@ -1323,10 +1331,15 @@ __mfu_unregister (void *ptr, size_t sz, 
                 (old_obj->type == __MF_TYPE_HEAP
                  || old_obj->type == __MF_TYPE_HEAP_I))
               {
+		/* The problem with a warning message here is that we may not
+		   be privy to accesses to such objects that occur within
+		   uninstrumented libraries.  */
+#if 0
                 fprintf (stderr,
                          "*******\n"
                          "mudflap warning: unaccessed registered object:\n");
                 __mf_describe_object (old_obj);
+#endif
               }
           }
 
@@ -1855,6 +1868,14 @@ __mfu_report ()
 
       /* Free up any remaining alloca()'d blocks.  */
       __mf_wrap_alloca_indirect (0);
+#ifdef HAVE___LIBC_FREERES
+      if (__mf_opts.call_libc_freeres)
+        {
+          extern void __libc_freeres (void);
+          __libc_freeres ();
+        }
+#endif
+
       __mf_describe_object (NULL); /* Reset description epoch.  */
       l = __mf_report_leaks ();
       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]