[Here's an updated-updated patch ;)]
Since we now have a similar pool debug mode in APR, we
can remove this code from Subversion. To turn
debug mode on, simple pass: --enable-pool-debug=verbose
to configure. If you have electric fence, pass
--with-efence. If you don't want the verbose output,
but still want the mallocy pools, simply use
--enable-pool-debug (without any arguments).
Sander
Log:
* subversion/include/svn_pools.h
Remove the comments about how to turn on debugging and
what the output format looks like.
(svn_pool_create, svn_pool_create_debug, svn_pool_clear,
svn_pool_clear_debug): change arguments for _debug from
seperate file, line, to a single string. Pass
APR_POOL__FILE_LINE__ which is a single string containing
__FILE__:__LINE__. Always declare both the regular
function aswell as the debug counterpart.
(svn_pool_destroy): defined to apr_pool_destroy.
(svn_pool_destroy_debug): deleted. This is implicit now,
per the above define.
* subversion/libsvn_subr/svn_error.c
(svn_pool_create, svn_pool_create_debug, svn_pool_clear,
svn_pool_clear_debug): moved to the bottom of the file.
Make sure that both the regular function aswell as the
debug counterpart are always implemented. This ensures
binary compatibility (for quick switching between debug
and regular). Changed arguments for _debug from seperate
file, line, to a single string. In debug mode call
apr_pool_xxx_debug to get the debug functionality with
the correct file:line in the output.
(svn_pool_destroy, svn_pool_destroy_debug): deleted.
(find_oldest_pool_ancestor): deleted.
Index: subversion/libsvn_subr/svn_error.c
===================================================================
--- subversion/libsvn_subr/svn_error.c
+++ subversion/libsvn_subr/svn_error.c Wed Jan 30 13:06:35 2002
@@ -287,184 +287,6 @@
}
-#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)
-{
- while (1)
- {
- apr_pool_t *parent = apr_pool_get_parent (p);
-
- if (parent == NULL) /* too far? */
- return p;
- p = parent;
- }
- /* NOTREACHED */
-}
-#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;
-
- apr_pool_create_ex (&ret_pool, parent_pool, abort_on_pool_failure,
- APR_POOL_FDEFAULT);
-
- /* If there is no parent, then initialize ret_pool as the "top". */
- if (parent_pool == NULL)
- {
- apr_status_t apr_err = svn_error_init_pool (ret_pool);
- if (apr_err)
- abort_on_pool_failure (apr_err);
- }
- else
- {
- /* Inherit the error pool and feedback vtable from the parent. */
- svn_pool_feedback_t *vtable;
- svn_pool__inherit_error_pool (ret_pool);
- apr_pool_userdata_get ((void **)&vtable,
- SVN_ERROR_FEEDBACK_VTABLE, parent_pool);
- apr_pool_userdata_set (vtable, SVN_ERROR_FEEDBACK_VTABLE,
- apr_pool_cleanup_null, ret_pool);
- }
-
- /* Sanity check: do we actually have an error pool? */
- {
- svn_boolean_t subpool_of_p_p;
- apr_pool_t *error_pool;
- svn_error__get_error_pool (ret_pool, &error_pool,
- &subpool_of_p_p);
- if (! error_pool)
- abort_on_pool_failure (SVN_ERR_BAD_CONTAINING_POOL);
- }
-
-#ifdef SVN_POOL_DEBUG
- {
- fprintf (stderr,
- "PDEBUG: + "
- " " /* 10/10 here */
- " 0x%08X (%s:%d) parent=0x%08X\n",
- (unsigned int)ret_pool, file, line, (unsigned int)parent_pool);
- }
-#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_pool_feedback_t *vtable, vtable_tmp;
- svn_boolean_t subpool_of_p_p; /* That's "predicate" to you, bud. */
-
-#ifdef SVN_POOL_DEBUG
- {
- apr_size_t num_bytes = apr_pool_num_bytes (p, 1);
- apr_size_t global_num_bytes =
- apr_pool_num_bytes (find_oldest_pool_ancestor (p), 1);
-
- fprintf (stderr, "PDEBUG: 0 %10lu %10lu 0x%08X (%s:%d)\n",
- (unsigned long)num_bytes, (unsigned long)global_num_bytes,
- (unsigned int)p, file, line);
- }
-#endif /* SVN_POOL_DEBUG */
-
- /* Get the error_pool from this pool. If it's rooted in this pool, we'll
- need to re-create it after we clear the pool. */
- svn_error__get_error_pool (p, &error_pool, &subpool_of_p_p);
-
- /* Get the feedback vtable */
- apr_pool_userdata_get ((void **)&vtable, SVN_ERROR_FEEDBACK_VTABLE, p);
-
- if (subpool_of_p_p)
- {
- /* Here we have a problematic situation. We're getting ready to
- clear this pool P, which will invalidate all its userdata.
- The problem is that as far as we can tell, the error pool and
- feedback vtable on this pool aren't copies of the originals,
- they *are* the originals. We need to be able to re-create
- them in this pool after it has been cleared.
-
- For the error pool, this turns out to be not that big of a
- deal. We don't actually need to keep *the* original error
- pool -- we can just initialize a new error pool to stuff into
- P here after it's been cleared.
-
- The feedback vtable doesn't offer quite the luxury. We can't
- really afford to just create a new feedback vtable, since the
- caller may have already overridden the functions therein.
- So, we have to copy out those function pointers temporarily. */
- vtable_tmp = *vtable;
- }
-
- /* Clear the pool. All userdata of this pool is now invalid. */
- apr_pool_clear (p);
-
- if (subpool_of_p_p)
- {
- /* Make new error pool. */
- svn_error__make_error_pool (p, &error_pool);
-
- /* Dupe our squirreled-away vtable back into P... */
- vtable = apr_palloc (p, sizeof (*vtable));
- *vtable = vtable_tmp;
- }
-
- /* Now, reset the error pool and feedback stream on P. */
- svn_error__set_error_pool (p, error_pool, subpool_of_p_p);
- apr_pool_userdata_set (vtable, SVN_ERROR_FEEDBACK_VTABLE,
- apr_pool_cleanup_null, p);
-
-}
-
-
-#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 = apr_pool_num_bytes (p, 1);
- apr_size_t global_num_bytes =
- apr_pool_num_bytes (find_oldest_pool_ancestor (p), 1);
-
- fprintf (stderr, "PDEBUG: - %10lu %10lu 0x%08X (%s:%d)\n",
- (unsigned long)num_bytes, (unsigned long)global_num_bytes,
- (unsigned int)p, file, line);
- }
-#endif /* SVN_POOL_DEBUG */
-
- apr_pool_destroy (p);
-}
-
-
/*** Creating and destroying errors. ***/
@@ -613,6 +435,145 @@
return apr_strerror (statcode, buf, bufsize);
}
+
+
+/*
+ Macros to make the preprocessor logic less confusing.
+ We need to always have svn_pool_xxx aswell as
+ svn_pool_xxx_debug, where one of the two is a simple
+ wrapper calling the other.
+ */
+#if !APR_POOL_DEBUG
+#define SVN_POOL_FUNC_DEFINE(rettype, name) \
+ rettype name(apr_pool_t *pool)
+
+#define SVN_POOL_WRAPPER_DEFINE(rettype, name) \
+ rettype name##_debug(apr_pool_t *pool, const char *file_line) \
+ { \
+ return name(pool); \
+ }
+
+#else /* APR_POOL_DEBUG */
+#undef svn_pool_create
+#undef svn_pool_clear
+
+#define SVN_POOL_FUNC_DEFINE(rettype, name) \
+ rettype name##_debug(apr_pool_t *pool, const char *file_line)
+
+#define SVN_POOL_WRAPPER_DEFINE(rettype, name) \
+ rettype name(apr_pool_t *pool) \
+ { \
+ return name##_debug(pool, "svn:<undefined>"); \
+ }
+#endif /* APR_POOL_DEBUG */
+
+
+SVN_POOL_FUNC_DEFINE(apr_pool_t *, svn_pool_create)
+{
+ apr_pool_t *ret_pool;
+
+#if !APR_POOL_DEBUG
+ apr_pool_create_ex (&ret_pool, pool, abort_on_pool_failure,
+ APR_POOL_FDEFAULT);
+#else /* APR_POOL_DEBUG */
+ apr_pool_create_ex_debug (&ret_pool, pool, abort_on_pool_failure,
+ APR_POOL_FDEFAULT, file_line);
+#endif /* APR_POOL_DEBUG */
+
+ /* If there is no parent, then initialize ret_pool as the "top". */
+ if (pool == NULL)
+ {
+ apr_status_t apr_err = svn_error_init_pool (ret_pool);
+ if (apr_err)
+ abort_on_pool_failure (apr_err);
+ }
+ else
+ {
+ /* Inherit the error pool and feedback vtable from the parent. */
+ svn_pool_feedback_t *vtable;
+ svn_pool__inherit_error_pool (ret_pool);
+ apr_pool_userdata_get ((void **)&vtable,
+ SVN_ERROR_FEEDBACK_VTABLE, pool);
+ apr_pool_userdata_set (vtable, SVN_ERROR_FEEDBACK_VTABLE,
+ apr_pool_cleanup_null, ret_pool);
+ }
+
+ /* Sanity check: do we actually have an error pool? */
+ {
+ svn_boolean_t subpool_of_p_p;
+ apr_pool_t *error_pool;
+ svn_error__get_error_pool (ret_pool, &error_pool,
+ &subpool_of_p_p);
+ if (! error_pool)
+ abort_on_pool_failure (SVN_ERR_BAD_CONTAINING_POOL);
+ }
+
+ return ret_pool;
+}
+
+
+SVN_POOL_FUNC_DEFINE(void, svn_pool_clear)
+{
+ apr_pool_t *error_pool;
+ svn_pool_feedback_t *vtable, vtable_tmp;
+ svn_boolean_t subpool_of_p_p; /* That's "predicate" to you, bud. */
+
+ /* Get the error_pool from this pool. If it's rooted in this pool, we'll
+ need to re-create it after we clear the pool. */
+ svn_error__get_error_pool (pool, &error_pool, &subpool_of_p_p);
+
+ /* Get the feedback vtable */
+ apr_pool_userdata_get ((void **)&vtable, SVN_ERROR_FEEDBACK_VTABLE, pool);
+
+ if (subpool_of_p_p)
+ {
+ /* Here we have a problematic situation. We're getting ready to
+ clear this pool P, which will invalidate all its userdata.
+ The problem is that as far as we can tell, the error pool and
+ feedback vtable on this pool aren't copies of the originals,
+ they *are* the originals. We need to be able to re-create
+ them in this pool after it has been cleared.
+
+ For the error pool, this turns out to be not that big of a
+ deal. We don't actually need to keep *the* original error
+ pool -- we can just initialize a new error pool to stuff into
+ P here after it's been cleared.
+
+ The feedback vtable doesn't offer quite the luxury. We can't
+ really afford to just create a new feedback vtable, since the
+ caller may have already overridden the functions therein.
+ So, we have to copy out those function pointers temporarily. */
+ vtable_tmp = *vtable;
+ }
+
+ /* Clear the pool. All userdata of this pool is now invalid. */
+#if !APR_POOL_DEBUG
+ apr_pool_clear (pool);
+#else /* APR_POOL_DEBUG */
+ apr_pool_clear_debug (pool, file_line);
+#endif /* APR_POOL_DEBUG */
+
+ if (subpool_of_p_p)
+ {
+ /* Make new error pool. */
+ svn_error__make_error_pool (pool, &error_pool);
+
+ /* Dupe our squirreled-away vtable back into P... */
+ vtable = apr_palloc (pool, sizeof (*vtable));
+ *vtable = vtable_tmp;
+ }
+
+ /* Now, reset the error pool and feedback stream on P. */
+ svn_error__set_error_pool (pool, error_pool, subpool_of_p_p);
+ apr_pool_userdata_set (vtable, SVN_ERROR_FEEDBACK_VTABLE,
+ apr_pool_cleanup_null, pool);
+
+}
+
+
+SVN_POOL_WRAPPER_DEFINE(apr_pool_t *, svn_pool_create)
+SVN_POOL_WRAPPER_DEFINE(void, svn_pool_clear)
+
/*
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Oct 21 14:37:01 2006