aboutsummaryrefslogtreecommitdiff
path: root/libmudflap/mf-runtime.c
diff options
context:
space:
mode:
authorFrank Ch. Eigler <fche@redhat.com>2006-11-06 18:02:13 +0000
committerFrank Ch. Eigler <fche@gcc.gnu.org>2006-11-06 18:02:13 +0000
commita548d7b75391323fb617554e965311a6897dd6ed (patch)
tree56b8c0aa4258be292832ad52f6e3be9089c63077 /libmudflap/mf-runtime.c
parent8f75f38989e10491c8a5fcf0f7ae855b4763afc2 (diff)
downloadgcc-a548d7b75391323fb617554e965311a6897dd6ed.zip
gcc-a548d7b75391323fb617554e965311a6897dd6ed.tar.gz
gcc-a548d7b75391323fb617554e965311a6897dd6ed.tar.bz2
configure.ac (__libc_freeres): Look for it.
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. From-SVN: r118523
Diffstat (limited to 'libmudflap/mf-runtime.c')
-rw-r--r--libmudflap/mf-runtime.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/libmudflap/mf-runtime.c b/libmudflap/mf-runtime.c
index 72d1a57..d6e3226 100644
--- a/libmudflap/mf-runtime.c
+++ b/libmudflap/mf-runtime.c
@@ -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, int type)
(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);