capture: add simple mark support

The goal here is to have an API that allows us to record things like
frame timing data. We might iterate on this API a bit, but this gets us
started.

A SpCaptureMark with a zero duration should be treated like an epoch mark
once a visualizer is created. SpCaptureMark with a non-zero duration should
be treated like a begin/end of operation. This may be useful in generating
something like a flame graph.
This commit is contained in:
Christian Hergert
2018-05-14 17:15:57 +01:00
parent e6d5d2b70d
commit 4bdbf130b2
8 changed files with 173 additions and 0 deletions

View File

@ -536,6 +536,45 @@ sp_capture_writer_add_map (SpCaptureWriter *self,
return TRUE;
}
gboolean
sp_capture_writer_add_mark (SpCaptureWriter *self,
gint64 time,
gint cpu,
GPid pid,
guint64 duration,
const gchar *name,
const gchar *message)
{
SpCaptureMark *ev;
gsize message_len;
gsize len;
g_assert (self != NULL);
g_assert (name != NULL);
if (message == NULL)
message = "";
message_len = strlen (message) + 1;
len = sizeof *ev + message_len;
ev = (SpCaptureMark *)sp_capture_writer_allocate (self, &len);
if (!ev)
return FALSE;
sp_capture_writer_frame_init (&ev->frame,
len,
cpu,
pid,
time,
SP_CAPTURE_FRAME_MARK);
ev->duration = duration;
memcpy (ev->name, name, sizeof ev->name);
memcpy (ev->message, message, message_len);
return TRUE;
}
SpCaptureAddress
sp_capture_writer_add_jitmap (SpCaptureWriter *self,
const gchar *name)