fix libltt error messages
[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 if(!lttvwindowtraces_background_request_find(trace, "stats"))
172 lttvwindowtraces_background_request_queue(trace, "stats");
173 lttvwindowtraces_background_notify_queue(svd,
174 trace,
175 ltt_time_infinite,
176 NULL,
177 background_ready_hook);
178 } else { /* in progress */
179
180 lttvwindowtraces_background_notify_current(svd,
181 trace,
182 ltt_time_infinite,
183 NULL,
184 background_ready_hook);
185
186 }
187 } else {
188 /* ready */
189 lttv_hooks_call(background_ready_hook, NULL);
190 }
191 }
192 lttv_hooks_destroy(background_ready_hook);
193 }
194
195
196 GtkWidget *guistatistic_get_widget(StatisticViewerData *svd)
197 {
198 return svd->hpaned_v;
199 }
200
201
202 void
203 gui_statistic_destructor(StatisticViewerData *statistic_viewer_data)
204 {
205 Tab *tab = statistic_viewer_data->tab;
206
207 /* May already been done by GTK window closing */
208 if(GTK_IS_WIDGET(guistatistic_get_widget(statistic_viewer_data))){
209 g_info("widget still exists");
210 }
211 if(tab != NULL) {
212 lttvwindow_unregister_traceset_notify(statistic_viewer_data->tab,
213 statistic_traceset_changed,
214 statistic_viewer_data);
215 }
216 lttvwindowtraces_background_notify_remove(statistic_viewer_data);
217
218 g_hash_table_destroy(statistic_viewer_data->statistic_hash);
219 g_statistic_viewer_data_list =
220 g_slist_remove(g_statistic_viewer_data_list, statistic_viewer_data);
221 g_free(statistic_viewer_data);
222 }
223
224
225 /**
226 * Statistic Viewer's constructor hook
227 *
228 * This constructor is given as a parameter to the menuitem and toolbar button
229 * registration. It creates the list.
230 * @param parent_window A pointer to the parent window.
231 * @return The widget created.
232 */
233 GtkWidget *
234 h_gui_statistic(Tab *tab)
235 {
236 StatisticViewerData* statistic_viewer_data = gui_statistic(tab) ;
237
238 if(statistic_viewer_data)
239 return guistatistic_get_widget(statistic_viewer_data);
240 else return NULL;
241
242 }
243
244 #if 0
245 gboolean statistic_insert_traceset_stats(void * stats)
246 {
247 int i, len;
248 gpointer s;
249
250 len = statistic_traceset->len;
251 for(i=0;i<len;i++){
252 s = g_ptr_array_index(statistic_traceset, i);
253 if(s == stats) break;
254 }
255 if(i==len){
256 g_ptr_array_add(statistic_traceset, stats);
257 return TRUE;
258 }
259 return FALSE;
260 }
261 #endif //0
262
263 /**
264 * Statistic Viewer's constructor
265 *
266 * This constructor is used to create StatisticViewerData data structure.
267 * @return The Statistic viewer data created.
268 */
269 StatisticViewerData *
270 gui_statistic(Tab *tab)
271 {
272 GtkCellRenderer *renderer;
273 GtkTreeViewColumn *column;
274
275 StatisticViewerData* statistic_viewer_data = g_new(StatisticViewerData,1);
276
277 statistic_viewer_data->tab = tab;
278 // statistic_viewer_data->stats =
279 // lttvwindow_get_traceset_stats(statistic_viewer_data->tab);
280 // statistic_viewer_data->calculate_stats =
281 // statistic_insert_traceset_stats((void *)statistic_viewer_data->stats);
282
283 lttvwindow_register_traceset_notify(statistic_viewer_data->tab,
284 statistic_traceset_changed,
285 statistic_viewer_data);
286 request_background_data(statistic_viewer_data);
287
288 statistic_viewer_data->statistic_hash = g_hash_table_new_full(g_str_hash,
289 g_str_equal,
290 statistic_destroy_hash_key,
291 NULL);
292
293 statistic_viewer_data->hpaned_v = gtk_hpaned_new();
294 statistic_viewer_data->store_m = gtk_tree_store_new (N_COLUMNS, G_TYPE_STRING);
295 statistic_viewer_data->tree_v =
296 gtk_tree_view_new_with_model (
297 GTK_TREE_MODEL (statistic_viewer_data->store_m));
298 g_object_unref (G_OBJECT (statistic_viewer_data->store_m));
299
300 // Setup the selection handler
301 statistic_viewer_data->select_c = gtk_tree_view_get_selection (GTK_TREE_VIEW (statistic_viewer_data->tree_v));
302 gtk_tree_selection_set_mode (statistic_viewer_data->select_c, GTK_SELECTION_SINGLE);
303 g_signal_connect (G_OBJECT (statistic_viewer_data->select_c), "changed",
304 G_CALLBACK (tree_selection_changed_cb),
305 statistic_viewer_data);
306
307 renderer = gtk_cell_renderer_text_new ();
308 column = gtk_tree_view_column_new_with_attributes ("Statistic Name",
309 renderer,
310 "text", NAME_COLUMN,
311 NULL);
312 gtk_tree_view_column_set_alignment (column, 0.0);
313 // gtk_tree_view_column_set_fixed_width (column, 45);
314 gtk_tree_view_append_column (GTK_TREE_VIEW (statistic_viewer_data->tree_v), column);
315
316
317 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW (statistic_viewer_data->tree_v), FALSE);
318
319 statistic_viewer_data->scroll_win_tree = gtk_scrolled_window_new (NULL, NULL);
320 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(statistic_viewer_data->scroll_win_tree),
321 GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
322
323 gtk_container_add (GTK_CONTAINER (statistic_viewer_data->scroll_win_tree), statistic_viewer_data->tree_v);
324 gtk_paned_pack1(GTK_PANED(statistic_viewer_data->hpaned_v),statistic_viewer_data->scroll_win_tree, TRUE, FALSE);
325 gtk_paned_set_position(GTK_PANED(statistic_viewer_data->hpaned_v), 160);
326
327 statistic_viewer_data->scroll_win_text = gtk_scrolled_window_new (NULL, NULL);
328 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(statistic_viewer_data->scroll_win_text),
329 GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
330
331 statistic_viewer_data->text_v = gtk_text_view_new ();
332
333 gtk_text_view_set_editable(GTK_TEXT_VIEW(statistic_viewer_data->text_v),FALSE);
334 gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(statistic_viewer_data->text_v),FALSE);
335 gtk_container_add (GTK_CONTAINER (statistic_viewer_data->scroll_win_text), statistic_viewer_data->text_v);
336 gtk_paned_pack2(GTK_PANED(statistic_viewer_data->hpaned_v), statistic_viewer_data->scroll_win_text, TRUE, FALSE);
337
338 gtk_container_set_border_width(
339 GTK_CONTAINER(statistic_viewer_data->hpaned_v), 1);
340
341 gtk_widget_show(statistic_viewer_data->scroll_win_tree);
342 gtk_widget_show(statistic_viewer_data->scroll_win_text);
343 gtk_widget_show(statistic_viewer_data->tree_v);
344 gtk_widget_show(statistic_viewer_data->text_v);
345 gtk_widget_show(statistic_viewer_data->hpaned_v);
346
347 g_object_set_data_full(
348 G_OBJECT(guistatistic_get_widget(statistic_viewer_data)),
349 "statistic_viewer_data",
350 statistic_viewer_data,
351 (GDestroyNotify)gui_statistic_destructor);
352
353 /* Add the object's information to the module's array */
354 g_statistic_viewer_data_list = g_slist_append(
355 g_statistic_viewer_data_list,
356 statistic_viewer_data);
357
358 return statistic_viewer_data;
359 }
360
361 static void
362 tree_selection_changed_cb (GtkTreeSelection *selection, gpointer data)
363 {
364 StatisticViewerData *statistic_viewer_data = (StatisticViewerData*)data;
365 GtkTreeIter iter;
366 GtkTreeModel *model = GTK_TREE_MODEL(statistic_viewer_data->store_m);
367 gchar *event;
368 GtkTextBuffer* buf;
369 gchar * str;
370 GtkTreePath * path;
371 GtkTextIter text_iter;
372 LttvAttribute * stats;
373
374 if (gtk_tree_selection_get_selected (selection, &model, &iter))
375 {
376 gtk_tree_model_get (model, &iter, NAME_COLUMN, &event, -1);
377
378 path = gtk_tree_model_get_path(GTK_TREE_MODEL(model),&iter);
379 str = gtk_tree_path_to_string (path);
380 stats = (LttvAttribute*)g_hash_table_lookup (statistic_viewer_data->statistic_hash,str);
381 g_free(str);
382
383 buf = gtk_text_view_get_buffer((GtkTextView*)statistic_viewer_data->text_v);
384 gtk_text_buffer_set_text(buf,"Statistic for '", -1);
385 gtk_text_buffer_get_end_iter(buf, &text_iter);
386 gtk_text_buffer_insert(buf, &text_iter, event, strlen(event));
387 gtk_text_buffer_get_end_iter(buf, &text_iter);
388 gtk_text_buffer_insert(buf, &text_iter, "' :\n\n",5);
389
390 show_statistic(statistic_viewer_data, stats, buf);
391
392 g_free (event);
393 }
394 }
395
396 void statistic_destroy_hash_key(gpointer key)
397 {
398 g_free(key);
399 }
400
401 #ifdef DEBUG
402 #include <stdio.h>
403 extern FILE *stdin;
404 extern FILE *stdout;
405 extern FILE *stderr;
406 #endif //DEBUG
407
408 void show_traceset_stats(StatisticViewerData * statistic_viewer_data)
409 {
410 Tab *tab = statistic_viewer_data->tab;
411 int i, nb;
412 LttvTraceset *ts;
413 LttvTraceStats *tcs;
414 LttSystemDescription *desc;
415 LttvTracesetStats * tscs = lttvwindow_get_traceset_stats(tab);
416 gchar * str, trace_str[PATH_LENGTH];
417 GtkTreePath * path;
418 GtkTreeIter iter;
419 GtkTreeStore * store = statistic_viewer_data->store_m;
420
421 if(tscs->stats == NULL) return;
422 #ifdef DEBUG
423 lttv_attribute_write_xml(tscs->stats, stdout, 1, 4);
424 #endif //DEBUG
425
426 ts = tscs->parent.parent.ts;
427 nb = lttv_traceset_number(ts);
428 if(nb == 0)return;
429
430 gtk_tree_store_append (store, &iter, NULL);
431 gtk_tree_store_set (store, &iter,
432 NAME_COLUMN, "Traceset statistics",
433 -1);
434 path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter);
435 str = gtk_tree_path_to_string (path);
436 g_hash_table_insert(statistic_viewer_data->statistic_hash,
437 (gpointer)str, tscs->stats);
438 show_tree(statistic_viewer_data, tscs->stats, &iter);
439
440 //show stats for all traces
441 for(i = 0 ; i < nb ; i++) {
442 tcs = (LttvTraceStats *)(LTTV_TRACESET_CONTEXT(tscs)->traces[i]);
443 #if 0 //FIXME
444 desc = ltt_trace_system_description(tcs->parent.parent.t);
445 LttTime start_time = ltt_trace_system_description_trace_start_time(desc);
446 sprintf(trace_str, "Trace on system %s at time %lu.%09lu",
447 ltt_trace_system_description_node_name(desc),
448 start_time.tv_sec,
449 start_time.tv_nsec);
450 #endif //0
451 sprintf(trace_str, g_quark_to_string(ltt_trace_name(tcs->parent.parent.t)));
452 gtk_tree_store_append (store, &iter, NULL);
453 gtk_tree_store_set (store, &iter,NAME_COLUMN,trace_str,-1);
454 path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter);
455 str = gtk_tree_path_to_string (path);
456 g_hash_table_insert(statistic_viewer_data->statistic_hash,
457 (gpointer)str,tcs->stats);
458 show_tree(statistic_viewer_data, tcs->stats, &iter);
459 #ifdef DEBUG
460 lttv_attribute_write_xml(tcs->stats, stdout, 3, 4);
461 #endif //DEBUG
462 }
463 }
464
465 void show_tree(StatisticViewerData * statistic_viewer_data,
466 LttvAttribute* stats, GtkTreeIter* parent)
467 {
468 int i, nb;
469 LttvAttribute *subtree;
470 LttvAttributeName name;
471 LttvAttributeValue value;
472 LttvAttributeType type;
473 gchar * str, dir_str[PATH_LENGTH];
474 GtkTreePath * path;
475 GtkTreeIter iter;
476 GtkTreeStore * store = statistic_viewer_data->store_m;
477
478 nb = lttv_attribute_get_number(stats);
479 for(i = 0 ; i < nb ; i++) {
480 type = lttv_attribute_get(stats, i, &name, &value);
481 switch(type) {
482 case LTTV_GOBJECT:
483 if(LTTV_IS_ATTRIBUTE(*(value.v_gobject))) {
484 sprintf(dir_str, "%s", g_quark_to_string(name));
485 subtree = (LttvAttribute *)*(value.v_gobject);
486 gtk_tree_store_append (store, &iter, parent);
487 gtk_tree_store_set (store, &iter,NAME_COLUMN,dir_str,-1);
488 path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter);
489 str = gtk_tree_path_to_string (path);
490 g_hash_table_insert(statistic_viewer_data->statistic_hash,
491 (gpointer)str, subtree);
492 show_tree(statistic_viewer_data, subtree, &iter);
493 }
494 break;
495 default:
496 break;
497 }
498 }
499 }
500
501 void show_statistic(StatisticViewerData * statistic_viewer_data,
502 LttvAttribute* stats, GtkTextBuffer* buf)
503 {
504 int i, nb , flag;
505 LttvAttributeName name;
506 LttvAttributeValue value;
507 LttvAttributeType type;
508 gchar type_name[PATH_LENGTH], type_value[PATH_LENGTH];
509 GtkTextIter text_iter;
510
511 flag = 0;
512 nb = lttv_attribute_get_number(stats);
513 for(i = 0 ; i < nb ; i++) {
514 type = lttv_attribute_get(stats, i, &name, &value);
515 sprintf(type_name,"%s", g_quark_to_string(name));
516 type_value[0] = '\0';
517 switch(type) {
518 case LTTV_INT:
519 sprintf(type_value, " : %d\n", *value.v_int);
520 break;
521 case LTTV_UINT:
522 sprintf(type_value, " : %u\n", *value.v_uint);
523 break;
524 case LTTV_LONG:
525 sprintf(type_value, " : %ld\n", *value.v_long);
526 break;
527 case LTTV_ULONG:
528 sprintf(type_value, " : %lu\n", *value.v_ulong);
529 break;
530 case LTTV_FLOAT:
531 sprintf(type_value, " : %f\n", (double)*value.v_float);
532 break;
533 case LTTV_DOUBLE:
534 sprintf(type_value, " : %f\n", *value.v_double);
535 break;
536 case LTTV_TIME:
537 sprintf(type_value, " : %10lu.%09lu\n", value.v_time->tv_sec,
538 value.v_time->tv_nsec);
539 break;
540 case LTTV_POINTER:
541 sprintf(type_value, " : POINTER\n");
542 break;
543 case LTTV_STRING:
544 sprintf(type_value, " : %s\n", *value.v_string);
545 break;
546 default:
547 break;
548 }
549 if(strlen(type_value)){
550 flag = 1;
551 strcat(type_name,type_value);
552 gtk_text_buffer_get_end_iter(buf, &text_iter);
553 gtk_text_buffer_insert(buf, &text_iter, type_name, strlen(type_name));
554 }
555 }
556
557 if(flag == 0){
558 sprintf(type_value, "No statistic information in this directory.\nCheck in subdirectories please.\n");
559 gtk_text_buffer_get_end_iter(buf, &text_iter);
560 gtk_text_buffer_insert(buf, &text_iter, type_value, strlen(type_value));
561
562 }
563 }
564
565 gboolean statistic_traceset_changed(void * hook_data, void * call_data)
566 {
567 StatisticViewerData *statistic_viewer_data = (StatisticViewerData*) hook_data;
568
569 request_background_data(statistic_viewer_data);
570
571 return FALSE;
572 }
573
574 #if 0
575 void statistic_add_context_hooks(StatisticViewerData * statistic_viewer_data,
576 LttvTracesetContext * tsc)
577 {
578 gint i, j, nbi, nb_tracefile;
579 LttTrace *trace;
580 LttvTraceContext *tc;
581 LttvTracefileContext *tfc;
582 LttvTracesetSelector * ts_s;
583 LttvTraceSelector * t_s;
584 LttvTracefileSelector * tf_s;
585 gboolean selected;
586
587 ts_s = (LttvTracesetSelector*)g_object_get_data(G_OBJECT(statistic_viewer_data->hpaned_v),
588 statistic_viewer_data->filter_key);
589
590 //if there are hooks for traceset, add them here
591
592 nbi = lttv_traceset_number(tsc->ts);
593 for(i = 0 ; i < nbi ; i++) {
594 t_s = lttv_traceset_selector_trace_get(ts_s,i);
595 selected = lttv_trace_selector_get_selected(t_s);
596 if(!selected) continue;
597 tc = tsc->traces[i];
598 trace = tc->t;
599 //if there are hooks for trace, add them here
600
601 nb_tracefile = ltt_trace_control_tracefile_number(trace) +
602 ltt_trace_per_cpu_tracefile_number(trace);
603
604 for(j = 0 ; j < nb_tracefile ; j++) {
605 tf_s = lttv_trace_selector_tracefile_get(t_s,j);
606 selected = lttv_tracefile_selector_get_selected(tf_s);
607 if(!selected) continue;
608 tfc = tc->tracefiles[j];
609
610 //if there are hooks for tracefile, add them here
611 // lttv_tracefile_context_add_hooks(tfc, NULL,NULL,NULL,NULL,
612 // statistic_viewer_data->before_event_hooks,NULL);
613 }
614 }
615
616 lttv_stats_add_event_hooks(LTTV_TRACESET_STATS(tsc));
617
618 }
619
620 void statistic_remove_context_hooks(StatisticViewerData * statistic_viewer_data,
621 LttvTracesetContext * tsc)
622 {
623 gint i, j, nbi, nb_tracefile;
624 LttTrace *trace;
625 LttvTraceContext *tc;
626 LttvTracefileContext *tfc;
627 LttvTracesetSelector * ts_s;
628 LttvTraceSelector * t_s;
629 LttvTracefileSelector * tf_s;
630 gboolean selected;
631
632 ts_s = (LttvTracesetSelector*)g_object_get_data(G_OBJECT(statistic_viewer_data->hpaned_v),
633 statistic_viewer_data->filter_key);
634
635 //if there are hooks for traceset, remove them here
636
637 nbi = lttv_traceset_number(tsc->ts);
638 for(i = 0 ; i < nbi ; i++) {
639 t_s = lttv_traceset_selector_trace_get(ts_s,i);
640 selected = lttv_trace_selector_get_selected(t_s);
641 if(!selected) continue;
642 tc = tsc->traces[i];
643 trace = tc->t;
644 //if there are hooks for trace, remove them here
645
646 nb_tracefile = ltt_trace_control_tracefile_number(trace) +
647 ltt_trace_per_cpu_tracefile_number(trace);
648
649 for(j = 0 ; j < nb_tracefile ; j++) {
650 tf_s = lttv_trace_selector_tracefile_get(t_s,j);
651 selected = lttv_tracefile_selector_get_selected(tf_s);
652 if(!selected) continue;
653 tfc = tc->tracefiles[j];
654
655 //if there are hooks for tracefile, remove them here
656 // lttv_tracefile_context_remove_hooks(tfc, NULL,NULL,NULL,NULL,
657 // statistic_viewer_data->before_event_hooks,NULL);
658 }
659 }
660
661 lttv_stats_remove_event_hooks(LTTV_TRACESET_STATS(tsc));
662 }
663 #endif //0
664
665 /**
666 * plugin's init function
667 *
668 * This function initializes the Statistic Viewer functionnality through the
669 * gtkTraceSet API.
670 */
671 static void init() {
672
673 lttvwindow_register_constructor("guistatistics",
674 "/",
675 "Insert Statistic Viewer",
676 hGuiStatisticInsert_xpm,
677 "Insert Statistic Viewer",
678 h_gui_statistic);
679 }
680
681 void statistic_destroy_walk(gpointer data, gpointer user_data)
682 {
683 StatisticViewerData *svd = (StatisticViewerData*)data;
684
685 g_debug("CFV.c : statistic_destroy_walk, %p", svd);
686 /* May already have been done by GTK window closing */
687 if(GTK_IS_WIDGET(guistatistic_get_widget(svd)))
688 gtk_widget_destroy(guistatistic_get_widget(svd));
689 }
690
691 /**
692 * plugin's destroy function
693 *
694 * This function releases the memory reserved by the module and unregisters
695 * everything that has been registered in the gtkTraceSet API.
696 */
697 static void destroy() {
698
699 g_slist_foreach(g_statistic_viewer_data_list, statistic_destroy_walk, NULL );
700 g_slist_free(g_statistic_viewer_data_list);
701
702 lttvwindow_unregister_constructor(h_gui_statistic);
703
704 }
705
706
707 LTTV_MODULE("guistatistics", "Statistics viewer", \
708 "Graphical module to view statistics about processes, CPUs and systems", \
709 init, destroy, "lttvwindow")
710
This page took 0.044764 seconds and 5 git commands to generate.