| 1 | /* This file is part of the Linux Trace Toolkit viewer |
| 2 | * Copyright (C) 2006 Parisa heidari (inspired from CFV by Mathieu Desnoyers) |
| 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 | |
| 20 | #ifdef HAVE_CONFIG_H |
| 21 | #include <config.h> |
| 22 | #endif |
| 23 | |
| 24 | #include <glib.h> |
| 25 | #include <lttv/lttv.h> |
| 26 | #include <lttv/module.h> |
| 27 | #include <lttvwindow/lttvwindow.h> |
| 28 | |
| 29 | #include "histocfv.h" |
| 30 | #include "histoeventhooks.h" |
| 31 | |
| 32 | #include "hHistogramInsert.xpm" |
| 33 | |
| 34 | |
| 35 | GQuark LTT_NAME_CPU; |
| 36 | |
| 37 | /** Array containing instanced objects. Used when module is unloaded */ |
| 38 | GSList *g_histo_control_flow_data_list = NULL ; |
| 39 | |
| 40 | /***************************************************************************** |
| 41 | * Functions for module loading/unloading * |
| 42 | *****************************************************************************/ |
| 43 | /** |
| 44 | * plugin's init function |
| 45 | * |
| 46 | * This function initializes the Histogram Control Flow Viewer functionnality through the |
| 47 | * gtkTraceSet API. |
| 48 | */ |
| 49 | static void histo_init() { |
| 50 | |
| 51 | g_info("GUI ControlFlow Viewer init()"); |
| 52 | |
| 53 | /* Register the toolbar insert button and menu entry*/ |
| 54 | lttvwindow_register_constructor("histogram", |
| 55 | "/", |
| 56 | "Insert Histogram Viewer", |
| 57 | hHistogramInsert_xpm, |
| 58 | "Insert Histogram Viewer", |
| 59 | h_guihistocontrolflow); |
| 60 | |
| 61 | LTT_NAME_CPU = g_quark_from_string("/cpu"); |
| 62 | } |
| 63 | |
| 64 | void histo_destroy_walk(gpointer data, gpointer user_data) |
| 65 | { |
| 66 | g_info("Walk destroy GUI Histogram Control Flow Viewer"); |
| 67 | guihistocontrolflow_destructor_full((HistoControlFlowData*)data); |
| 68 | } |
| 69 | |
| 70 | |
| 71 | |
| 72 | /** |
| 73 | * plugin's destroy function |
| 74 | * |
| 75 | * This function releases the memory reserved by the module and unregisters |
| 76 | * everything that has been registered in the gtkTraceSet API. |
| 77 | */ |
| 78 | static void histo_destroy() { |
| 79 | g_info("GUI Histogram Control Flow Viewer destroy()"); |
| 80 | |
| 81 | g_slist_foreach(g_histo_control_flow_data_list, histo_destroy_walk, NULL ); |
| 82 | |
| 83 | g_slist_free(g_histo_control_flow_data_list); |
| 84 | |
| 85 | /* Unregister the toolbar insert button and menu entry */ |
| 86 | lttvwindow_unregister_constructor(h_guihistocontrolflow); |
| 87 | |
| 88 | } |
| 89 | |
| 90 | |
| 91 | LTTV_MODULE("guihistogram", "Event Histogram viewer", \ |
| 92 | "Graphical module to view events' density histogram", \ |
| 93 | histo_init, histo_destroy, "lttvwindow") |