[mutter/gbsneto/tracing: 7/9] 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: 7/9] cogl/trace: Add user-visible group name
- Date: Fri, 31 May 2019 01:22:26 +0000 (UTC)
commit 105276e6d6df33db7d11d62b363adbddfbc3765c
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 d5c66cc17..89d55bc82 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;
}
@@ -134,7 +137,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;
@@ -180,6 +183,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)
{
@@ -188,6 +192,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 ();
@@ -203,16 +208,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
@@ -234,14 +241,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 1c3b81348..e9c9edafc 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 112a62519..10d433afa 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"
@@ -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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]