filter for selecting eventtype
authoryangxx <yangxx@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 27 Nov 2003 20:29:35 +0000 (20:29 +0000)
committeryangxx <yangxx@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 27 Nov 2003 20:29:35 +0000 (20:29 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@339 04897980-b3bd-0310-b5e0-8ef037075253

ltt/branches/poly/include/lttv/lttvfilter.h
ltt/branches/poly/lttv/modules/gui/mainWin/src/callbacks.c
ltt/branches/poly/lttv/modules/gui/mainWin/src/lttvfilter.c
ltt/branches/poly/lttv/modules/guiEvents.c
ltt/branches/poly/lttv/modules/guiStatistic/guiStatistic.c

index b0d22bcbaefaa4d7e6184c1d668e39236ec23bbe..c73882a263439f3df67bfb2a71a160938cbda0ee 100644 (file)
@@ -7,33 +7,65 @@
 typedef struct _LttvTracesetSelector  LttvTracesetSelector;
 typedef struct _LttvTraceSelector     LttvTraceSelector;
 typedef struct _LttvTracefileSelector LttvTracefileSelector;
+typedef struct _LttvEventtypeSelector LttvEventtypeSelector;
 
 
 LttvTracesetSelector *lttv_traceset_selector_new(char * name);
 LttvTraceSelector *lttv_trace_selector_new(LttTrace *t);
 LttvTracefileSelector *lttv_tracefile_selector_new(LttTracefile *t);
+LttvEventtypeSelector *lttv_eventtype_selector_new(LttEventType * et);
 void lttv_traceset_selector_destroy(LttvTracesetSelector *s);
 void lttv_trace_selector_destroy(LttvTraceSelector *t);
 void lttv_tracefile_selector_destroy(LttvTracefileSelector *t);
+void lttv_eventtype_selector_destroy(LttvEventtypeSelector *t);
 
 
-void lttv_traceset_selector_add(LttvTracesetSelector *s, LttvTraceSelector *t);
-unsigned lttv_traceset_selector_number(LttvTracesetSelector *s);
-LttvTraceSelector *lttv_traceset_selector_get(LttvTracesetSelector *s, unsigned i);
-void lttv_traceset_selector_remove(LttvTracesetSelector *s, unsigned i);
+void lttv_traceset_selector_trace_add(LttvTracesetSelector *s, 
+                                     LttvTraceSelector *t);
+unsigned lttv_traceset_selector_trace_number(LttvTracesetSelector *s);
+LttvTraceSelector *lttv_traceset_selector_trace_get(LttvTracesetSelector *s,
+                                                   unsigned i);
+void lttv_traceset_selector_trace_remove(LttvTracesetSelector *s,
+                                        unsigned i);
 
 
-void lttv_trace_selector_add(LttvTraceSelector *s, LttvTracefileSelector *t);
-unsigned lttv_trace_selector_number(LttvTraceSelector *s);
-LttvTracefileSelector *lttv_trace_selector_get(LttvTraceSelector *s, unsigned i);
-void lttv_trace_selector_remove(LttvTraceSelector *s, unsigned i);
+void lttv_trace_selector_tracefile_add(LttvTraceSelector *s,
+                                      LttvTracefileSelector *t);
+unsigned lttv_trace_selector_tracefile_number(LttvTraceSelector *s);
+LttvTracefileSelector *lttv_trace_selector_tracefile_get(LttvTraceSelector *s,
+                                                        unsigned i);
+void lttv_trace_selector_tracefile_remove(LttvTraceSelector *s, unsigned i);
+
+void lttv_trace_selector_eventtype_add(LttvTraceSelector *s,
+                                      LttvEventtypeSelector *et);
+unsigned lttv_trace_selector_eventtype_number(LttvTraceSelector *s);
+LttvEventtypeSelector *lttv_trace_selector_eventtype_get(LttvTraceSelector *s,
+                                                        unsigned i);
+void lttv_trace_selector_eventtype_remove(LttvTraceSelector *s, unsigned i);
+
+
+void lttv_tracefile_selector_eventtype_add(LttvTracefileSelector *s,
+                                          LttvEventtypeSelector *et);
+unsigned lttv_tracefile_selector_eventtype_number(LttvTracefileSelector *s);
+LttvEventtypeSelector *lttv_tracefile_selector_eventtype_get(LttvTracefileSelector *s,
+                                                            unsigned i);
+void lttv_tracefile_selector_eventtype_remove(LttvTracefileSelector *s, unsigned i);
+
 
 void lttv_trace_selector_set_selected(LttvTraceSelector *s, gboolean g);
 void lttv_tracefile_selector_set_selected(LttvTracefileSelector *s, gboolean g);
+void lttv_eventtype_selector_set_selected(LttvEventtypeSelector *s, gboolean g);
 gboolean lttv_trace_selector_get_selected(LttvTraceSelector *s);
 gboolean lttv_tracefile_selector_get_selected(LttvTracefileSelector *s);
+gboolean lttv_eventtype_selector_get_selected(LttvEventtypeSelector *s);
+char * lttv_traceset_selector_get_name(LttvTracesetSelector *s);
 char * lttv_trace_selector_get_name(LttvTraceSelector *s);
 char * lttv_tracefile_selector_get_name(LttvTracefileSelector *s);
+char * lttv_eventtype_selector_get_name(LttvEventtypeSelector *s);
+
+LttvEventtypeSelector * lttv_eventtype_selector_clone(LttvEventtypeSelector * s);
+void lttv_eventtype_selector_copy(LttvTraceSelector *s, LttvTracefileSelector *d);
+
 
 #endif // LTTV_FILTER_H
 
index 9a62b515c331c19c982e32bf83518e3c9a9584fb..cce4dc4283c83196ca2d14c2241ddbd58a71c0fe 100644 (file)
@@ -17,6 +17,7 @@
 #include <lttv/iattribute.h>
 #include <lttv/lttvfilter.h>
 #include <ltt/trace.h>
+#include <ltt/facility.h>
 
 #define PATH_LENGTH          256
 #define DEFAULT_TIME_WIDTH_S   1
@@ -70,10 +71,14 @@ LttvTracesetSelector * construct_traceset_selector(LttvTraceset * traceset)
   LttvTracesetSelector  * s;
   LttvTraceSelector     * trace;
   LttvTracefileSelector * tracefile;
-  int i, j, nb_trace, nb_tracefile, nb_control, nb_per_cpu;
+  LttvEventtypeSelector * eventtype;
+  int i, j, k, m;
+  int nb_trace, nb_tracefile, nb_control, nb_per_cpu, nb_facility, nb_event;
   LttvTrace * trace_v;
   LttTrace  * t;
   LttTracefile *tf;
+  LttFacility * fac;
+  LttEventType * et;
 
   s = lttv_traceset_selector_new(lttv_traceset_name(traceset));
   nb_trace = lttv_traceset_number(traceset);
@@ -81,7 +86,19 @@ LttvTracesetSelector * construct_traceset_selector(LttvTraceset * traceset)
     trace_v = lttv_traceset_get(traceset, i);
     t       = lttv_trace(trace_v);
     trace   = lttv_trace_selector_new(t);
-    lttv_traceset_selector_add(s, trace);
+    lttv_traceset_selector_trace_add(s, trace);
+
+    nb_facility = ltt_trace_facility_number(t);
+    for(k=0;k<nb_facility;k++){
+      fac = ltt_trace_facility_get(t,k);
+      nb_event = (int) ltt_facility_eventtype_number(fac);
+      for(m=0;m<nb_event;m++){
+       et = ltt_facility_eventtype_get(fac,m);
+       eventtype = lttv_eventtype_selector_new(et);
+       lttv_trace_selector_eventtype_add(trace, eventtype);
+      }
+    }
+
     nb_control = ltt_trace_control_tracefile_number(t);
     nb_per_cpu = ltt_trace_per_cpu_tracefile_number(t);
     nb_tracefile = nb_control + nb_per_cpu;
@@ -92,7 +109,8 @@ LttvTracesetSelector * construct_traceset_selector(LttvTraceset * traceset)
       else
         tf = ltt_trace_per_cpu_tracefile_get(t, j - nb_control);     
       tracefile = lttv_tracefile_selector_new(tf);  
-      lttv_trace_selector_add(trace, tracefile);
+      lttv_trace_selector_tracefile_add(trace, tracefile);
+      lttv_eventtype_selector_copy(trace, tracefile);
     }
   } 
   return s;
@@ -318,19 +336,34 @@ void redraw_viewer(MainWindow * mw_data, TimeWindow * time_window)
 
 void add_trace_into_traceset_selector(GtkMultiVPaned * paned, LttTrace * t)
 {
-  int j, nb_tracefile, nb_control, nb_per_cpu;
+  int j, k, m, nb_tracefile, nb_control, nb_per_cpu, nb_facility, nb_event;
   LttvTracesetSelector  * s;
   LttvTraceSelector     * trace;
   LttvTracefileSelector * tracefile;
+  LttvEventtypeSelector * eventtype;
   LttTracefile          * tf;
   GtkWidget             * w;
+  LttFacility           * fac;
+  LttEventType          * et;
 
   w = gtk_multi_vpaned_get_first_widget(paned);  
   while(w){
     s = g_object_get_data(G_OBJECT(w), "Traceset_Selector");
 
     trace   = lttv_trace_selector_new(t);
-    lttv_traceset_selector_add(s, trace);
+    lttv_traceset_selector_trace_add(s, trace);
+
+    nb_facility = ltt_trace_facility_number(t);
+    for(k=0;k<nb_facility;k++){
+      fac = ltt_trace_facility_get(t,k);
+      nb_event = (int) ltt_facility_eventtype_number(fac);
+      for(m=0;m<nb_event;m++){
+       et = ltt_facility_eventtype_get(fac,m);
+       eventtype = lttv_eventtype_selector_new(et);
+       lttv_trace_selector_eventtype_add(trace, eventtype);
+      }
+    }
+
     nb_control = ltt_trace_control_tracefile_number(t);
     nb_per_cpu = ltt_trace_per_cpu_tracefile_number(t);
     nb_tracefile = nb_control + nb_per_cpu;
@@ -341,7 +374,8 @@ void add_trace_into_traceset_selector(GtkMultiVPaned * paned, LttTrace * t)
       else
        tf = ltt_trace_per_cpu_tracefile_get(t, j - nb_control);     
       tracefile = lttv_tracefile_selector_new(tf);  
-      lttv_trace_selector_add(trace, tracefile);
+      lttv_trace_selector_tracefile_add(trace, tracefile);
+      lttv_eventtype_selector_copy(trace, tracefile);
     }
 
     w = gtk_multi_vpaned_get_next_widget(paned);  
@@ -405,8 +439,8 @@ void remove_trace_from_traceset_selector(GtkMultiVPaned * paned, unsigned i)
   w = gtk_multi_vpaned_get_first_widget(paned);  
   while(w){
     s = g_object_get_data(G_OBJECT(w), "Traceset_Selector");
-    t = lttv_traceset_selector_get(s,i);
-    lttv_traceset_selector_remove(s, i);
+    t = lttv_traceset_selector_trace_get(s,i);
+    lttv_traceset_selector_trace_remove(s, i);
     lttv_trace_selector_destroy(t);
     w = gtk_multi_vpaned_get_next_widget(paned);  
   }
@@ -442,14 +476,14 @@ void remove_trace(GtkWidget * widget, gpointer user_data)
        //unselect the trace from the current viewer
        w = gtk_multi_vpaned_get_widget(mw_data->current_tab->multi_vpaned);  
        s = g_object_get_data(G_OBJECT(w), "Traceset_Selector");
-       t = lttv_traceset_selector_get(s,i);
+       t = lttv_traceset_selector_trace_get(s,i);
        lttv_trace_selector_set_selected(t, FALSE);
 
        //check if other viewers select the trace
        w = gtk_multi_vpaned_get_first_widget(mw_data->current_tab->multi_vpaned);  
        while(w){
          s = g_object_get_data(G_OBJECT(w), "Traceset_Selector");
-         t = lttv_traceset_selector_get(s,i);
+         t = lttv_traceset_selector_trace_get(s,i);
          selected = lttv_trace_selector_get_selected(t);
          if(selected)break;
          w = gtk_multi_vpaned_get_next_widget(mw_data->current_tab->multi_vpaned);  
@@ -1110,24 +1144,56 @@ void checkbox_changed(GtkTreeView *treeview,
 
 void update_filter(LttvTracesetSelector *s,  GtkTreeStore *store )
 {
-  GtkTreeIter iter, child_iter;
-  int i, j;
+  GtkTreeIter iter, child_iter, child_iter1, child_iter2;
+  int i, j, k, nb_eventtype;
   LttvTraceSelector     * trace;
   LttvTracefileSelector * tracefile;
-  gboolean value, value1;
+  LttvEventtypeSelector * eventtype;
+  gboolean value, value1, value2;
 
   if(gtk_tree_model_get_iter_first((GtkTreeModel*)store, &iter)){
     i = 0;
     do{
-      trace = lttv_traceset_selector_get(s, i);
+      trace = lttv_traceset_selector_trace_get(s, i);
+      nb_eventtype = lttv_trace_selector_eventtype_number(trace);
       gtk_tree_model_get ((GtkTreeModel*)store, &iter, CHECKBOX_COLUMN, &value,-1);
       if(value){
        j = 0;
        if(gtk_tree_model_iter_children ((GtkTreeModel*)store, &child_iter, &iter)){
          do{
-           tracefile = lttv_trace_selector_get(trace, j);
-           gtk_tree_model_get ((GtkTreeModel*)store, &child_iter, CHECKBOX_COLUMN, &value1,-1);
-           lttv_tracefile_selector_set_selected(tracefile,value1);
+           if(j<1){//eventtype selector for trace
+             gtk_tree_model_get ((GtkTreeModel*)store, &child_iter, CHECKBOX_COLUMN, &value2,-1);
+             if(value2){
+               k=0;
+               if(gtk_tree_model_iter_children ((GtkTreeModel*)store, &child_iter1, &child_iter)){
+                 do{
+                   eventtype = lttv_trace_selector_eventtype_get(trace,k);
+                   gtk_tree_model_get ((GtkTreeModel*)store, &child_iter1, CHECKBOX_COLUMN, &value2,-1);
+                   lttv_eventtype_selector_set_selected(eventtype,value2);
+                   k++;
+                 }while(gtk_tree_model_iter_next((GtkTreeModel*)store, &child_iter1));
+               }
+             }
+           }else{ //tracefile selector
+             tracefile = lttv_trace_selector_tracefile_get(trace, j - 1);
+             gtk_tree_model_get ((GtkTreeModel*)store, &child_iter, CHECKBOX_COLUMN, &value1,-1);
+             lttv_tracefile_selector_set_selected(tracefile,value1);
+             if(value1){
+               gtk_tree_model_iter_children((GtkTreeModel*)store, &child_iter1, &child_iter); //eventtype selector
+               gtk_tree_model_get ((GtkTreeModel*)store, &child_iter1, CHECKBOX_COLUMN, &value2,-1);
+               if(value2){
+                 k = 0;
+                 if(gtk_tree_model_iter_children ((GtkTreeModel*)store, &child_iter2, &child_iter1)){
+                   do{//eventtype selector for tracefile
+                     eventtype = lttv_tracefile_selector_eventtype_get(tracefile,k);
+                     gtk_tree_model_get ((GtkTreeModel*)store, &child_iter2, CHECKBOX_COLUMN, &value2,-1);
+                     lttv_eventtype_selector_set_selected(eventtype,value2);
+                     k++;
+                   }while(gtk_tree_model_iter_next((GtkTreeModel*)store, &child_iter2));
+                 }
+               }
+             }
+           }
            j++;
          }while(gtk_tree_model_iter_next((GtkTreeModel*)store, &child_iter));
        }
@@ -1146,10 +1212,11 @@ gboolean get_filter_selection(LttvTracesetSelector *s,char *title, char * column
   GtkWidget         * scroll_win;
   GtkCellRenderer   * renderer;
   GtkTreeViewColumn * column;
-  GtkTreeIter         iter, child_iter;
-  int i, j, id, nb_trace, nb_tracefile;
+  GtkTreeIter         iter, child_iter, child_iter1, child_iter2;
+  int i, j, k, id, nb_trace, nb_tracefile, nb_eventtype;
   LttvTraceSelector     * trace;
   LttvTracefileSelector * tracefile;
+  LttvEventtypeSelector * eventtype;
   char * name;
   gboolean checked;
 
@@ -1159,7 +1226,7 @@ gboolean get_filter_selection(LttvTracesetSelector *s,char *title, char * column
                                         GTK_STOCK_OK,GTK_RESPONSE_ACCEPT,
                                         GTK_STOCK_CANCEL,GTK_RESPONSE_REJECT,
                                         NULL); 
-  gtk_window_set_default_size((GtkWindow*)dialogue, 300, 100);
+  gtk_window_set_default_size((GtkWindow*)dialogue, 300, 500);
 
   store = gtk_tree_store_new (TOTAL_COLUMNS, G_TYPE_BOOLEAN, G_TYPE_STRING);
   tree  = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
@@ -1201,9 +1268,9 @@ gboolean get_filter_selection(LttvTracesetSelector *s,char *title, char * column
   gtk_widget_show(scroll_win);
   gtk_widget_show(tree);
   
-  nb_trace = lttv_traceset_selector_number(s);
+  nb_trace = lttv_traceset_selector_trace_number(s);
   for(i=0;i<nb_trace;i++){
-    trace = lttv_traceset_selector_get(s, i);
+    trace = lttv_traceset_selector_trace_get(s, i);
     name  = lttv_trace_selector_get_name(trace);    
     gtk_tree_store_append (store, &iter, NULL);
     checked = lttv_trace_selector_get_selected(trace);
@@ -1211,9 +1278,28 @@ gboolean get_filter_selection(LttvTracesetSelector *s,char *title, char * column
                        CHECKBOX_COLUMN,checked,
                        NAME_COLUMN,name,
                        -1);
-    nb_tracefile = lttv_trace_selector_number(trace);
+
+    gtk_tree_store_append (store, &child_iter, &iter);      
+    gtk_tree_store_set (store, &child_iter, 
+                       CHECKBOX_COLUMN, checked,
+                       NAME_COLUMN,"eventtype",
+                       -1);
+    
+    nb_eventtype = lttv_trace_selector_eventtype_number(trace);
+    for(j=0;j<nb_eventtype;j++){
+      eventtype = lttv_trace_selector_eventtype_get(trace,j);
+      name      = lttv_eventtype_selector_get_name(eventtype);    
+      checked   = lttv_eventtype_selector_get_selected(eventtype);
+      gtk_tree_store_append (store, &child_iter1, &child_iter);      
+      gtk_tree_store_set (store, &child_iter1, 
+                         CHECKBOX_COLUMN, checked,
+                         NAME_COLUMN,name,
+                         -1);
+    }
+
+    nb_tracefile = lttv_trace_selector_tracefile_number(trace);
     for(j=0;j<nb_tracefile;j++){
-      tracefile = lttv_trace_selector_get(trace, j);
+      tracefile = lttv_trace_selector_tracefile_get(trace, j);
       name      = lttv_tracefile_selector_get_name(tracefile);    
       gtk_tree_store_append (store, &child_iter, &iter);
       checked = lttv_tracefile_selector_get_selected(tracefile);
@@ -1221,6 +1307,23 @@ gboolean get_filter_selection(LttvTracesetSelector *s,char *title, char * column
                          CHECKBOX_COLUMN, checked,
                          NAME_COLUMN,name,
                          -1);
+
+      gtk_tree_store_append (store, &child_iter1, &child_iter);      
+      gtk_tree_store_set (store, &child_iter1, 
+                         CHECKBOX_COLUMN, checked,
+                         NAME_COLUMN,"eventtype",
+                         -1);
+    
+      for(k=0;k<nb_eventtype;k++){
+       eventtype = lttv_tracefile_selector_eventtype_get(tracefile,k);
+       name      = lttv_eventtype_selector_get_name(eventtype);    
+       checked   = lttv_eventtype_selector_get_selected(eventtype);
+       gtk_tree_store_append (store, &child_iter2, &child_iter1);      
+       gtk_tree_store_set (store, &child_iter2, 
+                           CHECKBOX_COLUMN, checked,
+                           NAME_COLUMN,name,
+                           -1);
+      }
     }
   }
 
index ed5f98243c927d0616fe77efe7dbc0ff9684c013..2c7398d96ac23090c70003b20773beb66ccbd151 100644 (file)
@@ -2,21 +2,29 @@
 #include <lttv/lttvfilter.h>
 #include <stdio.h>
 #include <ltt/trace.h>
+#include <ltt/type.h>
 
 struct _LttvTracesetSelector {
   char      * traceset_name;
-  GPtrArray *traces;
+  GPtrArray * traces;
 };
 
 
 struct _LttvTraceSelector {
   char      * trace_name;
   GPtrArray * tracefiles;
+  GPtrArray * eventtypes;
   gboolean    selected;
 };
 
 struct _LttvTracefileSelector {
   char      * tracefile_name;
+  GPtrArray * eventtypes;
+  gboolean    selected;
+};
+
+struct _LttvEventtypeSelector {
+  char      * eventtype_name;
   gboolean    selected;
 };
 
@@ -41,6 +49,7 @@ LttvTraceSelector *lttv_trace_selector_new(LttTrace *t)
   trace = g_new(LttvTraceSelector, 1);
   trace->trace_name = g_strdup(ltt_trace_name(t));
   trace->tracefiles = g_ptr_array_new();
+  trace->eventtypes = g_ptr_array_new();
   trace->selected = TRUE;
   return trace;
 }
@@ -51,10 +60,19 @@ LttvTracefileSelector *lttv_tracefile_selector_new(LttTracefile *t)
 
   tracefile = g_new(LttvTracefileSelector, 1);
   tracefile->tracefile_name = g_strdup(ltt_tracefile_name(t));
+  tracefile->eventtypes = g_ptr_array_new();
   tracefile->selected = TRUE;
   return tracefile;
 }
 
+LttvEventtypeSelector *lttv_eventtype_selector_new(LttEventType * et)
+{
+  LttvEventtypeSelector * ev;
+  ev = g_new(LttvEventtypeSelector, 1);
+  ev->eventtype_name = g_strdup(ltt_eventtype_name(et));
+  ev->selected = TRUE;
+  return ev;
+}
 
 void lttv_traceset_selector_destroy(LttvTracesetSelector *s) 
 {
@@ -74,66 +92,135 @@ void lttv_trace_selector_destroy(LttvTraceSelector *s)
 {
   int i;
   LttvTracefileSelector * t;
+  LttvEventtypeSelector * e;
 
   for(i=0;i<s->tracefiles->len;i++){
     t = (LttvTracefileSelector*)s->tracefiles->pdata[i];
     lttv_tracefile_selector_destroy(t);
   }
+  for(i=0;i<s->eventtypes->len;i++){
+    e = (LttvEventtypeSelector*)s->eventtypes->pdata[i];
+    lttv_eventtype_selector_destroy(e);
+  }
   if(s->trace_name) g_free(s->trace_name);
   g_free(s);
 }
 
 void lttv_tracefile_selector_destroy(LttvTracefileSelector *t) 
 {
+  int i;
+  LttvEventtypeSelector * e;
+
+  for(i=0;i<t->eventtypes->len;i++){
+    e = (LttvEventtypeSelector*)t->eventtypes->pdata[i];
+    lttv_eventtype_selector_destroy(e);
+  }
+
   if(t->tracefile_name) g_free(t->tracefile_name);
   g_free(t);
 }
 
-void lttv_traceset_selector_add(LttvTracesetSelector *s, LttvTraceSelector *t) 
+void lttv_eventtype_selector_destroy(LttvEventtypeSelector *e)
+{
+  if(e->eventtype_name) g_free(e->eventtype_name);
+  free(e);
+}
+
+void lttv_traceset_selector_trace_add(LttvTracesetSelector *s, 
+                                     LttvTraceSelector *t) 
 {
   g_ptr_array_add(s->traces, t);
 }
 
-void lttv_trace_selector_add(LttvTraceSelector *s, LttvTracefileSelector *t) 
+void lttv_trace_selector_tracefile_add(LttvTraceSelector *s, 
+                                      LttvTracefileSelector *t) 
 {
   g_ptr_array_add(s->tracefiles, t);
 }
 
+void lttv_trace_selector_eventtype_add(LttvTraceSelector *s, 
+                                      LttvEventtypeSelector *et)
+{  
+  g_ptr_array_add(s->eventtypes, et);
+}
+
+void lttv_tracefile_selector_eventtype_add(LttvTracefileSelector *s, 
+                                          LttvEventtypeSelector *et)
+{
+  g_ptr_array_add(s->eventtypes, et);
+}
 
-unsigned lttv_traceset_selector_number(LttvTracesetSelector *s) 
+unsigned lttv_traceset_selector_trace_number(LttvTracesetSelector *s) 
 {
   return s->traces->len;
 }
 
-unsigned lttv_trace_selector_number(LttvTraceSelector *s) 
+unsigned lttv_trace_selector_tracefile_number(LttvTraceSelector *s) 
 {
   return s->tracefiles->len;
 }
 
-LttvTraceSelector *lttv_traceset_selector_get(LttvTracesetSelector *s, unsigned i) 
+unsigned lttv_trace_selector_eventtype_number(LttvTraceSelector *s)
+{
+  return s->eventtypes->len;
+}
+
+unsigned lttv_tracefile_selector_eventtype_number(LttvTracefileSelector *s)
+{
+  return s->eventtypes->len;
+}
+
+LttvTraceSelector *lttv_traceset_selector_trace_get(LttvTracesetSelector *s,
+                                                   unsigned i) 
 {
   g_assert(s->traces->len > i);
   return ((LttvTraceSelector *)s->traces->pdata[i]);
 }
 
-LttvTracefileSelector *lttv_trace_selector_get(LttvTraceSelector *s, unsigned i) 
+LttvTracefileSelector *lttv_trace_selector_tracefile_get(LttvTraceSelector *s,
+                                                        unsigned i) 
 {
   g_assert(s->tracefiles->len > i);
   return ((LttvTracefileSelector *)s->tracefiles->pdata[i]);
 }
 
-void lttv_traceset_selector_remove(LttvTracesetSelector *s, unsigned i) 
+LttvEventtypeSelector *lttv_trace_selector_eventtype_get(LttvTraceSelector *s,
+                                                        unsigned i)
+{
+  g_assert(s->eventtypes->len > i);
+  return ((LttvEventtypeSelector *)s->eventtypes->pdata[i]);
+}
+
+LttvEventtypeSelector *lttv_tracefile_selector_eventtype_get(LttvTracefileSelector *s,
+                                                            unsigned i)
+{
+  g_assert(s->eventtypes->len > i);
+  return ((LttvEventtypeSelector *)s->eventtypes->pdata[i]);
+}
+
+void lttv_traceset_selector_trace_remove(LttvTracesetSelector *s, unsigned i) 
 {
   g_assert(s->traces->len > i);
   g_ptr_array_remove_index(s->traces, i);
 }
 
-void lttv_trace_selector_remove(LttvTraceSelector *s, unsigned i) 
+void lttv_trace_selector_tracefile_remove(LttvTraceSelector *s, unsigned i) 
 {
   g_assert(s->tracefiles->len > i);
   g_ptr_array_remove_index(s->tracefiles, i);
 }
 
+void lttv_trace_selector_eventtype_remove(LttvTraceSelector *s, unsigned i)
+{
+  g_assert(s->eventtypes->len > i);
+  g_ptr_array_remove_index(s->eventtypes, i);
+}
+
+void lttv_tracefile_selector_eventtype_remove(LttvTracefileSelector *s, unsigned i)
+{
+  g_assert(s->eventtypes->len > i);
+  g_ptr_array_remove_index(s->eventtypes, i);
+}
 
 void lttv_trace_selector_set_selected(LttvTraceSelector *s, gboolean g)
 {
@@ -145,6 +232,11 @@ void lttv_tracefile_selector_set_selected(LttvTracefileSelector *s, gboolean g)
   s->selected = g;
 }
 
+void lttv_eventtype_selector_set_selected(LttvEventtypeSelector *s, gboolean g)
+{
+  s->selected = g;
+}
+
 gboolean lttv_trace_selector_get_selected(LttvTraceSelector *s)
 {
   return s->selected;
@@ -155,6 +247,16 @@ gboolean lttv_tracefile_selector_get_selected(LttvTracefileSelector *s)
   return s->selected;
 }
 
+gboolean lttv_eventtype_selector_get_selected(LttvEventtypeSelector *s)
+{
+  return s->selected;
+}
+
+char * lttv_traceset_selector_get_name(LttvTracesetSelector *s)
+{
+  return s->traceset_name;
+}
+
 char * lttv_trace_selector_get_name(LttvTraceSelector *s)
 {
   return s->trace_name;
@@ -164,3 +266,29 @@ char * lttv_tracefile_selector_get_name(LttvTracefileSelector *s)
 {
   return s->tracefile_name;
 }
+
+char * lttv_eventtype_selector_get_name(LttvEventtypeSelector *s)
+{
+  return s->eventtype_name;
+}
+
+LttvEventtypeSelector * lttv_eventtype_selector_clone(LttvEventtypeSelector * s)
+{
+  LttvEventtypeSelector * ev = g_new(LttvEventtypeSelector, 1);
+  ev->eventtype_name = g_strdup(s->eventtype_name);
+  ev->selected = s->selected;
+  return ev;
+}
+
+void lttv_eventtype_selector_copy(LttvTraceSelector * s, LttvTracefileSelector * d)
+{
+  int i, len;
+  LttvEventtypeSelector * ev, *ev1;
+
+  len = s->eventtypes->len;
+  for(i=0;i<len;i++){
+    ev = lttv_trace_selector_eventtype_get(s,i);
+    ev1 = lttv_eventtype_selector_clone(ev);
+    lttv_tracefile_selector_eventtype_add(d,ev1);
+  }
+}
index 051147e75fb12933aa5ae9c1b74784231cef6dfa..078314dd013bdf2d598c92005b2b2f600ba16721 100644 (file)
@@ -41,6 +41,7 @@
 #include <ltt/event.h>
 #include <ltt/type.h>
 #include <ltt/trace.h>
+#include <ltt/facility.h>
 #include <string.h>
 
 //#include "mw_api.h"
@@ -931,12 +932,16 @@ void get_test_data(double time_value, guint list_height,
          end.tv_sec = G_MAXULONG;
          end.tv_nsec = G_MAXULONG;
          get_events(event_viewer_data, start, end, RESERVE_SMALL_SIZE, &size);
+         if(size == 0){
+           get_events(event_viewer_data, start, end, G_MAXULONG, &size);
+         }
        }else size = 1;
        if(size > 0) event_number = event_viewer_data->start_event_index + 1;   
        else         event_number = event_viewer_data->start_event_index;
        break;
       case SCROLL_PAGE_DOWN:
-       if(event_viewer_data->end_event_index >= event_viewer_data->number_of_events - 1 - list_height){
+       i = event_viewer_data->number_of_events - 1 - list_height;
+       if((gint)(event_viewer_data->end_event_index) >= i){
          event_viewer_data->append = TRUE;
          first = event_viewer_data->raw_trace_data_queue->head;
          if(!first)break;
@@ -946,6 +951,9 @@ void get_test_data(double time_value, guint list_height,
          end.tv_sec = G_MAXULONG;
          end.tv_nsec = G_MAXULONG;
          get_events(event_viewer_data, start, end, RESERVE_SMALL_SIZE,&size);
+         if(size == 0){
+           get_events(event_viewer_data, start, end, G_MAXULONG,&size);
+         }
        }
        if(list_height <= event_viewer_data->number_of_events - 1 - event_viewer_data->end_event_index)
          event_number = event_viewer_data->start_event_index + list_height - 1;        
@@ -961,7 +969,7 @@ void get_test_data(double time_value, guint list_height,
        start = ltt_time_add(event_viewer_data->time_span.startTime, time);
        event_viewer_data->previous_value = time_value;
        get_events(event_viewer_data, start, end, RESERVE_SMALL_SIZE,&size);
-       if(size < list_height){
+       if(size < list_height && size > 0){
          event_viewer_data->append = FALSE;
          first = event_viewer_data->raw_trace_data_queue->head;
          if(!first)break;
@@ -983,6 +991,9 @@ void get_test_data(double time_value, guint list_height,
            event_viewer_data->start_event_index = event_viewer_data->current_event_index;
          }
          event_number = event_viewer_data->raw_trace_data_queue->length - list_height;
+       }else if(size == 0){
+         get_events(event_viewer_data, start, end, RESERVE_SMALL_SIZE*RESERVE_SMALL_SIZE,&size);
+         event_number = 0;
        }else{
          event_number = 0;
        }
@@ -1001,6 +1012,7 @@ void get_test_data(double time_value, guint list_height,
       first = event_viewer_data->raw_trace_data_queue->head;
       if(first){
        raw_data = (RawTraceData*)g_list_nth_data(first,event_number);
+       if(!raw_data) raw_data = (RawTraceData*)g_list_nth_data(first,0);       
        time = ltt_time_sub(raw_data->time, event_viewer_data->time_span.startTime);
        event_viewer_data->vadjust_c->value = ltt_time_to_double(time) * NANOSECONDS_PER_SECOND;
        g_signal_stop_emission_by_name(G_OBJECT(event_viewer_data->vadjust_c), "value-changed");
@@ -1011,6 +1023,9 @@ void get_test_data(double time_value, guint list_height,
 
     event_viewer_data->start_event_index = event_number;
     event_viewer_data->end_event_index = event_number + list_height - 1;    
+    if(event_viewer_data->end_event_index > event_viewer_data->number_of_events - 1){
+      event_viewer_data->end_event_index = event_viewer_data->number_of_events - 1;
+    }
 
     first = event_viewer_data->raw_trace_data_queue->head;
     gtk_list_store_clear(event_viewer_data->store_m);
@@ -1218,11 +1233,14 @@ int event_selected_hook(void *hook_data, void *call_data)
 
 }
 
-
+/* If every module uses the filter, maybe these two 
+ * (add/remove_context_hooks functions) should be put in common place
+ */
 void add_context_hooks(EventViewerData * event_viewer_data, 
                       LttvTracesetContext * tsc)
 {
-  gint i, j, nbi, nb_tracefile, nb_control, nb_per_cpu;
+  gint i, j, k, m,n, nbi, id;
+  gint nb_tracefile, nb_control, nb_per_cpu, nb_facility, nb_event;
   LttTrace *trace;
   LttvTraceContext *tc;
   LttvTracefileContext *tfc;
@@ -1230,6 +1248,9 @@ void add_context_hooks(EventViewerData * event_viewer_data,
   LttvTraceSelector     * t_s;
   LttvTracefileSelector * tf_s;
   gboolean selected;
+  LttFacility           * fac;
+  LttEventType          * et;
+  LttvEventtypeSelector * eventtype;
 
   ts_s = (LttvTracesetSelector*)g_object_get_data(G_OBJECT(event_viewer_data->hbox_v), 
                                                  event_viewer_data->filter_key);
@@ -1238,7 +1259,7 @@ void add_context_hooks(EventViewerData * event_viewer_data,
   
   nbi = lttv_traceset_number(tsc->ts);
   for(i = 0 ; i < nbi ; i++) {
-    t_s = lttv_traceset_selector_get(ts_s,i);
+    t_s = lttv_traceset_selector_trace_get(ts_s,i);
     selected = lttv_trace_selector_get_selected(t_s);
     if(!selected) continue;
     tc = tsc->traces[i];
@@ -1250,7 +1271,7 @@ void add_context_hooks(EventViewerData * event_viewer_data,
     nb_tracefile = nb_control + nb_per_cpu;
     
     for(j = 0 ; j < nb_tracefile ; j++) {
-      tf_s = lttv_trace_selector_get(t_s,j);
+      tf_s = lttv_trace_selector_tracefile_get(t_s,j);
       selected = lttv_tracefile_selector_get_selected(tf_s);
       if(!selected) continue;
       
@@ -1260,8 +1281,28 @@ void add_context_hooks(EventViewerData * event_viewer_data,
        tfc = tc->per_cpu_tracefiles[j - nb_control];
       
       //if there are hooks for tracefile, add them here
-      lttv_tracefile_context_add_hooks(tfc, NULL,NULL,NULL,NULL,
-                                      event_viewer_data->before_event_hooks,NULL);
+      //      lttv_tracefile_context_add_hooks(tfc, NULL,NULL,NULL,NULL,
+      //                                      event_viewer_data->before_event_hooks,NULL);
+
+      nb_facility = ltt_trace_facility_number(trace);
+      n = 0;
+      for(k=0;k<nb_facility;k++){
+       fac = ltt_trace_facility_get(trace,k);
+       nb_event = (int) ltt_facility_eventtype_number(fac);
+       for(m=0;m<nb_event;m++){
+         et = ltt_facility_eventtype_get(fac,m);
+         eventtype = lttv_tracefile_selector_eventtype_get(tf_s, n);
+         selected = lttv_eventtype_selector_get_selected(eventtype);
+         if(selected){
+           id = (gint) ltt_eventtype_id(et);
+           lttv_tracefile_context_add_hooks_by_id(tfc,id, 
+                                                  event_viewer_data->before_event_hooks,
+                                                  NULL);
+         }
+         n++;
+       }
+      }
+
     }
   }
   
@@ -1274,7 +1315,8 @@ void add_context_hooks(EventViewerData * event_viewer_data,
 void remove_context_hooks(EventViewerData * event_viewer_data, 
                          LttvTracesetContext * tsc)
 {
-  gint i, j, nbi, nb_tracefile, nb_control, nb_per_cpu;
+  gint i, j, k, m, nbi, n, id;
+  gint nb_tracefile, nb_control, nb_per_cpu, nb_facility, nb_event;
   LttTrace *trace;
   LttvTraceContext *tc;
   LttvTracefileContext *tfc;
@@ -1282,6 +1324,9 @@ void remove_context_hooks(EventViewerData * event_viewer_data,
   LttvTraceSelector     * t_s;
   LttvTracefileSelector * tf_s;
   gboolean selected;
+  LttFacility           * fac;
+  LttEventType          * et;
+  LttvEventtypeSelector * eventtype;
 
   ts_s = (LttvTracesetSelector*)g_object_get_data(G_OBJECT(event_viewer_data->hbox_v), 
                                                  event_viewer_data->filter_key);
@@ -1290,7 +1335,7 @@ void remove_context_hooks(EventViewerData * event_viewer_data,
   
   nbi = lttv_traceset_number(tsc->ts);
   for(i = 0 ; i < nbi ; i++) {
-    t_s = lttv_traceset_selector_get(ts_s,i);
+    t_s = lttv_traceset_selector_trace_get(ts_s,i);
     selected = lttv_trace_selector_get_selected(t_s);
     if(!selected) continue;
     tc = tsc->traces[i];
@@ -1302,7 +1347,7 @@ void remove_context_hooks(EventViewerData * event_viewer_data,
     nb_tracefile = nb_control + nb_per_cpu;
     
     for(j = 0 ; j < nb_tracefile ; j++) {
-      tf_s = lttv_trace_selector_get(t_s,j);
+      tf_s = lttv_trace_selector_tracefile_get(t_s,j);
       selected = lttv_tracefile_selector_get_selected(tf_s);
       if(!selected) continue;
       
@@ -1312,8 +1357,25 @@ void remove_context_hooks(EventViewerData * event_viewer_data,
        tfc = tc->per_cpu_tracefiles[j - nb_control];
       
       //if there are hooks for tracefile, remove them here
-      lttv_tracefile_context_remove_hooks(tfc, NULL,NULL,NULL,NULL,
-                                         event_viewer_data->before_event_hooks,NULL);
+      //      lttv_tracefile_context_remove_hooks(tfc, NULL,NULL,NULL,NULL,
+      //                                         event_viewer_data->before_event_hooks,NULL);
+
+      nb_facility = ltt_trace_facility_number(trace);
+      n = 0;
+      for(k=0;k<nb_facility;k++){
+       fac = ltt_trace_facility_get(trace,k);
+       nb_event = (int) ltt_facility_eventtype_number(fac);
+       for(m=0;m<nb_event;m++){
+         et = ltt_facility_eventtype_get(fac,m);
+         eventtype = lttv_tracefile_selector_eventtype_get(tf_s, n);
+         selected = lttv_eventtype_selector_get_selected(eventtype);
+         if(selected){
+           id = (gint) ltt_eventtype_id(et);
+           lttv_tracefile_context_remove_hooks_by_id(tfc,id); 
+         }
+         n++;
+       }
+      }
     }
   }
   //remove hooks from context
index 2f54a22d1db24e5750081440af84de10a2a6d1ad..410abdf4cb1a824ea4761b3f3b02d4bb2e7b5aa6 100644 (file)
@@ -553,7 +553,7 @@ void statistic_add_context_hooks(StatisticViewerData * statistic_viewer_data,
   
   nbi = lttv_traceset_number(tsc->ts);
   for(i = 0 ; i < nbi ; i++) {
-    t_s = lttv_traceset_selector_get(ts_s,i);
+    t_s = lttv_traceset_selector_trace_get(ts_s,i);
     selected = lttv_trace_selector_get_selected(t_s);
     if(!selected) continue;
     tc = tsc->traces[i];
@@ -565,7 +565,7 @@ void statistic_add_context_hooks(StatisticViewerData * statistic_viewer_data,
     nb_tracefile = nb_control + nb_per_cpu;
     
     for(j = 0 ; j < nb_tracefile ; j++) {
-      tf_s = lttv_trace_selector_get(t_s,j);
+      tf_s = lttv_trace_selector_tracefile_get(t_s,j);
       selected = lttv_tracefile_selector_get_selected(tf_s);
       if(!selected) continue;
       
@@ -605,7 +605,7 @@ void statistic_remove_context_hooks(StatisticViewerData * statistic_viewer_data,
   
   nbi = lttv_traceset_number(tsc->ts);
   for(i = 0 ; i < nbi ; i++) {
-    t_s = lttv_traceset_selector_get(ts_s,i);
+    t_s = lttv_traceset_selector_trace_get(ts_s,i);
     selected = lttv_trace_selector_get_selected(t_s);
     if(!selected) continue;
     tc = tsc->traces[i];
@@ -617,7 +617,7 @@ void statistic_remove_context_hooks(StatisticViewerData * statistic_viewer_data,
     nb_tracefile = nb_control + nb_per_cpu;
     
     for(j = 0 ; j < nb_tracefile ; j++) {
-      tf_s = lttv_trace_selector_get(t_s,j);
+      tf_s = lttv_trace_selector_tracefile_get(t_s,j);
       selected = lttv_tracefile_selector_get_selected(tf_s);
       if(!selected) continue;
       
This page took 0.034983 seconds and 4 git commands to generate.