Return-Path: Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 42406 invoked by uid 500); 13 Jan 2002 17:30:17 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 42395 invoked from network); 13 Jan 2002 17:30:16 -0000 To: dev@apr.apache.org Path: not-for-mail From: Ian Holsman Newsgroups: server.http.apr.dev Subject: Re: [PATCH] Default tagging of pools in debug mode [2] Date: Sun, 13 Jan 2002 09:31:11 -0800 Organization: Holsman.NET Lines: 256 Message-ID: <3C41C45F.6000003@apache.org> References: NNTP-Posting-Host: nt.holsman.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: flame.holsman.net 1010943018 4959 192.168.0.1 (13 Jan 2002 17:30:18 GMT) X-Complaints-To: news@flame.holsman.net NNTP-Posting-Date: Sun, 13 Jan 2002 17:30:18 +0000 (UTC) To: Sander Striker User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.7+) Gecko/20020111 X-Accept-Language: en-us X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Stupid Question Time: is there a problem just enabling file/line passing to this ALL the time? I mean.. it's just a extra parameter on the stack. this would make it MUCH easier to enable/disable debugging. Sander Striker wrote: > Hi, > > This is the approach we could take to set a tag by default > (at create time in debug mode). It introduces a macro to > concatenate __FILE__ and __LINE__. Maybe this belongs at > a more general place in APR. > > Sander > > > Index: include/apr_pools.h > =================================================================== > RCS file: /home/cvs/apr/include/apr_pools.h,v > retrieving revision 1.69 > diff -u -r1.69 apr_pools.h > --- include/apr_pools.h 13 Jan 2002 02:12:24 -0000 1.69 > +++ include/apr_pools.h 13 Jan 2002 12:03:19 -0000 > @@ -100,6 +100,11 @@ > #if defined(APR_POOL_DEBUG_VERBOSE) && !defined(APR_POOL_DEBUG) > #define APR_POOL_DEBUG > #endif > + > +#define APR_POOL_STRINGIZE(x) APR_POOL__STRINGIZE(x) > +#define APR_POOL__STRINGIZE(x) #x > +#define APR_POOL__FILE_LINE__ __FILE__ ":" APR_POOL_STRINGIZE(__LINE__) > + > > /** The fundamental pool type */ > typedef struct apr_pool_t apr_pool_t; > @@ -161,14 +166,13 @@ > #if defined(APR_POOL_DEBUG) > #define apr_pool_create_ex(newpool, parent, abort_fn, flag) \ > apr_pool_create_ex_debug(newpool, parent, abort_fn, flag, \ > - __FILE__, __LINE__) > + APR_POOL__FILE_LINE__) > > APR_DECLARE(apr_status_t) apr_pool_create_ex_debug(apr_pool_t **newpool, > apr_pool_t *parent, > apr_abortfunc_t abort_fn, > apr_uint32_t flags, > - const char *file, > - int line); > + const char *file_line); > #else > APR_DECLARE(apr_status_t) apr_pool_create_ex(apr_pool_t **newpool, > apr_pool_t *parent, > @@ -191,7 +195,7 @@ > #if defined(APR_POOL_DEBUG) > #define apr_pool_create(newpool, parent) \ > apr_pool_create_ex_debug(newpool, parent, NULL, APR_POOL_FDEFAULT, \ > - __FILE__, __LINE__) > + APR_POOL__FILE_LINE__) > #else > #define apr_pool_create(newpool, parent) \ > apr_pool_create_ex(newpool, parent, NULL, APR_POOL_FDEFAULT) > @@ -215,7 +219,7 @@ > #define apr_pool_sub_make(newpool, parent, abort_fn) \ > (void)apr_pool_create_ex_debug(newpool, parent, abort_fn, \ > APR_POOL_FDEFAULT, \ > - __FILE__, __LINE__) > + APR_POOL__FILE_LINE__) > #else > #define apr_pool_sub_make(newpool, parent, abort_fn) \ > (void)apr_pool_create_ex(newpool, parent, abort_fn, APR_POOL_FDEFAULT) > @@ -232,10 +236,10 @@ > */ > #if defined(APR_POOL_DEBUG) > #define apr_pool_clear(p) \ > - apr_pool_clear_debug(p, __FILE__, __LINE__) > + apr_pool_clear_debug(p, APR_POOL__FILE_LINE__) > > APR_DECLARE(void) apr_pool_clear_debug(apr_pool_t *p, > - const char *file, int line); > + const char *file_line); > #else > APR_DECLARE(void) apr_pool_clear(apr_pool_t *p); > #endif > @@ -248,10 +252,10 @@ > */ > #if defined(APR_POOL_DEBUG) > #define apr_pool_destroy(p) \ > - apr_pool_destroy_debug(p, __FILE__, __LINE__) > + apr_pool_destroy_debug(p, APR_POOL__FILE_LINE__) > > APR_DECLARE(void) apr_pool_destroy_debug(apr_pool_t *p, > - const char *file, int line); > + const char *file_line); > #else > APR_DECLARE(void) apr_pool_destroy(apr_pool_t *p); > #endif > Index: memory/unix/apr_pools.c > =================================================================== > RCS file: /home/cvs/apr/memory/unix/apr_pools.c,v > retrieving revision 1.130 > diff -u -r1.130 apr_pools.c > --- memory/unix/apr_pools.c 13 Jan 2002 02:12:24 -0000 1.130 > +++ memory/unix/apr_pools.c 13 Jan 2002 12:03:26 -0000 > @@ -161,8 +161,7 @@ > > #else /* !defined(APR_POOL_DEBUG) */ > debug_node_t *nodes; > - const char *file; > - int line; > + const char *file_line; > unsigned int stat_alloc; > unsigned int stat_total_alloc; > unsigned int stat_clear; > @@ -987,7 +986,7 @@ > * Pool creation/destruction (debug) > */ > > -static void pool_clear_debug(apr_pool_t *pool, const char *file, int line) > +static void pool_clear_debug(apr_pool_t *pool, const char *file_line) > { > debug_node_t *node; > apr_uint32_t index; > @@ -996,7 +995,7 @@ > * this pool thus this loop is safe and easy. > */ > while (pool->child) > - apr_pool_destroy_debug(pool->child, file, line); > + apr_pool_destroy_debug(pool->child, file_line); > > /* Run cleanups */ > run_cleanups(pool->cleanups); > @@ -1024,45 +1023,45 @@ > } > > APR_DECLARE(void) apr_pool_clear_debug(apr_pool_t *pool, > - const char *file, int line) > + const char *file_line) > { > check_integrity(pool); > > #if defined(APR_POOL_DEBUG_VERBOSE) > if (file_stderr) { > apr_file_printf(file_stderr, > - "POOL DEBUG: CLEAR [%10lu/%10lu/%10lu] 0x%08X \"%s\" [%s:%d] (%u/%u/%u)\n", > + "POOL DEBUG: CLEAR [%10lu/%10lu/%10lu] 0x%08X \"%s\" [%s] (%u/%u/%u)\n", > (unsigned long)apr_pool_num_bytes(pool, 0), > (unsigned long)apr_pool_num_bytes(pool, 1), > (unsigned long)apr_pool_num_bytes(global_pool, 1), > (unsigned int)pool, pool->tag, > - file, line, > + file_line, > pool->stat_alloc, pool->stat_total_alloc, pool->stat_clear); > } > #endif > > - pool_clear_debug(pool, file, line); > + pool_clear_debug(pool, file_line); > } > > APR_DECLARE(void) apr_pool_destroy_debug(apr_pool_t *pool, > - const char *file, int line) > + const char *file_line) > { > check_integrity(pool); > > #if defined(APR_POOL_DEBUG_VERBOSE) > if (file_stderr) { > apr_file_printf(file_stderr, > - "POOL DEBUG: DESTROY [%10lu/%10lu/%10lu] 0x%08X \"%s\" [%s:%d] (%u/%u/%u)\n", > + "POOL DEBUG: DESTROY [%10lu/%10lu/%10lu] 0x%08X \"%s\" [%s] (%u/%u/%u)\n", > (unsigned long)apr_pool_num_bytes(pool, 0), > (unsigned long)apr_pool_num_bytes(pool, 1), > (unsigned long)apr_pool_num_bytes(global_pool, 1), > (unsigned int)pool, pool->tag, > - file, line, > + file_line, > pool->stat_alloc, pool->stat_total_alloc, pool->stat_clear); > } > #endif > > - pool_clear_debug(pool, file, line); > + pool_clear_debug(pool, file_line); > > /* Remove the pool from the parents child list */ > if (pool->parent) { > @@ -1090,8 +1089,7 @@ > apr_pool_t *parent, > apr_abortfunc_t abort_fn, > apr_uint32_t flags, > - const char *file, > - int line) > + const char *file_line) > { > apr_pool_t *pool; > > @@ -1115,9 +1113,8 @@ > memset(pool, 0, SIZEOF_POOL_T); > > pool->abort_fn = abort_fn; > - pool->tag = ""; > - pool->file = file; > - pool->line = line; > + pool->tag = file_line; > + pool->file_line = file_line; > > if ((flags & APR_POOL_FNEW_ALLOCATOR) == APR_POOL_FNEW_ALLOCATOR) { > #if APR_HAS_THREADS > @@ -1165,12 +1162,12 @@ > #if defined(APR_POOL_DEBUG_VERBOSE) > if (file_stderr) { > apr_file_printf(file_stderr, > - "POOL DEBUG: CREATE [%10lu/%10lu/%10lu] 0x%08X \"%s\" [%s:%u] parent: 0x%08X \"%s\"\n", > + "POOL DEBUG: CREATE [%10lu/%10lu/%10lu] 0x%08X \"%s\" [%s] parent: 0x%08X \"%s\"\n", > (unsigned long)0, > (unsigned long)0, > (unsigned long)apr_pool_num_bytes(global_pool, 1), > (unsigned int)pool, pool->tag, > - file, line, > + file_line, > (unsigned int)parent, parent ? parent->tag : ""); > } > #endif > @@ -1190,7 +1187,7 @@ > > APR_DECLARE(void) apr_pool_clear(apr_pool_t *pool) > { > - apr_pool_clear_debug(pool, "", 0); > + apr_pool_clear_debug(pool, ""); > } > > #undef apr_pool_destroy > @@ -1198,7 +1195,7 @@ > > APR_DECLARE(void) apr_pool_destroy(apr_pool_t *pool) > { > - apr_pool_destroy_debug(pool, "", 0); > + apr_pool_destroy_debug(pool, ""); > } > > #undef apr_pool_create_ex > @@ -1214,7 +1211,7 @@ > { > return apr_pool_create_ex_debug(newpool, parent, > abort_fn, flags, > - "", 0); > + ""); > } > > > >