From bd24feaa86f8154e550107990392ac9ac05e60d4 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Fri, 19 Oct 2012 11:23:39 +0200 Subject: Trace the use of GPG_ERR_INV_ENGINE. * src/debug.h: Include "gpgme.h" (_gpgme_trace_gpgme_error): New. (trace_gpg_error): New macro. Use it in all files where we return GPG_ERR_INV_ENGINE; also "include debug.h" as needed. -- This is a pretty common error code but often it is hard to figure out the actual cause. With debug level 4 we now print the file name and line number where this error code is generated by gpgme. Along with the git revision printed in the first log lines, this should give us an easier way to track down the problems related to this error code. --- src/debug.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/debug.h') diff --git a/src/debug.h b/src/debug.h index ead92b24..c99b7003 100644 --- a/src/debug.h +++ b/src/debug.h @@ -26,6 +26,9 @@ #include #endif +#include "gpgme.h" /* Required for gpgme_error stuff. */ + + /* Indirect stringification, requires __STDC__ to work. */ #define STRINGIFY(v) #v #define XSTRINGIFY(v) STRINGIFY(v) @@ -81,6 +84,13 @@ void _gpgme_debug_buffer (int lvl, const char *const fmt, void _gpgme_debug_frame_begin (void); void _gpgme_debug_frame_end (void); +static inline gpgme_error_t +_gpgme_trace_gpgme_error (gpgme_error_t err, const char *file, int line) +{ + _gpgme_debug (DEBUG_ENGINE, "%s:%d: returning error: %s\n", + _gpgme_debug_srcname (file), line, gpgme_strerror (err)); + return err; +} /* Trace support. */ @@ -262,4 +272,11 @@ void _gpgme_debug_frame_end (void); _gpgme_debug_end (&(hlp)) #define TRACE_ENABLED(hlp) (!!(hlp)) +/* And finally a simple macro to trace the location of an error code. + This macro is independent of the other trace macros and may be used + without any preconditions. */ +#define trace_gpg_error(e) \ + _gpgme_trace_gpgme_error (gpg_error (e), __FILE__, __LINE__) + + #endif /* DEBUG_H */ -- cgit v1.2.3