mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-10 23:20:54 +00:00
libsysprof-capture: add or condition
This commit is contained in:
@ -40,6 +40,7 @@
|
|||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
SYSPROF_CAPTURE_CONDITION_AND,
|
SYSPROF_CAPTURE_CONDITION_AND,
|
||||||
|
SYSPROF_CAPTURE_CONDITION_OR,
|
||||||
SYSPROF_CAPTURE_CONDITION_WHERE_TYPE_IN,
|
SYSPROF_CAPTURE_CONDITION_WHERE_TYPE_IN,
|
||||||
SYSPROF_CAPTURE_CONDITION_WHERE_TIME_BETWEEN,
|
SYSPROF_CAPTURE_CONDITION_WHERE_TIME_BETWEEN,
|
||||||
SYSPROF_CAPTURE_CONDITION_WHERE_PID_IN,
|
SYSPROF_CAPTURE_CONDITION_WHERE_PID_IN,
|
||||||
@ -61,7 +62,7 @@ struct _SysprofCaptureCondition
|
|||||||
struct {
|
struct {
|
||||||
SysprofCaptureCondition *left;
|
SysprofCaptureCondition *left;
|
||||||
SysprofCaptureCondition *right;
|
SysprofCaptureCondition *right;
|
||||||
} and;
|
} and, or;
|
||||||
} u;
|
} u;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -78,6 +79,10 @@ sysprof_capture_condition_match (const SysprofCaptureCondition *self,
|
|||||||
return sysprof_capture_condition_match (self->u.and.left, frame) &&
|
return sysprof_capture_condition_match (self->u.and.left, frame) &&
|
||||||
sysprof_capture_condition_match (self->u.and.right, frame);
|
sysprof_capture_condition_match (self->u.and.right, frame);
|
||||||
|
|
||||||
|
case SYSPROF_CAPTURE_CONDITION_OR:
|
||||||
|
return sysprof_capture_condition_match (self->u.or.left, frame) ||
|
||||||
|
sysprof_capture_condition_match (self->u.or.right, frame);
|
||||||
|
|
||||||
case SYSPROF_CAPTURE_CONDITION_WHERE_TYPE_IN:
|
case SYSPROF_CAPTURE_CONDITION_WHERE_TYPE_IN:
|
||||||
for (guint i = 0; i < self->u.where_type_in->len; i++)
|
for (guint i = 0; i < self->u.where_type_in->len; i++)
|
||||||
{
|
{
|
||||||
@ -173,6 +178,11 @@ sysprof_capture_condition_copy (const SysprofCaptureCondition *self)
|
|||||||
sysprof_capture_condition_copy (self->u.and.left),
|
sysprof_capture_condition_copy (self->u.and.left),
|
||||||
sysprof_capture_condition_copy (self->u.and.right));
|
sysprof_capture_condition_copy (self->u.and.right));
|
||||||
|
|
||||||
|
case SYSPROF_CAPTURE_CONDITION_OR:
|
||||||
|
return sysprof_capture_condition_new_or (
|
||||||
|
sysprof_capture_condition_copy (self->u.or.left),
|
||||||
|
sysprof_capture_condition_copy (self->u.or.right));
|
||||||
|
|
||||||
case SYSPROF_CAPTURE_CONDITION_WHERE_TYPE_IN:
|
case SYSPROF_CAPTURE_CONDITION_WHERE_TYPE_IN:
|
||||||
return sysprof_capture_condition_new_where_type_in (
|
return sysprof_capture_condition_new_where_type_in (
|
||||||
self->u.where_type_in->len,
|
self->u.where_type_in->len,
|
||||||
@ -209,6 +219,11 @@ sysprof_capture_condition_finalize (SysprofCaptureCondition *self)
|
|||||||
sysprof_capture_condition_unref (self->u.and.right);
|
sysprof_capture_condition_unref (self->u.and.right);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case SYSPROF_CAPTURE_CONDITION_OR:
|
||||||
|
sysprof_capture_condition_unref (self->u.or.left);
|
||||||
|
sysprof_capture_condition_unref (self->u.or.right);
|
||||||
|
break;
|
||||||
|
|
||||||
case SYSPROF_CAPTURE_CONDITION_WHERE_TYPE_IN:
|
case SYSPROF_CAPTURE_CONDITION_WHERE_TYPE_IN:
|
||||||
g_array_free (self->u.where_type_in, TRUE);
|
g_array_free (self->u.where_type_in, TRUE);
|
||||||
break;
|
break;
|
||||||
@ -340,7 +355,7 @@ sysprof_capture_condition_new_where_counter_in (guint n_counters,
|
|||||||
*/
|
*/
|
||||||
SysprofCaptureCondition *
|
SysprofCaptureCondition *
|
||||||
sysprof_capture_condition_new_and (SysprofCaptureCondition *left,
|
sysprof_capture_condition_new_and (SysprofCaptureCondition *left,
|
||||||
SysprofCaptureCondition *right)
|
SysprofCaptureCondition *right)
|
||||||
{
|
{
|
||||||
SysprofCaptureCondition *self;
|
SysprofCaptureCondition *self;
|
||||||
|
|
||||||
@ -354,3 +369,30 @@ sysprof_capture_condition_new_and (SysprofCaptureCondition *left,
|
|||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sysprof_capture_condition_new_or:
|
||||||
|
* @left: (transfer full): An #SysprofCaptureCondition
|
||||||
|
* @right: (transfer full): An #SysprofCaptureCondition
|
||||||
|
*
|
||||||
|
* Creates a new #SysprofCaptureCondition that requires either left and right
|
||||||
|
* to evaluate to %TRUE.
|
||||||
|
*
|
||||||
|
* Returns: (transfer full): A new #SysprofCaptureCondition.
|
||||||
|
*/
|
||||||
|
SysprofCaptureCondition *
|
||||||
|
sysprof_capture_condition_new_or (SysprofCaptureCondition *left,
|
||||||
|
SysprofCaptureCondition *right)
|
||||||
|
{
|
||||||
|
SysprofCaptureCondition *self;
|
||||||
|
|
||||||
|
g_return_val_if_fail (left != NULL, NULL);
|
||||||
|
g_return_val_if_fail (right != NULL, NULL);
|
||||||
|
|
||||||
|
self = sysprof_capture_condition_init ();
|
||||||
|
self->type = SYSPROF_CAPTURE_CONDITION_OR;
|
||||||
|
self->u.or.left = left;
|
||||||
|
self->u.or.right = right;
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|||||||
@ -35,6 +35,9 @@ SYSPROF_AVAILABLE_IN_ALL
|
|||||||
SysprofCaptureCondition *sysprof_capture_condition_new_and (SysprofCaptureCondition *left,
|
SysprofCaptureCondition *sysprof_capture_condition_new_and (SysprofCaptureCondition *left,
|
||||||
SysprofCaptureCondition *right);
|
SysprofCaptureCondition *right);
|
||||||
SYSPROF_AVAILABLE_IN_ALL
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
|
SysprofCaptureCondition *sysprof_capture_condition_new_or (SysprofCaptureCondition *left,
|
||||||
|
SysprofCaptureCondition *right);
|
||||||
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
SysprofCaptureCondition *sysprof_capture_condition_new_where_type_in (guint n_types,
|
SysprofCaptureCondition *sysprof_capture_condition_new_where_type_in (guint n_types,
|
||||||
const SysprofCaptureFrameType *types);
|
const SysprofCaptureFrameType *types);
|
||||||
SYSPROF_AVAILABLE_IN_ALL
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
|
|||||||
Reference in New Issue
Block a user