X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Flttv%2Fmodules%2Fgui%2Flttvwindow%2Flttvwindow%2Flttvwindowtraces.c;h=26a127052297ea1615d5a73ed34cfed71be366a3;hb=088f6772c700cf75d4ba27adf086dc37d961a960;hp=156ea7d355f57e9d190ab0af91097665a93a8c2f;hpb=b052368a0d53ff62ed9110fbafdb857a2b034ca8;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 156ea7d3..26a12705 100644 --- a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindowtraces.c +++ b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindowtraces.c @@ -20,9 +20,14 @@ /* Here is the implementation of the API */ +#ifdef HAVE_CONFIG_H +#include +#endif + #include #include #include +#include #include #include @@ -65,7 +70,6 @@ gboolean lttvwindowtraces_process_pending_requests(LttvTrace *trace); LttvTrace *lttvwindowtraces_get_trace_by_name(gchar *path) { - LttvAttribute *attribute = lttv_global_attributes(); guint i; for(i=0;i= 0); + snprintf(attribute_path, PATH_MAX, "%llu:%llu", buf.st_dev, buf.st_ino) >= 0); g_assert(attribute = LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(g_attribute), @@ -157,6 +161,7 @@ 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), @@ -176,7 +181,15 @@ void lttvwindowtraces_add_trace(LttvTrace *trace) *(value.v_pointer) = tss; lttv_context_init(LTTV_TRACESET_CONTEXT(tss), ts); +#if 0 + g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + LTTV_COMPUTATION_SYNC_POSITION, + LTTV_POINTER, + &value)); + sync_position = lttv_traceset_context_position_new(); + *(value.v_pointer) = sync_position; +#endif //0 value = lttv_attribute_add(attribute, LTTV_REQUESTS_QUEUE, LTTV_POINTER); @@ -220,9 +233,10 @@ void lttvwindowtraces_remove_trace(LttvTrace *trace) /* Found */ LttvAttribute *l_attribute; - /* create new traceset and tracesetcontext */ + /* destroy traceset and tracesetcontext */ LttvTraceset *ts; LttvTracesetStats *tss; + //LttvTracesetContextPosition *sync_position; l_attribute = lttv_trace_attribute(trace); @@ -244,7 +258,18 @@ void lttvwindowtraces_remove_trace(LttvTrace *trace) LTTV_POINTER, &value)); ts = (LttvTraceset*)*(value.v_pointer); - +#if 0 + g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(l_attribute), + LTTV_COMPUTATION_SYNC_POSITION, + LTTV_POINTER, + &value)); + sync_position = (LttvTracesetContextPosition*)*(value.v_pointer); + lttv_traceset_context_position_destroy(sync_position); + + lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(l_attribute), + LTTV_COMPUTATION_SYNC_POSITION); + +#endif //0 g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(l_attribute), LTTV_COMPUTATION_TRACESET_CONTEXT, LTTV_POINTER, @@ -255,9 +280,10 @@ void lttvwindowtraces_remove_trace(LttvTrace *trace) g_object_unref(tss); lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(l_attribute), LTTV_COMPUTATION_TRACESET_CONTEXT); - lttv_traceset_destroy(ts); lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(l_attribute), LTTV_COMPUTATION_TRACESET); + /* Destroy the traceset and the trace also */ + lttv_traceset_destroy(ts); /* finally, remove the global attribute */ lttv_attribute_remove(attribute, i); @@ -283,7 +309,10 @@ void lttvwindowtraces_background_request_queue { BackgroundRequest *bg_req; LttvAttribute *attribute = lttv_trace_attribute(trace); + LttvAttribute *g_attribute = lttv_global_attributes(); + LttvAttribute *module_attribute; LttvAttributeValue value; + LttvAttributeType type; GSList **slist; guint num; @@ -292,7 +321,21 @@ void lttvwindowtraces_background_request_queue LTTV_POINTER, &value)); slist = (GSList**)(value.v_pointer); - + + /* Verify that the calculator is loaded */ + g_assert(module_attribute = + LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(g_attribute), + LTTV_COMPUTATION))); + + + type = lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute), + g_quark_from_string(module_name), + &value); + if(type == LTTV_NONE) { + g_critical("Missing background calculator %s", module_name); + return; + } + bg_req = g_new(BackgroundRequest,1); bg_req->module_name = g_quark_from_string(module_name); bg_req->trace = trace; @@ -531,7 +574,66 @@ void lttvwindowtraces_background_notify_remove(gpointer owner) /* Background processing helper functions */ void lttvwindowtraces_add_computation_hooks(LttvAttributeName module_name, - LttvTracesetContext *tsc) + LttvTracesetContext *tsc, + LttvHooks *hook_adder) +{ + LttvAttribute *g_attribute = lttv_global_attributes(); + LttvAttribute *module_attribute; + LttvAttributeType type; + LttvAttributeValue value; + + + g_assert(module_attribute = + LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(g_attribute), + LTTV_COMPUTATION))); + + g_assert(module_attribute = + LTTV_ATTRIBUTE(lttv_iattribute_find_subdir( + LTTV_IATTRIBUTE(module_attribute), + module_name))); + + /* 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; + + g_assert(module_attribute = + LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(g_attribute), + LTTV_COMPUTATION))); + + g_assert(module_attribute = + LTTV_ATTRIBUTE(lttv_iattribute_find_subdir( + LTTV_IATTRIBUTE(module_attribute), + module_name))); + + /* 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; @@ -589,27 +691,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); - } - - - 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) + + + +void lttvwindowtraces_call_after_chunk(LttvAttributeName module_name, + LttvTracesetContext *tsc) { LttvAttribute *g_attribute = lttv_global_attributes(); LttvAttribute *module_attribute; @@ -673,13 +766,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); - } } @@ -799,7 +885,9 @@ 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; LttvAttributeValue value; LttvAttributeType type; @@ -848,10 +936,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; @@ -867,8 +960,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 */ @@ -908,9 +1001,31 @@ gboolean lttvwindowtraces_process_pending_requests(LttvTrace *trace) while(iter != NULL) { BackgroundRequest *bg_req = (BackgroundRequest*)iter->data; - /*- add hooks to context*/ + /* - set hooks'in_progress flag to TRUE */ lttvwindowtraces_set_in_progress(bg_req->module_name, bg_req->trace); + + /* - call before request hook */ + /* Get before request hook */ + LttvAttribute *module_attribute; + + g_assert(module_attribute = + LTTV_ATTRIBUTE(lttv_iattribute_find_subdir( + LTTV_IATTRIBUTE(g_attribute), + LTTV_COMPUTATION))); + + g_assert(module_attribute = + LTTV_ATTRIBUTE(lttv_iattribute_find_subdir( + LTTV_IATTRIBUTE(module_attribute), + bg_req->module_name))); + + type = lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(module_attribute), + LTTV_BEFORE_REQUEST, + &value); + g_assert(type == LTTV_POINTER); + LttvHooks *before_request = (LttvHooks*)*(value.v_pointer); + + if(before_request != NULL) lttv_hooks_call(before_request, tsc); iter = g_slist_next(iter); } @@ -951,6 +1066,24 @@ 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); + } + + } { @@ -960,18 +1093,17 @@ gboolean lttvwindowtraces_process_pending_requests(LttvTrace *trace) 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, + lttvwindowtraces_call_before_chunk(bg_req->module_name, tsc); iter = g_slist_next(iter); } } - } + } /* 2. call process traceset middle for a chunk */ { /*(assert list_in is not empty! : should not even be called in that case)*/ - LttTime end = { G_MAXUINT, G_MAXUINT }; + LttTime end = ltt_time_infinite; g_assert(g_slist_length(*list_in) != 0); lttv_process_traceset_middle(tsc, end, CHUNK_NUM_EVENTS, NULL); @@ -987,8 +1119,7 @@ gboolean lttvwindowtraces_process_pending_requests(LttvTrace *trace) 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, + lttvwindowtraces_call_after_chunk(bg_req->module_name, tsc); iter = g_slist_next(iter); } @@ -1047,7 +1178,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; @@ -1064,6 +1212,27 @@ gboolean lttvwindowtraces_process_pending_requests(LttvTrace *trace) /* - set hooks'ready flag to TRUE */ lttvwindowtraces_set_ready(bg_req->module_name, bg_req->trace); + /* - call after request hook */ + /* Get after request hook */ + LttvAttribute *module_attribute; + + g_assert(module_attribute = + LTTV_ATTRIBUTE(lttv_iattribute_find_subdir( + LTTV_IATTRIBUTE(g_attribute), + LTTV_COMPUTATION))); + + g_assert(module_attribute = + LTTV_ATTRIBUTE(lttv_iattribute_find_subdir( + LTTV_IATTRIBUTE(module_attribute), + bg_req->module_name))); + + 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); + + if(after_request != NULL) lttv_hooks_call(after_request, tsc); /* - remove request */ remove = TRUE; free_data = TRUE; @@ -1111,12 +1280,21 @@ gboolean lttvwindowtraces_process_pending_requests(LttvTrace *trace) } } } - - /* - return FALSE (scheduler stopped) */ - 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; + { + /* - reset the context */ + LTTV_TRACESET_CONTEXT_GET_CLASS(tsc)->fini(tsc); + LTTV_TRACESET_CONTEXT_GET_CLASS(tsc)->init(tsc,ts); + } + /* - if list_out is empty */ + if(g_slist_length(*list_out) == 0) { + /* - return FALSE (scheduler stopped) */ + 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; + } } else { /* 3.4 else, end of trace not reached */ /* - return TRUE (scheduler still registered) */ @@ -1127,7 +1305,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; @@ -1354,6 +1533,7 @@ void lttvwindowtraces_unregister_computation_hooks { LttvAttribute *g_attribute = lttv_global_attributes(); LttvAttribute *attribute; + LttvAttributeValue value; g_assert(attribute = LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(g_attribute), @@ -1363,6 +1543,103 @@ void lttvwindowtraces_unregister_computation_hooks module_name))); + g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + LTTV_BEFORE_CHUNK_TRACESET, + LTTV_POINTER, + &value)); + LttvHooks *before_chunk_traceset = (LttvHooks*)*(value.v_pointer); + if(before_chunk_traceset != NULL) + lttv_hooks_destroy(before_chunk_traceset); + + g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + LTTV_BEFORE_CHUNK_TRACE, + LTTV_POINTER, + &value)); + LttvHooks *before_chunk_trace = (LttvHooks*)*(value.v_pointer); + if(before_chunk_trace != NULL) + lttv_hooks_destroy(before_chunk_trace); + + g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + LTTV_BEFORE_CHUNK_TRACEFILE, + LTTV_POINTER, + &value)); + LttvHooks *before_chunk_tracefile = (LttvHooks*)*(value.v_pointer); + if(before_chunk_tracefile != NULL) + lttv_hooks_destroy(before_chunk_tracefile); + + g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + LTTV_AFTER_CHUNK_TRACESET, + LTTV_POINTER, + &value)); + LttvHooks *after_chunk_traceset = (LttvHooks*)*(value.v_pointer); + if(after_chunk_traceset != NULL) + lttv_hooks_destroy(after_chunk_traceset); + + g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + LTTV_AFTER_CHUNK_TRACE, + LTTV_POINTER, + &value)); + LttvHooks *after_chunk_trace = (LttvHooks*)*(value.v_pointer); + if(after_chunk_trace != NULL) + lttv_hooks_destroy(after_chunk_trace); + + g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + LTTV_AFTER_CHUNK_TRACEFILE, + LTTV_POINTER, + &value)); + LttvHooks *after_chunk_tracefile = (LttvHooks*)*(value.v_pointer); + if(after_chunk_tracefile != NULL) + lttv_hooks_destroy(after_chunk_tracefile); + + g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + LTTV_BEFORE_REQUEST, + LTTV_POINTER, + &value)); + LttvHooks *before_request = (LttvHooks*)*(value.v_pointer); + if(before_request != NULL) + lttv_hooks_destroy(before_request); + + g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + LTTV_AFTER_REQUEST, + LTTV_POINTER, + &value)); + LttvHooks *after_request = (LttvHooks*)*(value.v_pointer); + if(after_request != NULL) + lttv_hooks_destroy(after_request); + + g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + LTTV_EVENT_HOOK, + LTTV_POINTER, + &value)); + LttvHooks *event_hook = (LttvHooks*)*(value.v_pointer); + if(event_hook != NULL) + lttv_hooks_destroy(event_hook); + + g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + LTTV_EVENT_HOOK_BY_ID, + LTTV_POINTER, + &value)); + LttvHooksById *event_hook_by_id = (LttvHooksById*)*(value.v_pointer); + if(event_hook_by_id != NULL) + lttv_hooks_by_id_destroy(event_hook_by_id); + + g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + LTTV_HOOK_ADDER, + LTTV_POINTER, + &value)); + LttvHooks *hook_adder = (LttvHooks*)*(value.v_pointer); + if(hook_adder != NULL) + lttv_hooks_destroy(hook_adder); + + g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + LTTV_HOOK_REMOVER, + LTTV_POINTER, + &value)); + LttvHooks *hook_remover = (LttvHooks*)*(value.v_pointer); + if(hook_remover != NULL) + lttv_hooks_destroy(hook_remover); + + lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute), LTTV_EVENT_HOOK_BY_ID); lttv_iattribute_remove_by_name(LTTV_IATTRIBUTE(attribute),