summaryrefslogtreecommitdiff
path: root/src/gpgrt-int.h
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2017-02-27 00:22:26 +0100
committerWerner Koch <wk@gnupg.org>2017-02-27 00:22:26 +0100
commita52f12cc1879d171ddf309b5ac461bab06c8b5e2 (patch)
tree078802fbcafb2eb41b7fc1d3716c7f7933748188 /src/gpgrt-int.h
parentbe49b02a56e8b405eeb0c07c80eb24e71e841b4a (diff)
downloadlibgpg-error-a52f12cc1879d171ddf309b5ac461bab06c8b5e2.tar.gz
Add a tracing framework.
* src/init.c (trace_save_errno, trace_arg_module) (trace_arg_file, trace_arg_line): New module vars. (do_internal_trace): New. (_gpgrt_internal_trace_printf): New. (_gpgrt_internal_trace): New. (_gpgrt_internal_trace_errno): New. (_gpgrt_internal_trace_end): New. * src/gpgrt-int.h (trace): New macro. (trace_errno): New macro. (trace_start): New macro. (trace_append): New macro. (trace_finish): New macro. -- We want to be abale to use libgpg-error also with pre-c99 compilers and thus we can use the __VA_ARGS__ but resort to the common macro trick.
Diffstat (limited to 'src/gpgrt-int.h')
-rw-r--r--src/gpgrt-int.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/gpgrt-int.h b/src/gpgrt-int.h
index 8a2dae7..e1cf50b 100644
--- a/src/gpgrt-int.h
+++ b/src/gpgrt-int.h
@@ -49,6 +49,50 @@ gpg_err_code_t _gpgrt_lock_unlock (gpgrt_lock_t *lockhd);
gpg_err_code_t _gpgrt_lock_destroy (gpgrt_lock_t *lockhd);
gpg_err_code_t _gpgrt_yield (void);
+/* Trace support. */
+
+void _gpgrt_internal_trace_begin (const char *mod, const char *file, int line);
+void _gpgrt_internal_trace (const char *format,
+ ...) GPGRT_ATTR_PRINTF(1,2);
+void _gpgrt_internal_trace_errno (const char *format,
+ ...) GPGRT_ATTR_PRINTF(1,2);
+void _gpgrt_internal_trace_printf (const char *format,
+ ...) GPGRT_ATTR_PRINTF(1,2);
+void _gpgrt_internal_trace_end (void);
+
+#ifdef ENABLE_TRACING
+# define trace(X) do { \
+ _gpgrt_internal_trace_begin \
+ (ENABLE_TRACING, __func__, __LINE__); \
+ _gpgrt_internal_trace X; \
+ _gpgrt_internal_trace_end (); \
+ } while (0)
+# define trace_errno(X) do { \
+ _gpgrt_internal_trace_begin \
+ (ENABLE_TRACING, __func__, __LINE__); \
+ _gpgrt_internal_trace_errno X; \
+ _gpgrt_internal_trace_end (); \
+ } while (0)
+# define trace_start(X) do { \
+ _gpgrt_internal_trace_begin \
+ (ENABLE_TRACING, __func__, __LINE__); \
+ _gpgrt_internal_trace_printf X; \
+ } while (0)
+# define trace_append(X) do { \
+ _gpgrt_internal_trace_printf X; \
+ } while (0)
+# define trace_finish(X) do { \
+ _gpgrt_internal_trace_printf X; \
+ _gpgrt_internal_trace_end (); \
+ } while (0)
+#else
+# define trace(X) do { } while (0)
+# define trace_errno(X) do { } while (0)
+# define trace_start(X) do { } while (0)
+# define trace_append(X) do { } while (0)
+# define trace_finish(X) do { } while (0)
+#endif /*!ENABLE_TRACING*/
+
/* Local definitions for estream. */