[sysprof] libsysprof-capture: add mark and log variants
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof] libsysprof-capture: add mark and log variants
- Date: Thu, 5 Mar 2020 23:44:05 +0000 (UTC)
commit 745eb981d133168c684edc9b9538b0c5dc63f7bc
Author: Christian Hergert <chergert redhat com>
Date: Thu Mar 5 15:42:39 2020 -0800
libsysprof-capture: add mark and log variants
src/libsysprof-capture/sysprof-collector.c | 88 +++++++++++++++++++++++++++++-
src/libsysprof-capture/sysprof-collector.h | 24 +++++---
2 files changed, 102 insertions(+), 10 deletions(-)
---
diff --git a/src/libsysprof-capture/sysprof-collector.c b/src/libsysprof-capture/sysprof-collector.c
index 7e2281c..916b88e 100644
--- a/src/libsysprof-capture/sysprof-collector.c
+++ b/src/libsysprof-capture/sysprof-collector.c
@@ -116,10 +116,10 @@ _do_getcpu (void)
#endif
}
-static inline void
-_realign (gsize *pos)
+static inline gsize
+realign (gsize size)
{
- *pos = (*pos + SYSPROF_CAPTURE_ALIGN - 1) & ~(SYSPROF_CAPTURE_ALIGN - 1);
+ return (size + SYSPROF_CAPTURE_ALIGN - 1) & ~(SYSPROF_CAPTURE_ALIGN - 1);
}
static MappedRingBuffer *
@@ -372,3 +372,85 @@ sysprof_collector_sample (SysprofBacktraceFunc backtrace_func,
} COLLECTOR_END;
}
+
+void
+sysprof_collector_mark (gint64 time,
+ gint64 duration,
+ const gchar *group,
+ const gchar *mark,
+ const gchar *message)
+{
+ COLLECTOR_BEGIN {
+ SysprofCaptureMark *ev;
+ gsize len;
+ gsize sl;
+
+ if (group == NULL)
+ group = "";
+
+ if (mark == NULL)
+ mark = "";
+
+ if (message == NULL)
+ message = "";
+
+ sl = strlen (message);
+ len = realign (sizeof *ev + sl + 1);
+
+ if ((ev = mapped_ring_buffer_allocate (collector->buffer, len)))
+ {
+ ev->frame.len = len;
+ ev->frame.type = SYSPROF_CAPTURE_FRAME_MARK;
+ ev->frame.cpu = _do_getcpu ();
+ ev->frame.pid = collector->pid;
+ ev->frame.time = time;
+ ev->duration = duration;
+ g_strlcpy (ev->group, group, sizeof ev->group);
+ g_strlcpy (ev->name, message, sizeof ev->name);
+ memcpy (ev->message, message, sl);
+ ev->message[sl] = 0;
+
+ mapped_ring_buffer_advance (collector->buffer, ev->frame.len);
+ }
+
+ } COLLECTOR_END;
+}
+
+void
+sysprof_collector_log (GLogLevelFlags severity,
+ const gchar *domain,
+ const gchar *message)
+{
+ COLLECTOR_BEGIN {
+ SysprofCaptureLog *ev;
+ gsize len;
+ gsize sl;
+
+ if (domain == NULL)
+ domain = "";
+
+ if (message == NULL)
+ message = "";
+
+ sl = strlen (message);
+ len = realign (sizeof *ev + sl + 1);
+
+ if ((ev = mapped_ring_buffer_allocate (collector->buffer, len)))
+ {
+ ev->frame.len = len;
+ ev->frame.type = SYSPROF_CAPTURE_FRAME_LOG;
+ ev->frame.cpu = _do_getcpu ();
+ ev->frame.pid = collector->pid;
+ ev->frame.time = SYSPROF_CAPTURE_CURRENT_TIME;
+ ev->severity = severity & 0xFFFF;
+ ev->padding1 = 0;
+ ev->padding2 = 0;
+ g_strlcpy (ev->domain, domain, sizeof ev->domain);
+ memcpy (ev->message, message, sl);
+ ev->message[sl] = 0;
+
+ mapped_ring_buffer_advance (collector->buffer, ev->frame.len);
+ }
+
+ } COLLECTOR_END;
+}
diff --git a/src/libsysprof-capture/sysprof-collector.h b/src/libsysprof-capture/sysprof-collector.h
index 140eeb7..6e1f9ed 100644
--- a/src/libsysprof-capture/sysprof-collector.h
+++ b/src/libsysprof-capture/sysprof-collector.h
@@ -62,14 +62,24 @@
G_BEGIN_DECLS
SYSPROF_AVAILABLE_IN_3_36
-void sysprof_collector_init (void);
+void sysprof_collector_init (void);
SYSPROF_AVAILABLE_IN_3_36
-void sysprof_collector_allocate (SysprofCaptureAddress alloc_addr,
- gint64 alloc_size,
- SysprofBacktraceFunc backtrace_func,
- gpointer backtrace_data);
+void sysprof_collector_allocate (SysprofCaptureAddress alloc_addr,
+ gint64 alloc_size,
+ SysprofBacktraceFunc backtrace_func,
+ gpointer backtrace_data);
SYSPROF_AVAILABLE_IN_3_36
-void sysprof_collector_sample (SysprofBacktraceFunc backtrace_func,
- gpointer backtrace_data);
+void sysprof_collector_sample (SysprofBacktraceFunc backtrace_func,
+ gpointer backtrace_data);
+SYSPROF_AVAILABLE_IN_3_36
+void sysprof_collector_mark (gint64 time,
+ gint64 duration,
+ const gchar *group,
+ const gchar *mark,
+ const gchar *message);
+SYSPROF_AVAILABLE_IN_3_36
+void sysprof_collector_log (GLogLevelFlags severity,
+ const gchar *domain,
+ const gchar *message);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]