[sysprof] capture: add sp_capture_reader_peek_frame()
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof] capture: add sp_capture_reader_peek_frame()
- Date: Fri, 15 Apr 2016 11:55:48 +0000 (UTC)
commit 253b3873238af1de722e0c001dd2719fe99f0386
Author: Christian Hergert <chergert redhat com>
Date: Fri Apr 15 04:48:46 2016 -0700
capture: add sp_capture_reader_peek_frame()
It can be useful to peek at the whole frame header (for things like time
or pid or cpu).
lib/sp-capture-reader.c | 34 +++++++++++++++++++++++++---------
lib/sp-capture-reader.h | 2 ++
2 files changed, 27 insertions(+), 9 deletions(-)
---
diff --git a/lib/sp-capture-reader.c b/lib/sp-capture-reader.c
index c283928..70ce4bc 100644
--- a/lib/sp-capture-reader.c
+++ b/lib/sp-capture-reader.c
@@ -277,26 +277,42 @@ sp_capture_reader_skip (SpCaptureReader *self)
}
gboolean
-sp_capture_reader_peek_type (SpCaptureReader *self,
- SpCaptureFrameType *type)
+sp_capture_reader_peek_frame (SpCaptureReader *self,
+ SpCaptureFrame *frame)
{
- SpCaptureFrame *frame;
+ SpCaptureFrame *real_frame;
g_assert (self != NULL);
g_assert ((self->pos % SP_CAPTURE_ALIGN) == 0);
g_assert (self->pos <= self->bufsz);
- g_assert (type != NULL);
-
- *type = 0;
- if (!sp_capture_reader_ensure_space_for (self, sizeof *frame))
+ if (!sp_capture_reader_ensure_space_for (self, sizeof *real_frame))
return FALSE;
g_assert ((self->pos % SP_CAPTURE_ALIGN) == 0);
- frame = (SpCaptureFrame *)(gpointer)&self->buf[self->pos];
+ real_frame = (SpCaptureFrame *)(gpointer)&self->buf[self->pos];
+
+ *frame = *real_frame;
+
+ sp_capture_reader_bswap_frame (self, frame);
+
+ return TRUE;
+}
+
+gboolean
+sp_capture_reader_peek_type (SpCaptureReader *self,
+ SpCaptureFrameType *type)
+{
+ SpCaptureFrame frame;
+
+ g_assert (self != NULL);
+ g_assert (type != NULL);
+
+ if (!sp_capture_reader_peek_frame (self, &frame))
+ return FALSE;
- *type = frame->type;
+ *type = frame.type;
return TRUE;
}
diff --git a/lib/sp-capture-reader.h b/lib/sp-capture-reader.h
index bfe6217..f8160f3 100644
--- a/lib/sp-capture-reader.h
+++ b/lib/sp-capture-reader.h
@@ -37,6 +37,8 @@ gint64 sp_capture_reader_get_start_time (SpCapt
gboolean sp_capture_reader_skip (SpCaptureReader *self);
gboolean sp_capture_reader_peek_type (SpCaptureReader *self,
SpCaptureFrameType *type);
+gboolean sp_capture_reader_peek_frame (SpCaptureReader *self,
+ SpCaptureFrame *frame);
const SpCaptureMap *sp_capture_reader_read_map (SpCaptureReader *self);
const SpCaptureExit *sp_capture_reader_read_exit (SpCaptureReader *self);
const SpCaptureFork *sp_capture_reader_read_fork (SpCaptureReader *self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]