summaryrefslogtreecommitdiff
path: root/cogl
diff options
context:
space:
mode:
authorJonas Ådahl <jadahl@gmail.com>2021-02-02 23:32:27 +0100
committerJonas Ådahl <jadahl@gmail.com>2021-07-29 15:16:48 +0200
commit8bd75747b1ee565f767a5045583649b8f0ce819a (patch)
tree4eeee67dd886d455f31f560984d6aa315240330a /cogl
parentb1ac1327cdf85c7b70e630660c8fcf6b630b21da (diff)
downloadmutter-8bd75747b1ee565f767a5045583649b8f0ce819a.tar.gz
cogl/trace: Add scoped trace anchors
A trace "anchor" is a trace head (CoglTraceHead) that is placed in a certain scope (e.g. function scope), but then only triggered in another scope, e.g. a condition. This makes it possible to have optional trace instrumentation, that is enabled only given e.g. a debug flag. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1700>
Diffstat (limited to 'cogl')
-rw-r--r--cogl/cogl/cogl-trace.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/cogl/cogl/cogl-trace.h b/cogl/cogl/cogl-trace.h
index 3a2a20c63..224655594 100644
--- a/cogl/cogl/cogl-trace.h
+++ b/cogl/cogl/cogl-trace.h
@@ -111,6 +111,18 @@ cogl_auto_trace_end_helper (CoglTraceHead **head)
if (g_private_get (&cogl_trace_thread_data)) \
cogl_trace_describe (&CoglTrace##Name, description);
+#define COGL_TRACE_SCOPED_ANCHOR(Name) \
+ CoglTraceHead G_GNUC_UNUSED CoglTrace##Name = { 0 }; \
+ __attribute__((cleanup (cogl_auto_trace_end_helper))) \
+ CoglTraceHead *ScopedCoglTrace##Name = NULL; \
+
+#define COGL_TRACE_BEGIN_ANCHORED(Name, name) \
+ if (g_private_get (&cogl_trace_thread_data)) \
+ { \
+ cogl_trace_begin (&CoglTrace##Name, name); \
+ ScopedCoglTrace##Name = &CoglTrace##Name; \
+ }
+
#else /* COGL_HAS_TRACING */
#include <stdio.h>
@@ -119,6 +131,8 @@ cogl_auto_trace_end_helper (CoglTraceHead **head)
#define COGL_TRACE_END(Name) (void) 0
#define COGL_TRACE_BEGIN_SCOPED(Name, name) (void) 0
#define COGL_TRACE_DESCRIBE(Name, description) (void) 0
+#define COGL_TRACE_ANCHOR(Name) (void) 0
+#define COGL_TRACE_BEGIN_ANCHORED(Name, name) (void) 0
COGL_EXPORT void
cogl_set_tracing_enabled_on_thread_with_fd (void *data,