thread brand
[lttv.git] / ltt / branches / poly / lttv / modules / text / textFilter.c
index 8f7a7d81ed567a4da53a9ad8c514bcdf94ececf7..6934011c1dd344c49a3b6afcaaa9209994454a3d 100644 (file)
@@ -1,5 +1,5 @@
 /* This file is part of the Linux Trace Toolkit viewer
- * Copyright (C) 2003-2004 Michel Dagenais
+ * Copyright (C) 2005 Simon Bouvier-Zappa 
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License Version 2 as
  * MA 02111-1307, USA.
  */
 
-/* 
- * The text filter facility will prompt for user filter option 
- * and transmit them to the lttv core 
+/*! \file lttv/modules/text/textFilter.c
+ *  \brief Textual prompt for user filtering expression.
+ *  
+ *  The text filter facility will prompt for user filter option 
+ *  and transmit them to the lttv core.  User can either specify 
+ *  a filtering string with the command line or/and specify a 
+ *  file containing filtering expressions.
  */
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include <lttv/lttv.h>
 #include <lttv/option.h>
 #include <lttv/module.h>
 /* Insert the hooks before and after each trace and tracefile, and for each
    event. Print a global header. */
 
-/*
- *  YET TO BE ANSWERED !
- *  - why does this module need dependency with batchAnalysis ?
- */
-
 /*
  *  TODO
  *  - specify wich hook function will be used to call the core filter
@@ -59,13 +62,10 @@ static LttvHooks
 
 /**
  * filters the file input from user
- * @param hook_data the hook data
- * @return success/failure of operation
+ * @param hook_data the hook data, unused
  */
 void filter_analyze_file(void *hook_data) {
 
-  g_print("textFilter::filter_analyze_file\n");
   LttvAttributeValue value;
 
   LttvIAttribute *attributes = LTTV_IATTRIBUTE(lttv_global_attributes());
@@ -75,27 +75,6 @@ void filter_analyze_file(void *hook_data) {
         *      and/or command line string.  From these sources, an 
         *      option string is rebuilded and sent to the filter core
         */
-  
-/* OLD CODE
- * GString* a_file_content = g_string_new("");
-  a_file = fopen(a_file_name, "r"); 
-       if(a_file == NULL) { 
-               g_warning("file %s does not exist", a_file_name);
-    return;
-  }
-  
-  char* line = NULL;
-  size_t len = 0;
-
-  while(!feof(a_file)) {
-    len = getline(&line,&len,a_file);
-    g_string_append(a_file_content,line);
-  }
-  free(line);
-
-  fclose(a_file);
-*/  
-  
   if(!g_file_test(a_file_name,G_FILE_TEST_EXISTS)) {
     g_warning("file %s does not exist", a_file_name);
     return;
@@ -117,13 +96,10 @@ void filter_analyze_file(void *hook_data) {
 
 /**
  * filters the string input from user
- * @param hook_data the hook data
- * @return success/failure of operation
+ * @param hook_data the hook data, unused
  */
 void filter_analyze_string(void *hook_data) {
 
-  g_print("textFilter::filter_analyze_string\n");
-
   LttvAttributeValue value;
 
   LttvIAttribute *attributes = LTTV_IATTRIBUTE(lttv_global_attributes());
@@ -133,16 +109,6 @@ void filter_analyze_string(void *hook_data) {
         *      and/or command line string.  From these sources, an 
         *      option string is rebuilded and sent to the filter core
         */
-/*  if(a_filter_string==NULL) {
-    a_filter_string = g_string_new("");
-    g_string_append(a_filter_string,a_string);
-  }
-  else {
-    g_string_append(a_filter_string,"&"); 
-    g_string_append(a_filter_string,a_string);
-  }
-*/
-  
   g_assert(lttv_iattribute_find_by_path(attributes, "filter/expression",
       LTTV_POINTER, &value));
 
@@ -151,8 +117,46 @@ void filter_analyze_string(void *hook_data) {
   g_string_append((GString*)*(value.v_pointer),a_string);
   g_string_append_c((GString*)*(value.v_pointer),')');
 
-//  LttvFilter* filter = lttv_filter_new();
-//  lttv_filter_append_expression(filter,a_string);
+}
+
+/**
+ * Output all filter commands on console 
+ * @param hook_data the hook data
+ */
+void filter_list_commands(void *hook_data) {
+
+  g_print("[field] [op] [value]\n\n");
+
+  g_print("*** Possible fields ***\n");
+  g_print("event.name (string)\n");
+  g_print("event.facility (string)\n");
+  g_print("event.category (string)\n");
+  g_print("event.time (double)\n");
+  g_print("event.tsc (integer)\n");
+  g_print("event.field.facility_name.event_name.field_name.subfield_name (field_type)\n");
+  g_print("tracefile.name (string)\n");
+  g_print("trace.name (string)\n");
+  g_print("state.pid (integer)\n");
+  g_print("state.ppid (integer)\n");
+  g_print("state.creation_time (double)\n");
+  g_print("state.insertion_time (double)\n");
+  g_print("state.process_name (string)\n");
+  g_print("state.thread_brand (string)\n");
+  g_print("state.execution_mode (string)\n");
+  g_print("state.execution_submode (string)\n");
+  g_print("state.process_status (string)\n");
+  g_print("state.cpu (string)\n\n");
+  
+  g_print("*** Possible operators ***\n");
+  g_print("equal '='\n");
+  g_print("not equal '!='\n");
+  g_print("greater '>'\n");
+  g_print("greater or equal '>='\n");
+  g_print("lower '<'\n");
+  g_print("lower or equal '<='\n");
+  g_print("*** Possible values ***\n");
+  g_print("string, integer, double");
 }
 
 /**
@@ -160,8 +164,6 @@ void filter_analyze_string(void *hook_data) {
  */
 static void init() {
   
-  g_print("textFilter::init()\n");     /* debug */
-
   LttvAttributeValue value;
 
   LttvIAttribute *attributes = LTTV_IATTRIBUTE(lttv_global_attributes());
@@ -186,6 +188,11 @@ static void init() {
       "file name", 
       LTTV_OPT_STRING, &a_file_name, filter_analyze_file, NULL);
 
+  lttv_option_add("list", 'l',
+      "list all possible filter commands for module",
+      "list commands",
+      LTTV_OPT_NONE, NULL, filter_list_commands, NULL);
+  
 }
 
 /**
@@ -198,6 +205,8 @@ static void destroy() {
 
   lttv_option_remove("filename");
 
+  lttv_option_remove("list");
+
   LttvAttributeValue value;
 
   LttvIAttribute *attributes = LTTV_IATTRIBUTE(lttv_global_attributes());
This page took 0.037857 seconds and 4 git commands to generate.