I'm debugging/fixing some env unsetting issues and found this function to be handy, currently it's on if MOD_PERL_TRACE/PerlTrace is set to some non-false value.
First I'm not sure where to put it, modperl_util.c seems ok, but it's really for non-debug functions, may be we need to start modperl_debug.c, move all the debug helper functions there and enable them only if mp is built with MP_MAINTAINER=1?


On the other hand, do you think it could be handy in the Perl API, as part of APR::Table? Sure, there are the _do functions to traverse the table, but being able to just dump contents at once would be useful too. May be something to think about for later, since it can't be used in the current form (as in the patch).

Index: src/modules/perl/modperl_util.c
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_util.c,v
retrieving revision 1.53
diff -u -r1.53 modperl_util.c
--- src/modules/perl/modperl_util.c     18 Sep 2003 07:44:24 -0000      1.53
+++ src/modules/perl/modperl_util.c     21 Sep 2003 03:23:30 -0000
@@ -734,3 +734,24 @@

     return newRV_noinc(sv);
 }
+
+#ifdef MP_TRACE
+/* XXX: internal debug function */
+/* any non-false value for MOD_PERL_TRACE/PerlTrace enables this function */
+void modperl_apr_table_dump(pTHX_ apr_table_t *table, char *name)
+{
+    int i;
+    const apr_array_header_t *array;
+    apr_table_entry_t *elts;
+
+    array = apr_table_elts(table);
+    elts  = (apr_table_entry_t *)array->elts;
+    modperl_trace(MP_FUNC, "Contents of table %s", name);
+    for (i = 0; i < array->nelts; i++) {
+        if (!elts[i].key || !elts[i].val) {
+            continue;
+        }
+        modperl_trace(MP_FUNC, "%s => %s", elts[i].key, elts[i].val);
+    }
+}
+#endif
Index: src/modules/perl/modperl_util.h
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_util.h,v
retrieving revision 1.47
diff -u -r1.47 modperl_util.h
--- src/modules/perl/modperl_util.h     18 Sep 2003 07:44:24 -0000      1.47
+++ src/modules/perl/modperl_util.h     21 Sep 2003 03:23:30 -0000
@@ -155,4 +155,8 @@

void modperl_clear_symtab(pTHX_ HV *symtab);

+#ifdef MP_TRACE
+void modperl_apr_table_dump(pTHX_ apr_table_t *table, char *name);
+#endif
+
 #endif /* MODPERL_UTIL_H */


__________________________________________________________________ Stas Bekman JAm_pH ------> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to