now default viewers on main tab
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Tue, 10 Aug 2004 13:23:28 +0000 (13:23 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Tue, 10 Aug 2004 13:23:28 +0000 (13:23 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@696 04897980-b3bd-0310-b5e0-8ef037075253

ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.c
ltt/branches/poly/lttv/modules/gui/controlflow/module.c
ltt/branches/poly/lttv/modules/gui/detailedevents/events.c
ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c
ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/init_module.c
ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindow.c
ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindow.h
ltt/branches/poly/lttv/modules/gui/statistics/statistics.c

index 662090105665f681173f946d79e576da3a5b106b..d458fe04ae5d94d757722aa7e3d0e8c591b5253e 100644 (file)
@@ -397,6 +397,12 @@ int draw_before_hook(void *hook_data, void *call_data)
                 &height,
                 &hashed_process_data) == 1)
         {
+          g_assert(!(process->pid == 432 && 
+                        ltt_time_compare(process->creation_time,
+                                         ltt_time_zero)==0));
+
+          g_assert(!(process->pid == 432 && 
+                        process->creation_time.tv_nsec == 47797905));
           /* Process not present */
           processlist_add(process_list,
               pid_out,
@@ -1270,6 +1276,13 @@ int draw_after_hook(void *hook_data, void *call_data)
               &height,
               &hashed_process_data_in) == 1)
       {
+          g_assert(!(process_in->pid == 432 && 
+                        ltt_time_compare(process_in->creation_time,
+                                         ltt_time_zero)==0));
+
+          g_assert(!(process_in->pid == 432 && 
+                        process_in->creation_time.tv_nsec == 47797905));
+
         /* Process not present */
         processlist_add(process_list,
             pid_in,
@@ -2158,35 +2171,6 @@ typedef struct _ClosureData {
 } ClosureData;
   
 
-/* find_process
- * Input : A trace and a PID.
- * 
- * - For each CPU of the trace
- *   - Search in trace states by PID and CPU key
- * - If no ProcessState found, return NULL.
- */
-static LttvProcessState *find_process(LttvTraceState *tstate, guint pid)
-{
-  guint cpu_num = ltt_trace_per_cpu_tracefile_number(tstate->parent.t);
-  GQuark cpu_name;
-  guint i;
-  
-  LttvProcessState *real_state = NULL;
-  
-  for(i=0;i<cpu_num;i++) {
-    cpu_name = ((LttvTracefileState*)tstate->parent.tracefiles[i])->cpu_name;
-    LttvProcessState *state = lttv_state_find_process_from_trace(tstate,
-                                                                 cpu_name,
-                                                                 pid);
-    if(state != NULL) {
-      real_state = state;
-      break;
-    }
-  }
-  return real_state;
-}
-
-
 void draw_closure(gpointer key, gpointer value, gpointer user_data)
 {
   ProcessInfo *process_info = (ProcessInfo*)key;
@@ -2222,11 +2206,14 @@ void draw_closure(gpointer key, gpointer value, gpointer user_data)
      * be added after the state update.  */
     g_assert(lttv_traceset_number(tsc->ts) > 0);
 
-    LttvTraceState *trace_state =
-      (LttvTraceState*)tsc->traces[process_info->trace_num];
+    /* tracefiles[0] is ok here, because we draw for every PID, and
+     * assume CPU 0 for PID 0 //FIXME */
+    LttvTracefileState *tfs =
+      (LttvTracefileState*)tsc->traces[process_info->trace_num]->tracefiles[0];
 
     LttvProcessState *process;
-    process = find_process(trace_state, process_info->pid);
+    process = lttv_state_find_process(tfs,
+                                      process_info->pid);
 
     if(process != NULL) {
       
index db6d256f957cc29e97f7ce7ff125db636f822173..d2099fc47ca3108f961a46d93f0b47df72b26f3f 100644 (file)
@@ -70,7 +70,8 @@ static void init() {
   g_info("GUI ControlFlow Viewer init()");
 
   /* Register the toolbar insert button and menu entry*/
-  lttvwindow_register_constructor("/",
+  lttvwindow_register_constructor("guicontrolflow",
+                                  "/",
                                   "Insert Control Flow Viewer",
                                   hGuiControlFlowInsert_xpm,
                                   "Insert Control Flow Viewer",
index f16e7436ec7403739ab2b4c9f11a21a9bd3e2a80..414a311b297e96cc842e88b16c0f0dc8ef77e819 100644 (file)
@@ -1867,7 +1867,8 @@ void remove_all_items_from_queue(GQueue *q)
  */
 static void init() {
 
-  lttvwindow_register_constructor("/",
+  lttvwindow_register_constructor("guievents",
+                                  "/",
                                   "Insert Event Viewer",
                                   hGuiEventsInsert_xpm,
                                   "Insert Event Viewer",
index 5630febb54977dd490786ea726e9d9c4459d60ca..273207da007bda0ed98840e7c71bf34cc4179a58 100644 (file)
@@ -4308,6 +4308,50 @@ void construct_main_window(MainWindow * parent)
     }
     LttvTraceset *traceset = new_tab->traceset_info->traceset;
     SetTraceset(new_tab, traceset);
+
+    /* Insert default viewers */
+    {
+      LttvAttributeType type;
+      LttvAttributeName name;
+      LttvAttributeValue value;
+      LttvAttribute *attribute;
+      
+      LttvIAttribute *attributes_global = 
+         LTTV_IATTRIBUTE(lttv_global_attributes());
+
+      g_assert(attribute = 
+        LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(
+                                  LTTV_IATTRIBUTE(attributes_global),
+                                  LTTV_VIEWER_CONSTRUCTORS)));
+
+      name = g_quark_from_string("guievents");
+      type = lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute),
+                                         name, &value);
+      if(type == LTTV_POINTER) {
+        lttvwindow_viewer_constructor viewer_constructor = 
+                  (lttvwindow_viewer_constructor)*value.v_pointer;
+        insert_viewer(new_window, viewer_constructor);
+      }
+
+      name = g_quark_from_string("guicontrolflow");
+      type = lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute),
+                                         name, &value);
+      if(type == LTTV_POINTER) {
+        lttvwindow_viewer_constructor viewer_constructor = 
+                  (lttvwindow_viewer_constructor)*value.v_pointer;
+        insert_viewer(new_window, viewer_constructor);
+      }
+
+      name = g_quark_from_string("guistatistics");
+      type = lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute),
+                                         name, &value);
+      if(type == LTTV_POINTER) {
+        lttvwindow_viewer_constructor viewer_constructor = 
+                  (lttvwindow_viewer_constructor)*value.v_pointer;
+        insert_viewer(new_window, viewer_constructor);
+      }
+
+    }
   }
 
   g_printf("There are now : %d windows\n",g_slist_length(g_main_window_list));
@@ -4323,7 +4367,7 @@ void tab_destructor(Tab * tab)
   int i, nb, ref_count;
   LttvTrace * trace;
 
-  g_object_free(tab->tooltips);
+  g_object_unref(tab->tooltips);
   
   if(tab->attributes)
     g_object_unref(tab->attributes);
index a4e7d4272dfd9b9cc6a5db88d391f35a0f0e91c1..67c6a54e335ec34fd4015cbfe700da95e32cda65 100644 (file)
@@ -50,6 +50,7 @@
 
 LttvTraceInfo LTTV_TRACES,
        LTTV_COMPUTATION,
+       LTTV_VIEWER_CONSTRUCTORS,
        LTTV_REQUESTS_QUEUE,
        LTTV_REQUESTS_CURRENT,
        LTTV_NOTIFY_QUEUE,
@@ -144,6 +145,7 @@ static void init() {
   
   LTTV_TRACES = g_quark_from_string("traces");
   LTTV_COMPUTATION = g_quark_from_string("computation");
+  LTTV_VIEWER_CONSTRUCTORS = g_quark_from_string("viewer_constructors");
   LTTV_REQUESTS_QUEUE = g_quark_from_string("requests_queue");
   LTTV_REQUESTS_CURRENT = g_quark_from_string("requests_current");
   LTTV_NOTIFY_QUEUE = g_quark_from_string("notify_queue");
index 9f153a75ed54169a1b92dc388a383c1ec113e98d..ea848ada2accc84d2682d8b650dbba36c03487a5 100644 (file)
@@ -228,6 +228,7 @@ void remove_menu_constructor(MainWindow *mw, lttvwindow_viewer_constructor viewe
  * 
  * It should be called by init function of the module.
  * 
+ * @param name name of the viewer
  * @param menu_path path of the menu item.
  * @param menu_text text of the menu item.
  * @param pixmap Image shown on the toolbar item.
@@ -236,7 +237,8 @@ void remove_menu_constructor(MainWindow *mw, lttvwindow_viewer_constructor viewe
  */
 
 void lttvwindow_register_constructor
-                            (char *  menu_path, 
+                            (char *  name,
+                             char *  menu_path, 
                              char *  menu_text,
                              char ** pixmap,
                              char *  tooltip,
@@ -249,6 +251,8 @@ void lttvwindow_register_constructor
   LttvMenuClosure menu_c;
   LttvAttributeValue value;
 
+  if(view_constructor == NULL) return;
+  
   if(pixmap != NULL) {
     g_assert(lttv_iattribute_find_by_path(attributes_global,
        "viewers/toolbar", LTTV_POINTER, &value));
@@ -281,6 +285,19 @@ void lttvwindow_register_constructor
                     (gpointer)add_menu_constructor,
                     &menu_c);
   }
+  {
+    LttvAttribute *attribute;
+    g_assert(attribute = 
+      LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(
+                                LTTV_IATTRIBUTE(attributes_global),
+                                LTTV_VIEWER_CONSTRUCTORS)));
+  
+    g_assert(lttv_iattribute_find_by_path(LTTV_IATTRIBUTE(attribute),
+                            name, LTTV_POINTER, &value));
+
+    *(value.v_pointer) = view_constructor;
+
+  }
 }
 
 
@@ -324,6 +341,29 @@ void lttvwindow_unregister_constructor
                     view_constructor);
     lttv_menus_remove(menu, view_constructor);
   }
+
+  {
+    LttvAttribute *attribute;
+    g_assert(attribute = 
+      LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(
+                                LTTV_IATTRIBUTE(attributes_global),
+                                LTTV_VIEWER_CONSTRUCTORS)));
+  
+    guint num = lttv_iattribute_get_number(LTTV_IATTRIBUTE(attribute));
+    guint i;
+    LttvAttributeName name;
+    LttvAttributeValue value;
+    LttvAttributeType type;
+    
+    for(i=0;i<num;i++) {
+      type = lttv_iattribute_get(LTTV_IATTRIBUTE(attribute), i, &name, &value);
+      g_assert(type == LTTV_POINTER);
+      if(*(value.v_pointer) == view_constructor) {
+        lttv_iattribute_remove(LTTV_IATTRIBUTE(attribute), i);
+        break;
+      }
+    }
+  }
 }
 
 
index bc0521522b87ccb76ac8cf77300626ab7d36d311..773f7b5e9d1d7fc455962aa87d953d04cc34b05a 100644 (file)
@@ -262,6 +262,8 @@ FIXME : explain other important events
 
 /* Module Related API */
 
+/* GQuark containing constructors of viewers in global attributes */
+extern GQuark LTTV_VIEWER_CONSTRUCTORS;
 
 /* constructor a the viewer */
 typedef GtkWidget* (*lttvwindow_viewer_constructor)(Tab *tab);
@@ -274,7 +276,8 @@ typedef GtkWidget* (*lttvwindow_viewer_constructor)(Tab *tab);
  * window.
  * 
  * It should be called by init function of the module.
- * 
+ *
+ * @param name name of the viewer : mainly used as tag for constructor
  * @param menu_path path of the menu item. NULL : no menu entry.
  * @param menu_text text of the menu item.
  * @param pixmap Image shown on the toolbar item. NULL : no button.
@@ -283,7 +286,8 @@ typedef GtkWidget* (*lttvwindow_viewer_constructor)(Tab *tab);
  */
 
 void lttvwindow_register_constructor
-                            (char *  menu_path, 
+                            (char * name,
+                             char *  menu_path, 
                              char *  menu_text,
                              char ** pixmap,
                              char *  tooltip,
index a4a0567cf31aa4b5281e3e609ce49c044f31c82b..0af3c08dfdbadec5867112ffa275a05761323d9b 100644 (file)
@@ -17,6 +17,7 @@
  */
 
 #include <glib.h>
+#include <string.h>
 #include <gtk/gtk.h>
 #include <gdk/gdk.h>
 
@@ -281,7 +282,7 @@ gui_statistic(Tab *tab)
   statistic_viewer_data->statistic_hash = g_hash_table_new_full(g_str_hash,
                                                   g_str_equal,
                                                   statistic_destroy_hash_key,
-                                                  statistic_destroy_hash_data);
+                                                  NULL);
 
   statistic_viewer_data->hpaned_v  = gtk_hpaned_new();
   statistic_viewer_data->store_m = gtk_tree_store_new (N_COLUMNS, G_TYPE_STRING);
@@ -388,15 +389,12 @@ void statistic_destroy_hash_key(gpointer key)
   g_free(key);
 }
 
-void statistic_destroy_hash_data(gpointer data)
-{
-  //  g_free(data);
-}
-
+#ifdef DEBUG
 #include <stdio.h>
 extern FILE *stdin;
 extern FILE *stdout;
 extern FILE *stderr;
+#endif //DEBUG
 
 void show_traceset_stats(StatisticViewerData * statistic_viewer_data)
 {
@@ -434,9 +432,11 @@ void show_traceset_stats(StatisticViewerData * statistic_viewer_data)
   for(i = 0 ; i < nb ; i++) {
     tcs = (LttvTraceStats *)(LTTV_TRACESET_CONTEXT(tscs)->traces[i]);
     desc = ltt_trace_system_description(tcs->parent.parent.t);    
-    sprintf(trace_str, "Trace on system %s at time %d secs", 
+    LttTime start_time = ltt_trace_system_description_trace_start_time(desc);
+    sprintf(trace_str, "Trace on system %s at time %lu.%09lu", 
             ltt_trace_system_description_node_name(desc),
-      (ltt_trace_system_description_trace_start_time(desc)).tv_sec);
+            start_time.tv_sec,
+            start_time.tv_nsec);
     
     gtk_tree_store_append (store, &iter, NULL);  
     gtk_tree_store_set (store, &iter,NAME_COLUMN,trace_str,-1);  
@@ -491,7 +491,6 @@ void show_statistic(StatisticViewerData * statistic_viewer_data,
         LttvAttribute* stats, GtkTextBuffer* buf)
 {
   int i, nb , flag;
-  LttvAttribute *subtree;
   LttvAttributeName name;
   LttvAttributeValue value;
   LttvAttributeType type;
@@ -524,7 +523,7 @@ void show_statistic(StatisticViewerData * statistic_viewer_data,
         sprintf(type_value, " :  %f\n", *value.v_double);
         break;
       case LTTV_TIME:
-        sprintf(type_value, " :  %10u.%09u\n", value.v_time->tv_sec, 
+        sprintf(type_value, " :  %10lu.%09lu\n", value.v_time->tv_sec, 
             value.v_time->tv_nsec);
         break;
       case LTTV_POINTER:
@@ -660,7 +659,8 @@ void statistic_remove_context_hooks(StatisticViewerData * statistic_viewer_data,
  */
 static void init() {
 
-  lttvwindow_register_constructor("/",
+  lttvwindow_register_constructor("guistatistics",
+                                  "/",
                                   "Insert Statistic Viewer",
                                   hGuiStatisticInsert_xpm,
                                   "Insert Statistic Viewer",
@@ -684,7 +684,6 @@ void statistic_destroy_walk(gpointer data, gpointer user_data)
  * everything that has been registered in the gtkTraceSet API.
  */
 static void destroy() {
-  int i;
   
   g_slist_foreach(g_statistic_viewer_data_list, statistic_destroy_walk, NULL );    
   g_slist_free(g_statistic_viewer_data_list);
This page took 0.031273 seconds and 4 git commands to generate.