* MA 02111-1307, USA.
*/
-/*
- read_token
-
- read_expression
- ( read expr )
- simple expr [ op expr ]
-
- read_simple_expression
- read_field_path [ rel value ]
-
- read_field_path
- read_field_component [. field path]
-
- read_field_component
- name [ \[ value \] ]
-
- data struct:
- and/or(left/right)
- not(child)
- op(left/right)
- path(component...) -> field
-
- consist in AND, OR and NOT nested expressions, forming a tree with
- simple relations as leaves. The simple relations test is a field
- in an event is equal, not equal, smaller, smaller or equal, larger, or
- larger or equal to a specified value.
-*/
-
-/*
- * YET TO BE ANSWERED
- * - none yet
+/*! \file lttv/lttv/filter.c
+ * \brief Defines the core filter of application
+ *
+ * consist in AND, OR and NOT nested expressions, forming a tree with
+ * simple relations as leaves. The simple relations test if a field
+ * in an event is equal, not equal, smaller, smaller or equal, larger, or
+ * larger or equal to a specified value.
+ *
+ * Fields specified in a simple expression can take following
+ * values
+ *
+ * LttvTracefileContext{}\
+ * |->event\
+ * | |->name (String, converted to GQuark)
+ * | |->category (String, not yet implemented)
+ * | |->time (LttTime)
+ * | |->tsc (LttCycleCount)
+ * | |->fields
+ * | |->"event name"
+ * | |->"field name"
+ * | |->"sub-field name"
+ * | |->...
+ * | |->"leaf-field name" (field type)
+ * |->tracefile
+ * | |->name (String, converted to GQuark)
+ * |->trace
+ * | |->name (String, converted to GQuark)
+ * |->state
+ * |->pid (uint64)
+ * |->ppid (uint64)
+ * |->creation_time (LttTime)
+ * |->insertion_time (LttTime)
+ * |->process_name (String, converted to GQuark)
+ * |->execution_mode (LttvExecutionMode)
+ * |->execution_submode (LttvExecutionSubmode)
+ * |->process_status (LttvProcessStatus)
+ * |->cpu (GQuark)
*/
/*
* TODO
* - refine switch of expression in multiple uses functions
* - remove the idle expressions in the tree ****
- * - add the current simple expression to the tree
- * * clear the field_path array after use
*/
#include <lttv/filter.h>
-#include <ltt/time.h>
-
-/*
-GQuark
- LTTV_FILTER_TRACE,
- LTTV_FILTER_TRACESET,
- LTTV_FILTER_TRACEFILE,
- LTTV_FILTER_STATE,
- LTTV_FILTER_EVENT,
- LTTV_FILTER_NAME,
- LTTV_FILTER_CATEGORY,
- LTTV_FILTER_TIME,
- LTTV_FILTER_TSC,
- LTTV_FILTER_PID,
- LTTV_FILTER_PPID,
- LTTV_FILTER_C_TIME,
- LTTV_FILTER_I_TIME,
- LTTV_FILTER_P_NAME,
- LTTV_FILTER_EX_MODE,
- LTTV_FILTER_EX_SUBMODE,
- LTTV_FILTER_P_STATUS,
- LTTV_FILTER_CPU;
-*/
-
/**
* @fn LttvSimpleExpression* lttv_simple_expression_new()
}
/**
- * @fn gboolean lttv_simple_expression_add_field(GPtrArray*,LttvSimpleExpression*)
+ * @fn gboolean lttv_simple_expression_assign_field(GPtrArray*,LttvSimpleExpression*)
*
* Parse through filtering field hierarchy as specified
* by user. This function compares each value to
* Sets the function pointer for the current
* Simple Expression
* @param se current simple expression
+ * @param op current operator
* @return success/failure of operation
*/
gboolean lttv_simple_expression_assign_operator(LttvSimpleExpression* se, LttvExpressionOp op) {
}
/**
- * @fn void lttv_simple_expression_assign_value(LttvSimpleExpression*,char*)
+ * @fn gboolean lttv_simple_expression_assign_value(LttvSimpleExpression*,char*)
*
* Assign the value field to the current LttvSimpleExpression
* @param se pointer to the current LttvSimpleExpression
}
/**
- * @fn gboolean lttv_apply_op_eq_uint64(const gpointer,LttvFieldValue)
+ * @fn gboolean lttv_apply_op_eq_uint64(gpointer,LttvFieldValue)
*
* Applies the 'equal' operator to the
* specified structure and value
}
/**
- * @fn gboolean lttv_apply_op_eq_uint32(const gpointer,LttvFieldValue)
+ * @fn gboolean lttv_apply_op_eq_uint32(gpointer,LttvFieldValue)
*
* Applies the 'equal' operator to the
* specified structure and value
}
/**
- * @fn gboolean lttv_apply_op_eq_uint16(const gpointer,LttvFieldValue)
+ * @fn gboolean lttv_apply_op_eq_uint16(gpointer,LttvFieldValue)
*
* Applies the 'equal' operator to the
* specified structure and value
}
/**
- * @fn gboolean lttv_apply_op_eq_double(const gpointer,LttvFieldValue)
+ * @fn gboolean lttv_apply_op_eq_double(gpointer,LttvFieldValue)
*
* Applies the 'equal' operator to the
* specified structure and value
}
/**
- * @fn gboolean lttv_apply_op_eq_string(const gpointer,LttvFieldValue)
+ * @fn gboolean lttv_apply_op_eq_string(gpointer,LttvFieldValue)
*
* Applies the 'equal' operator to the
* specified structure and value
}
/**
- * @fn gboolean lttv_apply_op_eq_quark(const gpointer,LttvFieldValue)
+ * @fn gboolean lttv_apply_op_eq_quark(gpointer,LttvFieldValue)
*
* Applies the 'equal' operator to the
* specified structure and value
}
/**
- * @fn gboolean lttv_apply_op_eq_ltttime(const gpointer,LttvFieldValue)
+ * @fn gboolean lttv_apply_op_eq_ltttime(gpointer,LttvFieldValue)
*
* Applies the 'equal' operator to the
* specified structure and value
/**
- * @fn gboolean lttv_apply_op_ne_uint64(const gpointer,LttvFieldValue)
+ * @fn gboolean lttv_apply_op_ne_uint64(gpointer,LttvFieldValue)
*
* Applies the 'not equal' operator to the
* specified structure and value
}
/**
- * @fn gboolean lttv_apply_op_ne_uint32(const gpointer,LttvFieldValue)
+ * @fn gboolean lttv_apply_op_ne_uint32(gpointer,LttvFieldValue)
*
* Applies the 'not equal' operator to the
* specified structure and value
}
/**
- * @fn gboolean lttv_apply_op_ne_uint16(const gpointer,LttvFieldValue)
+ * @fn gboolean lttv_apply_op_ne_uint16(gpointer,LttvFieldValue)
*
* Applies the 'not equal' operator to the
* specified structure and value
}
/**
- * @fn gboolean lttv_apply_op_ne_double(const gpointer,LttvFieldValue)
+ * @fn gboolean lttv_apply_op_ne_double(gpointer,LttvFieldValue)
*
* Applies the 'not equal' operator to the
* specified structure and value
}
/**
- * @fn gboolean lttv_apply_op_ne_string(const gpointer,LttvFieldValue)
+ * @fn gboolean lttv_apply_op_ne_string(gpointer,LttvFieldValue)
*
* Applies the 'not equal' operator to the
* specified structure and value
}
/**
- * @fn gboolean lttv_apply_op_ne_quark(const gpointer,LttvFieldValue)
+ * @fn gboolean lttv_apply_op_ne_quark(gpointer,LttvFieldValue)
*
* Applies the 'not equal' operator to the
* specified structure and value
/**
- * @fn gboolean lttv_apply_op_ne_ltttime(const gpointer,LttvFieldValue)
+ * @fn gboolean lttv_apply_op_ne_ltttime(gpointer,LttvFieldValue)
*
* Applies the 'not equal' operator to the
* specified structure and value
/**
- * @fn gboolean lttv_apply_op_lt_uint64(const gpointer,LttvFieldValue)
+ * @fn gboolean lttv_apply_op_lt_uint64(gpointer,LttvFieldValue)
*
* Applies the 'lower than' operator to the
* specified structure and value
}
/**
- * @fn gboolean lttv_apply_op_lt_uint32(const gpointer,LttvFieldValue)
+ * @fn gboolean lttv_apply_op_lt_uint32(gpointer,LttvFieldValue)
*
* Applies the 'lower than' operator to the
* specified structure and value
}
/**
- * @fn gboolean lttv_apply_op_lt_uint16(const gpointer,LttvFieldValue)
+ * @fn gboolean lttv_apply_op_lt_uint16(gpointer,LttvFieldValue)
*
* Applies the 'lower than' operator to the
* specified structure and value
}
/**
- * @fn gboolean lttv_apply_op_lt_double(const gpointer,LttvFieldValue)
+ * @fn gboolean lttv_apply_op_lt_double(gpointer,LttvFieldValue)
*
* Applies the 'lower than' operator to the
* specified structure and value
}
/**
- * @fn gboolean lttv_apply_op_lt_ltttime(const gpointer,LttvFieldValue)
+ * @fn gboolean lttv_apply_op_lt_ltttime(gpointer,LttvFieldValue)
*
* Applies the 'lower than' operator to the
* specified structure and value
/**
- * @fn gboolean lttv_apply_op_le_uint64(const gpointer,LttvFieldValue)
+ * @fn gboolean lttv_apply_op_le_uint64(gpointer,LttvFieldValue)
*
* Applies the 'lower or equal' operator to the
* specified structure and value
}
/**
- * @fn gboolean lttv_apply_op_le_uint32(const gpointer,LttvFieldValue)
+ * @fn gboolean lttv_apply_op_le_uint32(gpointer,LttvFieldValue)
*
* Applies the 'lower or equal' operator to the
* specified structure and value
}
/**
- * @fn gboolean lttv_apply_op_le_uint16(const gpointer,LttvFieldValue)
+ * @fn gboolean lttv_apply_op_le_uint16(gpointer,LttvFieldValue)
*
* Applies the 'lower or equal' operator to the
* specified structure and value
}
/**
- * @fn gboolean lttv_apply_op_le_double(const gpointer,LttvFieldValue)
+ * @fn gboolean lttv_apply_op_le_double(gpointer,LttvFieldValue)
*
* Applies the 'lower or equal' operator to the
* specified structure and value
}
/**
- * @fn gboolean lttv_apply_op_le_ltttime(const gpointer,LttvFieldValue)
+ * @fn gboolean lttv_apply_op_le_ltttime(gpointer,LttvFieldValue)
*
* Applies the 'lower or equal' operator to the
* specified structure and value
/**
- * @fn gboolean lttv_apply_op_gt_uint64(const gpointer,LttvFieldValue)
+ * @fn gboolean lttv_apply_op_gt_uint64(gpointer,LttvFieldValue)
*
* Applies the 'greater than' operator to the
* specified structure and value
}
/**
- * @fn gboolean lttv_apply_op_gt_uint32(const gpointer,LttvFieldValue)
+ * @fn gboolean lttv_apply_op_gt_uint32(gpointer,LttvFieldValue)
*
* Applies the 'greater than' operator to the
* specified structure and value
}
/**
- * @fn gboolean lttv_apply_op_gt_uint16(const gpointer,LttvFieldValue)
+ * @fn gboolean lttv_apply_op_gt_uint16(gpointer,LttvFieldValue)
*
* Applies the 'greater than' operator to the
* specified structure and value
}
/**
- * @fn gboolean lttv_apply_op_gt_double(const gpointer,LttvFieldValue)
+ * @fn gboolean lttv_apply_op_gt_double(gpointer,LttvFieldValue)
*
* Applies the 'greater than' operator to the
* specified structure and value
}
/**
- * @fn gboolean lttv_apply_op_gt_ltttime(const gpointer,LttvFieldValue)
+ * @fn gboolean lttv_apply_op_gt_ltttime(gpointer,LttvFieldValue)
*
* Applies the 'greater than' operator to the
* specified structure and value
/**
- * @fn gboolean lttv_apply_op_ge_uint64(const gpointer,LttvFieldValue)
+ * @fn gboolean lttv_apply_op_ge_uint64(gpointer,LttvFieldValue)
*
* Applies the 'greater or equal' operator to the
* specified structure and value
}
/**
- * @fn gboolean lttv_apply_op_ge_uint32(const gpointer,LttvFieldValue)
+ * @fn gboolean lttv_apply_op_ge_uint32(gpointer,LttvFieldValue)
*
* Applies the 'greater or equal' operator to the
* specified structure and value
}
/**
- * @fn gboolean lttv_apply_op_ge_uint16(const gpointer,LttvFieldValue)
+ * @fn gboolean lttv_apply_op_ge_uint16(gpointer,LttvFieldValue)
*
* Applies the 'greater or equal' operator to the
* specified structure and value
}
/**
- * @fn gboolean lttv_apply_op_ge_double(const gpointer,LttvFieldValue)
+ * @fn gboolean lttv_apply_op_ge_double(gpointer,LttvFieldValue)
*
* Applies the 'greater or equal' operator to the
* specified structure and value
}
/**
- * @fn gboolean lttv_apply_op_ge_ltttime(const gpointer,LttvFieldValue)
+ * @fn gboolean lttv_apply_op_ge_ltttime(gpointer,LttvFieldValue)
*
* Applies the 'greater or equal' operator to the
* specified structure and value
/**
- * @fn LttvFilterTree* lttv_filter_tree_clone(LttvFilterTree*)
- *
* Makes a copy of the current filter tree
* @param tree pointer to the current tree
* @return new copy of the filter tree
}
/**
- * @fn LttvFilter* lttv_filter_clone(LttvFilter*)
- *
* Makes a copy of the current filter
* @param filter pointer to the current filter
* @return new copy of the filter
LttvFilter* newfilter = g_new(LttvFilter,1);
- // newfilter->expression = g_new(char,1)
strcpy(newfilter->expression,filter->expression);
newfilter->head = lttv_filter_tree_clone(filter->head);
/**
* @fn LttvFilter* lttv_filter_new()
*
- * Creates a new lttv_filter
- * @param expression filtering options string
- * @param t pointer to the current LttvTrace
- * @return the current lttv_filter or NULL if error
+ * Creates a new LttvFilter
+ * @return the current LttvFilter or NULL if error
*/
LttvFilter*
lttv_filter_new() {
LttvFilter* filter = g_new(LttvFilter,1);
filter->expression = NULL;
filter->head = NULL;
+
+ return filter;
}
}
/**
- * @fn gboolean lttv_filter_tree_parse(LttvFilterTree*,LttEvent,LttTracefile,LttTrace,LttvProcessState)
- *
* Global parsing function for the current
* LttvFilterTree
- * @param tree pointer to the current LttvFilterTree
+ * @param t pointer to the current LttvFilterTree
* @param event current LttEvent, NULL if not used
* @param tracefile current LttTracefile, NULL if not used
* @param trace current LttTrace, NULL if not used
}
/**
- * @fn gboolean lttv_filter_tree_parse_branch(LttvFilterTree*,LttEvent*,LttTracefile*,LttTrace*,LttvProcessState*,LttvTracefileContext*)
- *
* This function parses a particular branch of the tree
- * @param tree pointer to the current LttvFilterTree
+ * @param se pointer to the current LttvSimpleExpression
* @param event current LttEvent, NULL if not used
* @param tracefile current LttTracefile, NULL if not used
* @param trace current LttTrace, NULL if not used
/**
- * @fn void lttv_print_tree(LttvFilterTree*)
- *
- * Debug
+ * Debug function. Prints tree memory allocation.
* @param t the pointer to the current LttvFilterTree
*/
void
}
/**
- * @fn Destroys the filter module and specific values
+ * Destroys the filter module and specific values
*/
static void module_destroy()
{