[mutter/gbsneto/tracing: 47/49] cogl/trace: Add user-visible group name
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/gbsneto/tracing: 47/49] cogl/trace: Add user-visible group name
- Date: Wed, 29 May 2019 21:29:44 +0000 (UTC)
commit e6b14e85d214990cab19d8cea3eca9e9d04c6cb3
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Thu May 23 22:45:27 2019 -0300
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
cogl/cogl/cogl-trace.c | 23 ++++++++++++++++-------
cogl/cogl/cogl-trace.h | 8 ++++++--
src/backends/meta-profiler.c | 17 +++++++++++++++--
3 files changed, 37 insertions(+), 11 deletions(-)
---
diff --git a/cogl/cogl/cogl-trace.c b/cogl/cogl/cogl-trace.c
index 434ad9800..3dfd17515 100644
--- a/cogl/cogl/cogl-trace.c
+++ b/cogl/cogl/cogl-trace.c
@@ -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);
}
@@ -103,7 +105,7 @@ ensure_sigpipe_ignored (void)
}
static CoglTraceThreadContext *
-cogl_trace_thread_context_new (void)
+cogl_trace_thread_context_new (const char *group)
{
CoglTraceThreadContext *thread_context;
pid_t tid;
@@ -113,7 +115,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;
}
@@ -132,7 +135,7 @@ enable_tracing_idle_callback (gpointer user_data)
return G_SOURCE_REMOVE;
}
- cogl_trace_thread_context = cogl_trace_thread_context_new ();
+ cogl_trace_thread_context = cogl_trace_thread_context_new (data->group);
return G_SOURCE_REMOVE;
}
@@ -171,6 +174,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)
{
@@ -179,6 +183,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 ();
@@ -194,16 +199,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
@@ -225,14 +232,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");
diff --git a/cogl/cogl/cogl-trace.h b/cogl/cogl/cogl-trace.h
index f4d5121e5..408f6dcd2 100644
--- a/cogl/cogl/cogl-trace.h
+++ b/cogl/cogl/cogl-trace.h
@@ -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);
diff --git a/src/backends/meta-profiler.c b/src/backends/meta-profiler.c
index d97f114d4..a99a609cc 100644
--- a/src/backends/meta-profiler.c
+++ b/src/backends/meta-profiler.c
@@ -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"
@@ -56,6 +57,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;
@@ -75,10 +77,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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]