[libdazzle] debug: add tracing helpers
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libdazzle] debug: add tracing helpers
- Date: Sat, 17 Jun 2017 08:13:06 +0000 (UTC)
commit 4602ab4bc7b3b1a148d6a206fcd2a314224d4252
Author: Christian Hergert <chergert redhat com>
Date: Sat Jun 17 00:53:53 2017 -0700
debug: add tracing helpers
These can be used when -Denable_tracing=true is set. They compile out when
that build option is not set. This header does not get installed, it is
private to the library.
src/dzl-debug.h.in | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++
src/meson.build | 9 +++++
2 files changed, 92 insertions(+), 0 deletions(-)
---
diff --git a/src/dzl-debug.h.in b/src/dzl-debug.h.in
new file mode 100644
index 0000000..c8286f3
--- /dev/null
+++ b/src/dzl-debug.h.in
@@ -0,0 +1,83 @@
+/* dzl-debug.h.in
+ *
+ * Copyright (C) 2013-2017 Christian Hergert <christian hergert me>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef DZL_DEBUG_H
+#define DZL_DEBUG_H
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+#ifndef DZL_ENABLE_TRACE
+# define DZL_ENABLE_TRACE @ENABLE_TRACING@
+#endif
+#if DZL_ENABLE_TRACE != 1
+# undef DZL_ENABLE_TRACE
+#endif
+
+/**
+ * DZL_LOG_LEVEL_TRACE: (skip)
+ */
+#ifndef DZL_LOG_LEVEL_TRACE
+# define DZL_LOG_LEVEL_TRACE ((GLogLevelFlags)(1 << G_LOG_LEVEL_USER_SHIFT))
+#endif
+
+#ifdef DZL_ENABLE_TRACE
+# define DZL_TRACE_MSG(fmt, ...) \
+ g_log(G_LOG_DOMAIN, DZL_LOG_LEVEL_TRACE, " MSG: %s():%d: " fmt, \
+ G_STRFUNC, __LINE__, ##__VA_ARGS__)
+# define DZL_PROBE \
+ g_log(G_LOG_DOMAIN, DZL_LOG_LEVEL_TRACE, "PROBE: %s():%d", \
+ G_STRFUNC, __LINE__)
+# define DZL_TODO(_msg) \
+ g_log(G_LOG_DOMAIN, DZL_LOG_LEVEL_TRACE, " TODO: %s():%d: %s", \
+ G_STRFUNC, __LINE__, _msg)
+# define DZL_ENTRY \
+ g_log(G_LOG_DOMAIN, DZL_LOG_LEVEL_TRACE, "ENTRY: %s():%d", \
+ G_STRFUNC, __LINE__)
+# define DZL_EXIT \
+ G_STMT_START { \
+ g_log(G_LOG_DOMAIN, DZL_LOG_LEVEL_TRACE, " EXIT: %s():%d", \
+ G_STRFUNC, __LINE__); \
+ return; \
+ } G_STMT_END
+# define DZL_GOTO(_l) \
+ G_STMT_START { \
+ g_log(G_LOG_DOMAIN, DZL_LOG_LEVEL_TRACE, " GOTO: %s():%d ("#_l")", \
+ G_STRFUNC, __LINE__); \
+ goto _l; \
+ } G_STMT_END
+# define DZL_RETURN(_r) \
+ G_STMT_START { \
+ g_log(G_LOG_DOMAIN, DZL_LOG_LEVEL_TRACE, " EXIT: %s():%d ", \
+ G_STRFUNC, __LINE__); \
+ return _r; \
+ } G_STMT_END
+#else
+# define DZL_TODO(_msg)
+# define DZL_PROBE
+# define DZL_TRACE_MSG(fmt, ...)
+# define DZL_ENTRY
+# define DZL_GOTO(_l) goto _l
+# define DZL_EXIT return
+# define DZL_RETURN(_r) return _r
+#endif
+
+G_END_DECLS
+
+#endif /* DZL_DEBUG_H */
diff --git a/src/meson.build b/src/meson.build
index 7dbcc0d..0017ae2 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -22,7 +22,16 @@ dzl_version_h = configure_file(
install: true,
configuration: version_data)
+debug_data = configuration_data()
+debug_data.set10('ENABLE_TRACING', get_option('enable_tracing'))
+
+dzl_debug_h = configure_file(
+ input: 'dzl-debug.h.in',
+ output: 'dzl-debug.h',
+ configuration: debug_data)
+
libdazzle_generated_headers = [
+ dzl_debug_h,
dzl_version_h,
]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]