running_process = *(value.v_pointer);
g_free(running_process);
- /* free cpu resource states */
+ /* free cpu resources */
type = lttv_attribute_get_by_name(container, LTTV_STATE_RESOURCE_CPUS_COUNT, &value);
g_assert(type == LTTV_UINT);
nb_cpus = *value.v_uint;
cpu = lttv_traceset_get_cpuid_from_event(event);
ts = event->state;
process = ts->running_process[cpu];
- pid_out = lttv_event_get_long_unsigned(event, "prev_tid");
- pid_in = lttv_event_get_long_unsigned(event, "next_tid");
+ pid_out = lttv_event_get_long(event, "prev_tid");
+ pid_in = lttv_event_get_long(event, "next_tid");
state_out = lttv_event_get_long(event, "prev_state");
strncpy(next_comm, lttv_event_get_string(event, "next_comm"), 20);
gint lttv_state_hook_remove_event_hooks(void *hook_data, void *call_data)
{
- //TODO ybrosseau 2012-05-11 Reactivate the remove
-#if 0
- LttvTracesetState *tss = (LttvTracesetState*)(call_data);
- lttv_state_remove_event_hooks(tss);
-#endif
+ LttvTraceset *traceset = (LttvTraceset*)(call_data);
+
+ lttv_state_remove_event_hooks(traceset);
+
return 0;
}
-#if 0
-void lttv_state_remove_event_hooks(LttvTracesetState *self)
+
+void lttv_state_remove_event_hooks(LttvTraceset *traceset)
{
- LttvTraceset *traceset = self->parent.ts;
guint i, j, k, nb_trace, nb_tracefile;
- LttvTraceState *ts;
+ //LttvTraceState *ts;
- LttvTracefileState *tfs;
+ //GArray *hooks;
- GArray *hooks;
+ //LttvTraceHook *th;
- LttvTraceHook *th;
+ //LttvAttributeValue val;
- LttvAttributeValue val;
+ LttvHooks*event_hook;
+ //TODO ybrosseau 2012-07-17 validate this. Reversed what's done in the add
+ event_hook = lttv_traceset_get_hooks(traceset);
+ g_assert(event_hook);
+
+
+ lttv_hooks_remove(event_hook,syscall_entry );
+ lttv_hooks_remove(event_hook,syscall_exit);
+ lttv_hooks_remove(event_hook,irq_entry );
+ lttv_hooks_remove(event_hook,irq_exit );
+ lttv_hooks_remove(event_hook,soft_irq_raise);
+ lttv_hooks_remove(event_hook,soft_irq_entry);
+ lttv_hooks_remove(event_hook,soft_irq_exit);
+ lttv_hooks_remove(event_hook,schedchange);
+ lttv_hooks_remove(event_hook,sched_try_wakeup);
+ lttv_hooks_remove(event_hook,process_exit);
+ lttv_hooks_remove(event_hook,process_free);
+ lttv_hooks_remove(event_hook,process_exec);
+ lttv_hooks_remove(event_hook,enum_process_state);
+ lttv_hooks_remove(event_hook,statedump_end);
+ lttv_hooks_remove(event_hook,enum_interrupt);
+#ifdef BABEL_CLEANUP
nb_trace = lttv_traceset_number(traceset);
for(i = 0 ; i < nb_trace ; i++) {
- ts = LTTV_TRACE_STATE(self->parent.traces[i]);
+ ts = lttv_traceset_get(i);
lttv_attribute_find(ts->parent.a, LTTV_STATE_HOOKS, LTTV_POINTER, &val);
hooks = *(val.v_pointer);
lttv_trace_hook_remove_all(&hooks);
g_array_free(hooks, TRUE);
}
-}
#endif
-#ifdef BABEL_CLEANUP
+}
+
+
static gboolean state_save_event_hook(void *hook_data, void *call_data)
{
guint *event_count = (guint*)hook_data;
else
*event_count = 0;
- LttvTracefileState *self = (LttvTracefileState *)call_data;
+ LttvEvent *event = (LttvEvent *)call_data;
- LttvTraceState *tcs = (LttvTraceState *)(self->parent.t_context);
+ LttvTraceset *traceset = lttv_trace_get_traceset(event->state->trace);
LttvAttribute *saved_states_tree, *saved_state_tree;
LttvAttributeValue value;
+ LttTime currentTime;
+ guint i;
+ currentTime = lttv_event_get_timestamp(event);
+ int nb_trace = lttv_traceset_number(traceset);
+ for(i = 0 ; i < nb_trace ; i++) {
- saved_states_tree = lttv_attribute_find_subdir(tcs->parent.t_a,
- LTTV_STATE_SAVED_STATES);
- saved_state_tree = g_object_new(LTTV_ATTRIBUTE_TYPE, NULL);
- value = lttv_attribute_add(saved_states_tree,
- lttv_attribute_get_number(saved_states_tree), LTTV_GOBJECT);
- *(value.v_gobject) = (GObject *)saved_state_tree;
- value = lttv_attribute_add(saved_state_tree, LTTV_STATE_TIME, LTTV_TIME);
- *(value.v_time) = self->parent.timestamp;
- lttv_state_save(tcs, saved_state_tree);
- g_debug("Saving state at time %lu.%lu", self->parent.timestamp.tv_sec,
- self->parent.timestamp.tv_nsec);
+ LttvTrace *trace = lttv_traceset_get(traceset, i);
+ LttvTraceState *tstate = trace->state;
+ saved_states_tree = lttv_attribute_find_subdir(trace->a,
+ LTTV_STATE_SAVED_STATES);
+
+ saved_state_tree = g_object_new(LTTV_ATTRIBUTE_TYPE, NULL);
+ value = lttv_attribute_add(saved_states_tree,
+ lttv_attribute_get_number(saved_states_tree), LTTV_GOBJECT);
+ *(value.v_gobject) = (GObject *)saved_state_tree;
- *(tcs->max_time_state_recomputed_in_seek) = self->parent.timestamp;
+ value = lttv_attribute_add(saved_state_tree, LTTV_STATE_TIME, LTTV_TIME);
+ *(value.v_time) = currentTime;
+
+ lttv_state_save(tstate, saved_state_tree);
+ g_debug("Saving state at time %lu.%lu", currentTime.tv_sec,
+ currentTime.tv_nsec);
+
+ *(tstate->max_time_state_recomputed_in_seek) = currentTime;
+ }
return FALSE;
}
static gboolean state_save_after_trace_hook(void *hook_data, void *call_data)
{
- LttvTraceState *tcs = (LttvTraceState *)(call_data);
+#warning "Would we move max_time to traceset"
+ LttvTrace *trace = (LttvTrace *)(call_data);
+ LttvTraceState *tcs = trace->state;
+ TimeInterval time_span = lttv_traceset_get_time_span_real(lttv_trace_get_traceset(trace));
- *(tcs->max_time_state_recomputed_in_seek) = tcs->parent.time_span.end_time;
+ *(tcs->max_time_state_recomputed_in_seek) = time_span.end_time;
return FALSE;
}
-
+#ifdef BABEL_CLEANUP
guint lttv_state_current_cpu(LttvTracefileState *tfs)
{
return tfs->cpu;
}
}
#endif //0
-#ifdef BABEL_CLEANUP
-void lttv_state_save_add_event_hooks(LttvTracesetState *self)
+
+void lttv_state_save_add_event_hooks(LttvTraceset *traceset)
{
- LttvTraceset *traceset = self->parent.ts;
guint i, j, nb_trace, nb_tracefile;
LttvTracefileState *tfs;
-
+
+ if(!traceset->has_precomputed_states) {
+ guint *event_count = g_new(guint, 1);
+
+ *event_count = 0;
+ lttv_hooks_add(traceset->event_hooks,
+ state_save_event_hook,
+ event_count,
+ LTTV_PRIO_STATE);
+
+#ifdef BABEL_CLEANUP
nb_trace = lttv_traceset_number(traceset);
for(i = 0 ; i < nb_trace ; i++) {
}
}
-
- lttv_process_traceset_begin(&self->parent,
- NULL, NULL, NULL, NULL, NULL);
+#endif
+ lttv_process_traceset_begin(traceset,
+ NULL, NULL, NULL, NULL, NULL);
+ }
}
gint lttv_state_save_hook_add_event_hooks(void *hook_data, void *call_data)
{
- LttvTracesetState *tss = (LttvTracesetState*)(call_data);
+ LttvTraceset *ts = (LttvTraceset*)(call_data);
- lttv_state_save_add_event_hooks(tss);
+ lttv_state_save_add_event_hooks(ts);
return 0;
}
-#endif
+
#if 0
void lttv_state_save_remove_event_hooks(LttvTracesetState *self)
}
}
#endif //0
-#ifdef BABEL_CLEANUP
-void lttv_state_save_remove_event_hooks(LttvTracesetState *self)
+
+void lttv_state_save_remove_event_hooks(LttvTraceset *traceset)
{
- LttvTraceset *traceset = self->parent.ts;
guint i, j, nb_trace, nb_tracefile;
LttvTracefileState *tfs;
LttvHooks *after_trace = lttv_hooks_new();
+ guint *event_count = NULL;
lttv_hooks_add(after_trace,
state_save_after_trace_hook,
LTTV_PRIO_STATE);
- lttv_process_traceset_end(&self->parent,
- NULL, after_trace, NULL, NULL, NULL);
+ lttv_process_traceset_end(traceset,
+ NULL, after_trace, NULL, NULL);
lttv_hooks_destroy(after_trace);
- nb_trace = lttv_traceset_number(traceset);
+ //nb_trace = lttv_traceset_number(traceset);
+
+ event_count = lttv_hooks_remove(traceset->event_hooks,
+ state_save_event_hook);
+
+ if(event_count) g_free(event_count);
+
+#ifdef BABEL_CLEANUP
for(i = 0 ; i < nb_trace ; i++) {
ts = (LttvTraceState *)self->parent.traces[i];
}
if(event_count) g_free(event_count);
}
+#endif
}
gint lttv_state_save_hook_remove_event_hooks(void *hook_data, void *call_data)
{
- LttvTracesetState *tss = (LttvTracesetState*)(call_data);
+ LttvTraceset *ts = (LttvTraceset*)(call_data);
- lttv_state_save_remove_event_hooks(tss);
+ lttv_state_save_remove_event_hooks(ts);
return 0;
}
-void lttv_state_traceset_seek_time_closest(LttvTracesetState *self, LttTime t)
+
+void lttv_state_traceset_seek_time(LttvTraceset *traceset, LttTime t)
{
- LttvTraceset *traceset = self->parent.ts;
+ lttv_state_traceset_seek_time_closest(traceset,
+ t);
+ lttv_process_traceset_middle(traceset, t, G_MAXUINT,
+ NULL);
+}
+void lttv_state_traceset_seek_position(LttvTraceset *traceset, LttvTracesetPosition *position)
+{
+ LttTime t = lttv_traceset_position_get_time(position);
+
+ lttv_state_traceset_seek_time_closest(traceset,
+ t);
+ lttv_process_traceset_middle(traceset,
+ ltt_time_infinite,
+ G_MAXUINT,
+ position);
+}
+
+void lttv_state_traceset_seek_time_closest(LttvTraceset *traceset, LttTime t)
+{
guint i, nb_trace;
int min_pos, mid_pos, max_pos;
guint call_rest = 0;
-
- LttvTraceState *tcs;
+ guint resto_start = 0;
+ guint resto_at = 0;
LttvAttributeValue value;
gboolean is_named;
LttvAttribute *saved_states_tree, *saved_state_tree, *closest_tree = NULL;
+
+ LttTime closest_tree_time, restored_time;
//g_tree_destroy(self->parent.pqueue);
//self->parent.pqueue = g_tree_new(compare_tracefile);
nb_trace = lttv_traceset_number(traceset);
for(i = 0 ; i < nb_trace ; i++) {
- tcs = (LttvTraceState *)self->parent.traces[i];
- if(ltt_time_compare(t, *(tcs->max_time_state_recomputed_in_seek)) < 0) {
- saved_states_tree = lttv_attribute_find_subdir(tcs->parent.t_a,
+ LttvTrace *trace = lttv_traceset_get(traceset, i);
+ LttvTraceState *tstate = trace->state;
+
+ if(ltt_time_compare(t, *(tstate->max_time_state_recomputed_in_seek)) < 0) {
+ saved_states_tree = lttv_attribute_find_subdir(trace->a,
LTTV_STATE_SAVED_STATES);
min_pos = -1;
if(ltt_time_compare(*(value.v_time), t) < 0) {
min_pos = mid_pos;
closest_tree = saved_state_tree;
+ closest_tree_time = *(value.v_time);
}
else max_pos = mid_pos - 1;
/* restore the closest earlier saved state */
if(min_pos != -1) {
- lttv_state_restore(tcs, closest_tree);
- call_rest = 1;
+ if(ltt_time_compare(restored_time, closest_tree_time) == 0) {
+
+ lttv_state_restore(tstate, closest_tree);
+
+ restored_time = closest_tree_time;
+ call_rest = 1;
+ } else {
+ g_debug("State: restored time mismatch between traces");
+ resto_start = 1;
+ break;
+ }
+
}
/* There is no saved state, yet we want to have it. Restart at T0 */
else {
- restore_init_state(tcs);
- lttv_process_trace_seek_time(&(tcs->parent), ltt_time_zero);
+ resto_start = 1;
+ break;
}
}
/* We want to seek quickly without restoring/updating the state */
else {
- restore_init_state(tcs);
- lttv_process_trace_seek_time(&(tcs->parent), t);
+ resto_at = 1;
+ break;
}
}
- if(!call_rest) g_info("NOT Calling restore");
+
+ if(resto_start || resto_at) {
+ // Restore init state and seek so
+ for(i = 0 ; i < nb_trace ; i++) {
+
+ LttvTrace *trace = lttv_traceset_get(traceset, i);
+ LttvTraceState *tstate = trace->state;
+
+ restore_init_state(tstate);
+ }
+
+ // If t > max saved state
+ if(resto_at) {
+ lttv_process_traceset_seek_time(traceset, t);
+ } else if (resto_start) {
+ // If no saved state
+ lttv_process_traceset_seek_time(traceset, ltt_time_zero);
+ } else {
+ g_assert(FALSE);
+ }
+ g_info("NOT Calling restore");
+
+ } else {
+ // Seek at checkpoint
+ lttv_process_traceset_seek_time(traceset, restored_time);
+
+
+ }
+
+
}
-#endif
+
#ifdef BABEL_CLEANUP
static void traceset_state_instance_init (GTypeInstance *instance, gpointer g_class)
{
#include <lttv/module.h>
#include <lttv/iattribute.h>
#include <lttv/traceset.h>
+#include <lttv/state.h>
#ifdef BABEL_CLEANUP
#include <lttv/stats.h>
#include <lttv/sync/sync_chain_lttv.h>
}
lttv_state_add_event_hooks(traceset);
+ //TODO ybrosseau 2012-08-03 Temporarly compute checkpoints right at the adding
+ // of the traceset
+ //Compute the traceset state checkpoint
+ {
+
+ EventsRequest *events_request = g_new(EventsRequest, 1);
+
+ LttvHooks *hook_adder = lttv_hooks_new();
+ lttv_hooks_add(hook_adder, lttv_state_save_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);
+
+ // Fill the events request
+ events_request->owner = NULL;
+ events_request->viewer_data = NULL;
+ events_request->servicing = FALSE;
+ events_request->start_time = ltt_time_zero;
+ events_request->start_position = NULL;
+ events_request->stop_flag = FALSE;
+ events_request->end_time = ltt_time_infinite;
+ events_request->num_events = G_MAXUINT;
+ events_request->end_position = NULL;
+ events_request->trace = 1; //fixed /* FIXME */
+ events_request->before_chunk_traceset = NULL;
+ events_request->before_chunk_trace = NULL;
+ events_request->before_chunk_tracefile = NULL;
+ events_request->event = traceset->event_hooks;
+ events_request->after_chunk_tracefile = NULL;
+ events_request->after_chunk_trace = NULL;
+ events_request->after_chunk_traceset = NULL;
+ events_request->before_request = hook_adder;
+ events_request->after_request = hook_remover;
+
+ lttvwindow_events_request(tab, events_request);
+ }
+
/* Finally, call the update hooks of the viewers */
gint retval = update_traceset(tab, traceset);
/* - Seek to that time */
g_debug("SEEK TIME : %lu, %lu", events_request->start_time.tv_sec,
events_request->start_time.tv_nsec);
- //lttv_process_traceset_seek_time(tsc, events_request->start_time);
- lttv_process_traceset_seek_time(ts,
+ lttv_state_traceset_seek_time_closest(ts,
events_request->start_time);
/* Process the traceset with only state hooks */
} else {
- //LttTime pos_time;
+ LttTime pos_time;
//LttvTracefileContext *tfc =
// lttv_traceset_context_get_current_tfc(tsc);
/* Else, the first request in list_in is a position request */
/* 1.2.2.1 Seek to that position */
g_debug("SEEK POSITION");
//lttv_process_traceset_seek_position(tsc, events_request->start_position);
- //pos_time = lttv_traceset_position_get_time(
- // events_request->start_position);
- //
- //lttv_state_traceset_seek_time(ts,
- // pos_time);
- lttv_traceset_seek_to_position( events_request->start_position);
+ pos_time = lttv_traceset_position_get_time(
+ events_request->start_position);
+
+ lttv_state_traceset_seek_time_closest(ts,
+ pos_time);
+ //lttv_traceset_seek_to_position( events_request->start_position);
/* Process the traceset with only state hooks */
#ifdef DEBUG
/* 5. After process traceset middle */
LttTime curTime = lttv_traceset_get_current_time(ts);
- /* - if current context time > traceset.end time */
- if(ltt_time_compare(curTime,
- lttv_traceset_get_time_span_real(ts).end_time) > 0) {
+ /* - if the iterator is not valid anymore (got to the end) */
+ if(bt_ctf_iter_read_event(ts->iter) == NULL) {
/* - For each req in list_in */
GSList *iter = list_in;
LttTime new_time = lttv_traceset_position_get_time(pos);
/* Put the context in a state coherent position */
-#ifdef BABEL_CLEANUP
- lttv_state_traceset_seek_time_closest((LttvTracesetState*)tsc, ltt_time_zero);
-#endif /* BABEL_CLEANUP */
+
+ lttv_state_traceset_seek_time_closest(tab->traceset_info->traceset, ltt_time_zero);
+
current_time_change_manager(tab, new_time);
set_current_position(tab, pos);