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