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