This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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]

Re: [RFC v2][BZ #7233] Do not let tr_break call be optimized away.


On Fri, Oct 25, 2013 at 02:51:59PM -0700, Roland McGrath wrote:
> This has never been part of the ABI and I don't think it's the sort of
> thing we should be trying to support in this way.  A probe point would
> serve the same purpose using a method that we do support.

Then we should not leave broken code. We should fix that or remove it
completely. This removes a tr_break which would also need to update
abilist.

As mtrace is slow and thread unsafe it could be completely replaced by
better alternative in 2.20

	[BZ #7233]
	* malloc/mtrace.c (tr_mallochook, tr_reallochook, tr_freehook):
	Remove tr_break.
	(tr_break): Remove.
	(mallwatch): Likewise.

diff --git a/malloc/mtrace.c b/malloc/mtrace.c
index 99ebaff..6f9c0db 100644
--- a/malloc/mtrace.c
+++ b/malloc/mtrace.c
@@ -53,8 +53,6 @@ static char *malloc_trace_buffer;
 
 __libc_lock_define_initialized (static, lock);
 
-/* Address to breakpoint on accesses to... */
-__ptr_t mallwatch;
 
 /* Old hook values.  */
 static void (*tr_old_free_hook) (__ptr_t ptr, const __ptr_t);
@@ -64,19 +62,6 @@ static __ptr_t (*tr_old_realloc_hook) (__ptr_t ptr, size_t size,
 static __ptr_t (*tr_old_memalign_hook) (size_t __alignment, size_t __size,
                                         const __ptr_t);
 
-/* This function is called when the block being alloc'd, realloc'd, or
-   freed has an address matching the variable "mallwatch".  In a debugger,
-   set "mallwatch" to the address of interest, then put a breakpoint on
-   tr_break.  */
-
-extern void tr_break (void) __THROW;
-libc_hidden_proto (tr_break)
-void
-tr_break (void)
-{
-}
-libc_hidden_def (tr_break)
-
 static void tr_where (const __ptr_t, Dl_info *) __THROW internal_function;
 static void
 internal_function tr_where (caller, info)
@@ -142,12 +127,6 @@ const __ptr_t caller;
   tr_where (caller, info);
   /* Be sure to print it first.  */
   fprintf (mallstream, "- %p\n", ptr);
-  if (ptr == mallwatch)
-    {
-      __libc_lock_unlock (lock);
-      tr_break ();
-      __libc_lock_lock (lock);
-    }
   __free_hook = tr_old_free_hook;
   if (tr_old_free_hook != NULL)
     (*tr_old_free_hook)(ptr, caller);
@@ -180,9 +159,6 @@ const __ptr_t caller;
 
   __libc_lock_unlock (lock);
 
-  if (hdr == mallwatch)
-    tr_break ();
-
   return hdr;
 }
 
@@ -195,9 +171,6 @@ const __ptr_t caller;
 {
   __ptr_t hdr;
 
-  if (ptr == mallwatch)
-    tr_break ();
-
   Dl_info mem;
   Dl_info *info = lock_and_info (caller, &mem);
 
@@ -232,9 +205,6 @@ const __ptr_t caller;
 
   __libc_lock_unlock (lock);
 
-  if (hdr == mallwatch)
-    tr_break ();
-
   return hdr;
 }
 
@@ -264,9 +234,6 @@ const __ptr_t caller;
 
   __libc_lock_unlock (lock);
 
-  if (hdr == mallwatch)
-    tr_break ();
-
   return hdr;
 }
 
@@ -287,10 +254,8 @@ release_libc_mem (void)
 #endif
 
 
-/* We enable tracing if either the environment variable MALLOC_TRACE
-   is set, or if the variable mallwatch has been patched to an address
-   that the debugging user wants us to stop on.  When patching mallwatch,
-   don't forget to set a breakpoint on tr_break!  */
+/* We enable tracing when environment variable MALLOC_TRACE
+   is set.  */
 
 void
 mtrace (void)
@@ -312,7 +277,7 @@ mtrace (void)
 #else
   mallfile = getenv (mallenv);
 #endif
-  if (mallfile != NULL || mallwatch != NULL)
+  if (mallfile != NULL)
     {
       char *mtb = malloc (TRACE_BUFFER_SIZE);
       if (mtb == NULL)


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