ianh 02/01/11 13:01:20
Modified: include apr_pools.h
memory/unix apr_pools.c
. CHANGES STATUS
Log:
add a new define APR_POOL_DEBUG_VERBOSE
which will print out where pools are created and their
children in the destroy function
Revision Changes Path
1.67 +37 -3 apr/include/apr_pools.h
Index: apr_pools.h
===================================================================
RCS file: /home/cvs/apr/include/apr_pools.h,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -r1.66 -r1.67
--- apr_pools.h 1 Jan 2002 23:49:23 -0000 1.66
+++ apr_pools.h 11 Jan 2002 21:01:19 -0000 1.67
@@ -158,11 +158,23 @@
* (this flag only makes sense in combination with
POOL_FNEW_ALLOCATOR)
*
*/
+#if defined(APR_POOL_DEBUG)
+#define apr_pool_create_ex( newpool, parent, abort_fn, flag) \
+ apr_pool_create_ex_dbg( newpool, parent, abort_fn,
flag,__FILE__,__LINE__)
+
+APR_DECLARE(apr_status_t) apr_pool_create_ex_dbg(apr_pool_t **newpool,
+ apr_pool_t *parent,
+ apr_abortfunc_t abort_fn,
+ apr_uint32_t flags,
+ const char *file,
+ int line);
+#
+#else
APR_DECLARE(apr_status_t) apr_pool_create_ex(apr_pool_t **newpool,
apr_pool_t *parent,
apr_abortfunc_t abort_fn,
apr_uint32_t flags);
-
+#endif
/**
* Create a new pool.
* @param newpool The pool we have just created.
@@ -175,9 +187,14 @@
APR_DECLARE(apr_status_t) apr_pool_create(apr_pool_t **newpool,
apr_pool_t *parent);
#else
+#if defined(APR_POOL_DEBUG)
+#define apr_pool_create(newpool, parent) \
+ apr_pool_create_ex_dbg(newpool, parent, NULL,
APR_POOL_FDEFAULT,__FILE__,__LINE__)
+#else
#define apr_pool_create(newpool, parent) \
apr_pool_create_ex(newpool, parent, NULL, APR_POOL_FDEFAULT)
#endif
+#endif
/**
* This function is deprecated. Use apr_pool_create_ex.
@@ -193,9 +210,14 @@
apr_pool_t *parent,
int (*apr_abort)(int retcode));
#else
+#if defined(APR_POOL_DEBUG)
+#define apr_pool_sub_make(newpool, parent, abort_fn) \
+ (void)apr_pool_create_ex_dbg(newpool, parent, abort_fn,
APR_POOL_FDEFAULT,__FILE__,__LINE__);
+#else
#define apr_pool_sub_make(newpool, parent, abort_fn) \
(void)apr_pool_create_ex(newpool, parent, abort_fn, APR_POOL_FDEFAULT);
#endif
+#endif
/**
* Destroy the pool. This takes similar action as apr_pool_clear() and then
@@ -203,8 +225,14 @@
* @param p The pool to destroy
* @remark This will actually free the memory
*/
-APR_DECLARE(void) apr_pool_destroy(apr_pool_t *p);
+#if defined(APR_POOL_DEBUG)
+#define apr_pool_destroy(p) \
+ apr_pool_destroy_dbg(p, __FILE__,__LINE__)
+APR_DECLARE(void) apr_pool_destroy_dbg(apr_pool_t *p, const char *file, int
line);
+#else
+APR_DECLARE(void) apr_pool_destroy(apr_pool_t *p);
+#endif
/*
* Memory allocation
@@ -234,8 +262,14 @@
* to re-use this memory for the next allocation.
* @see apr_pool_destroy()
*/
-APR_DECLARE(void) apr_pool_clear(apr_pool_t *p);
+#if defined(APR_POOL_DEBUG)
+#define apr_pool_clear(p) \
+ apr_pool_clear_dbg(p, __FILE__,__LINE__)
+APR_DECLARE(void) apr_pool_clear_dbg(apr_pool_t *p, const char*file, int
line);
+#else
+APR_DECLARE(void) apr_pool_clear(apr_pool_t *p);
+#endif
/*
* Pool Properties
1.128 +52 -6 apr/memory/unix/apr_pools.c
Index: apr_pools.c
===================================================================
RCS file: /home/cvs/apr/memory/unix/apr_pools.c,v
retrieving revision 1.127
retrieving revision 1.128
diff -u -r1.127 -r1.128
--- apr_pools.c 10 Jan 2002 18:52:49 -0000 1.127
+++ apr_pools.c 11 Jan 2002 21:01:19 -0000 1.128
@@ -91,6 +91,14 @@
#define APR_ALIGN_DEFAULT(size) APR_ALIGN(size, 8)
+/*
+ * This option prints out the pool creation info
+ * (and info about its children)
+ * when the pool is destroyed.
+ */
+/*
+#define APR_POOL_DEBUG_VERBOSE
+*/
/*
* Structures
@@ -161,6 +169,8 @@
#else /* !defined(APR_POOL_DEBUG) */
debug_node_t *nodes;
+ const char *file;
+ int line;
#if APR_HAS_THREADS
apr_thread_mutex_t *mutex;
#endif
@@ -887,6 +897,9 @@
return mem;
}
+/*
+ * (debug)
+ */
APR_DECLARE(void *) apr_pcalloc(apr_pool_t *pool, apr_size_t size)
{
void *mem;
@@ -900,9 +913,10 @@
/*
* Pool creation/destruction (debug)
+ * TODO: printout a line if _VERBOSE is on
*/
-APR_DECLARE(void) apr_pool_clear(apr_pool_t *pool)
+APR_DECLARE(void) apr_pool_clear_dbg(apr_pool_t *pool,const char*file, int
line)
{
debug_node_t *node;
apr_uint32_t index;
@@ -911,7 +925,7 @@
* this pool thus this loop is safe and easy.
*/
while (pool->child)
- apr_pool_destroy(pool->child);
+ apr_pool_destroy_dbg(pool->child,file,line);
/* Run cleanups */
run_cleanups(pool->cleanups);
@@ -935,9 +949,32 @@
}
}
-APR_DECLARE(void) apr_pool_destroy(apr_pool_t *pool)
+/*
+ * destroy (debug)
+ */
+APR_DECLARE(void) apr_pool_destroy_dbg(apr_pool_t *pool,const char*file, int
line)
{
- apr_pool_clear(pool);
+#if defined APR_POOL_DEBUG_VERBOSE
+ apr_file_t *stderr_log = NULL;
+ apr_pool_t *child;
+
+ apr_file_open_stderr(&stderr_log,pool); /* XXX not sure about this one */
+ if (stderr_log) {
+ apr_file_printf(stderr_log,
+ "DEBUG: %s:%d destroy pool tagged %s created %s:%d\n",
+ file, line, pool->tag, pool->file, pool->line);
+ child= pool->child;
+ while (child) {
+ apr_file_printf(stderr_log,
+ "DEBUG:\tpool child tagged %s created %s:%d\n",
+ child->tag, child->file, child->line);
+ child = child->sibling;
+ }
+ apr_file_close(stderr_log);
+ }
+#endif
+
+ apr_pool_clear_dbg(pool,file,line);
/* Remove the pool from the parents child list */
if (pool->parent) {
@@ -961,10 +998,16 @@
free(pool);
}
-APR_DECLARE(apr_status_t) apr_pool_create_ex(apr_pool_t **newpool,
+/*
+ * create (debug)
+ * there is a macro which adds the file/line #
+ */
+APR_DECLARE(apr_status_t) apr_pool_create_ex_dbg(apr_pool_t **newpool,
apr_pool_t *parent,
apr_abortfunc_t abort_fn,
- apr_uint32_t flags)
+ apr_uint32_t flags,
+ const char *file,
+ int line)
{
apr_pool_t *pool;
@@ -1027,6 +1070,9 @@
pool->sibling = NULL;
pool->ref = NULL;
}
+
+ pool->file = file;
+ pool->line = line;
*newpool = pool;
1.205 +2 -0 apr/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/apr/CHANGES,v
retrieving revision 1.204
retrieving revision 1.205
diff -u -r1.204 -r1.205
--- CHANGES 10 Jan 2002 23:46:43 -0000 1.204
+++ CHANGES 11 Jan 2002 21:01:19 -0000 1.205
@@ -1,4 +1,6 @@
Changes with APR b1
+ *) Add new define APR_POOL_DEBUG_VERBOSE which spits out info
+ about pool creation/destruction [Ian Holsman]
*) Fix GMT offset adjustments for platforms that do not have native
GMT offset adjustments. [Jon Travis <[EMAIL PROTECTED]>]
1.89 +2 -6 apr/STATUS
Index: STATUS
===================================================================
RCS file: /home/cvs/apr/STATUS,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -r1.88 -r1.89
--- STATUS 10 Jan 2002 22:28:34 -0000 1.88
+++ STATUS 11 Jan 2002 21:01:20 -0000 1.89
@@ -1,5 +1,5 @@
APACHE PORTABLE RUNTIME (APR) LIBRARY STATUS:
-*-text-*-
-Last modified at [$Date: 2002/01/10 22:28:34 $]
+Last modified at [$Date: 2002/01/11 21:01:20 $]
Release:
@@ -54,11 +54,7 @@
RELEASE NON-SHOWSTOPPERS BUT WOULD BE REAL NICE TO WRAP THESE UP:
- * Add pool lifetime tracking/checking to the pools debug code.
- It would be nice to generate some output on at what line(s) a
- pool was created, cleared and/or destroyed. Maybe introduce
- an APR_POOL_LIFETIME_VERBOSE define for this?
- We should check if a pool is still existent when passed into
+ * We should check if a pool is still existent when passed into
any apr_pool_xxx function. We could do this by recursively
checking if the pool is in a child list, starting at
global_pool. If it is not, bail out and report sourcefile