cmpilato@tigris.org writes:
> *_debug version of these functions print pool usage stats to stderr.
> JimB is The Friggin' Man for suggesting this to me (though he never
> asked me to commit these changes to CVS...I get full blame if this
> is a no-no).
I definitely do _not_ think this is a no-no, fwiw.
If Malloc Minnesota is the last time we ever want pool tracking for
debugging purposes, we'll be doing surprisingly well. :-)
-K
> Revision Changes Path
> 1.59 +70 -2 subversion/subversion/libsvn_subr/svn_error.c
>
> Index: svn_error.c
> ===================================================================
> RCS file: /cvs/subversion/subversion/libsvn_subr/svn_error.c,v
> retrieving revision 1.58
> retrieving revision 1.59
> diff -u -r1.58 -r1.59
> --- svn_error.c 2001/04/12 08:02:37 1.58
> +++ svn_error.c 2001/04/12 09:01:34 1.59
> @@ -206,8 +206,34 @@
> }
>
>
> +#ifdef SVN_POOL_DEBUG
> +/* Find the oldest living ancestor of pool P (which could very well be
> + P itself) */
> +static apr_pool_t *
> +find_oldest_pool_ancestor (apr_pool_t *p)
> +{
> + apr_pool_t *ret_pool = p;
> +
> + if (ret_pool != NULL)
> + {
> + while (ret_pool->parent)
> + ret_pool = ret_pool->parent;
> + }
> + return ret_pool;
> +}
> +#endif /* SVN_POOL_DEBUG */
> +
> +
> +
> +#ifndef SVN_POOL_DEBUG
> apr_pool_t *
> svn_pool_create (apr_pool_t *parent_pool)
> +#else /* SVN_POOL_DEBUG */
> +apr_pool_t *
> +svn_pool_create_debug (apr_pool_t *parent_pool,
> + const char *file,
> + int line)
> +#endif /* SVN_POOL_DEBUG */
> {
> apr_pool_t *ret_pool;
>
> @@ -224,18 +250,42 @@
> }
> else
> svn_pool__inherit_error_pool (ret_pool);
> -
> +
> +#ifdef SVN_POOL_DEBUG
> + {
> + fprintf (stderr, "Pool 0x%08X created at %s:%d\n",
> + (unsigned int)ret_pool, file, line);
> + }
> +#endif /* SVN_POOL_DEBUG */
> +
> return ret_pool;
> }
>
> -
>
> +#ifndef SVN_POOL_DEBUG
> void
> svn_pool_clear (apr_pool_t *p)
> +#else /* SVN_POOL_DEBUG */
> +void
> +svn_pool_clear_debug (apr_pool_t *p,
> + const char *file,
> + int line)
> +#endif /* SVN_POOL_DEBUG */
> {
> apr_pool_t *error_pool;
> svn_boolean_t subpool_of_p_p; /* That's "predicate" to you, bud. */
>
> +#ifdef SVN_POOL_DEBUG
> + {
> + apr_size_t num_bytes = svn_pool_get_size (p);
> + apr_size_t global_num_bytes =
> + svn_pool_get_size (find_oldest_pool_ancestor (p));
> +
> + fprintf (stderr, "Pool 0x%08X cleared at %s:%d (%d/%d bytes)\n",
> + (unsigned int)p, file, line, num_bytes, global_num_bytes);
> + }
> +#endif /* SVN_POOL_DEBUG */
> +
> if (p->parent)
> svn_error__get_error_pool (p->parent, &error_pool, &subpool_of_p_p);
> else
> @@ -261,9 +311,27 @@
> }
>
>
> +#ifndef SVN_POOL_DEBUG
> void
> svn_pool_destroy (apr_pool_t *p)
> +#else /* SVN_POOL_DEBUG */
> +void
> +svn_pool_destroy_debug (apr_pool_t *p,
> + const char *file,
> + int line)
> +#endif /* SVN_POOL_DEBUG */
> {
> +#ifdef SVN_POOL_DEBUG
> + {
> + apr_size_t num_bytes = svn_pool_get_size (p);
> + apr_size_t global_num_bytes =
> + svn_pool_get_size (find_oldest_pool_ancestor (p));
> +
> + fprintf (stderr, "Pool 0x%08X destroyed at %s:%d (%d/%d bytes)\n",
> + (unsigned int)p, file, line, num_bytes, global_num_bytes);
> + }
> +#endif /* SVN_POOL_DEBUG */
> +
> apr_pool_destroy (p);
> }
>
>
>
>
> 1.98 +43 -2 subversion/subversion/include/svn_error.h
>
> Index: svn_error.h
> ===================================================================
> RCS file: /cvs/subversion/subversion/include/svn_error.h,v
> retrieving revision 1.97
> retrieving revision 1.98
> diff -u -r1.97 -r1.98
> --- svn_error.h 2001/04/12 08:02:35 1.97
> +++ svn_error.h 2001/04/12 09:01:35 1.98
> @@ -274,6 +274,14 @@
>
> /*** Wrappers around APR pools, so we get error pools. ***/
>
> +/* If you want pool usage debug info dumped to stderr (in environments
> + * that support that kind of thing), #define SVN_POOL_DEBUG here.
> + */
> +/*
> +#define SVN_POOL_DEBUG
> +*/
> +
> +
>
> /* THE ERROR POOL
> *
> @@ -334,6 +342,8 @@
> apr_size_t svn_pool_get_size (apr_pool_t *pool);
>
>
> +
> +#ifndef SVN_POOL_DEBUG
> /* Return a new pool. If PARENT_POOL is non-null, then the new
> * pool will be a subpool of it, and will inherit the containing
> * pool's dedicated error subpool.
> @@ -348,11 +358,16 @@
> */
> apr_pool_t *svn_pool_create (apr_pool_t *parent_pool);
>
> +#else /* SVN_POOL_DEBUG */
> +apr_pool_t *svn_pool_create_debug (apr_pool_t *parent_pool,
> + const char *file,
> + int line);
> +#define svn_pool_create(p) svn_pool_create_debug(p, __FILE__, __LINE__)
> +#endif /* SVN_POOL_DEBUG */
>
> -/* Destroy a POOL */
> -void svn_pool_destroy (apr_pool_t *pool);
>
>
> +#ifndef SVN_POOL_DEBUG
> /* Clear the passed in pool.
> *
> * The reason we need this wrapper to apr_pool_clear, is because
> @@ -363,6 +378,32 @@
> * If anything goes wrong, an abort function will be called.
> */
> void svn_pool_clear (apr_pool_t *p);
> +
> +#else /* SVN_POOL_DEBUG */
> +void svn_pool_clear_debug (apr_pool_t *p,
> + const char *file,
> + int line);
> +#define svn_pool_clear(p) svn_pool_clear_debug(p, __FILE__, __LINE__)
> +#endif /* SVN_POOL_DEBUG */
> +
> +
> +#ifndef SVN_POOL_DEBUG
> +
> +/* Destroy a POOL and all of its children.
> + *
> + * This wrapper to apr_pool_destroy exists for symmatry (the
> + * not-so-grand reason) and for the existence of a great memory usage
> + * debugging hook (the grand reason).
> + */
> +void svn_pool_destroy (apr_pool_t *p);
> +
> +#else /* SVN_POOL_DEBUG */
> +void svn_pool_destroy_debug (apr_pool_t *p,
> + const char *file,
> + int line);
> +#define svn_pool_destroy(p) svn_pool_destroy_debug(p, __FILE__, __LINE__)
> +#endif /* SVN_POOL_DEBUG */
> +
>
>
>
>
>
>
Received on Sat Oct 21 14:36:28 2006