[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

debugging from test logs (was: [PATCH] Win32 File Permission Fixes)

From: Jay Freeman \(saurik\) <saurik_at_saurik.com>
Date: 2002-02-12 08:51:53 CET

Branko:

Hmmm... I can't figure out how to run those tests. Mind sharing the
secret? :) (The logs aren't enough for me.) I keep getting things
like:

Checking out t1.

apr_error: #22503, src_err 0 : <The system cannot find the path
specified. >
  src:
d:\code\ninetjer\external\subversion\subversion\libsvn_client\checkout.c
:
135
  unable to open
/cygdrive/d/Code/ninetjer/external/subversion/subversion/tests/
clients/cmdline/xmltests/../../../xml/co1-inline.xml

Speaking of which, looking at this log gave me the idea for this patch
(which you can see the output of above, but heavily damaged due to
wrapping issues). What do you think about it? It makes it so that,
when SVN_DEBUG and _WIN32 are declared (this should work on gcc, but I
haven't tested it) the source code file and line are displayed to the
user getting the error. It looks like this (as the directory I have my
code in is quite long, wrapping makes this look kind of stupid, so I've
truncated it to <.=.>):

D:\<.=.>\clients\cmdline\Debug>svn co h

svn_error: #21076 : <Bad URL passed to RA layer>
  src: d:\<.=.>\libsvn_ra\ra_loader.c:199
  Unrecognized URL scheme: h

D:\<.=.>\clients\cmdline\Debug>

I find it makes it a _ton_ easier to figure out where things are
happening from when you can't put a breakpoint in make_error_internal()
or svn_error_create().

Sincerely,
Jay Freeman (saurik)
saurik@saurik.com

Index: .\subversion\include\svn_types.h
===================================================================
--- .\subversion\include\svn_types.h
+++ .\subversion\include\svn_types.h Tue Feb 12 01:10:44 2002
@@ -47,6 +47,8 @@
   struct svn_error *child; /* ptr to the error we "wrap" */
   apr_pool_t *pool; /* The pool holding this error and any
                                 child errors it wraps */
+ const char *file; /* the source file that threw the error */
+ int line; /* the source line that threw the error */
 } svn_error_t;

Index: .\subversion\include\svn_error.h
===================================================================
--- .\subversion\include\svn_error.h
+++ .\subversion\include\svn_error.h Tue Feb 12 01:33:41 2002
@@ -75,6 +75,17 @@
                                const char *message);

 /* Create an error structure with the given APR_ERR, SRC_ERR, CHILD,
+ POOL and MESSAGE, but support extra debugging information from the
+ compiler so we actually know what we are doing (heaven forbid). */
+svn_error_t *svn_error_create_debug (apr_status_t apr_err,
+ int src_err,
+ svn_error_t *child,
+ apr_pool_t *pool,
+ const char *src_file,
+ int src_line,
+ const char *message);
+
+/* Create an error structure with the given APR_ERR, SRC_ERR, CHILD,
    and POOL, with a printf-style error message produced by passing
    FMT, ... through apr_psprintf. */
 svn_error_t *svn_error_createf (apr_status_t apr_err,
@@ -85,6 +96,23 @@
                                 ...)
        __attribute__ ((format (printf, 5, 6)));

+/* Create an error structure with the given APR_ERR, SRC_ERR, CHILD,
+ and POOL, with a printf-style error message produced by passing
+ FMT, ... through apr_psprintf with some extra debug info. */
+svn_error_t *svn_error_createf_debug (apr_status_t apr_err,
+ int src_err,
+ svn_error_t *child,
+ apr_pool_t *pool,
+ const char *src_file,
+ int src_line,
+ const char *fmt,
+ ...)
+ __attribute__ ((format (printf, 5, 6)));
+
+/* When all else fails, simply pass the current source and line for
+ check-pointing purposes. Subsequent errors will assume these. */
+svn_error_t *svn_error_set_debug(const char *src_file, int src_line);
+

 /* A quick n' easy way to create a wrappered exception with your own
    message, before throwing it up the stack. (It uses all of the
@@ -134,6 +162,26 @@
       return svn_err__temp; \
   } while (0)

+#if defined(SVN_DEBUG) && defined(_WIN32)
+
+#define svn_error_create(apr_err, \
+ src_err, \
+ child, \
+ pool, \
+ message) \
+ svn_error_create_debug (apr_err, \
+ src_err, \
+ child, \
+ pool, \
+ __FILE__, \
+ __LINE__, \
+ message)
+
+#define svn_error_createf \
+ svn_error_set_debug (__FILE__, __LINE__), \
+ svn_error_createf
+
+#endif /* SVN_DEBUG && _WIN32 */

 #ifdef __cplusplus
 }
Index: .\subversion\libsvn_subr\svn_error.c
===================================================================
--- .\subversion\libsvn_subr\svn_error.c
+++ .\subversion\libsvn_subr\svn_error.c Tue Feb 12 01:38:17 2002
@@ -30,6 +30,10 @@
 #include "svn_error.h"
 #include "svn_io.h"

+/* Undo the effects of various debugging #define's */
+#undef svn_error_create
+#undef svn_error_createf
+
 /* Key for the error pool itself. */
 #define SVN_ERROR_POOL "svn-error-pool"

@@ -37,6 +41,9 @@
    the pool whose prog_data we got it from. */
 #define SVN_ERROR_POOL_ROOTED_HERE "svn-error-pool-rooted-here"

+static const char *g_src_file = NULL;
+static int g_src_line = 0;
+

 $B!j(B
 /*** helpers for creating errors ***/
@@ -74,7 +81,9 @@
   new_error->apr_err = apr_err;
   new_error->src_err = src_err;
   new_error->child = child;
- new_error->pool = newpool;
+ new_error->pool = newpool;
+ new_error->file = g_src_file;
+ new_error->line = g_src_line;

   return new_error;
 }
@@ -226,6 +235,47 @@
   return err;
 }

+svn_error_t *
+svn_error_create_debug (apr_status_t apr_err,
+ int src_err,
+ svn_error_t *child,
+ apr_pool_t *pool,
+ const char *src_file,
+ int src_line,
+ const char *message)
+{
+ svn_error_t *err;
+
+ err = svn_error_create(apr_err,
+ src_err,
+ child,
+ pool,
+ message);
+
+ err->file = src_file;
+ err->line = src_line;
+
+ return err;
+}
+
+
+svn_error_t *
+svn_error_internal_createf (apr_status_t apr_err,
+ int src_err,
+ svn_error_t *child,
+ apr_pool_t *pool,
+ const char *fmt,
+ va_list ap)
+{
+ svn_error_t *err;
+
+ err = make_error_internal (apr_err, src_err, child, pool);
+
+ err->message = apr_pvsprintf (err->pool, fmt, ap);
+
+ return err;
+}
+

 svn_error_t *
 svn_error_createf (apr_status_t apr_err,
@@ -239,17 +289,58 @@

   va_list ap;

- err = make_error_internal (apr_err, src_err, child, pool);
+ va_start (ap, fmt);
+ err = svn_error_internal_createf (apr_err,
+ src_err,
+ child,
+ pool,
+ fmt,
+ ap);
+ va_end (ap);
+
+ return err;
+}
+
+
+svn_error_t *
+svn_error_createf_debug (apr_status_t apr_err,
+ int src_err,
+ svn_error_t *child,
+ apr_pool_t *pool,
+ const char *src_file,
+ int src_line,
+ const char *fmt,
+ ...)
+{
+ svn_error_t *err;
+
+ va_list ap;

   va_start (ap, fmt);
- err->message = apr_pvsprintf (err->pool, fmt, ap);
+ err = svn_error_internal_createf (apr_err,
+ src_err,
+ child,
+ pool,
+ fmt,
+ ap);
   va_end (ap);

+ err->file = src_file;
+ err->line = src_line;
+
   return err;
 }

 svn_error_t *
+svn_error_set_debug(const char *src_file, int src_line) {
+ g_src_file = src_file;
+ g_src_line = src_line;
+ return NULL;
+}
+
+
+svn_error_t *
 svn_error_quick_wrap (svn_error_t *child, const char *new_msg)
 {
   return svn_error_create (child->apr_err,
@@ -297,6 +388,9 @@
              err->apr_err,
              err->src_err,
              apr_strerror (err->apr_err, buf, sizeof(buf)));
+
+ if (err->file)
+ fprintf (stream, " src: %s:%i\n", err->file, err->line);

   if (err->message)
     fprintf (stream, " %s", err->message);

---------------------------------------------------------------------
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:06 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.