#include <lttv/traceset.h>
#include <lttv/iattribute.h>
#include <lttv/state.h>
+#include <lttv/event.h>
#include <lttv/hook.h>
#include <stdio.h>
#include <babeltrace/babeltrace.h>
LttvTraceset *lttv_traceset_new(void)
{
- LttvTraceset *s;
- struct bt_iter_pos begin_pos;
+ LttvTraceset *ts;
+ struct bt_iter_pos begin_pos;
- s = g_new(LttvTraceset, 1);
- s->filename = NULL;
- s->traces = g_ptr_array_new();
- s->context = bt_context_create();
- s->a = g_object_new(LTTV_ATTRIBUTE_TYPE, NULL);
+ ts = g_new(LttvTraceset, 1);
+ ts->filename = NULL;
+ ts->traces = g_ptr_array_new();
+ ts->context = bt_context_create();
+ ts->a = g_object_new(LTTV_ATTRIBUTE_TYPE, NULL);
//TODO remove this when we have really mecanism
//s->tmpState = g_new(LttvTraceState *, 1);
//lttv_trace_state_init(s->tmpState,0);
- s->iter = 0;
- s->event_hooks = lttv_hooks_new();
-
- s->state_trace_handle_index = g_ptr_array_new();
+ /*Initialize iterator to the beginning of the traces*/
+ begin_pos.type = BT_SEEK_BEGIN;
+ ts->iter = bt_ctf_iter_create(ts->context, &begin_pos, NULL);
- return s;
+ ts->event_hooks = lttv_hooks_new();
+
+ ts->state_trace_handle_index = g_ptr_array_new();
+
+ return ts;
}
char * lttv_traceset_name(LttvTraceset * s)
*/
static LttvTrace *lttv_trace_create(LttvTraceset *ts, const char *path)
{
- int id = bt_context_add_trace(lttv_traceset_get_context(ts),
- path,
- "ctf",
- NULL,
- NULL,
- NULL);
- if (id < 0) {
- return NULL;
- }
- // Create the trace and save the trace handle id returned by babeltrace
- LttvTrace *new_trace;
+ int id = bt_context_add_trace(lttv_traceset_get_context(ts),
+ path,
+ "ctf",
+ NULL,
+ NULL,
+ NULL);
+ if (id < 0) {
+ return NULL;
+ }
+ // Create the trace and save the trace handle id returned by babeltrace
+ LttvTrace *new_trace;
- new_trace = g_new(LttvTrace, 1);
- new_trace->a = g_object_new(LTTV_ATTRIBUTE_TYPE, NULL);
- new_trace->id = id;
- new_trace->ref_count = 0;
- new_trace->traceset = ts;
- new_trace->state = g_new(LttvTraceState,1);
- lttv_trace_state_init(new_trace->state,new_trace);
+ new_trace = g_new(LttvTrace, 1);
+ new_trace->a = g_object_new(LTTV_ATTRIBUTE_TYPE, NULL);
+ new_trace->id = id;
+ new_trace->ref_count = 0;
+ new_trace->traceset = ts;
+ new_trace->state = g_new(LttvTraceState,1);
+ lttv_trace_state_init(new_trace->state,new_trace);
- /* Add the state to the trace_handle to state index */
- g_ptr_array_set_size(ts->state_trace_handle_index,id+1);
- g_ptr_array_index(ts->state_trace_handle_index,id) = new_trace->state;
+ /* Add the state to the trace_handle to state index */
+ g_ptr_array_set_size(ts->state_trace_handle_index,id+1);
+ g_ptr_array_index(ts->state_trace_handle_index,id) = new_trace->state;
- return new_trace;
+ return new_trace;
}
/*
*/
static int lttv_traceset_create_trace(LttvTraceset *ts, const char *path)
{
- LttvTrace *trace = lttv_trace_create(ts, path);
- if (trace == NULL) {
- return -1;
- }
- lttv_traceset_add(ts, trace);
- return 0;
+ LttvTrace *trace = lttv_trace_create(ts, path);
+ if (trace == NULL) {
+ return -1;
+ }
+ lttv_traceset_add(ts, trace);
+ return 0;
}
LttvTraceset *lttv_traceset_copy(LttvTraceset *s_orig)
int lttv_traceset_add_path(LttvTraceset *ts, char *trace_path)
{
-
FTS *tree;
FTSENT *node;
char * const paths[2] = { trace_path, NULL };
gint lttv_trace_get_id(LttvTrace *t)
{
- return t->id;
+ return t->id;
}
guint lttv_trace_get_ref_number(LttvTrace * t)
traceset_pos = g_new(LttvTracesetPosition, 1);
- /* Check in the new passed */
+ /* Check if the new passed */
if(traceset_pos == NULL) {
return NULL;
}
return traceset_pos;
}
+LttvTracesetPosition *lttv_traceset_create_time_position(LttvTraceset *traceset,
+ LttTime timestamp)
+{
+ LttvTracesetPosition *traceset_pos;
+
+ traceset_pos = g_new(LttvTracesetPosition, 1);
+
+ /* Check if the new passed */
+ if(traceset_pos == NULL) {
+ return NULL;
+ }
+
+ traceset_pos->iter = traceset->iter;
+ traceset_pos->bt_pos = bt_iter_create_time_pos(
+ bt_ctf_get_iter(traceset_pos->iter),
+ ltt_time_to_uint64(timestamp));
+
+ return traceset_pos;
+}
+
void lttv_traceset_destroy_position(LttvTracesetPosition *traceset_pos)
{
bt_iter_free_pos(traceset_pos->bt_pos);
g_free(traceset_pos);
}
-void lttv_traceset_seek_to_position(LttvTracesetPosition *traceset_pos)
+void lttv_traceset_seek_to_position(const LttvTracesetPosition *traceset_pos)
{
- bt_iter_set_pos(traceset_pos->iter, traceset_pos->bt_pos);
+ bt_iter_set_pos(bt_ctf_get_iter(traceset_pos->iter), traceset_pos->bt_pos);
}
guint lttv_traceset_get_cpuid_from_event(LttvEvent *event)
{
- struct definition *scope;
unsigned long timestamp;
unsigned int cpu_id;
if (timestamp == -1ULL) {
return 0;
}
- scope = bt_ctf_get_top_level_scope(ctf_event, BT_STREAM_PACKET_CONTEXT);
+ const struct definition *scope = bt_ctf_get_top_level_scope(ctf_event, BT_STREAM_PACKET_CONTEXT);
if (bt_ctf_field_get_error()) {
return 0;
}
return cpu_id;
}
}
+
+guint64 lttv_traceset_get_timestamp_first_event(LttvTraceset *ts)
+{
+ LttvTracesetPosition begin_position;
+ struct bt_iter_pos pos;
+ begin_position.bt_pos = &pos;
+
+ /* Assign iterator to the beginning of the traces */
+ begin_position.bt_pos->type = BT_SEEK_BEGIN;
+ begin_position.iter = ts->iter;
+
+ return lttv_traceset_position_get_timestamp(&begin_position);
+}
+
/*
* lttv_traceset_get_timestamp_begin : returns the minimum timestamp of
* all the traces in the traceset.
*
*/
-
guint64 lttv_traceset_get_timestamp_begin(LttvTraceset *traceset)
{
- struct bt_context *bt_ctx;
- bt_ctx = lttv_traceset_get_context(traceset);
- guint64 timestamp_min = G_MAXUINT64, timestamp_cur = 0;
- int i;
- int trace_count;
- LttvTrace *currentTrace;
- trace_count = traceset->traces->len;
- if(trace_count == 0)
- timestamp_min = 0;
- else{
- timestamp_min = G_MAXUINT64;
-
- for(i = 0; i < trace_count;i++)
- {
- currentTrace = g_ptr_array_index(traceset->traces,i);
- timestamp_cur = bt_trace_handle_get_timestamp_begin(bt_ctx, currentTrace->id);
- if(timestamp_cur < timestamp_min)
- timestamp_min = timestamp_cur;
- }
- }
- return timestamp_min;
+ struct bt_context *bt_ctx;
+ bt_ctx = lttv_traceset_get_context(traceset);
+ guint64 timestamp_min, timestamp_cur = 0;
+ int i;
+ int trace_count;
+ LttvTrace *currentTrace;
+ trace_count = traceset->traces->len;
+ if(trace_count == 0)
+ timestamp_min = 0;
+ else{
+ timestamp_min = G_MAXUINT64;
+ for(i = 0; i < trace_count;i++)
+ {
+ currentTrace = g_ptr_array_index(traceset->traces,i);
+ timestamp_cur = bt_trace_handle_get_timestamp_begin(bt_ctx,
+ currentTrace->id);
+ if(timestamp_cur < timestamp_min)
+ timestamp_min = timestamp_cur;
+ }
+ }
+ return timestamp_min;
}
/*
*/
guint64 lttv_traceset_get_timestamp_end(LttvTraceset *traceset)
{
- struct bt_context *bt_ctx;
- bt_ctx = lttv_traceset_get_context(traceset);
- guint64 timestamp_max, timestamp_cur = 0;
- int i;
- int trace_count;
- LttvTrace *currentTrace;
- trace_count = traceset->traces->len;
-
- if(trace_count == 0)
- timestamp_max = 1;
- else
- {
- timestamp_max = 0;
- for(i =0; i < trace_count;i++)
- {
- currentTrace = g_ptr_array_index(traceset->traces,i);
- timestamp_cur = bt_trace_handle_get_timestamp_end(bt_ctx, currentTrace->id);
- if(timestamp_cur > timestamp_max)
- timestamp_max = timestamp_cur;
- }
- }
- return timestamp_max;
+ struct bt_context *bt_ctx;
+ bt_ctx = lttv_traceset_get_context(traceset);
+ guint64 timestamp_max, timestamp_cur = 0;
+ int i;
+ int trace_count;
+ LttvTrace *currentTrace;
+ trace_count = traceset->traces->len;
+
+ if(trace_count == 0){
+ timestamp_max = 1;
+ }
+ else{
+ timestamp_max = 0;
+ for(i =0; i < trace_count;i++)
+ {
+ currentTrace = g_ptr_array_index(traceset->traces,i);
+ timestamp_cur = bt_trace_handle_get_timestamp_end(bt_ctx,
+ currentTrace->id);
+ if(timestamp_cur > timestamp_max){
+ timestamp_max = timestamp_cur;
+ }
+ }
+ }
+ return timestamp_max;
+}
+/*
+ * lttv_traceset_get_time_span_real : return a TimeInterval representing the
+ * minimum timestamp dans le maximum timestamp of the traceset.
+ *
+ */
+TimeInterval lttv_traceset_get_time_span_real(LttvTraceset *ts)
+{
+ TimeInterval time_span;
+ time_span.start_time =ltt_time_from_uint64(lttv_traceset_get_timestamp_first_event(ts));
+ time_span.end_time = ltt_time_from_uint64(lttv_traceset_get_timestamp_end(ts));
+ return time_span;
}
/*
TimeInterval lttv_traceset_get_time_span(LttvTraceset *ts)
{
TimeInterval time_span;
- time_span.start_time =ltt_time_from_uint64( lttv_traceset_get_timestamp_begin(ts));
+ time_span.start_time =ltt_time_from_uint64(lttv_traceset_get_timestamp_begin(ts));
time_span.end_time = ltt_time_from_uint64(lttv_traceset_get_timestamp_end(ts));
return time_span;
}
{
return bt_ctf_event_name(event->bt_event);
}
+
+guint64 lttv_traceset_position_get_timestamp(const LttvTracesetPosition *pos)
+{
+ guint64 timestamp = 0;
+ /*We save the current iterator,so we can reassign it after the seek*/
+ LttvTracesetPosition previous_pos;
+ previous_pos.iter = pos->iter;
+ previous_pos.bt_pos = bt_iter_get_pos(bt_ctf_get_iter(pos->iter));
+ /* Seek to the new desired position */
+ lttv_traceset_seek_to_position(pos);
+ /*Read the event*/
+ struct bt_ctf_event *event = bt_ctf_iter_read_event(pos->iter);
+
+ if(event != NULL){
+ timestamp = bt_ctf_get_timestamp_raw(event);
+ }
+ /* Reassign the previously saved position */
+ lttv_traceset_seek_to_position(&previous_pos);
+ return timestamp;
+}
+
+LttTime lttv_traceset_position_get_time(const LttvTracesetPosition *pos)
+{
+ return ltt_time_from_uint64(lttv_traceset_position_get_timestamp(pos));
+}
+
+int lttv_traceset_position_compare(const LttvTracesetPosition *pos1, const LttvTracesetPosition *pos2)
+{
+#warning " TODO :Rename for lttv_traceset_position_equals && Must return COMPARAISON OF THE 2 POSITION && verify if it is the best way to compare position"
+ if(pos1 == NULL || pos2 == NULL){
+ return -1;
+ }
+
+ guint64 timeStampPos1,timeStampPos2;
+ guint cpuId1, cpuId2;
+ LttvEvent event1, event2;
+ int ret;
+
+ timeStampPos1 = lttv_traceset_position_get_timestamp(pos1);
+ timeStampPos2 = lttv_traceset_position_get_timestamp(pos2);
+
+ event1.bt_event = bt_ctf_iter_read_event(pos1->iter);
+ event2.bt_event = bt_ctf_iter_read_event(pos2->iter);
+
+ if(event1.bt_event == NULL || event2.bt_event == NULL){
+ return -1;
+ }
+
+ cpuId1 = lttv_traceset_get_cpuid_from_event(&event1);
+ cpuId2 = lttv_traceset_get_cpuid_from_event(&event2);
+
+ if(timeStampPos1 == timeStampPos2 && cpuId1 == cpuId2){
+ return 0;
+ }
+ else{
+ return 1;
+ }
+}
#include <lttv/lttv.h>
#include <lttv/module.h>
#include <lttv/hook.h>
-#include <lttv/tracecontext.h>
+#include <lttv/traceset.h>
#include <lttv/state.h>
+#ifdef BABEL_CLEANUP
#include <lttv/filter.h>
+#endif //babel_cleanup
#include <lttv/print.h>
#include <lttvwindow/lttvwindow.h>
#include <lttvwindow/lttvwindowtraces.h>
//gboolean show_event_detail(void * hook_data, void * call_data);
gboolean traceset_changed(void * hook_data, void * call_data);
gboolean timespan_changed(void * hook_data, void * call_data);
+#ifdef BABEL_CLEANUP
gboolean filter_changed(void * hook_data, void * call_data);
-
+#endif // babel_cleanup
static void request_background_data(EventViewerData *event_viewer_data);
//! Event Viewer's constructor hook
GtkSettings* gtk_settings = gtk_settings_get_default();
g_object_set(gtk_settings, "gtk-error-bell", FALSE, NULL);
+
LttTime end;
GtkTreeViewColumn *column;
GtkCellRenderer *renderer;
event_viewer_data->tab = tab;
event_viewer_data->ptab = ptab;
GtkWidget *tmp_toolbar_icon;
-
- LttvTracesetContext * tsc =
- lttvwindow_get_traceset_context(event_viewer_data->tab);
-
+ LttvTraceset *ts =lttvwindow_get_traceset(event_viewer_data->tab);
+
event_viewer_data->event_hooks = lttv_hooks_new();
lttv_hooks_add(event_viewer_data->event_hooks,
event_hook,
traceset_changed,event_viewer_data);
lttvwindow_register_timespan_notify(tab,
timespan_changed,event_viewer_data);
+#ifdef BABEL_CLEANUP
lttvwindow_register_filter_notify(tab,
filter_changed, event_viewer_data);
+#endif
lttvwindow_register_redraw_notify(tab,
evd_redraw_notify, event_viewer_data);
-
-
event_viewer_data->scroll_win = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_show (event_viewer_data->scroll_win);
gtk_scrolled_window_set_policy(
GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER);
event_viewer_data->currently_selected_position =
- lttv_traceset_context_position_new(tsc);
+ lttv_traceset_create_position(ts);
event_viewer_data->first_event =
- lttv_traceset_context_position_new(tsc);
+ lttv_traceset_create_position(ts);
event_viewer_data->last_event =
- lttv_traceset_context_position_new(tsc);
-
+ lttv_traceset_create_position(ts);
event_viewer_data->main_win_filter = lttvwindow_get_filter(tab);
event_viewer_data->update_cursor = TRUE;
event_viewer_data->previous_value = 0;
event_viewer_data->vadjust_c->lower = 0.0;
//event_viewer_data->vadjust_c->upper = event_viewer_data->number_of_events;
+
LttTime time = lttvwindow_get_current_time(tab);
- time = ltt_time_sub(time, tsc->time_span.start_time);
+ TimeInterval time_span = lttv_traceset_get_time_span_real(ts);
+ time = ltt_time_sub(time, time_span.start_time);
//TODO ybrosseau 2011-01-06: Which one do we keep?
+#ifdef BABEL_CLEANUP
event_viewer_data->vadjust_c->value = ltt_time_to_double(time);
+#endif //babel_cleanup
event_viewer_data->vadjust_c->value = 0.0;
event_viewer_data->vadjust_c->step_increment = 1.0;
event_viewer_data->vadjust_c->page_increment = 2.0;
//get the life span of the traceset and set the upper of the scroll bar
- TimeInterval time_span = tsc->time_span;
end = ltt_time_sub(time_span.end_time, time_span.start_time);
- event_viewer_data->vadjust_c->upper =
- ltt_time_to_double(end);
+ event_viewer_data->vadjust_c->upper = ltt_time_to_double(end);
/* Set the Selected Event */
// tree_v_set_cursor(event_viewer_data);
request_background_data(event_viewer_data);
-
return event_viewer_data;
}
static void request_background_data(EventViewerData *event_viewer_data)
{
- LttvTracesetContext * tsc =
- lttvwindow_get_traceset_context(event_viewer_data->tab);
- gint num_traces = lttv_traceset_number(tsc->ts);
+ LttvTraceset * ts =
+ lttvwindow_get_traceset(event_viewer_data->tab);
+ gint num_traces = ts->traces->len;
gint i;
LttvTrace *trace;
LttvTraceState *tstate;
lttv_hooks_add(background_ready_hook, background_ready, event_viewer_data,
LTTV_PRIO_DEFAULT);
event_viewer_data->background_info_waiting = 0;
-
+
for(i=0;i<num_traces;i++) {
- trace = lttv_traceset_get(tsc->ts, i);
+ trace = g_ptr_array_index(ts->traces,i);
+#ifdef BABEL_CLEANUP
tstate = LTTV_TRACE_STATE(tsc->traces[i]);
+#endif /*babel_cleanup*/
if(lttvwindowtraces_get_ready(g_quark_from_string("state"),trace)==FALSE
- && !tstate->has_precomputed_states) {
+ /*&& !tstate->has_precomputed_states*/) {
if(lttvwindowtraces_get_in_progress(g_quark_from_string("state"),
trace) == FALSE) {
}
lttv_hooks_destroy(background_ready_hook);
-
}
static gboolean
gint arg2,
gpointer data)
{
+
GtkTreePath *path; // = gtk_tree_path_new();
EventViewerData *event_viewer_data = (EventViewerData*)data;
}
#endif //0
-
+
g_debug("tree view move cursor : arg1 is %u and arg2 is %d",
(guint)arg1, arg2);
if(arg2 == 1) {
/* Move one line down */
if(event_viewer_data->pos->len > 0) {
- LttvTracesetContextPosition *end_pos =
- (LttvTracesetContextPosition*)g_ptr_array_index(
+ LttvTracesetPosition *end_pos =
+ (LttvTracesetPosition*)g_ptr_array_index(
event_viewer_data->pos,
event_viewer_data->pos->len-1);
- if(lttv_traceset_context_pos_pos_compare(end_pos,
+ if(lttv_traceset_position_compare(end_pos,
event_viewer_data->currently_selected_position) == 0) {
/* Must get down one event and select the last one */
gtk_tree_selection_unselect_all(gtk_tree_view_get_selection(
max(0, event_viewer_data->pos->len - 1), -1);
if(path) {
gtk_tree_view_set_cursor(GTK_TREE_VIEW(event_viewer_data->tree_v),
- path, NULL, FALSE);
+ path, NULL, FALSE);
gtk_tree_path_free(path);
}
}
max(0, event_viewer_data->pos->len - 1), -1);
if(path) {
gtk_tree_view_set_cursor(GTK_TREE_VIEW(event_viewer_data->tree_v),
- path, NULL, FALSE);
+ path, NULL, FALSE);
gtk_tree_path_free(path);
}
}
} else {
if(event_viewer_data->pos->len > 0) {
/* Move one line up */
- LttvTracesetContextPosition *begin_pos =
- (LttvTracesetContextPosition*)g_ptr_array_index(
+ LttvTracesetPosition *begin_pos =
+ (LttvTracesetPosition*)g_ptr_array_index(
event_viewer_data->pos,
0);
- if(lttv_traceset_context_pos_pos_compare(begin_pos,
+ if(lttv_traceset_position_compare(begin_pos,
event_viewer_data->currently_selected_position) == 0) {
/* Must get up one event and select the first one */
gtk_tree_selection_unselect_all(gtk_tree_view_get_selection(
if(arg2 == 1) {
/* Move one page down */
if(event_viewer_data->pos->len > 0) {
- LttvTracesetContextPosition *end_pos =
- (LttvTracesetContextPosition*)g_ptr_array_index(
+ LttvTracesetPosition *end_pos =
+ (LttvTracesetPosition*)g_ptr_array_index(
event_viewer_data->pos,
event_viewer_data->pos->len-1);
- if(lttv_traceset_context_pos_pos_compare(end_pos,
+ if(lttv_traceset_position_compare(end_pos,
event_viewer_data->currently_selected_position) == 0) {
/* Must get down one page and select the last one */
gtk_tree_selection_unselect_all(gtk_tree_view_get_selection(
} else {
/* Move one page up */
if(event_viewer_data->pos->len > 0) {
- LttvTracesetContextPosition *begin_pos =
- (LttvTracesetContextPosition*)g_ptr_array_index(
+ LttvTracesetPosition *begin_pos =
+ (LttvTracesetPosition*)g_ptr_array_index(
event_viewer_data->pos,
0);
- if(lttv_traceset_context_pos_pos_compare(begin_pos,
+ if(lttv_traceset_position_compare(begin_pos,
event_viewer_data->currently_selected_position) == 0) {
/* Must get up one page and select the first one */
gtk_tree_selection_unselect_all(gtk_tree_view_get_selection(
default:
break;
}
-
//gtk_tree_path_free(path);
-
#if 0
if(arg1 == GTK_MOVEMENT_DISPLAY_LINES)
{
void tree_v_cursor_changed_cb (GtkWidget *widget, gpointer data)
{
+
EventViewerData *event_viewer_data = (EventViewerData*) data;
+
Tab *tab = event_viewer_data->tab;
GtkTreeIter iter;
GtkTreeModel* model = GTK_TREE_MODEL(event_viewer_data->store_m);
GtkTreePath *path;
- LttvTracesetContextPosition *pos;
+ LttvTracesetPosition *pos;
g_debug("cursor changed cb");
-
+
/* On cursor change, modify the currently selected event by calling
* the right API function */
if(event_viewer_data->report_position) {
if(gtk_tree_model_get_iter(model,&iter,path)){
gtk_tree_model_get(model, &iter, POSITION_COLUMN, &pos, -1);
- if(lttv_traceset_context_pos_pos_compare(pos,
+ if(lttv_traceset_position_compare(pos,
event_viewer_data->currently_selected_position) != 0)
lttvwindow_report_current_position(tab, pos);
}else{
/ (double)cell_height ;
event_viewer_data->num_visible_events = ceil(exact_num_visible) ;
-
-/*
+
event_viewer_data->vadjust_c->page_increment =
- floor(exact_num_visible);
+ floor(exact_num_visible);
event_viewer_data->vadjust_c->page_size =
- floor(exact_num_visible);
-*/
+ floor(exact_num_visible);
+
g_debug("size allocate %p : last_num_visible_events : %d",
event_viewer_data, last_num_visible_events);
static void get_events(double new_value, EventViewerData *event_viewer_data)
{
+#ifdef BABEL_CLEANUP
LttvTracesetStats *tss =
lttvwindow_get_traceset_stats(event_viewer_data->tab);
- LttvTracesetContext *tsc = (LttvTracesetContext*)tss;
+#endif //babel_cleanup
+ LttvTraceset *ts = lttvwindow_get_traceset(event_viewer_data->tab);
guint i;
gboolean seek_by_time;
- int retval;
-
+
if(lttvwindow_preempt_count > 0) return;
double value = new_value - event_viewer_data->previous_value;
-
+
/* Set stop button status for foreground processing */
event_viewer_data->tab->stop_foreground = FALSE;
lttvwindow_events_request_disable();
}
} else direction = SCROLL_NONE; /* 0.0 */
-
switch(direction) {
case SCROLL_STEP_UP:
g_debug("get_events : SCROLL_STEP_UP");
}
LttTime time = ltt_time_from_double(new_value);
- time = ltt_time_add(tsc->time_span.start_time, time);
+ TimeInterval time_span = lttv_traceset_get_time_span_real(ts);
+ time = ltt_time_add(time_span.start_time, time);
+
+ LttvTracesetPosition *timePos = lttv_traceset_create_time_position(ts,time);
+
if(!seek_by_time) {
-
- LttvTracesetContextPosition *pos =
- lttv_traceset_context_position_new(tsc);
-
+
/* Remember the beginning position */
if(event_viewer_data->pos->len > 0) {
- LttvTracesetContextPosition *first_pos =
- (LttvTracesetContextPosition*)g_ptr_array_index(
- event_viewer_data->pos,
- 0);
- lttv_traceset_context_position_copy(pos, first_pos);
-
- if(relative_position >= 0) {
- LttTime first_event_time =
- lttv_traceset_context_position_get_time(
- pos);
- lttv_state_traceset_seek_time_closest((LttvTracesetState*)tsc,
- first_event_time);
- lttv_process_traceset_middle(tsc, ltt_time_infinite,
- G_MAXUINT,
- pos);
-
- } else if(relative_position < 0) {
- retval= lttv_process_traceset_seek_position(tsc, pos);
- g_assert_cmpint(retval, ==, 0);
+
+ if(relative_position != 0)
+ {
+ LttvTracesetPosition *pos = 0;
+ pos = (LttvTracesetPosition*)g_ptr_array_index(
+ event_viewer_data->pos,
+ 0);
+ lttv_traceset_seek_to_position(pos);
}
- } else {
- /* There is nothing in the list : simply seek to the time value. */
- lttv_state_traceset_seek_time_closest((LttvTracesetState*)tsc,
- time);
- lttv_process_traceset_middle(tsc, time, G_MAXUINT,
- NULL);
- }
-
+ }
+
/* Note that, as we mess with the tsc position, this function CANNOT be called
* from a hook inside the lttv_process_traceset_middle. */
/* As the lttvwindow API keeps a sync_position inside the tsc to go back at
/* Get the beginning position of the read (with seek backward or seek forward)
*/
if(relative_position > 0) {
-
- lttv_process_traceset_seek_n_forward(tsc, relative_position,
+ lttv_process_traceset_seek_n_forward(ts, relative_position,
events_check_handler,
&event_viewer_data->tab->stop_foreground,
event_viewer_data->main_win_filter,
event_viewer_data->filter, NULL, event_viewer_data);
} else if(relative_position < 0) {
-
/* Get an idea of currently shown event dispersion */
- LttTime first_event_time =
- lttv_traceset_context_position_get_time(event_viewer_data->first_event);
- LttTime last_event_time =
- lttv_traceset_context_position_get_time(event_viewer_data->last_event);
- LttTime time_diff = ltt_time_sub(last_event_time, first_event_time);
- if(ltt_time_compare(time_diff, ltt_time_zero) == 0)
- time_diff = seek_back_default_offset;
-
- lttv_process_traceset_seek_n_backward(tsc,
- abs(relative_position),
- time_diff,
- (seek_time_fct)lttv_state_traceset_seek_time_closest,
+ guint64 first_event_time_stamp =
+ lttv_traceset_position_get_timestamp(event_viewer_data->first_event);
+ guint64 last_event_time_stamp =
+ lttv_traceset_position_get_timestamp(event_viewer_data->last_event);
+ guint64 timeSpan = (last_event_time_stamp - first_event_time_stamp);
+ gdouble ratio = (gdouble)timeSpan / (gdouble)event_viewer_data->num_visible_events;
+ if(ratio <= 0){
+ ratio = SEEK_BACK_DEFAULT_RATIO;
+ }
+
+ lttv_process_traceset_seek_n_backward(ts,
+ (guint)abs(relative_position),
+ ratio,
events_check_handler,
&event_viewer_data->tab->stop_foreground,
event_viewer_data->main_win_filter,
event_viewer_data->filter, NULL, event_viewer_data);
} /* else 0 : do nothing : we are already at the beginning position */
- lttv_traceset_context_position_destroy(pos);
-
/* Save the first event position */
- lttv_traceset_context_position_save(tsc, event_viewer_data->first_event);
-
- time = lttv_traceset_context_position_get_time(
- event_viewer_data->first_event);
+
+ event_viewer_data->first_event = lttv_traceset_create_position(ts);
+
+ time = ltt_time_from_uint64(lttv_traceset_position_get_timestamp(
+ event_viewer_data->first_event));
//if(ltt_time_compare(time, tsc->time_span.end_time) > 0)
// time = tsc->time_span.end_time;
- LttTime time_val = ltt_time_sub(time,
- tsc->time_span.start_time);
+ LttTime time_val = ltt_time_sub(time,time_span.start_time);
event_viewer_data->previous_value = ltt_time_to_double(time_val);
-
- lttv_state_traceset_seek_time_closest((LttvTracesetState*)tsc, time);
- lttv_process_traceset_middle(tsc, ltt_time_infinite, G_MAXUINT,
- event_viewer_data->first_event);
+
+ lttv_traceset_seek_to_position(event_viewer_data->first_event);
} else {
/* Seek by time */
- lttv_state_traceset_seek_time_closest((LttvTracesetState*)tsc,
- time);
- lttv_process_traceset_middle(tsc, time, G_MAXUINT,
- NULL);
- LttTime time_val = ltt_time_sub(time,
- tsc->time_span.start_time);
+ lttv_traceset_seek_to_position(timePos);
+
+
+ LttTime time_val = ltt_time_sub(time,time_span.start_time);
event_viewer_data->previous_value = ltt_time_to_double(time_val);
- lttv_traceset_context_position_save(tsc, event_viewer_data->first_event);
+ event_viewer_data->first_event = timePos;
}
/* Clear the model (don't forget to free the TCS positions!) */
gtk_list_store_clear(event_viewer_data->store_m);
for(i=0;i<event_viewer_data->pos->len;i++) {
- LttvTracesetContextPosition *cur_pos =
- (LttvTracesetContextPosition*)g_ptr_array_index(event_viewer_data->pos,
+ LttvTracesetPosition *cur_pos =
+ (LttvTracesetPosition*)g_ptr_array_index(event_viewer_data->pos,
i);
- lttv_traceset_context_position_destroy(cur_pos);
+ lttv_traceset_destroy_position(cur_pos);
}
g_ptr_array_set_size(event_viewer_data->pos, 0);
* processing can be stopped.
*/
- lttv_process_traceset_begin(tsc,
- NULL, NULL, NULL, event_viewer_data->event_hooks, NULL);
+ lttv_process_traceset_begin(ts,
+ NULL, NULL, event_viewer_data->event_hooks);
event_viewer_data->num_events = 0;
- lttv_process_traceset_middle(tsc, ltt_time_infinite, G_MAXUINT, NULL);
+ lttv_process_traceset_middle(ts, ltt_time_infinite, G_MAXUINT, NULL);
- lttv_process_traceset_end(tsc,
- NULL, NULL, NULL, event_viewer_data->event_hooks, NULL);
+ lttv_process_traceset_end(ts, NULL, NULL, event_viewer_data->event_hooks);
/* Get the end position */
if(event_viewer_data->pos->len > 0) {
- LttvTracesetContextPosition *cur_pos =
- (LttvTracesetContextPosition*)g_ptr_array_index(event_viewer_data->pos,
+ LttvTracesetPosition *cur_pos =
+ (LttvTracesetPosition*)g_ptr_array_index(event_viewer_data->pos,
event_viewer_data->pos->len - 1);
- lttv_traceset_context_position_copy(event_viewer_data->last_event,
- cur_pos);
+ event_viewer_data->last_event = cur_pos;
} else
- lttv_traceset_context_position_save(tsc, event_viewer_data->last_event);
-
+ event_viewer_data->last_event =lttv_traceset_create_position(ts);
+
gtk_adjustment_set_value(event_viewer_data->vadjust_c,
event_viewer_data->previous_value);
gtk_widget_get_parent_window(event_viewer_data->tree_v));
lttvwindow_events_request_enable();
-
+
return;
}
int event_hook(void *hook_data, void *call_data)
{
+
EventViewerData *event_viewer_data = (EventViewerData*)hook_data;
- LttvTracefileContext *tfc = (LttvTracefileContext*)call_data;
- LttvTracefileState *tfs = (LttvTracefileState*)call_data;
- LttEvent *e = ltt_tracefile_get_event(tfc->tf);
+
+ LttvEvent * e = (LttvEvent *)call_data;
if(event_viewer_data->num_events % CHECK_GDK_INTERVAL == 0) {
GdkEvent *event;
if(event_viewer_data->tab->stop_foreground)
return TRUE;
}
+
event_viewer_data->num_events++;
-
+#ifdef BABEL_CLEANUP
LttvFilter *filter = event_viewer_data->main_win_filter;
if(filter != NULL && filter->head != NULL)
if(!lttv_filter_tree_parse(filter->head,e,tfc->tf,
if(!lttv_filter_tree_parse(filter->head,e,tfc->tf,
tfc->t_context->t,tfc,NULL,NULL))
return FALSE;
-
-
+#endif //babel_cleanup
+
// LttFacility *facility = ltt_event_facility(e);
// LttEventType *event_type = ltt_event_eventtype(e);
- LttTime time = ltt_event_time(e);
+ LttTime time = lttv_event_get_timestamp(e);
+ gint cpu = lttv_traceset_get_cpuid_from_event(e);
+
+ LttvTraceState *traceState = e->state;
+ LttvProcessState *process = traceState->running_process[cpu];
- guint cpu = tfs->cpu;
- LttvTraceState *ts = (LttvTraceState*)tfc->t_context;
- LttvProcessState *process = ts->running_process[cpu];
-
GtkTreeIter iter;
GString *desc = g_string_new("");
- LttvTracesetContextPosition *pos =
- lttv_traceset_context_position_new(tfc->t_context->ts_context);
+ LttvTracesetPosition *pos = lttv_traceset_create_position(traceState->trace->traceset);
- lttv_traceset_context_position_save(tfc->t_context->ts_context, pos);
-
- lttv_event_to_string(e, desc, TRUE, TRUE, (LttvTracefileState*)tfc);
+ lttv_event_to_string(e, desc, TRUE);
g_info("detail : %s", desc->str);
-
+
gtk_list_store_append (event_viewer_data->store_m, &iter);
+
gtk_list_store_set (event_viewer_data->store_m, &iter,
- TRACE_NAME_COLUMN, g_quark_to_string(ltt_trace_name(tfc->t_context->t)),
- TRACEFILE_NAME_COLUMN, g_quark_to_string(ltt_tracefile_name(tfc->tf)),
- CPUID_COLUMN, cpu,
- EVENT_COLUMN, g_quark_to_string(marker_get_info_from_id(tfc->tf->mdata,
- e->event_id)->name),
- TIME_S_COLUMN, time.tv_sec,
- TIME_NS_COLUMN, time.tv_nsec,
- PID_COLUMN, process->pid,
- EVENT_DESCR_COLUMN, desc->str,
- POSITION_COLUMN, pos,
- -1);
+ TRACE_NAME_COLUMN, "TraceName",
+ TRACEFILE_NAME_COLUMN,"TraceFile" /*traceState->trace->traceset->filename*/,
+ CPUID_COLUMN, cpu,
+ EVENT_COLUMN,"EventName" /*bt_ctf_event_name(e->bt_event)*/,
+ TIME_S_COLUMN, time.tv_sec,
+ TIME_NS_COLUMN, time.tv_nsec,
+ PID_COLUMN, process->pid,
+ EVENT_DESCR_COLUMN, desc->str,
+ POSITION_COLUMN, pos,
+ -1);
g_ptr_array_add(event_viewer_data->pos, pos);
g_string_free(desc, TRUE);
if(event_viewer_data->update_cursor) {
- if(lttv_traceset_context_pos_pos_compare(pos,
+ if(lttv_traceset_position_compare(pos,
event_viewer_data->currently_selected_position) == 0) {
GtkTreePath *path = gtk_tree_path_new_from_indices(
event_viewer_data->pos->len - 1, -1);
}
}
}
-
if(event_viewer_data->pos->len >= event_viewer_data->num_visible_events )
return TRUE;
else
return FALSE;
+
}
static void event_update_selection(EventViewerData *event_viewer_data)
{
+
guint i;
GPtrArray *positions = event_viewer_data->pos;
g_info("event_update_selection");
for(i=0;i<positions->len;i++) {
- LttvTracesetContextPosition *cur_pos =
- (LttvTracesetContextPosition*)g_ptr_array_index(positions, i);
- if(lttv_traceset_context_pos_pos_compare(cur_pos,
+ LttvTracesetPosition *cur_pos =
+ (LttvTracesetPosition*)g_ptr_array_index(positions, i);
+ if(lttv_traceset_position_compare(cur_pos,
event_viewer_data->currently_selected_position) == 0) {
GtkTreePath *path = gtk_tree_path_new_from_indices(i, -1);
if(path) {
gtk_tree_view_set_cursor(GTK_TREE_VIEW(event_viewer_data->tree_v),
path, NULL, FALSE);
gtk_tree_path_free(path);
- }
+ break;
+ }
}
- }
+ }
}
static int current_time_get_first_event_hook(void *hook_data, void *call_data)
{
+#ifdef BABEL_CLEANUP
EventViewerData *event_viewer_data = (EventViewerData*)hook_data;
+
LttvTracefileContext *tfc = (LttvTracefileContext*)call_data;
LttEvent *e = ltt_tracefile_get_event(tfc->tf);
lttv_traceset_context_position_save(tfc->t_context->ts_context,
event_viewer_data->current_time_get_first);
return TRUE;
+#endif // BABEL_CLEANUP
+
}
gboolean update_current_time(void * hook_data, void * call_data)
{
+
+ //LttvEvent * e = (LttvEvent *)call_data;
g_info("update_current_time");
EventViewerData *event_viewer_data = (EventViewerData*) hook_data;
+
const LttTime * current_time = (LttTime*)call_data;
- LttvTracesetContext * tsc =
- lttvwindow_get_traceset_context(event_viewer_data->tab);
+ LttvTraceset * ts =
+ lttvwindow_get_traceset(event_viewer_data->tab);
/* If the currently selected event time != current time, set the first event
* with this time as currently selected. */
- LttTime pos_time = lttv_traceset_context_position_get_time(
- event_viewer_data->currently_selected_position);
+ LttTime pos_time = lttv_traceset_position_get_time(
+ event_viewer_data->currently_selected_position);
+
if(ltt_time_compare(pos_time, *current_time) != 0) {
-
- lttv_state_traceset_seek_time_closest((LttvTracesetState*)tsc,
- *current_time);
- lttv_process_traceset_middle(tsc, *current_time, G_MAXUINT,
- NULL);
-
- /* Get the first event that passes in the filter */
- event_viewer_data->current_time_get_first =
- lttv_traceset_context_position_new(tsc);
- LttvHooks *hooks = lttv_hooks_new();
- lttv_hooks_add(hooks,
- current_time_get_first_event_hook,
- event_viewer_data,
- LTTV_PRIO_DEFAULT);
-
- lttv_process_traceset_begin(tsc,
- NULL, NULL, NULL, hooks, NULL);
-
- lttv_process_traceset_middle(tsc, ltt_time_infinite, G_MAXUINT, NULL);
-
- lttv_process_traceset_end(tsc,
- NULL, NULL, NULL, hooks, NULL);
- lttv_hooks_destroy(hooks);
+ /*create position*/
+ LttvTracesetPosition *currentPosition =
+ lttv_traceset_create_time_position(ts,*current_time );
+ /*seek to current position*/
+ lttv_traceset_seek_to_position(currentPosition);
+
+ event_viewer_data->currently_selected_position =
+ lttv_traceset_create_position(ts);
+
- lttv_traceset_context_position_copy(
- event_viewer_data->currently_selected_position,
- event_viewer_data->current_time_get_first);
- lttv_traceset_context_position_destroy(
- event_viewer_data->current_time_get_first);
- pos_time = lttv_traceset_context_position_get_time(
- event_viewer_data->currently_selected_position);
}
- LttTime time = ltt_time_sub(pos_time, tsc->time_span.start_time);
- double new_value = ltt_time_to_double(time);
-
event_viewer_data->report_position = FALSE;
- /* Change the viewed area if does not match */
- if(lttv_traceset_context_pos_pos_compare(
- event_viewer_data->currently_selected_position,
- event_viewer_data->first_event) < 0
- ||
- lttv_traceset_context_pos_pos_compare(
- event_viewer_data->currently_selected_position,
- event_viewer_data->last_event) > 0) {
- gtk_adjustment_set_value(event_viewer_data->vadjust_c, new_value);
- } else {
+
/* Simply update the current time : it is in the list */
- event_update_selection(event_viewer_data);
- }
+ event_update_selection(event_viewer_data);
event_viewer_data->report_position = TRUE;
return FALSE;
gboolean update_current_position(void * hook_data, void * call_data)
{
+
g_info("update_current_position");
EventViewerData *event_viewer_data = (EventViewerData*) hook_data;
- const LttvTracesetContextPosition *current_pos =
- (LttvTracesetContextPosition*)call_data;
- LttvTracesetContext * tsc =
- lttvwindow_get_traceset_context(event_viewer_data->tab);
+ const LttvTracesetPosition *current_pos = (LttvTracesetPosition*)call_data;
- if(lttv_traceset_context_pos_pos_compare(
+ if(lttv_traceset_position_compare(
event_viewer_data->currently_selected_position, current_pos) != 0) {
- lttv_traceset_context_position_copy(
- event_viewer_data->currently_selected_position, current_pos);
-
- /* Change the viewed area if does not match */
- if(lttv_traceset_context_pos_pos_compare(
- event_viewer_data->currently_selected_position,
- event_viewer_data->first_event) < 0
- ||
- lttv_traceset_context_pos_pos_compare(
- event_viewer_data->currently_selected_position,
- event_viewer_data->last_event) > 0) {
- LttTime time = lttv_traceset_context_position_get_time(current_pos);
- time = ltt_time_sub(time, tsc->time_span.start_time);
- double new_value = ltt_time_to_double(time);
- gtk_adjustment_set_value(event_viewer_data->vadjust_c, new_value);
- } else {
+ event_viewer_data->currently_selected_position = current_pos;
/* Simply update the current time : it is in the list */
event_update_selection(event_viewer_data);
}
-
- }
-
-
return FALSE;
+
}
gboolean timespan_changed(void * hook_data, void * call_data)
{
+
EventViewerData *event_viewer_data = (EventViewerData*) hook_data;
- LttvTracesetContext * tsc =
- lttvwindow_get_traceset_context(event_viewer_data->tab);
- TimeInterval time_span = tsc->time_span;
+ LttvTraceset * ts = lttvwindow_get_traceset(event_viewer_data->tab);
+ TimeInterval time_span = lttv_traceset_get_time_span(ts);
LttTime end;
gboolean traceset_changed(void * hook_data, void * call_data)
{
+
EventViewerData *event_viewer_data = (EventViewerData*) hook_data;
- LttvTracesetContext * tsc =
- lttvwindow_get_traceset_context(event_viewer_data->tab);
- TimeInterval time_span = tsc->time_span;
-
+ LttvTraceset * ts = lttvwindow_get_traceset(event_viewer_data->tab);
+ TimeInterval time_span = lttv_traceset_get_time_span(ts);
+
LttTime end;
gtk_list_store_clear(event_viewer_data->store_m);
g_ptr_array_set_size(event_viewer_data->pos, 0);
-
+
end = ltt_time_sub(time_span.end_time, time_span.start_time);
event_viewer_data->vadjust_c->upper = ltt_time_to_double(end);
-
+#ifdef BABEL_CLEANUP
/* Reset the positions */
- lttv_traceset_context_position_destroy(
- event_viewer_data->currently_selected_position);
- lttv_traceset_context_position_destroy(
- event_viewer_data->first_event);
- lttv_traceset_context_position_destroy(
- event_viewer_data->last_event);
+ lttv_traceset_destroy_position(event_viewer_data->currently_selected_position);
+ lttv_traceset_destroy_position(event_viewer_data->first_event);
+ lttv_traceset_destroy_position(event_viewer_data->last_event);
event_viewer_data->currently_selected_position =
- lttv_traceset_context_position_new(tsc);
+ lttv_traceset_create_position(ts);
event_viewer_data->first_event =
- lttv_traceset_context_position_new(tsc);
+ lttv_traceset_create_position(ts);
event_viewer_data->last_event =
- lttv_traceset_context_position_new(tsc);
+ lttv_traceset_create_position(ts);
get_events(event_viewer_data->vadjust_c->value, event_viewer_data);
+#endif //babel_cleanup
// event_viewer_data->vadjust_c->value = 0;
request_background_data(event_viewer_data);
-
+
return FALSE;
}
void gui_events_free(gpointer data)
{
+#ifdef BABEL_CLEANUP
LttvPluginEVD *plugin_evd = (LttvPluginEVD*)data;
Tab *tab = plugin_evd->evd->tab;
EventViewerData *event_viewer_data = plugin_evd->evd;
event_viewer_data);
//g_free(event_viewer_data);
g_object_unref(plugin_evd);
+#endif // BABEL_CLEANUP
}