mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 15:40:41 -05:00
cogl/trace: Add user-visible group name
This way, it shows up as "Compositor" in Sysprof instead of "t:XYZ". https://gitlab.gnome.org/GNOME/mutter/merge_requests/197
This commit is contained in:
parent
9b8f9b65b8
commit
7810f0e276
@ -34,6 +34,7 @@ typedef struct
|
||||
{
|
||||
int fd;
|
||||
char *filename;
|
||||
char *group;
|
||||
} TraceData;
|
||||
|
||||
static void
|
||||
@ -42,6 +43,7 @@ trace_data_free (gpointer user_data)
|
||||
TraceData *data = user_data;
|
||||
|
||||
data->fd = -1;
|
||||
g_clear_pointer (&data->group, g_free);
|
||||
g_clear_pointer (&data->filename, g_free);
|
||||
g_free (data);
|
||||
}
|
||||
@ -97,7 +99,7 @@ ensure_trace_context (TraceData *data)
|
||||
}
|
||||
|
||||
static CoglTraceThreadContext *
|
||||
cogl_trace_thread_context_new (void)
|
||||
cogl_trace_thread_context_new (const char *group)
|
||||
{
|
||||
CoglTraceThreadContext *thread_context;
|
||||
pid_t tid;
|
||||
@ -107,7 +109,8 @@ cogl_trace_thread_context_new (void)
|
||||
thread_context = g_new0 (CoglTraceThreadContext, 1);
|
||||
thread_context->cpu_id = -1;
|
||||
thread_context->pid = getpid ();
|
||||
thread_context->group = g_strdup_printf ("t:%d", tid);
|
||||
thread_context->group =
|
||||
group ? g_strdup (group) : g_strdup_printf ("t:%d", tid);
|
||||
|
||||
return thread_context;
|
||||
}
|
||||
@ -127,7 +130,7 @@ enable_tracing_idle_callback (gpointer user_data)
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
thread_context = cogl_trace_thread_context_new ();
|
||||
thread_context = cogl_trace_thread_context_new (data->group);
|
||||
g_private_set (&cogl_trace_thread_data, thread_context);
|
||||
|
||||
return G_SOURCE_REMOVE;
|
||||
@ -173,6 +176,7 @@ disable_tracing_idle_callback (gpointer user_data)
|
||||
|
||||
static void
|
||||
set_tracing_enabled_on_thread (GMainContext *main_context,
|
||||
const char *group,
|
||||
int fd,
|
||||
const char *filename)
|
||||
{
|
||||
@ -181,6 +185,7 @@ set_tracing_enabled_on_thread (GMainContext *main_context,
|
||||
|
||||
data = g_new0 (TraceData, 1);
|
||||
data->fd = fd;
|
||||
data->group = group ? strdup (group) : NULL;
|
||||
data->filename = filename ? strdup (filename) : NULL;
|
||||
|
||||
source = g_idle_source_new ();
|
||||
@ -196,16 +201,18 @@ set_tracing_enabled_on_thread (GMainContext *main_context,
|
||||
|
||||
void
|
||||
cogl_set_tracing_enabled_on_thread_with_fd (GMainContext *main_context,
|
||||
const char *group,
|
||||
int fd)
|
||||
{
|
||||
set_tracing_enabled_on_thread (main_context, fd, NULL);
|
||||
set_tracing_enabled_on_thread (main_context, group, fd, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
cogl_set_tracing_enabled_on_thread (GMainContext *main_context,
|
||||
const char *group,
|
||||
const char *filename)
|
||||
{
|
||||
set_tracing_enabled_on_thread (main_context, -1, filename);
|
||||
set_tracing_enabled_on_thread (main_context, group, -1, filename);
|
||||
}
|
||||
|
||||
void
|
||||
@ -227,14 +234,16 @@ cogl_set_tracing_disabled_on_thread (GMainContext *main_context)
|
||||
#include <stdio.h>
|
||||
|
||||
void
|
||||
cogl_set_tracing_enabled_on_thread_with_fd (void *data,
|
||||
int fd)
|
||||
cogl_set_tracing_enabled_on_thread_with_fd (void *data,
|
||||
const char *group,
|
||||
int fd)
|
||||
{
|
||||
fprintf (stderr, "Tracing not enabled");
|
||||
}
|
||||
|
||||
void
|
||||
cogl_set_tracing_enabled_on_thread (void *data,
|
||||
const char *group,
|
||||
const char *filename)
|
||||
{
|
||||
fprintf (stderr, "Tracing not enabled");
|
||||
|
@ -52,9 +52,11 @@ extern CoglTraceContext *cogl_trace_context;
|
||||
extern GMutex cogl_trace_mutex;
|
||||
|
||||
void cogl_set_tracing_enabled_on_thread_with_fd (GMainContext *main_context,
|
||||
const char *group,
|
||||
int fd);
|
||||
|
||||
void cogl_set_tracing_enabled_on_thread (GMainContext *main_context,
|
||||
const char *group,
|
||||
const char *filename);
|
||||
|
||||
void cogl_set_tracing_disabled_on_thread (GMainContext *main_context);
|
||||
@ -132,9 +134,11 @@ cogl_auto_trace_end_helper (CoglTraceHead **head)
|
||||
#define COGL_TRACE_END(Name) (void) 0
|
||||
#define COGL_TRACE_BEGIN_SCOPED(Name, description) (void) 0
|
||||
|
||||
void cogl_set_tracing_enabled_on_thread_with_fd (void *data,
|
||||
int fd);
|
||||
void cogl_set_tracing_enabled_on_thread_with_fd (void *data,
|
||||
const char *group,
|
||||
int fd);
|
||||
void cogl_set_tracing_enabled_on_thread (void *data,
|
||||
const char *group,
|
||||
const char *filename);
|
||||
void cogl_set_tracing_disabled_on_thread (void *data);
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "src/backends/meta-profiler.h"
|
||||
|
||||
#include <glib-unix.h>
|
||||
#include <glib/gi18n.h>
|
||||
#include <gio/gunixfdlist.h>
|
||||
|
||||
#include "cogl/cogl-trace.h"
|
||||
@ -57,6 +58,7 @@ handle_start (MetaDBusSysprof3Profiler *dbus_profiler,
|
||||
GMainContext *main_context = g_main_context_default ();
|
||||
GDBusMessage *message;
|
||||
GUnixFDList *fd_list;
|
||||
const char *group_name;
|
||||
int position;
|
||||
int fd = -1;
|
||||
|
||||
@ -76,10 +78,21 @@ handle_start (MetaDBusSysprof3Profiler *dbus_profiler,
|
||||
if (fd_list)
|
||||
fd = g_unix_fd_list_get (fd_list, position, NULL);
|
||||
|
||||
/* Translators: this string will appear in Sysprof */
|
||||
group_name = _("Compositor");
|
||||
|
||||
if (fd != -1)
|
||||
cogl_set_tracing_enabled_on_thread_with_fd (main_context, fd);
|
||||
{
|
||||
cogl_set_tracing_enabled_on_thread_with_fd (main_context,
|
||||
group_name,
|
||||
fd);
|
||||
}
|
||||
else
|
||||
cogl_set_tracing_enabled_on_thread (main_context, "mutter-profile.syscap");
|
||||
{
|
||||
cogl_set_tracing_enabled_on_thread (main_context,
|
||||
group_name,
|
||||
"mutter-profile.syscap");
|
||||
}
|
||||
|
||||
profiler->running = TRUE;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user