X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Flttv%2Fmodules%2Fgui%2Flttvwindow%2Flttvwindow%2Flttvwindowtraces.c;h=617f18cb0db8f42afc870b4755fbe9156202bf33;hb=167bee50bc90a840ad8d8bb0b57d7fc6a276f05f;hp=7e8a2a8eff3d31a0c7e126af01bcac76dc479b19;hpb=2eef04b5f3234a4e303bd6162eb20d055b7d44cf;p=lttv.git diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindowtraces.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindowtraces.c index 7e8a2a8e..617f18cb 100644 --- a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindowtraces.c +++ b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindowtraces.c @@ -20,6 +20,10 @@ /* Here is the implementation of the API */ +#ifdef HAVE_CONFIG_H +#include +#endif + #include #include #include @@ -34,13 +38,17 @@ #include #include #include // for CHUNK_NUM_EVENTS +#include /* for main window structure */ +extern GSList * g_main_window_list; typedef struct _BackgroundRequest { LttvAttributeName module_name; /* Hook path in global attributes, where all standard hooks under computation/. i.e. modulename */ LttvTrace *trace; /* trace concerned */ + GtkWidget *dialog; /* Dialog linked with the request, may be NULL */ + GtkWidget *parent_window; /* Parent window the dialog must be transient for */ } BackgroundRequest; typedef struct _BackgroundNotify { @@ -64,7 +72,7 @@ gboolean lttvwindowtraces_process_pending_requests(LttvTrace *trace); * NULL is returned if the trace is not present */ -LttvTrace *lttvwindowtraces_get_trace_by_name(gchar *path) +__EXPORT LttvTrace *lttvwindowtraces_get_trace_by_name(gchar *path) { guint i; @@ -76,7 +84,7 @@ LttvTrace *lttvwindowtraces_get_trace_by_name(gchar *path) trace = lttv_trace(trace_v); g_assert(trace != NULL); - name = ltt_trace_name(trace); + name = g_quark_to_string(ltt_trace_name(trace)); if(strcmp(name, path) == 0) { /* Found */ @@ -89,19 +97,22 @@ LttvTrace *lttvwindowtraces_get_trace_by_name(gchar *path) /* Get a trace by its number identifier */ -LttvTrace *lttvwindowtraces_get_trace(guint num) +__EXPORT LttvTrace *lttvwindowtraces_get_trace(guint num) { LttvAttribute *g_attribute = lttv_global_attributes(); LttvAttribute *attribute; LttvAttributeType type; LttvAttributeName name; LttvAttributeValue value; + gboolean is_named; - g_assert(attribute = + attribute = LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(g_attribute), - LTTV_TRACES))); + LTTV_TRACES)); + g_assert(attribute); - type = lttv_iattribute_get(LTTV_IATTRIBUTE(attribute), num, &name, &value); + type = lttv_iattribute_get(LTTV_IATTRIBUTE(attribute), num, &name, &value, + &is_named); if(type == LTTV_POINTER) { return (LttvTrace *)*(value.v_pointer); @@ -112,15 +123,15 @@ LttvTrace *lttvwindowtraces_get_trace(guint num) /* Total number of traces */ -guint lttvwindowtraces_get_number() +__EXPORT guint lttvwindowtraces_get_number() { LttvAttribute *g_attribute = lttv_global_attributes(); LttvAttribute *attribute; - LttvAttributeValue value; - g_assert(attribute = + attribute = LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(g_attribute), - LTTV_TRACES))); + LTTV_TRACES)); + g_assert(attribute); return ( lttv_iattribute_get_number(LTTV_IATTRIBUTE(attribute)) ); } @@ -132,21 +143,23 @@ void lttvwindowtraces_add_trace(LttvTrace *trace) LttvAttribute *g_attribute = lttv_global_attributes(); LttvAttribute *attribute; LttvAttributeValue value; - guint num; struct stat buf; gchar attribute_path[PATH_MAX]; + int result; + gboolean result_b; - if(stat(ltt_trace_name(lttv_trace(trace)), &buf)) { + if(stat(g_quark_to_string(ltt_trace_name(lttv_trace(trace))), &buf)) { g_warning("lttvwindowtraces_add_trace: Trace %s not found", - ltt_trace_name(lttv_trace(trace))); + g_quark_to_string(ltt_trace_name(lttv_trace(trace)))); return; } - g_assert( - snprintf(attribute_path, PATH_MAX, "%lu:%lu", buf.st_dev, buf.st_ino) >= 0); + result = snprintf(attribute_path, PATH_MAX, "%llu:%llu", buf.st_dev, buf.st_ino); + g_assert(result >= 0); - g_assert(attribute = + attribute = LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(g_attribute), - LTTV_TRACES))); + LTTV_TRACES)); + g_assert(attribute); value = lttv_attribute_add(attribute, g_quark_from_string(attribute_path), @@ -157,26 +170,40 @@ void lttvwindowtraces_add_trace(LttvTrace *trace) /* create new traceset and tracesetcontext */ LttvTraceset *ts; LttvTracesetStats *tss; + //LttvTracesetContextPosition *sync_position; attribute = lttv_trace_attribute(trace); - g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + result_b = lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), LTTV_COMPUTATION_TRACESET, LTTV_POINTER, - &value)); + &value); + g_assert(result_b); + ts = lttv_traceset_new(); *(value.v_pointer) = ts; lttv_traceset_add(ts,trace); - g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + result_b = lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), LTTV_COMPUTATION_TRACESET_CONTEXT, LTTV_POINTER, - &value)); + &value); + g_assert(result_b); + tss = g_object_new(LTTV_TRACESET_STATS_TYPE, NULL); *(value.v_pointer) = tss; lttv_context_init(LTTV_TRACESET_CONTEXT(tss), ts); +#if 0 + result_b = lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + LTTV_COMPUTATION_SYNC_POSITION, + LTTV_POINTER, + &value); + g_assert(result_b); + sync_position = lttv_traceset_context_position_new(); + *(value.v_pointer) = sync_position; +#endif //0 value = lttv_attribute_add(attribute, LTTV_REQUESTS_QUEUE, LTTV_POINTER); @@ -192,7 +219,6 @@ void lttvwindowtraces_add_trace(LttvTrace *trace) value = lttv_attribute_add(attribute, LTTV_NOTIFY_CURRENT, LTTV_POINTER); - } /* Remove a trace from the global attributes */ @@ -203,10 +229,12 @@ void lttvwindowtraces_remove_trace(LttvTrace *trace) LttvAttribute *attribute; LttvAttributeValue value; guint i; + gboolean result; - g_assert(attribute = + attribute = LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(g_attribute), - LTTV_TRACES))); + LTTV_TRACES)); + g_assert(attribute); for(i=0;idialog); + bg_req->dialog = NULL; +} + /** * Function to request data from a specific trace * * The memory allocated for the request will be managed by the API. * + * @param widget the current Window * @param trace the trace to compute * @param module_name the name of the module which registered global computation * hooks. */ -void lttvwindowtraces_background_request_queue - (LttvTrace *trace, gchar *module_name) +__EXPORT void lttvwindowtraces_background_request_queue + (GtkWidget *widget, LttvTrace *trace, gchar *module_name) { BackgroundRequest *bg_req; LttvAttribute *attribute = lttv_trace_attribute(trace); @@ -289,19 +342,21 @@ void lttvwindowtraces_background_request_queue LttvAttributeValue value; LttvAttributeType type; GSList **slist; - guint num; + gboolean result; - g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), LTTV_REQUESTS_QUEUE, LTTV_POINTER, - &value)); + &value); + g_assert(result); + slist = (GSList**)(value.v_pointer); /* Verify that the calculator is loaded */ - g_assert(module_attribute = + module_attribute = LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(g_attribute), - LTTV_COMPUTATION))); - + LTTV_COMPUTATION)); + g_assert(module_attribute); type = lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute), g_quark_from_string(module_name), @@ -324,7 +379,25 @@ void lttvwindowtraces_background_request_queue trace, NULL); /* FIXME : show message in status bar, need context and message id */ - g_info("Background computation started for trace %p", trace); + g_info("Background computation for %s started for trace %p", module_name, + trace); + GtkWidget *dialog = + gtk_message_dialog_new( + GTK_WINDOW(widget), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_INFO, GTK_BUTTONS_OK, + "Background computation for %s started for trace %s", + module_name, + g_quark_to_string(ltt_trace_name(lttv_trace(trace)))); + gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(widget)); + g_signal_connect_swapped (dialog, "response", + G_CALLBACK (destroy_dialog), + bg_req); + bg_req->dialog = dialog; + /* the parent window might vanish : only use this pointer for a + * comparison with existing windows */ + bg_req->parent_window = gtk_widget_get_toplevel(widget); + gtk_widget_show(dialog); } /** @@ -351,11 +424,14 @@ void lttvwindowtraces_background_request_remove LttvAttributeValue value; GSList *iter = NULL; GSList **slist; + gboolean result; - g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), LTTV_REQUESTS_QUEUE, LTTV_POINTER, - &value)); + &value); + g_assert(result); + slist = (GSList**)(value.v_pointer); for(iter=*slist;iter!=NULL;) { @@ -373,6 +449,40 @@ void lttvwindowtraces_background_request_remove } } +/** + * Find a background request in a trace + * + */ + +__EXPORT gboolean lttvwindowtraces_background_request_find + (LttvTrace *trace, gchar *module_name) +{ + LttvAttribute *attribute = lttv_trace_attribute(trace); + LttvAttributeValue value; + GSList *iter = NULL; + GSList **slist; + gboolean result; + + result = lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + LTTV_REQUESTS_QUEUE, + LTTV_POINTER, + &value); + g_assert(result); + + slist = (GSList**)(value.v_pointer); + + for(iter=*slist;iter!=NULL;) { + BackgroundRequest *bg_req = + (BackgroundRequest *)iter->data; + + if(bg_req->module_name == g_quark_from_string(module_name)) { + return TRUE; + } else { + iter=g_slist_next(iter); + } + } + return FALSE; +} /** * Register a callback to be called when requested data is passed in the next @@ -385,7 +495,7 @@ void lttvwindowtraces_background_request_remove * @param notify Hook to call when the notify position is passed */ -void lttvwindowtraces_background_notify_queue +__EXPORT void lttvwindowtraces_background_notify_queue (gpointer owner, LttvTrace *trace, LttTime notify_time, @@ -396,13 +506,23 @@ void lttvwindowtraces_background_notify_queue LttvAttribute *attribute = lttv_trace_attribute(trace); LttvAttributeValue value; GSList **slist; + gboolean result; - g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + result = lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), LTTV_NOTIFY_QUEUE, LTTV_POINTER, - &value)); + &value); + g_assert(result); + slist = (GSList**)(value.v_pointer); + result = lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + LTTV_COMPUTATION_TRACESET_CONTEXT, + LTTV_POINTER, + &value); + g_assert(result); + + LttvTracesetContext *tsc = (LttvTracesetContext*)(value.v_pointer); bg_notify = g_new(BackgroundNotify,1); @@ -410,7 +530,7 @@ void lttvwindowtraces_background_notify_queue bg_notify->trace = trace; bg_notify->notify_time = notify_time; if(notify_position != NULL) { - bg_notify->notify_position = lttv_traceset_context_position_new(); + bg_notify->notify_position = lttv_traceset_context_position_new(tsc); lttv_traceset_context_position_copy(bg_notify->notify_position, notify_position); } else { @@ -434,7 +554,7 @@ void lttvwindowtraces_background_notify_queue * @param notify Hook to call when the notify position is passed */ -void lttvwindowtraces_background_notify_current +__EXPORT void lttvwindowtraces_background_notify_current (gpointer owner, LttvTrace *trace, LttTime notify_time, @@ -445,20 +565,32 @@ void lttvwindowtraces_background_notify_current LttvAttribute *attribute = lttv_trace_attribute(trace); LttvAttributeValue value; GSList **slist; + gboolean result; - g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + result = lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), LTTV_NOTIFY_CURRENT, LTTV_POINTER, - &value)); + &value); + g_assert(result); + slist = (GSList**)(value.v_pointer); + result = lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + LTTV_COMPUTATION_TRACESET_CONTEXT, + LTTV_POINTER, + &value); + g_assert(result); + + LttvTracesetContext *tsc = (LttvTracesetContext*)(value.v_pointer); + + bg_notify = g_new(BackgroundNotify,1); bg_notify->owner = owner; bg_notify->trace = trace; bg_notify->notify_time = notify_time; if(notify_position!= NULL) { - bg_notify->notify_position = lttv_traceset_context_position_new(); + bg_notify->notify_position = lttv_traceset_context_position_new(tsc); lttv_traceset_context_position_copy(bg_notify->notify_position, notify_position); } else { @@ -488,7 +620,7 @@ static void notify_request_free(BackgroundNotify *notify_req) * @param owner owner of the background notification */ -void lttvwindowtraces_background_notify_remove(gpointer owner) +__EXPORT void lttvwindowtraces_background_notify_remove(gpointer owner) { guint i; @@ -498,15 +630,18 @@ void lttvwindowtraces_background_notify_remove(gpointer owner) LttvTrace *trace_v = lttvwindowtraces_get_trace(i); GSList **slist; GSList *iter = NULL; + gboolean result; g_assert(trace_v != NULL); attribute = lttv_trace_attribute(trace_v); - g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + result = lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), LTTV_NOTIFY_QUEUE, LTTV_POINTER, - &value)); + &value); + g_assert(result); + slist = (GSList**)(value.v_pointer); for(iter=*slist;iter!=NULL;) { @@ -523,10 +658,12 @@ void lttvwindowtraces_background_notify_remove(gpointer owner) } } - g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + result = lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), LTTV_NOTIFY_CURRENT, LTTV_POINTER, - &value)); + &value); + g_assert(result); + slist = (GSList**)(value.v_pointer); for(iter=*slist;iter!=NULL;) { @@ -556,22 +693,85 @@ void lttvwindowtraces_add_computation_hooks(LttvAttributeName module_name, LttvAttribute *module_attribute; LttvAttributeType type; LttvAttributeValue value; + + + module_attribute = + LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(g_attribute), + LTTV_COMPUTATION)); + g_assert(module_attribute); + + module_attribute = + LTTV_ATTRIBUTE(lttv_iattribute_find_subdir( + LTTV_IATTRIBUTE(module_attribute), + module_name)); + g_assert(module_attribute); + + /* Call the module's hook adder */ + type = lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute), + LTTV_HOOK_ADDER, + &value); + if(type == LTTV_POINTER) { + //lttv_hooks_call((LttvHooks*)*(value.v_pointer), (gpointer)tss); + if(hook_adder != NULL) + lttv_hooks_add_list(hook_adder, (LttvHooks*)*(value.v_pointer)); + } +} + +void lttvwindowtraces_remove_computation_hooks(LttvAttributeName module_name, + LttvTracesetContext *tsc, + LttvHooks *hook_remover) +{ + LttvAttribute *g_attribute = lttv_global_attributes(); + LttvAttribute *module_attribute; + LttvAttributeType type; + LttvAttributeValue value; + + module_attribute = + LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(g_attribute), + LTTV_COMPUTATION)); + g_assert(module_attribute); + + module_attribute = + LTTV_ATTRIBUTE(lttv_iattribute_find_subdir( + LTTV_IATTRIBUTE(module_attribute), + module_name)); + g_assert(module_attribute); + + /* Call the module's hook remover */ + type = lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute), + LTTV_HOOK_REMOVER, + &value); + if(type == LTTV_POINTER) { + //lttv_hooks_call((LttvHooks*)*(value.v_pointer), (gpointer)tss); + if(hook_remover != NULL) + lttv_hooks_add_list(hook_remover, (LttvHooks*)*(value.v_pointer)); + } +} + +void lttvwindowtraces_call_before_chunk(LttvAttributeName module_name, + LttvTracesetContext *tsc) +{ + LttvAttribute *g_attribute = lttv_global_attributes(); + LttvAttribute *module_attribute; + LttvAttributeType type; + LttvAttributeValue value; LttvHooks *before_chunk_traceset=NULL; LttvHooks *before_chunk_trace=NULL; LttvHooks *before_chunk_tracefile=NULL; LttvHooks *event_hook=NULL; LttvHooksById *event_hook_by_id=NULL; - LttvTracesetStats *tss = LTTV_TRACESET_STATS(tsc); - g_assert(module_attribute = + module_attribute = LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(g_attribute), - LTTV_COMPUTATION))); + LTTV_COMPUTATION)); + g_assert(module_attribute); - g_assert(module_attribute = + module_attribute = LTTV_ATTRIBUTE(lttv_iattribute_find_subdir( LTTV_IATTRIBUTE(module_attribute), - module_name))); + module_name)); + g_assert(module_attribute); type = lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute), LTTV_BEFORE_CHUNK_TRACESET, @@ -608,30 +808,18 @@ void lttvwindowtraces_add_computation_hooks(LttvAttributeName module_name, event_hook_by_id = (LttvHooksById*)*(value.v_pointer); } - /* Call the module's hook adder */ - type = lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute), - LTTV_HOOK_ADDER, - &value); - if(type == LTTV_POINTER) { - //lttv_hooks_call((LttvHooks*)*(value.v_pointer), (gpointer)tss); - if(hook_adder != NULL) - lttv_hooks_add_list(hook_adder, (LttvHooks*)*(value.v_pointer)); - } - - - lttv_process_traceset_begin(tsc, before_chunk_traceset, before_chunk_trace, before_chunk_tracefile, event_hook, event_hook_by_id); - } - -void lttvwindowtraces_remove_computation_hooks(LttvAttributeName module_name, - LttvTracesetContext *tsc, - LttvHooks *hook_remover) + + + +void lttvwindowtraces_call_after_chunk(LttvAttributeName module_name, + LttvTracesetContext *tsc) { LttvAttribute *g_attribute = lttv_global_attributes(); LttvAttribute *module_attribute; @@ -642,16 +830,17 @@ void lttvwindowtraces_remove_computation_hooks(LttvAttributeName module_name, LttvHooks *after_chunk_tracefile=NULL; LttvHooks *event_hook=NULL; LttvHooksById *event_hook_by_id=NULL; - LttvTracesetStats *tss = LTTV_TRACESET_STATS(tsc); - g_assert(module_attribute = + module_attribute = LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(g_attribute), - LTTV_COMPUTATION))); + LTTV_COMPUTATION)); + g_assert(module_attribute); - g_assert(module_attribute = + module_attribute = LTTV_ATTRIBUTE(lttv_iattribute_find_subdir( LTTV_IATTRIBUTE(module_attribute), - module_name))); + module_name)); + g_assert(module_attribute); type = lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute), LTTV_AFTER_CHUNK_TRACESET, @@ -695,15 +884,6 @@ void lttvwindowtraces_remove_computation_hooks(LttvAttributeName module_name, event_hook, event_hook_by_id); - /* Call the module's hook remover */ - type = lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute), - LTTV_HOOK_REMOVER, - &value); - if(type == LTTV_POINTER) { - //lttv_hooks_call((LttvHooks*)*(value.v_pointer), (gpointer)tss); - if(hook_remover != NULL) - lttv_hooks_add_list(hook_remover, (LttvHooks*)*(value.v_pointer)); - } } @@ -713,9 +893,10 @@ void lttvwindowtraces_set_in_progress(LttvAttributeName module_name, LttvAttribute *attribute = lttv_trace_attribute(trace); LttvAttributeValue value; - g_assert(attribute = + attribute = LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(attribute), - module_name))); + module_name)); + g_assert(attribute); value = lttv_iattribute_add(LTTV_IATTRIBUTE(attribute), LTTV_IN_PROGRESS, @@ -729,24 +910,26 @@ void lttvwindowtraces_unset_in_progress(LttvAttributeName module_name, { LttvAttribute *attribute = lttv_trace_attribute(trace); - g_assert(attribute = + attribute = LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(attribute), - module_name))); + module_name)); + g_assert(attribute); lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute), LTTV_IN_PROGRESS); } -gboolean lttvwindowtraces_get_in_progress(LttvAttributeName module_name, +__EXPORT gboolean lttvwindowtraces_get_in_progress(LttvAttributeName module_name, LttvTrace *trace) { LttvAttribute *attribute = lttv_trace_attribute(trace); LttvAttributeType type; LttvAttributeValue value; - g_assert(attribute = + attribute = LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(attribute), - module_name))); + module_name)); + g_assert(attribute); type = lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute), LTTV_IN_PROGRESS, @@ -764,9 +947,10 @@ void lttvwindowtraces_set_ready(LttvAttributeName module_name, LttvAttribute *attribute = lttv_trace_attribute(trace); LttvAttributeValue value; - g_assert(attribute = + attribute = LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(attribute), - module_name))); + module_name)); + g_assert(attribute); value = lttv_iattribute_add(LTTV_IATTRIBUTE(attribute), LTTV_READY, @@ -780,24 +964,26 @@ void lttvwindowtraces_unset_ready(LttvAttributeName module_name, { LttvAttribute *attribute = lttv_trace_attribute(trace); - g_assert(attribute = + attribute = LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(attribute), - module_name))); + module_name)); + g_assert(attribute); lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute), LTTV_READY); } -gboolean lttvwindowtraces_get_ready(LttvAttributeName module_name, +__EXPORT gboolean lttvwindowtraces_get_ready(LttvAttributeName module_name, LttvTrace *trace) { LttvAttribute *attribute = lttv_trace_attribute(trace); LttvAttributeType type; LttvAttributeValue value; - g_assert(attribute = + attribute = LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(attribute), - module_name))); + module_name)); + g_assert(attribute); type = lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute), LTTV_READY, @@ -809,6 +995,12 @@ gboolean lttvwindowtraces_get_ready(LttvAttributeName module_name, return TRUE; } +static gint find_window_widget(MainWindow *a, GtkWidget *b) +{ + if(a->mwindow == b) return 0; + else return -1; +} + /* lttvwindowtraces_process_pending_requests * @@ -823,6 +1015,7 @@ gboolean lttvwindowtraces_process_pending_requests(LttvTrace *trace) LttvTracesetContext *tsc; LttvTracesetStats *tss; LttvTraceset *ts; + //LttvTracesetContextPosition *sync_position; LttvAttribute *attribute; LttvAttribute *g_attribute = lttv_global_attributes(); GSList **list_out, **list_in, **notify_in, **notify_out; @@ -832,6 +1025,8 @@ gboolean lttvwindowtraces_process_pending_requests(LttvTrace *trace) if(trace == NULL) return FALSE; + + if(lttvwindow_preempt_count > 0) return TRUE; attribute = lttv_trace_attribute(trace); @@ -873,10 +1068,15 @@ gboolean lttvwindowtraces_process_pending_requests(LttvTrace *trace) tss = (LttvTracesetStats*)*(value.v_pointer); g_assert(LTTV_IS_TRACESET_CONTEXT(tsc)); g_assert(LTTV_IS_TRACESET_STATS(tss)); - +#if 0 + type = lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute), + LTTV_COMPUTATION_SYNC_POSITION, + &value); + g_assert(type == LTTV_POINTER); + sync_position = (LttvTracesetContextPosition*)*(value.v_pointer); +#endif //0 /* There is no events requests pending : we should never have been called! */ g_assert(g_slist_length(*list_out) != 0 || g_slist_length(*list_in) != 0); - /* 0.1 Lock traces */ { guint iter_trace=0; @@ -892,8 +1092,8 @@ gboolean lttvwindowtraces_process_pending_requests(LttvTrace *trace) } } /* 0.2 Sync tracefiles */ + //g_assert(lttv_process_traceset_seek_position(tsc, sync_position) == 0); lttv_process_traceset_synchronize_tracefiles(tsc); - /* 1. Before processing */ { /* if list_in is empty */ @@ -941,15 +1141,17 @@ gboolean lttvwindowtraces_process_pending_requests(LttvTrace *trace) /* Get before request hook */ LttvAttribute *module_attribute; - g_assert(module_attribute = + module_attribute = LTTV_ATTRIBUTE(lttv_iattribute_find_subdir( LTTV_IATTRIBUTE(g_attribute), - LTTV_COMPUTATION))); + LTTV_COMPUTATION)); + g_assert(module_attribute); - g_assert(module_attribute = + module_attribute = LTTV_ATTRIBUTE(lttv_iattribute_find_subdir( LTTV_IATTRIBUTE(module_attribute), - bg_req->module_name))); + bg_req->module_name)); + g_assert(module_attribute); type = lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute), LTTV_BEFORE_REQUEST, @@ -998,27 +1200,40 @@ gboolean lttvwindowtraces_process_pending_requests(LttvTrace *trace) } } } + { + GSList *iter = *list_in; + LttvHooks *hook_adder = lttv_hooks_new(); + /* - for each request in list_in */ + while(iter != NULL) { + + BackgroundRequest *bg_req = (BackgroundRequest*)iter->data; + /*- add hooks to context*/ + lttvwindowtraces_add_computation_hooks(bg_req->module_name, + tsc, + hook_adder); + iter = g_slist_next(iter); + } + lttv_hooks_call(hook_adder,tsc); + lttv_hooks_destroy(hook_adder); + } + + } { GSList *iter = *list_in; - LttvHooks *hook_adder = lttv_hooks_new(); /* - for each request in list_in */ while(iter != NULL) { BackgroundRequest *bg_req = (BackgroundRequest*)iter->data; /*- Call before chunk hooks for list_in*/ - /*- add hooks to context*/ - lttvwindowtraces_add_computation_hooks(bg_req->module_name, - tsc, - hook_adder); + lttvwindowtraces_call_before_chunk(bg_req->module_name, + tsc); iter = g_slist_next(iter); } - lttv_hooks_call(hook_adder,tsc); - lttv_hooks_destroy(hook_adder); } - } + } /* 2. call process traceset middle for a chunk */ { /*(assert list_in is not empty! : should not even be called in that case)*/ @@ -1033,20 +1248,15 @@ gboolean lttvwindowtraces_process_pending_requests(LttvTrace *trace) /* 3.1 call after_chunk hooks for list_in */ { GSList *iter = *list_in; - LttvHooks *hook_remover = lttv_hooks_new(); /* - for each request in list_in */ while(iter != NULL) { BackgroundRequest *bg_req = (BackgroundRequest*)iter->data; /* - Call after chunk hooks for list_in */ - /* - remove hooks from context */ - lttvwindowtraces_remove_computation_hooks(bg_req->module_name, - tsc, - hook_remover); + lttvwindowtraces_call_after_chunk(bg_req->module_name, + tsc); iter = g_slist_next(iter); } - lttv_hooks_call(hook_remover,tsc); - lttv_hooks_destroy(hook_remover); } /* 3.2 for each notify_in */ @@ -1102,7 +1312,24 @@ gboolean lttvwindowtraces_process_pending_requests(LttvTrace *trace) tfc->timestamp.tv_sec, tfc->timestamp.tv_nsec); if(tfc == NULL || ltt_time_compare(tfc->timestamp, tsc->time_span.end_time) > 0) { - + + { + GSList *iter = *list_in; + LttvHooks *hook_remover = lttv_hooks_new(); + /* - for each request in list_in */ + while(iter != NULL) { + + BackgroundRequest *bg_req = (BackgroundRequest*)iter->data; + /* - remove hooks from context */ + lttvwindowtraces_remove_computation_hooks(bg_req->module_name, + tsc, + hook_remover); + iter = g_slist_next(iter); + } + lttv_hooks_call(hook_remover,tsc); + lttv_hooks_destroy(hook_remover); + } + /* - for each request in list_in */ { GSList *iter = *list_in; @@ -1123,23 +1350,56 @@ gboolean lttvwindowtraces_process_pending_requests(LttvTrace *trace) /* Get after request hook */ LttvAttribute *module_attribute; - g_assert(module_attribute = + module_attribute = LTTV_ATTRIBUTE(lttv_iattribute_find_subdir( LTTV_IATTRIBUTE(g_attribute), - LTTV_COMPUTATION))); + LTTV_COMPUTATION)); + g_assert(module_attribute); - g_assert(module_attribute = + module_attribute = LTTV_ATTRIBUTE(lttv_iattribute_find_subdir( LTTV_IATTRIBUTE(module_attribute), - bg_req->module_name))); + bg_req->module_name)); + g_assert(module_attribute); type = lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute), LTTV_AFTER_REQUEST, &value); g_assert(type == LTTV_POINTER); LttvHooks *after_request = (LttvHooks*)*(value.v_pointer); + { + struct sum_traceset_closure t_closure; + t_closure.tss = (LttvTracesetStats*)tsc; + t_closure.current_time = ltt_time_infinite; + if(after_request != NULL) lttv_hooks_call(after_request, + &t_closure); + } + + if(bg_req->dialog != NULL) + gtk_widget_destroy(bg_req->dialog); + GtkWidget *parent_window; + if(g_slist_find_custom(g_main_window_list, + bg_req->parent_window, + (GCompareFunc)find_window_widget)) + parent_window = GTK_WIDGET(bg_req->parent_window); + else + parent_window = NULL; + + GtkWidget *dialog = + gtk_message_dialog_new(GTK_WINDOW(parent_window), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_INFO, GTK_BUTTONS_OK, + "Background computation %s finished for trace %s", + g_quark_to_string(bg_req->module_name), + g_quark_to_string(ltt_trace_name(lttv_trace(bg_req->trace)))); + if(parent_window != NULL) + gtk_window_set_transient_for(GTK_WINDOW(dialog), + GTK_WINDOW(parent_window)); + g_signal_connect_swapped (dialog, "response", + G_CALLBACK (gtk_widget_destroy), + dialog); + gtk_widget_show(dialog); - if(after_request != NULL) lttv_hooks_call(after_request, tsc); /* - remove request */ remove = TRUE; free_data = TRUE; @@ -1198,6 +1458,7 @@ gboolean lttvwindowtraces_process_pending_requests(LttvTrace *trace) g_debug("Background computation scheduler stopped"); g_info("Background computation finished for trace %p", trace); /* FIXME : remove status bar info, need context id and message id */ + ret_val = FALSE; } else { ret_val = TRUE; @@ -1212,7 +1473,8 @@ gboolean lttvwindowtraces_process_pending_requests(LttvTrace *trace) } /* 4. Unlock traces */ { - //lttv_process_traceset_get_sync_data(tsc); + lttv_process_traceset_get_sync_data(tsc); + //lttv_traceset_context_position_save(tsc, sync_position); guint iter_trace; for(iter_trace=0; @@ -1252,85 +1514,101 @@ void lttvwindowtraces_register_computation_hooks(LttvAttributeName module_name, LttvAttribute *g_attribute = lttv_global_attributes(); LttvAttribute *attribute; LttvAttributeValue value; + gboolean result; - g_assert(attribute = + attribute = LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(g_attribute), - LTTV_COMPUTATION))); + LTTV_COMPUTATION)); + g_assert(attribute); - g_assert(attribute = + attribute = LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(attribute), - module_name))); + module_name)); + g_assert(attribute); - g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + result = lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), LTTV_BEFORE_CHUNK_TRACESET, LTTV_POINTER, - &value)); + &value); + g_assert(result); + *(value.v_pointer) = before_chunk_traceset; - g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + result = lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), LTTV_BEFORE_CHUNK_TRACE, LTTV_POINTER, - &value)); + &value); + g_assert(result); *(value.v_pointer) = before_chunk_trace; - g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + result = lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), LTTV_BEFORE_CHUNK_TRACEFILE, LTTV_POINTER, - &value)); + &value); + g_assert(result); *(value.v_pointer) = before_chunk_tracefile; - g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + result = lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), LTTV_AFTER_CHUNK_TRACESET, LTTV_POINTER, - &value)); + &value); + g_assert(result); *(value.v_pointer) = after_chunk_traceset; - g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + result = lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), LTTV_AFTER_CHUNK_TRACE, LTTV_POINTER, - &value)); + &value); + g_assert(result); *(value.v_pointer) = after_chunk_trace; - g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + result = lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), LTTV_AFTER_CHUNK_TRACEFILE, LTTV_POINTER, - &value)); + &value); + g_assert(result); *(value.v_pointer) = after_chunk_tracefile; - g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + result = lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), LTTV_BEFORE_REQUEST, LTTV_POINTER, - &value)); + &value); + g_assert(result); *(value.v_pointer) = before_request; - g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + result = lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), LTTV_AFTER_REQUEST, LTTV_POINTER, - &value)); + &value); + g_assert(result); *(value.v_pointer) = after_request; - g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + result = lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), LTTV_EVENT_HOOK, LTTV_POINTER, - &value)); + &value); + g_assert(result); *(value.v_pointer) = event_hook; - g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + result = lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), LTTV_EVENT_HOOK_BY_ID, LTTV_POINTER, - &value)); + &value); + g_assert(result); *(value.v_pointer) = event_hook_by_id; - g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + result = lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), LTTV_HOOK_ADDER, LTTV_POINTER, - &value)); + &value); + g_assert(result); *(value.v_pointer) = hook_adder; - g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + result = lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), LTTV_HOOK_REMOVER, LTTV_POINTER, - &value)); + &value); + g_assert(result); *(value.v_pointer) = hook_remover; } @@ -1348,20 +1626,22 @@ void lttvwindowtraces_register_computation_hooks(LttvAttributeName module_name, void lttvwindowtraces_unregister_requests(LttvAttributeName module_name) { guint i; + gboolean result; for(i=0;i