[sysprof/wip/chergert/sysprof-3] libsysprof: add file frame with path condition
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof/wip/chergert/sysprof-3] libsysprof: add file frame with path condition
- Date: Wed, 29 May 2019 17:48:44 +0000 (UTC)
commit 7270e7d449489f1b841df2338cbbc4cf8262a57c
Author: Christian Hergert <chergert redhat com>
Date: Wed May 29 10:48:10 2019 -0700
libsysprof: add file frame with path condition
src/libsysprof-capture/sysprof-capture-condition.c | 52 ++++++++++++++++++----
src/libsysprof-capture/sysprof-capture-condition.h | 2 +
2 files changed, 45 insertions(+), 9 deletions(-)
---
diff --git a/src/libsysprof-capture/sysprof-capture-condition.c
b/src/libsysprof-capture/sysprof-capture-condition.c
index fd110c5..0a36fac 100644
--- a/src/libsysprof-capture/sysprof-capture-condition.c
+++ b/src/libsysprof-capture/sysprof-capture-condition.c
@@ -45,6 +45,7 @@ typedef enum
SYSPROF_CAPTURE_CONDITION_WHERE_TIME_BETWEEN,
SYSPROF_CAPTURE_CONDITION_WHERE_PID_IN,
SYSPROF_CAPTURE_CONDITION_WHERE_COUNTER_IN,
+ SYSPROF_CAPTURE_CONDITION_WHERE_FILE,
} SysprofCaptureConditionType;
struct _SysprofCaptureCondition
@@ -63,12 +64,13 @@ struct _SysprofCaptureCondition
SysprofCaptureCondition *left;
SysprofCaptureCondition *right;
} and, or;
+ gchar *where_file;
} u;
};
gboolean
sysprof_capture_condition_match (const SysprofCaptureCondition *self,
- const SysprofCaptureFrame *frame)
+ const SysprofCaptureFrame *frame)
{
g_assert (self != NULL);
g_assert (frame != NULL);
@@ -143,6 +145,12 @@ sysprof_capture_condition_match (const SysprofCaptureCondition *self,
return FALSE;
+ case SYSPROF_CAPTURE_CONDITION_WHERE_FILE:
+ if (frame->type != SYSPROF_CAPTURE_FRAME_FILE_CHUNK)
+ return FALSE;
+
+ return g_strcmp0 (((const SysprofCaptureFileChunk *)frame)->path, self->u.where_file) == 0;
+
default:
break;
}
@@ -166,11 +174,6 @@ sysprof_capture_condition_init (void)
SysprofCaptureCondition *
sysprof_capture_condition_copy (const SysprofCaptureCondition *self)
{
- SysprofCaptureCondition *copy;
-
- copy = sysprof_capture_condition_init ();
- copy->type = self->type;
-
switch (self->type)
{
case SYSPROF_CAPTURE_CONDITION_AND:
@@ -189,7 +192,9 @@ sysprof_capture_condition_copy (const SysprofCaptureCondition *self)
(const SysprofCaptureFrameType *)(gpointer)self->u.where_type_in->data);
case SYSPROF_CAPTURE_CONDITION_WHERE_TIME_BETWEEN:
- break;
+ return sysprof_capture_condition_new_where_time_between (
+ self->u.where_time_between.begin,
+ self->u.where_time_between.end);
case SYSPROF_CAPTURE_CONDITION_WHERE_PID_IN:
return sysprof_capture_condition_new_where_pid_in (
@@ -201,12 +206,14 @@ sysprof_capture_condition_copy (const SysprofCaptureCondition *self)
self->u.where_counter_in->len,
(const guint *)(gpointer)self->u.where_counter_in->data);
+ case SYSPROF_CAPTURE_CONDITION_WHERE_FILE:
+ return sysprof_capture_condition_new_where_file (self->u.where_file);
+
default:
- g_assert_not_reached ();
break;
}
- return copy;
+ g_return_val_if_reached (NULL);
}
static void
@@ -239,6 +246,10 @@ sysprof_capture_condition_finalize (SysprofCaptureCondition *self)
g_array_free (self->u.where_counter_in, TRUE);
break;
+ case SYSPROF_CAPTURE_CONDITION_WHERE_FILE:
+ g_free (self->u.where_file);
+ break;
+
default:
g_assert_not_reached ();
break;
@@ -396,3 +407,26 @@ sysprof_capture_condition_new_or (SysprofCaptureCondition *left,
return self;
}
+
+/**
+ * sysprof_capture_condition_new_where_file:
+ * @path: a file path to lookup
+ *
+ * Creates a new condition that matches #SysprofCaptureFileChunk frames
+ * which contain the path @path.
+ *
+ * Returns: (transfer full): a new #SysprofCaptureCondition
+ */
+SysprofCaptureCondition *
+sysprof_capture_condition_new_where_file (const gchar *path)
+{
+ SysprofCaptureCondition *self;
+
+ g_return_val_if_fail (path != NULL, NULL);
+
+ self = sysprof_capture_condition_init ();
+ self->type = SYSPROF_CAPTURE_CONDITION_WHERE_FILE;
+ self->u.where_file = g_strdup (path);
+
+ return self;
+}
diff --git a/src/libsysprof-capture/sysprof-capture-condition.h
b/src/libsysprof-capture/sysprof-capture-condition.h
index 280b6e6..26b28bc 100644
--- a/src/libsysprof-capture/sysprof-capture-condition.h
+++ b/src/libsysprof-capture/sysprof-capture-condition.h
@@ -50,6 +50,8 @@ SYSPROF_AVAILABLE_IN_ALL
SysprofCaptureCondition *sysprof_capture_condition_new_where_counter_in (guint
n_counters,
const guint
*counters);
SYSPROF_AVAILABLE_IN_ALL
+SysprofCaptureCondition *sysprof_capture_condition_new_where_file (const gchar
*path);
+SYSPROF_AVAILABLE_IN_ALL
gboolean sysprof_capture_condition_match (const SysprofCaptureCondition
*self,
const SysprofCaptureFrame
*frame);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]