apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dr...@apache.org
Subject cvs commit: apr/include apr_sms.h
Date Mon, 02 Jul 2001 22:22:53 GMT
dreid       01/07/02 15:22:52

  Modified:    memory/unix apr_sms.c
               include  apr_sms.h
  Log:
  This adds another somewhat drastic debugging mode, but it has already
  found a problem in the ongoing work to get pools as sms working correctly.
  
  Essentially it should only be used if all else has failed as it records
  a lot of information to a file.
  
  Revision  Changes    Path
  1.34      +52 -0     apr/memory/unix/apr_sms.c
  
  Index: apr_sms.c
  ===================================================================
  RCS file: /home/cvs/apr/memory/unix/apr_sms.c,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- apr_sms.c	2001/07/02 16:21:48	1.33
  +++ apr_sms.c	2001/07/02 22:22:50	1.34
  @@ -88,6 +88,37 @@
       apr_status_t (*cleanup_fn)(void *);
   };
   
  +#if APR_DEBUG_ALLOCATIONS
  +FILE *alloc_file = NULL;
  +
  +static void _record_(apr_sms_t *sms, const char *what, apr_size_t size,
  +                     void *ptr)
  +{
  +    if (!alloc_file)
  +        return;
  +
  +    if (ptr) {
  +#if APR_DEBUG_TAG_SMS
  +        fprintf(alloc_file, "%10s %p '%9s' [%9s] @ %p\n",
  +                what, sms, sms->tag, sms->identity, ptr);
  +#else
  +        fprintf(alloc_file, "%10s %p             [%9s] @ %p\n",
  +                what, sms, sms->identity, ptr);
  +#endif
  +    } else {
  +#if APR_DEBUG_TAG_SMS
  +        fprintf(alloc_file, "%10s %p '%9s' [%9s] %6" APR_SIZE_T_FMT " bytes\n",
  +                what, sms, sms->tag, sms->identity, size);
  +#else
  +        fprintf(alloc_file, "%10s %p             [%9s] %6" APR_SIZE_T_FMT " bytes\n",
  +                what, sms, sms->identity, size);
  +#endif
  +    }
  +    fflush(alloc_file);
  +}
  +#endif
  +
  +
   /* 
    * memory allocation functions
    */
  @@ -98,6 +129,10 @@
       if (size == 0)
           return NULL;
   
  +#if APR_DEBUG_ALLOCATIONS
  +    _record_(sms, "MALLOC", size, NULL);
  +#endif
  +
       return sms->malloc_fn(sms, size);
   }
   
  @@ -107,12 +142,20 @@
       if (size == 0)
           return NULL;
   
  +#if APR_DEBUG_ALLOCATIONS
  +    _record_(sms, "CALLOC", size, NULL);
  +#endif
  +
       return sms->calloc_fn(sms, size);
   }
   
   APR_DECLARE(void *) apr_sms_realloc(apr_sms_t *sms, void *mem,
                                       apr_size_t size)
   {
  +#if APR_DEBUG_ALLOCATIONS
  +    _record_(sms, "REALLOC", size, NULL);
  +#endif
  +
       if (!mem)
           return apr_sms_malloc(sms, size);
   
  @@ -131,6 +174,11 @@
   APR_DECLARE(apr_status_t) apr_sms_free(apr_sms_t *sms,
                                          void *mem)
   {
  +
  +#if APR_DEBUG_ALLOCATIONS
  +    _record_(sms, "FREE", 0, mem);
  +#endif
  +
       if (sms->free_fn)
           return sms->free_fn(sms, mem);  
   
  @@ -180,6 +228,10 @@
           dbg_file = fopen(APR_DEBUG_FILE, "w");
   #else
       dbg_file = stdout;
  +#endif
  +#if APR_DEBUG_ALLOCATIONS
  +    if (!alloc_file)
  +        alloc_file = fopen(APR_DEBUG_ALLOC_FILE, "w");
   #endif
   
       /* XXX - I've assumed that memory passed in will be zeroed,
  
  
  
  1.26      +13 -0     apr/include/apr_sms.h
  
  Index: apr_sms.h
  ===================================================================
  RCS file: /home/cvs/apr/include/apr_sms.h,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- apr_sms.h	2001/07/02 16:21:44	1.25
  +++ apr_sms.h	2001/07/02 22:22:52	1.26
  @@ -135,6 +135,19 @@
    */
   #define APR_DEBUG_TAG_SMS             0
   
  +/* APR_DEBUG_ALLOCATIONS
  + * This will record ALL calls made to
  + *     apr_sms_malloc
  + *     apr_sms_calloc
  + *     apr_sms_realloc
  + *     apr_sms_free
  + * Details are put into the file specified in the APR_DEBUG_ALLOC_FILE
  + * define
  + */
  +#define APR_DEBUG_ALLOCATIONS         0
  +#define APR_DEBUG_ALLOC_FILE "/tmp/sms_alloc"
  +
  +
   /**
    * @package APR memory system
    */
  
  
  

Mime
View raw message