/*
* \todo
* - refine switch of expression in multiple uses functions
- * - remove the idle expressions in the tree
+ * - remove the idle expressions in the tree
+ * - replace string for enum value for corresponding value
*/
+#define TEST
+#ifdef TEST
+#include <time.h>
+#include <sys/time.h>
+#endif
+
#include <lttv/filter.h>
/**
* @param op current operator
* @return success/failure of operation
*/
-gboolean lttv_simple_expression_assign_operator(LttvSimpleExpression* se, LttvExpressionOp op) {
+gboolean
+lttv_simple_expression_assign_operator(LttvSimpleExpression* se, LttvExpressionOp op) {
switch(se->field) {
/*
case LTTV_FILTER_STATE_P_NAME:
case LTTV_FILTER_EVENT_NAME:
case LTTV_FILTER_STATE_CPU:
+ case LTTV_FILTER_STATE_EX_MODE:
+ case LTTV_FILTER_STATE_EX_SUBMODE:
+ case LTTV_FILTER_STATE_P_STATUS:
switch(op) {
case LTTV_FIELD_EQ:
se->op = lttv_apply_op_eq_quark;
break;
/*
* Enums
+ * Entered as string, converted to enum
+ *
* can only be compared with 'equal' or 'not equal' operators
*
* unsigned int of 16 bits are used here since enums
- * should not over 2^16-1 values
+ * should not go over 2^16-1 values
*/
- case LTTV_FILTER_STATE_EX_MODE:
- case LTTV_FILTER_STATE_EX_SUBMODE:
- case LTTV_FILTER_STATE_P_STATUS:
- switch(op) {
- case LTTV_FIELD_EQ:
- se->op = lttv_apply_op_eq_uint16;
- break;
- case LTTV_FIELD_NE:
- se->op = lttv_apply_op_ne_uint16;
- break;
- default:
- g_warning("Error encountered in operator assignment = or != expected");
- return FALSE;
- }
- break;
+// case /*NOTHING*/:
+// switch(op) {
+// case LTTV_FIELD_EQ:
+// se->op = lttv_apply_op_eq_uint16;
+// break;
+// case LTTV_FIELD_NE:
+// se->op = lttv_apply_op_ne_uint16;
+// break;
+// default:
+// g_warning("Error encountered in operator assignment = or != expected");
+// return FALSE;
+// }
+// break;
/*
* Ltttime
*/
* @param se pointer to the current LttvSimpleExpression
* @param value string value for simple expression
*/
-gboolean lttv_simple_expression_assign_value(LttvSimpleExpression* se, char* value) {
+gboolean
+lttv_simple_expression_assign_value(LttvSimpleExpression* se, char* value) {
unsigned i;
gboolean is_double = FALSE;
switch(se->field) {
/*
- * string --> g_quark
+ * Strings
+ * entered as strings, converted to Quarks
*/
case LTTV_FILTER_TRACE_NAME:
case LTTV_FILTER_TRACEFILE_NAME:
case LTTV_FILTER_STATE_P_NAME:
case LTTV_FILTER_EVENT_NAME:
case LTTV_FILTER_STATE_CPU:
-// se->value.v_string = value;
+ case LTTV_FILTER_STATE_EX_MODE:
+ case LTTV_FILTER_STATE_EX_SUBMODE:
+ case LTTV_FILTER_STATE_P_STATUS:
+ // se->value.v_string = value;
se->value.v_uint32 = g_quark_from_string(value);
g_free(value);
break;
/*
- * integer
+ * integer -- supposed to be uint64
*/
case LTTV_FILTER_STATE_PID:
case LTTV_FILTER_STATE_PPID:
- case LTTV_FILTER_STATE_EX_MODE:
- case LTTV_FILTER_STATE_EX_SUBMODE:
- case LTTV_FILTER_STATE_P_STATUS:
case LTTV_FILTER_EVENT_TSC:
se->value.v_uint64 = atoi(value);
g_free(value);
* 2. the subtree is completed, allocate a new subtree
* 3. pop the tree value from the tree stack
*/
+
+#ifdef TEST
+ struct timeval starttime;
+ struct timeval endtime;
+ gettimeofday(&starttime, NULL);
+#endif
for(i=0;i<strlen(filter->expression);i++) {
// debug
g_assert(filter->head != NULL); /* tree should exist */
g_assert(subtree == NULL); /* remaining subtree should be included in main tree */
+
+#ifdef TEST
+ gettimeofday(&endtime, NULL);
+
+ /* Calcul du temps de l'algorithme */
+ double time1 = starttime.tv_sec + (starttime.tv_usec/1000000.0);
+ double time2 = endtime.tv_sec + (endtime.tv_usec/1000000.0);
+// g_print("Tree build took %.10f ms for strlen of %i\n",(time2-time1)*1000,strlen(filter->expression));
+ g_print("%.10f %i\n",(time2-time1)*1000,strlen(filter->expression));
+#endif
/* debug */
g_print("+++++++++++++++ BEGIN PRINT ++++++++++++++++\n");
* @param expression string that must be appended
* @return Success/Failure of operation
*/
-gboolean lttv_filter_append_expression(LttvFilter* filter, const char *expression) {
+gboolean
+lttv_filter_append_expression(LttvFilter* filter, const char *expression) {
if(expression == NULL) return FALSE;
if(filter == NULL) return FALSE;
* current filter and sets its pointer to NULL
* @param filter pointer to the current LttvFilter
*/
-void lttv_filter_clear_expression(LttvFilter* filter) {
+void
+lttv_filter_clear_expression(LttvFilter* filter) {
if(filter->expression != NULL) {
g_free(filter->expression);
* @param context current LttvTracefileContext, NULL if not used
* @return response of filter
*/
-gboolean lttv_filter_tree_parse_branch(
+gboolean
+lttv_filter_tree_parse_branch(
const LttvSimpleExpression* se,
const LttEvent* event,
const LttTracefile* tracefile,