cogl/trace: Add COGL_TRACE_MESSAGE
Emits a formatted message at the current time without a duration. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3417>
This commit is contained in:
parent
e63a5369d0
commit
1f22b3a2e2
@ -338,6 +338,38 @@ cogl_trace_end (CoglTraceHead *head)
|
||||
g_free (head->description);
|
||||
}
|
||||
|
||||
void
|
||||
cogl_trace_mark (const char *name,
|
||||
const char *description)
|
||||
{
|
||||
SysprofTimeStamp time;
|
||||
CoglTraceContext *trace_context;
|
||||
CoglTraceThreadContext *trace_thread_context;
|
||||
|
||||
time = g_get_monotonic_time () * 1000;
|
||||
trace_thread_context = g_private_get (&cogl_trace_thread_data);
|
||||
trace_context = trace_thread_context->trace_context;
|
||||
|
||||
g_mutex_lock (&cogl_trace_mutex);
|
||||
if (!sysprof_capture_writer_add_mark (trace_context->writer,
|
||||
time,
|
||||
trace_thread_context->cpu_id,
|
||||
trace_thread_context->pid,
|
||||
0,
|
||||
trace_thread_context->group,
|
||||
name,
|
||||
description))
|
||||
{
|
||||
/* XXX: g_main_context_get_thread_default() might be wrong, it probably
|
||||
* needs to store the GMainContext in CoglTraceThreadContext when creating
|
||||
* and use it here.
|
||||
*/
|
||||
if (errno == EPIPE)
|
||||
cogl_set_tracing_disabled_on_thread (g_main_context_get_thread_default ());
|
||||
}
|
||||
g_mutex_unlock (&cogl_trace_mutex);
|
||||
}
|
||||
|
||||
void
|
||||
cogl_trace_describe (CoglTraceHead *head,
|
||||
const char *description)
|
||||
|
@ -86,6 +86,10 @@ COGL_EXPORT void
|
||||
cogl_trace_describe (CoglTraceHead *head,
|
||||
const char *description);
|
||||
|
||||
COGL_EXPORT void
|
||||
cogl_trace_mark (const char *name,
|
||||
const char *description);
|
||||
|
||||
static inline void
|
||||
cogl_auto_trace_end_helper (CoglTraceHead **head)
|
||||
{
|
||||
@ -132,6 +136,17 @@ cogl_is_tracing_enabled (void)
|
||||
ScopedCoglTrace##Name = &CoglTrace##Name; \
|
||||
}
|
||||
|
||||
#define COGL_TRACE_MESSAGE(name, ...) \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
if (cogl_is_tracing_enabled ()) \
|
||||
{ \
|
||||
g_autofree char *CoglTraceMessage = g_strdup_printf (__VA_ARGS__); \
|
||||
cogl_trace_mark (name, CoglTraceMessage); \
|
||||
} \
|
||||
} \
|
||||
G_STMT_END
|
||||
|
||||
#else /* HAVE_PROFILER */
|
||||
|
||||
#include <stdio.h>
|
||||
@ -141,6 +156,7 @@ cogl_is_tracing_enabled (void)
|
||||
#define COGL_TRACE_DESCRIBE(Name, description) (void) 0
|
||||
#define COGL_TRACE_SCOPED_ANCHOR(Name) (void) 0
|
||||
#define COGL_TRACE_BEGIN_ANCHORED(Name, name) (void) 0
|
||||
#define COGL_TRACE_MESSAGE(name, ...) (void) 0
|
||||
|
||||
COGL_EXPORT
|
||||
gboolean cogl_start_tracing_with_path (const char *filename,
|
||||
|
Loading…
Reference in New Issue
Block a user