X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Flttv%2Fmodules%2Fgui%2Flttvwindow%2Flttvwindow%2Finit_module.c;h=21a30eedaaa354dbef12304f8772a6255fc39638;hb=45653836d75635b5b841d0d03f1f0789348adc56;hp=a6d63cb348aeaec6ef9570ee54327c30a4336932;hpb=754351700b3d5fb6112e72dd4722a546abc219f1;p=lttv.git diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/init_module.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/init_module.c index a6d63cb3..21a30eed 100644 --- a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/init_module.c +++ b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/init_module.c @@ -26,6 +26,7 @@ #endif #include +#include #include #include @@ -37,14 +38,43 @@ #include #include #include +#include #include "interface.h" #include "support.h" #include +#include #include "callbacks.h" #include +LttvTraceInfo LTTV_TRACES, + LTTV_COMPUTATION, + LTTV_VIEWER_CONSTRUCTORS, + LTTV_REQUESTS_QUEUE, + LTTV_REQUESTS_CURRENT, + LTTV_NOTIFY_QUEUE, + LTTV_NOTIFY_CURRENT, + LTTV_COMPUTATION_TRACESET, + LTTV_COMPUTATION_TRACESET_CONTEXT, + LTTV_COMPUTATION_SYNC_POSITION, + LTTV_BEFORE_CHUNK_TRACESET, + LTTV_BEFORE_CHUNK_TRACE, + LTTV_BEFORE_CHUNK_TRACEFILE, + LTTV_AFTER_CHUNK_TRACESET, + LTTV_AFTER_CHUNK_TRACE, + LTTV_AFTER_CHUNK_TRACEFILE, + LTTV_BEFORE_REQUEST, + LTTV_AFTER_REQUEST, + LTTV_EVENT_HOOK, + LTTV_EVENT_HOOK_BY_ID, + LTTV_HOOK_ADDER, + LTTV_HOOK_REMOVER, + LTTV_IN_PROGRESS, + LTTV_READY, + LTTV_LOCK; + + /** Array containing instanced objects. */ GSList * g_main_window_list = NULL ; @@ -56,13 +86,23 @@ LttvTrace *g_init_trace = NULL; static char *a_trace; + void lttv_trace_option(void *hook_data) { LttTrace *trace; - - trace = ltt_trace_open(a_trace); - if(trace == NULL) g_critical("cannot open trace %s", a_trace); - g_init_trace = lttv_trace_new(trace); + gchar abs_path[PATH_MAX]; + + get_absolute_pathname(a_trace, abs_path); + g_init_trace = lttvwindowtraces_get_trace_by_name(abs_path); + if(g_init_trace == NULL) { + trace = ltt_trace_open(abs_path); + if(trace == NULL) { + g_warning("cannot open trace %s", abs_path); + } else { + g_init_trace = lttv_trace_new(trace); + lttvwindowtraces_add_trace(g_init_trace); + } + } } /***************************************************************************** @@ -104,8 +144,36 @@ static void init() { // Global attributes only used for interaction with main() here. LttvIAttribute *attributes = LTTV_IATTRIBUTE(lttv_global_attributes()); + LTTV_TRACES = g_quark_from_string("traces"); + LTTV_COMPUTATION = g_quark_from_string("computation"); + LTTV_VIEWER_CONSTRUCTORS = g_quark_from_string("viewer_constructors"); + LTTV_REQUESTS_QUEUE = g_quark_from_string("requests_queue"); + LTTV_REQUESTS_CURRENT = g_quark_from_string("requests_current"); + LTTV_NOTIFY_QUEUE = g_quark_from_string("notify_queue"); + LTTV_NOTIFY_CURRENT = g_quark_from_string("notify_current"); + LTTV_COMPUTATION_TRACESET = g_quark_from_string("computation_traceset"); + LTTV_COMPUTATION_TRACESET_CONTEXT = + g_quark_from_string("computation_traceset_context"); + LTTV_COMPUTATION_SYNC_POSITION = + g_quark_from_string("computation_sync_position"); + LTTV_BEFORE_CHUNK_TRACESET = g_quark_from_string("before_chunk_traceset"); + LTTV_BEFORE_CHUNK_TRACE = g_quark_from_string("before_chunk_trace"); + LTTV_BEFORE_CHUNK_TRACEFILE = g_quark_from_string("before_chunk_tracefile"); + LTTV_AFTER_CHUNK_TRACESET = g_quark_from_string("after_chunk_traceset"); + LTTV_AFTER_CHUNK_TRACE = g_quark_from_string("after_chunk_trace"); + LTTV_AFTER_CHUNK_TRACEFILE = g_quark_from_string("after_chunk_tracefile"); + LTTV_BEFORE_REQUEST = g_quark_from_string("before_request"); + LTTV_AFTER_REQUEST = g_quark_from_string("after_request"); + LTTV_EVENT_HOOK = g_quark_from_string("event_hook"); + LTTV_EVENT_HOOK_BY_ID = g_quark_from_string("event_hook_by_id"); + LTTV_HOOK_ADDER = g_quark_from_string("hook_adder"); + LTTV_HOOK_REMOVER = g_quark_from_string("hook_remover"); + LTTV_IN_PROGRESS = g_quark_from_string("in_progress"); + LTTV_READY = g_quark_from_string("ready"); + LTTV_LOCK = g_quark_from_string("lock"); + g_debug("GUI init()"); - + lttv_option_add("trace", 't', "add a trace to the trace set to analyse", "pathname of the directory containing the trace", @@ -115,51 +183,61 @@ static void init() { LTTV_POINTER, &value)); g_assert((main_hooks = *(value.v_pointer)) != NULL); - lttv_hooks_add(main_hooks, window_creation_hook, NULL); - -} + lttv_hooks_add(main_hooks, window_creation_hook, NULL, LTTV_PRIO_DEFAULT); + + { + /* Register state calculator */ + LttvHooks *hook_adder = lttv_hooks_new(); + lttv_hooks_add(hook_adder, lttv_state_save_hook_add_event_hooks, NULL, + LTTV_PRIO_DEFAULT); + lttv_hooks_add(hook_adder, lttv_state_hook_add_event_hooks, NULL, + LTTV_PRIO_DEFAULT); + LttvHooks *hook_remover = lttv_hooks_new(); + lttv_hooks_add(hook_remover, lttv_state_save_hook_remove_event_hooks, + NULL, LTTV_PRIO_DEFAULT); + lttv_hooks_add(hook_remover, lttv_state_hook_remove_event_hooks, + NULL, LTTV_PRIO_DEFAULT); + /* Add state computation background hook adder to attributes */ + lttvwindowtraces_register_computation_hooks(g_quark_from_string("state"), + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + hook_adder, hook_remover); + } -void -main_window_free(MainWindow * mw) -{ - if(mw){ - while(mw->tab){ - lttv_state_remove_event_hooks( - (LttvTracesetState*)mw->tab->traceset_info->traceset_context); - mw->tab = mw->tab->next; - } - g_object_unref(mw->attributes); - g_main_window_list = g_slist_remove(g_main_window_list, mw); - - g_hash_table_destroy(mw->hash_menu_item); - g_hash_table_destroy(mw->hash_toolbar_item); - - g_free(mw); - mw = NULL; + { + /* Register statistics calculator */ + LttvHooks *hook_adder = lttv_hooks_new(); + lttv_hooks_add(hook_adder, lttv_stats_hook_add_event_hooks, NULL, + LTTV_PRIO_DEFAULT); + lttv_hooks_add(hook_adder, lttv_state_hook_add_event_hooks, NULL, + LTTV_PRIO_DEFAULT); + LttvHooks *hook_remover = lttv_hooks_new(); + lttv_hooks_add(hook_remover, lttv_stats_hook_remove_event_hooks, + NULL, LTTV_PRIO_DEFAULT); + lttv_hooks_add(hook_remover, lttv_state_hook_remove_event_hooks, + NULL, LTTV_PRIO_DEFAULT); + LttvHooks *after_request = lttv_hooks_new(); + lttv_hooks_add(after_request, lttv_stats_sum_traceset_hook, NULL, + LTTV_PRIO_DEFAULT); + /* Add state computation background hook adder to attributes */ + lttvwindowtraces_register_computation_hooks(g_quark_from_string("stats"), + NULL, NULL, NULL, NULL, NULL, NULL, NULL, + after_request, NULL, NULL, + hook_adder, hook_remover); } } void main_window_destructor(MainWindow * mw) { - if(GTK_IS_WIDGET(mw->mwindow)){ - gtk_widget_destroy(mw->mwindow); - // gtk_widget_destroy(mw->HelpContents); - // gtk_widget_destroy(mw->AboutBox); - mw = NULL; - } - //main_window_free called when the object mw in the widget is unref. - //main_window_free(mw); + g_assert(GTK_IS_WIDGET(mw->mwindow)); + gtk_widget_destroy(mw->mwindow); } - -void main_window_destroy_walk(gpointer data, gpointer user_data) +static void destroy_walk(gpointer data, gpointer user_data) { main_window_destructor((MainWindow*)data); } - - /** * plugin's destroy function * @@ -170,21 +248,21 @@ static void destroy() { LttvAttributeValue value; LttvTrace *trace; - + GSList *iter = NULL; + lttv_option_remove("trace"); lttv_hooks_remove_data(main_hooks, window_creation_hook, NULL); g_debug("GUI destroy()"); - if(g_main_window_list){ - g_slist_foreach(g_main_window_list, main_window_destroy_walk, NULL ); - g_slist_free(g_main_window_list); - } + g_slist_foreach(g_main_window_list, destroy_walk, NULL); + + g_slist_free(g_main_window_list); } LTTV_MODULE("lttvwindow", "Viewer main window", \ "Viewer with multiple windows, tabs and panes for graphical modules", \ - init, destroy, "stats") + init, destroy, "stats", "option")