now default viewers on main tab
[lttv.git] / ltt / branches / poly / lttv / modules / gui / statistics / statistics.c
1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2004 XangXiu Yang
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License Version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
16 * MA 02111-1307, USA.
17 */
18
19 #include <glib.h>
20 #include <string.h>
21 #include <gtk/gtk.h>
22 #include <gdk/gdk.h>
23
24 #include <ltt/ltt.h>
25 #include <ltt/event.h>
26 #include <ltt/type.h>
27 #include <ltt/trace.h>
28
29 #include <lttv/lttv.h>
30 #include <lttv/module.h>
31 #include <lttv/tracecontext.h>
32 #include <lttv/hook.h>
33 #include <lttv/state.h>
34 #include <lttv/stats.h>
35
36 #include <lttvwindow/lttvwindow.h>
37 #include <lttvwindow/lttvwindowtraces.h>
38
39 #include "hGuiStatisticInsert.xpm"
40
41 #define PATH_LENGTH 256 /* CHECK */
42 #define MAX_NUMBER_EVENT "max_number_event"
43
44 //???????????????6
45 //static GPtrArray * statistic_traceset;
46
47 /** Array containing instanced objects. Used when module is unloaded */
48 static GSList *g_statistic_viewer_data_list = NULL ;
49
50 typedef struct _StatisticViewerData StatisticViewerData;
51
52 static void request_background_data(StatisticViewerData *svd);
53 GtkWidget *guistatistic_get_widget(StatisticViewerData *svd);
54
55 //! Statistic Viewer's constructor hook
56 GtkWidget *h_gui_statistic(Tab *tab);
57 //! Statistic Viewer's constructor
58 StatisticViewerData *gui_statistic(Tab *tab);
59 //! Statistic Viewer's destructor
60 void gui_statistic_destructor(StatisticViewerData *statistic_viewer_data);
61
62 static void tree_selection_changed_cb (GtkTreeSelection *selection, gpointer data);
63
64 void statistic_destroy_hash_key(gpointer key);
65 void statistic_destroy_hash_data(gpointer data);
66
67 void show_traceset_stats(StatisticViewerData * statistic_viewer_data);
68 void show_tree(StatisticViewerData * statistic_viewer_data,
69 LttvAttribute* stats, GtkTreeIter* parent);
70 void show_statistic(StatisticViewerData * statistic_viewer_data,
71 LttvAttribute* stats, GtkTextBuffer* buf);
72
73
74 gboolean statistic_traceset_changed(void * hook_data, void * call_data);
75 //void statistic_add_context_hooks(StatisticViewerData * statistic_viewer_data,
76 // LttvTracesetContext * tsc);
77 //void statistic_remove_context_hooks(StatisticViewerData *statistic_viewer_data,
78 // LttvTracesetContext * tsc);
79
80 //gboolean statistic_insert_traceset_stats(void * stats);
81
82 enum
83 {
84 NAME_COLUMN,
85 N_COLUMNS
86 };
87
88 struct _StatisticViewerData{
89 Tab *tab;
90 //LttvTracesetStats * stats;
91 int size;
92
93 //gboolean shown; //indicate if the statistic is shown or not
94 //char * filter_key;
95
96 GtkWidget * hpaned_v;
97 GtkTreeStore * store_m;
98 GtkWidget * tree_v;
99
100 //scroll window containing Tree View
101 GtkWidget * scroll_win_tree;
102
103 GtkWidget * text_v;
104 //scroll window containing Text View
105 GtkWidget * scroll_win_text;
106
107 // Selection handler
108 GtkTreeSelection *select_c;
109
110 //hash
111 GHashTable *statistic_hash;
112 };
113
114
115
116
117 /* Action to do when background computation completed.
118 *
119 * Eventually, will have to check that every requested traces are finished
120 * before doing the redraw. It will save unnecessary processor usage.
121 */
122
123 static gint background_ready(void *hook_data, void *call_data)
124 {
125 StatisticViewerData *svd = (StatisticViewerData *)hook_data;
126 Tab *tab = svd->tab;
127 LttvTrace *trace = (LttvTrace*)call_data;
128
129 g_debug("statistics viewer : background computation data ready.");
130
131 gtk_tree_store_clear (svd->store_m);
132
133 lttv_stats_sum_traceset(lttvwindow_get_traceset_stats(tab));
134 show_traceset_stats(svd);
135
136 return 0;
137 }
138
139 /* Request background computation. Verify if it is in progress or ready first.
140 *
141 * Right now, for all loaded traces.
142 *
143 * Later : must be only for each trace in the tab's traceset.
144 */
145 static void request_background_data(StatisticViewerData *svd)
146 {
147 gint num_traces = lttvwindowtraces_get_number();
148 gint i;
149 LttvTrace *trace;
150
151 LttvHooks *background_ready_hook =
152 lttv_hooks_new();
153 lttv_hooks_add(background_ready_hook, background_ready, svd,
154 LTTV_PRIO_DEFAULT);
155
156 for(i=0;i<num_traces;i++) {
157 trace = lttvwindowtraces_get_trace(i);
158
159 if(lttvwindowtraces_get_ready(g_quark_from_string("stats"),trace)==FALSE) {
160
161 if(lttvwindowtraces_get_in_progress(g_quark_from_string("stats"),
162 trace) == FALSE) {
163 /* We first remove requests that could have been done for the same
164 * information. Happens when two viewers ask for it before servicing
165 * starts.
166 */
167 lttvwindowtraces_background_request_remove(trace, "stats");
168 lttvwindowtraces_background_request_queue(trace,
169 "stats");
170 lttvwindowtraces_background_notify_queue(svd,
171 trace,
172 ltt_time_infinite,
173 NULL,
174 background_ready_hook);
175 } else { /* in progress */
176
177 lttvwindowtraces_background_notify_current(svd,
178 trace,
179 ltt_time_infinite,
180 NULL,
181 background_ready_hook);
182
183 }
184 }
185 }
186 lttv_hooks_destroy(background_ready_hook);
187 }
188
189
190 GtkWidget *guistatistic_get_widget(StatisticViewerData *svd)
191 {
192 return svd->hpaned_v;
193 }
194
195
196 void
197 gui_statistic_destructor(StatisticViewerData *statistic_viewer_data)
198 {
199 Tab *tab = statistic_viewer_data->tab;
200
201 /* May already been done by GTK window closing */
202 if(GTK_IS_WIDGET(guistatistic_get_widget(statistic_viewer_data))){
203 g_info("widget still exists");
204 }
205 if(tab != NULL) {
206 lttvwindow_unregister_traceset_notify(statistic_viewer_data->tab,
207 statistic_traceset_changed,
208 statistic_viewer_data);
209 }
210 lttvwindowtraces_background_notify_remove(statistic_viewer_data);
211
212 g_hash_table_destroy(statistic_viewer_data->statistic_hash);
213 g_statistic_viewer_data_list =
214 g_slist_remove(g_statistic_viewer_data_list, statistic_viewer_data);
215 g_free(statistic_viewer_data);
216 }
217
218
219 /**
220 * Statistic Viewer's constructor hook
221 *
222 * This constructor is given as a parameter to the menuitem and toolbar button
223 * registration. It creates the list.
224 * @param parent_window A pointer to the parent window.
225 * @return The widget created.
226 */
227 GtkWidget *
228 h_gui_statistic(Tab *tab)
229 {
230 StatisticViewerData* statistic_viewer_data = gui_statistic(tab) ;
231
232 if(statistic_viewer_data)
233 return guistatistic_get_widget(statistic_viewer_data);
234 else return NULL;
235
236 }
237
238 #if 0
239 gboolean statistic_insert_traceset_stats(void * stats)
240 {
241 int i, len;
242 gpointer s;
243
244 len = statistic_traceset->len;
245 for(i=0;i<len;i++){
246 s = g_ptr_array_index(statistic_traceset, i);
247 if(s == stats) break;
248 }
249 if(i==len){
250 g_ptr_array_add(statistic_traceset, stats);
251 return TRUE;
252 }
253 return FALSE;
254 }
255 #endif //0
256
257 /**
258 * Statistic Viewer's constructor
259 *
260 * This constructor is used to create StatisticViewerData data structure.
261 * @return The Statistic viewer data created.
262 */
263 StatisticViewerData *
264 gui_statistic(Tab *tab)
265 {
266 GtkCellRenderer *renderer;
267 GtkTreeViewColumn *column;
268
269 StatisticViewerData* statistic_viewer_data = g_new(StatisticViewerData,1);
270
271 statistic_viewer_data->tab = tab;
272 // statistic_viewer_data->stats =
273 // lttvwindow_get_traceset_stats(statistic_viewer_data->tab);
274 // statistic_viewer_data->calculate_stats =
275 // statistic_insert_traceset_stats((void *)statistic_viewer_data->stats);
276
277 lttvwindow_register_traceset_notify(statistic_viewer_data->tab,
278 statistic_traceset_changed,
279 statistic_viewer_data);
280 request_background_data(statistic_viewer_data);
281
282 statistic_viewer_data->statistic_hash = g_hash_table_new_full(g_str_hash,
283 g_str_equal,
284 statistic_destroy_hash_key,
285 NULL);
286
287 statistic_viewer_data->hpaned_v = gtk_hpaned_new();
288 statistic_viewer_data->store_m = gtk_tree_store_new (N_COLUMNS, G_TYPE_STRING);
289 statistic_viewer_data->tree_v =
290 gtk_tree_view_new_with_model (
291 GTK_TREE_MODEL (statistic_viewer_data->store_m));
292 g_object_unref (G_OBJECT (statistic_viewer_data->store_m));
293
294 // Setup the selection handler
295 statistic_viewer_data->select_c = gtk_tree_view_get_selection (GTK_TREE_VIEW (statistic_viewer_data->tree_v));
296 gtk_tree_selection_set_mode (statistic_viewer_data->select_c, GTK_SELECTION_SINGLE);
297 g_signal_connect (G_OBJECT (statistic_viewer_data->select_c), "changed",
298 G_CALLBACK (tree_selection_changed_cb),
299 statistic_viewer_data);
300
301 renderer = gtk_cell_renderer_text_new ();
302 column = gtk_tree_view_column_new_with_attributes ("Statistic Name",
303 renderer,
304 "text", NAME_COLUMN,
305 NULL);
306 gtk_tree_view_column_set_alignment (column, 0.0);
307 // gtk_tree_view_column_set_fixed_width (column, 45);
308 gtk_tree_view_append_column (GTK_TREE_VIEW (statistic_viewer_data->tree_v), column);
309
310
311 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW (statistic_viewer_data->tree_v), FALSE);
312
313 statistic_viewer_data->scroll_win_tree = gtk_scrolled_window_new (NULL, NULL);
314 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(statistic_viewer_data->scroll_win_tree),
315 GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
316
317 gtk_container_add (GTK_CONTAINER (statistic_viewer_data->scroll_win_tree), statistic_viewer_data->tree_v);
318 gtk_paned_pack1(GTK_PANED(statistic_viewer_data->hpaned_v),statistic_viewer_data->scroll_win_tree, TRUE, FALSE);
319 gtk_paned_set_position(GTK_PANED(statistic_viewer_data->hpaned_v), 160);
320
321 statistic_viewer_data->scroll_win_text = gtk_scrolled_window_new (NULL, NULL);
322 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(statistic_viewer_data->scroll_win_text),
323 GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
324
325 statistic_viewer_data->text_v = gtk_text_view_new ();
326
327 gtk_text_view_set_editable(GTK_TEXT_VIEW(statistic_viewer_data->text_v),FALSE);
328 gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(statistic_viewer_data->text_v),FALSE);
329 gtk_container_add (GTK_CONTAINER (statistic_viewer_data->scroll_win_text), statistic_viewer_data->text_v);
330 gtk_paned_pack2(GTK_PANED(statistic_viewer_data->hpaned_v), statistic_viewer_data->scroll_win_text, TRUE, FALSE);
331
332 gtk_widget_show(statistic_viewer_data->scroll_win_tree);
333 gtk_widget_show(statistic_viewer_data->scroll_win_text);
334 gtk_widget_show(statistic_viewer_data->tree_v);
335 gtk_widget_show(statistic_viewer_data->text_v);
336 gtk_widget_show(statistic_viewer_data->hpaned_v);
337
338 g_object_set_data_full(
339 G_OBJECT(guistatistic_get_widget(statistic_viewer_data)),
340 "statistic_viewer_data",
341 statistic_viewer_data,
342 (GDestroyNotify)gui_statistic_destructor);
343
344 /* Add the object's information to the module's array */
345 g_statistic_viewer_data_list = g_slist_append(
346 g_statistic_viewer_data_list,
347 statistic_viewer_data);
348
349 return statistic_viewer_data;
350 }
351
352 static void
353 tree_selection_changed_cb (GtkTreeSelection *selection, gpointer data)
354 {
355 StatisticViewerData *statistic_viewer_data = (StatisticViewerData*)data;
356 GtkTreeIter iter;
357 GtkTreeModel *model = GTK_TREE_MODEL(statistic_viewer_data->store_m);
358 gchar *event;
359 GtkTextBuffer* buf;
360 gchar * str;
361 GtkTreePath * path;
362 GtkTextIter text_iter;
363 LttvAttribute * stats;
364
365 if (gtk_tree_selection_get_selected (selection, &model, &iter))
366 {
367 gtk_tree_model_get (model, &iter, NAME_COLUMN, &event, -1);
368
369 path = gtk_tree_model_get_path(GTK_TREE_MODEL(model),&iter);
370 str = gtk_tree_path_to_string (path);
371 stats = (LttvAttribute*)g_hash_table_lookup (statistic_viewer_data->statistic_hash,str);
372 g_free(str);
373
374 buf = gtk_text_view_get_buffer((GtkTextView*)statistic_viewer_data->text_v);
375 gtk_text_buffer_set_text(buf,"Statistic for '", -1);
376 gtk_text_buffer_get_end_iter(buf, &text_iter);
377 gtk_text_buffer_insert(buf, &text_iter, event, strlen(event));
378 gtk_text_buffer_get_end_iter(buf, &text_iter);
379 gtk_text_buffer_insert(buf, &text_iter, "' :\n\n",5);
380
381 show_statistic(statistic_viewer_data, stats, buf);
382
383 g_free (event);
384 }
385 }
386
387 void statistic_destroy_hash_key(gpointer key)
388 {
389 g_free(key);
390 }
391
392 #ifdef DEBUG
393 #include <stdio.h>
394 extern FILE *stdin;
395 extern FILE *stdout;
396 extern FILE *stderr;
397 #endif //DEBUG
398
399 void show_traceset_stats(StatisticViewerData * statistic_viewer_data)
400 {
401 Tab *tab = statistic_viewer_data->tab;
402 int i, nb;
403 LttvTraceset *ts;
404 LttvTraceStats *tcs;
405 LttSystemDescription *desc;
406 LttvTracesetStats * tscs = lttvwindow_get_traceset_stats(tab);
407 gchar * str, trace_str[PATH_LENGTH];
408 GtkTreePath * path;
409 GtkTreeIter iter;
410 GtkTreeStore * store = statistic_viewer_data->store_m;
411
412 if(tscs->stats == NULL) return;
413 #ifdef DEBUG
414 lttv_attribute_write_xml(tscs->stats, stdout, 1, 4);
415 #endif //DEBUG
416
417 ts = tscs->parent.parent.ts;
418 nb = lttv_traceset_number(ts);
419 if(nb == 0)return;
420
421 gtk_tree_store_append (store, &iter, NULL);
422 gtk_tree_store_set (store, &iter,
423 NAME_COLUMN, "Traceset statistics",
424 -1);
425 path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter);
426 str = gtk_tree_path_to_string (path);
427 g_hash_table_insert(statistic_viewer_data->statistic_hash,
428 (gpointer)str, tscs->stats);
429 show_tree(statistic_viewer_data, tscs->stats, &iter);
430
431 //show stats for all traces
432 for(i = 0 ; i < nb ; i++) {
433 tcs = (LttvTraceStats *)(LTTV_TRACESET_CONTEXT(tscs)->traces[i]);
434 desc = ltt_trace_system_description(tcs->parent.parent.t);
435 LttTime start_time = ltt_trace_system_description_trace_start_time(desc);
436 sprintf(trace_str, "Trace on system %s at time %lu.%09lu",
437 ltt_trace_system_description_node_name(desc),
438 start_time.tv_sec,
439 start_time.tv_nsec);
440
441 gtk_tree_store_append (store, &iter, NULL);
442 gtk_tree_store_set (store, &iter,NAME_COLUMN,trace_str,-1);
443 path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter);
444 str = gtk_tree_path_to_string (path);
445 g_hash_table_insert(statistic_viewer_data->statistic_hash,
446 (gpointer)str,tcs->stats);
447 show_tree(statistic_viewer_data, tcs->stats, &iter);
448 #ifdef DEBUG
449 lttv_attribute_write_xml(tcs->stats, stdout, 3, 4);
450 #endif //DEBUG
451 }
452 }
453
454 void show_tree(StatisticViewerData * statistic_viewer_data,
455 LttvAttribute* stats, GtkTreeIter* parent)
456 {
457 int i, nb;
458 LttvAttribute *subtree;
459 LttvAttributeName name;
460 LttvAttributeValue value;
461 LttvAttributeType type;
462 gchar * str, dir_str[PATH_LENGTH];
463 GtkTreePath * path;
464 GtkTreeIter iter;
465 GtkTreeStore * store = statistic_viewer_data->store_m;
466
467 nb = lttv_attribute_get_number(stats);
468 for(i = 0 ; i < nb ; i++) {
469 type = lttv_attribute_get(stats, i, &name, &value);
470 switch(type) {
471 case LTTV_GOBJECT:
472 if(LTTV_IS_ATTRIBUTE(*(value.v_gobject))) {
473 sprintf(dir_str, "%s", g_quark_to_string(name));
474 subtree = (LttvAttribute *)*(value.v_gobject);
475 gtk_tree_store_append (store, &iter, parent);
476 gtk_tree_store_set (store, &iter,NAME_COLUMN,dir_str,-1);
477 path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter);
478 str = gtk_tree_path_to_string (path);
479 g_hash_table_insert(statistic_viewer_data->statistic_hash,
480 (gpointer)str, subtree);
481 show_tree(statistic_viewer_data, subtree, &iter);
482 }
483 break;
484 default:
485 break;
486 }
487 }
488 }
489
490 void show_statistic(StatisticViewerData * statistic_viewer_data,
491 LttvAttribute* stats, GtkTextBuffer* buf)
492 {
493 int i, nb , flag;
494 LttvAttributeName name;
495 LttvAttributeValue value;
496 LttvAttributeType type;
497 gchar type_name[PATH_LENGTH], type_value[PATH_LENGTH];
498 GtkTextIter text_iter;
499
500 flag = 0;
501 nb = lttv_attribute_get_number(stats);
502 for(i = 0 ; i < nb ; i++) {
503 type = lttv_attribute_get(stats, i, &name, &value);
504 sprintf(type_name,"%s", g_quark_to_string(name));
505 type_value[0] = '\0';
506 switch(type) {
507 case LTTV_INT:
508 sprintf(type_value, " : %d\n", *value.v_int);
509 break;
510 case LTTV_UINT:
511 sprintf(type_value, " : %u\n", *value.v_uint);
512 break;
513 case LTTV_LONG:
514 sprintf(type_value, " : %ld\n", *value.v_long);
515 break;
516 case LTTV_ULONG:
517 sprintf(type_value, " : %lu\n", *value.v_ulong);
518 break;
519 case LTTV_FLOAT:
520 sprintf(type_value, " : %f\n", (double)*value.v_float);
521 break;
522 case LTTV_DOUBLE:
523 sprintf(type_value, " : %f\n", *value.v_double);
524 break;
525 case LTTV_TIME:
526 sprintf(type_value, " : %10lu.%09lu\n", value.v_time->tv_sec,
527 value.v_time->tv_nsec);
528 break;
529 case LTTV_POINTER:
530 sprintf(type_value, " : POINTER\n");
531 break;
532 case LTTV_STRING:
533 sprintf(type_value, " : %s\n", *value.v_string);
534 break;
535 default:
536 break;
537 }
538 if(strlen(type_value)){
539 flag = 1;
540 strcat(type_name,type_value);
541 gtk_text_buffer_get_end_iter(buf, &text_iter);
542 gtk_text_buffer_insert(buf, &text_iter, type_name, strlen(type_name));
543 }
544 }
545
546 if(flag == 0){
547 sprintf(type_value, "No statistic information in this directory.\nCheck in subdirectories please.\n");
548 gtk_text_buffer_get_end_iter(buf, &text_iter);
549 gtk_text_buffer_insert(buf, &text_iter, type_value, strlen(type_value));
550
551 }
552 }
553
554 gboolean statistic_traceset_changed(void * hook_data, void * call_data)
555 {
556 StatisticViewerData *statistic_viewer_data = (StatisticViewerData*) hook_data;
557
558 request_background_data(statistic_viewer_data);
559
560 return FALSE;
561 }
562
563 #if 0
564 void statistic_add_context_hooks(StatisticViewerData * statistic_viewer_data,
565 LttvTracesetContext * tsc)
566 {
567 gint i, j, nbi, nb_tracefile;
568 LttTrace *trace;
569 LttvTraceContext *tc;
570 LttvTracefileContext *tfc;
571 LttvTracesetSelector * ts_s;
572 LttvTraceSelector * t_s;
573 LttvTracefileSelector * tf_s;
574 gboolean selected;
575
576 ts_s = (LttvTracesetSelector*)g_object_get_data(G_OBJECT(statistic_viewer_data->hpaned_v),
577 statistic_viewer_data->filter_key);
578
579 //if there are hooks for traceset, add them here
580
581 nbi = lttv_traceset_number(tsc->ts);
582 for(i = 0 ; i < nbi ; i++) {
583 t_s = lttv_traceset_selector_trace_get(ts_s,i);
584 selected = lttv_trace_selector_get_selected(t_s);
585 if(!selected) continue;
586 tc = tsc->traces[i];
587 trace = tc->t;
588 //if there are hooks for trace, add them here
589
590 nb_tracefile = ltt_trace_control_tracefile_number(trace) +
591 ltt_trace_per_cpu_tracefile_number(trace);
592
593 for(j = 0 ; j < nb_tracefile ; j++) {
594 tf_s = lttv_trace_selector_tracefile_get(t_s,j);
595 selected = lttv_tracefile_selector_get_selected(tf_s);
596 if(!selected) continue;
597 tfc = tc->tracefiles[j];
598
599 //if there are hooks for tracefile, add them here
600 // lttv_tracefile_context_add_hooks(tfc, NULL,NULL,NULL,NULL,
601 // statistic_viewer_data->before_event_hooks,NULL);
602 }
603 }
604
605 lttv_stats_add_event_hooks(LTTV_TRACESET_STATS(tsc));
606
607 }
608
609 void statistic_remove_context_hooks(StatisticViewerData * statistic_viewer_data,
610 LttvTracesetContext * tsc)
611 {
612 gint i, j, nbi, nb_tracefile;
613 LttTrace *trace;
614 LttvTraceContext *tc;
615 LttvTracefileContext *tfc;
616 LttvTracesetSelector * ts_s;
617 LttvTraceSelector * t_s;
618 LttvTracefileSelector * tf_s;
619 gboolean selected;
620
621 ts_s = (LttvTracesetSelector*)g_object_get_data(G_OBJECT(statistic_viewer_data->hpaned_v),
622 statistic_viewer_data->filter_key);
623
624 //if there are hooks for traceset, remove them here
625
626 nbi = lttv_traceset_number(tsc->ts);
627 for(i = 0 ; i < nbi ; i++) {
628 t_s = lttv_traceset_selector_trace_get(ts_s,i);
629 selected = lttv_trace_selector_get_selected(t_s);
630 if(!selected) continue;
631 tc = tsc->traces[i];
632 trace = tc->t;
633 //if there are hooks for trace, remove them here
634
635 nb_tracefile = ltt_trace_control_tracefile_number(trace) +
636 ltt_trace_per_cpu_tracefile_number(trace);
637
638 for(j = 0 ; j < nb_tracefile ; j++) {
639 tf_s = lttv_trace_selector_tracefile_get(t_s,j);
640 selected = lttv_tracefile_selector_get_selected(tf_s);
641 if(!selected) continue;
642 tfc = tc->tracefiles[j];
643
644 //if there are hooks for tracefile, remove them here
645 // lttv_tracefile_context_remove_hooks(tfc, NULL,NULL,NULL,NULL,
646 // statistic_viewer_data->before_event_hooks,NULL);
647 }
648 }
649
650 lttv_stats_remove_event_hooks(LTTV_TRACESET_STATS(tsc));
651 }
652 #endif //0
653
654 /**
655 * plugin's init function
656 *
657 * This function initializes the Statistic Viewer functionnality through the
658 * gtkTraceSet API.
659 */
660 static void init() {
661
662 lttvwindow_register_constructor("guistatistics",
663 "/",
664 "Insert Statistic Viewer",
665 hGuiStatisticInsert_xpm,
666 "Insert Statistic Viewer",
667 h_gui_statistic);
668 }
669
670 void statistic_destroy_walk(gpointer data, gpointer user_data)
671 {
672 StatisticViewerData *svd = (StatisticViewerData*)data;
673
674 g_debug("CFV.c : statistic_destroy_walk, %p", svd);
675 /* May already have been done by GTK window closing */
676 if(GTK_IS_WIDGET(guistatistic_get_widget(svd)))
677 gtk_widget_destroy(guistatistic_get_widget(svd));
678 }
679
680 /**
681 * plugin's destroy function
682 *
683 * This function releases the memory reserved by the module and unregisters
684 * everything that has been registered in the gtkTraceSet API.
685 */
686 static void destroy() {
687
688 g_slist_foreach(g_statistic_viewer_data_list, statistic_destroy_walk, NULL );
689 g_slist_free(g_statistic_viewer_data_list);
690
691 lttvwindow_unregister_constructor(h_gui_statistic);
692
693 }
694
695
696 LTTV_MODULE("guistatistics", "Statistics viewer", \
697 "Graphical module to view statistics about processes, CPUs and systems", \
698 init, destroy, "lttvwindow")
699
This page took 0.056847 seconds and 4 git commands to generate.