static void lttv_trace_option(void __UNUSED__ *hook_data)
{
+#ifdef BABEL_CLEANUP
LttTrace *trace;
trace = ltt_trace_open(a_trace);
} else {
lttv_traceset_add(traceset, lttv_trace_new(trace));
}
+#endif
+
+ if(lttv_traceset_add_path(traceset, a_trace) < 0) {
+ g_critical("cannot open trace %s", a_trace);
+ }
}
static double get_time()
fclose(fp);
}
+// TODO mdenis: adapt to babeltrace
static gboolean process_traceset(void __UNUSED__ *hook_data,
void __UNUSED__ *call_data)
{
//guint i, j, count, nb_control, nb_tracefile, nb_block, nb_event, nb_equal;
guint i, j, count;
- LttTrace *trace;
-
LttTime max_time = { G_MAXULONG, G_MAXULONG };
+#ifdef BABEL_CLEANUP
+ LttTrace *trace;
+
a_event_position = ltt_event_position_new();
GData **tracefiles_groups;
}
}
+#endif
tscs = g_object_new(LTTV_TRACESET_STATS_TYPE, NULL);
ts = &tscs->parent;
for(i = 0 ; i < nb ; i++) {
trace = lttv_traceset_get(traceset, i);
lttv_traceset_remove(traceset,i);
+#ifdef BABEL_CLEANUP
ltt_trace_close(lttv_trace(trace));
lttv_trace_destroy(trace);
+#endif
}
lttv_traceset_destroy(traceset);
init((LttvTracesetContext *)self, ts);
nb_trace = lttv_traceset_number(ts);
+
+#ifdef BABEL_CLEANUP
for(i = 0 ; i < nb_trace ; i++) {
tc = self->parent.traces[i];
tcs = LTTV_TRACE_STATE(tc);
/* See if the trace has saved states */
state_load_saved_states(tcs);
}
+#endif
}
static void fini(LttvTracesetState *self)
{
+#ifdef BABEL_CLEANUP
guint i, nb_trace;
LttvTraceState *tcs;
tcs->processes = NULL;
tcs->usertraces = NULL;
}
+#endif
LTTV_TRACESET_CONTEXT_CLASS(g_type_class_peek(LTTV_TRACESET_CONTEXT_TYPE))->
fini((LttvTracesetContext *)self);
}
void lttv_traceset_context_compute_time_span(LttvTracesetContext *self,
TimeInterval *time_span)
{
+ //todo mdenis: adapt to babeltrace
+#ifdef BABEL_CLEANUP
LttvTraceset * traceset = self->ts;
int numTraces = lttv_traceset_number(traceset);
int i;
for(i=0; i<numTraces;i++){
tc = self->traces[i];
+
trace = tc->t;
ltt_trace_time_span_get(trace, &s, &e);
time_span->end_time = e;
}
}
+#endif
}
static void init_tracefile_context(LttTracefile *tracefile,
&begin_pos,
NULL);
self->event_hooks = lttv_hooks_new();
-#ifdef BABEL_CLEANUP
for(i = 0 ; i < nb_trace ; i++) {
tc = LTTV_TRACESET_CONTEXT_GET_CLASS(self)->new_trace_context(self);
self->traces[i] = tc;
tc->ts_context = self;
tc->index = i;
tc->vt = lttv_traceset_get(ts, i);
+#ifdef BABEL_CLEANUP
tc->t = lttv_trace(tc->vt);
+#endif
tc->a = g_object_new(LTTV_ATTRIBUTE_TYPE, NULL);
tc->t_a = lttv_trace_attribute(tc->vt);
tc->tracefiles = g_array_sized_new(FALSE, TRUE,
sizeof(LttvTracefileContext*), 10);
+#ifdef BABEL_CLEANUP
tracefiles_groups = ltt_trace_get_tracefiles_groups(tc->t);
if(tracefiles_groups != NULL) {
args.func = (ForEachTraceFileFunc)init_tracefile_context;
(GDataForeachFunc)compute_tracefile_group,
&args);
}
+#endif
}
-#endif
self->sync_position = lttv_traceset_context_position_new(self);
self->pqueue = g_tree_new(compare_tracefile);
lttv_process_traceset_seek_time(self, ltt_time_zero);
*/
void lttv_process_trace_seek_time(LttvTraceContext *self, LttTime start)
{
-
-
-#ifdef BABEL_CLEANUP
guint i, nb_tracefile;
gint ret;
g_debug("test tree after seek_time");
g_tree_foreach(pqueue, test_tree, NULL);
#endif //DEBUG
-#endif
}
/****************************************************************************
struct _LttvTrace {
- LttTrace *t;
+ // Trace id for babeltrace
+ gint id;
LttvAttribute *a;
guint ref_count;
};
-
LttvTraceset *lttv_traceset_new()
{
LttvTraceset *s;
return s->filename;
}
-LttvTrace *lttv_trace_new(LttTrace *t)
+#ifdef BABEL_CLEANUP
+LttvTrace *lttv_trace_new(LttTrace *t)
{
LttvTrace *new_trace;
new_trace = g_new(LttvTrace, 1);
new_trace->a = g_object_new(LTTV_ATTRIBUTE_TYPE, NULL);
- new_trace->t = t;
+ new_trace->id = t;
new_trace->ref_count = 0;
return new_trace;
}
+#endif
+/*
+ * lttv_trace_create : Create a trace from a path
+ *
+ * ts is the traceset in which will be contained the trace
+ *
+ * path is the path where to find a trace. It is not recursive.
+ *
+ * This function is static since a trace should always be contained in a
+ * traceset.
+ *
+ * return the created trace or NULL on failure
+ */
+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;
+
+ 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;
+ return new_trace;
+}
+
+/*
+ * lttv_trace_create : Create and add a single trace to a traceset
+ *
+ * ts is the traceset in which will be contained the trace
+ *
+ * path is the path where to find a trace. It is not recursive.
+ *
+ * return a positive integer (>=0)on success or -1 on failure
+ */
+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;
+}
LttvTraceset *lttv_traceset_copy(LttvTraceset *s_orig)
{
for(i=0;i<s->traces->len;i++) {
LttvTrace *trace = g_ptr_array_index(s->traces, i);
lttv_trace_unref(trace);
+ // todo mdenis 2012-03-27: uncomment when babeltrace gets fixed
+ //bt_context_remove_trace(lttv_traceset_get_context(s), trace->id);
if(lttv_trace_get_ref_number(trace) == 0)
lttv_trace_destroy(trace);
}
g_ptr_array_add(s->traces, t);
}
+int lttv_traceset_add_path(LttvTraceset *ts, const char *trace_path)
+{
+ // todo mdenis 2012-03-27: add trace recursively and update comment
+ int ret = lttv_traceset_create_trace(ts, trace_path);
+ return ret;
+}
unsigned lttv_traceset_number(LttvTraceset *s)
{
g_assert(s->traces->len > i);
t = (LttvTrace *)s->traces->pdata[i];
t->ref_count--;
+ bt_context_remove_trace(lttv_traceset_get_context(s), t->id);
g_ptr_array_remove_index(s->traces, i);
}
return t->a;
}
-
+#ifdef BABEL_CLEANUP
LttTrace *lttv_trace(LttvTrace *t)
{
return t->t;
}
+#endif
+
+gint lttv_trace_get_id(LttvTrace *t)
+{
+ return t->id;
+}
guint lttv_trace_get_ref_number(LttvTrace * t)
{
+ // todo mdenis: adapt to babeltrace
return t->ref_count;
}
char * lttv_traceset_name(LttvTraceset * s);
+#ifdef BABEL_CLEANUP
LttvTrace *lttv_trace_new(LttTrace *t);
+#endif
LttvTraceset *lttv_traceset_copy(LttvTraceset *s_orig);
void lttv_traceset_add(LttvTraceset *s, LttvTrace *t);
+/*
+ * lttv_traceset_add_path : Add all traces recursively to a traceset
+ *
+ * ts is the traceset in which will be contained the traces
+ *
+ * path is a path to a trace(s). It cannot be NULL and it is not parse
+ * recursively.
+ * todo mdenis: implement algorithm to go through all folders recursively to
+ * find all traces in the path
+ *
+ * @return 0 on success, -1 on failure
+ */
+int lttv_traceset_add_path(LttvTraceset *ts, const char *path);
+
unsigned lttv_traceset_number(LttvTraceset *s);
LttvTrace *lttv_traceset_get(LttvTraceset *s, unsigned i);
LttvAttribute *lttv_trace_attribute(LttvTrace *t);
+#ifdef BABEL_CLEANUP
LttTrace *lttv_trace(LttvTrace *t);
+#endif
guint lttv_trace_get_ref_number(LttvTrace * t);
*event_hook,
*main_hooks;
-static char *a_trace;
+static char *trace_path;
static gboolean a_stats;
static gboolean a_live;
}
if(trace == NULL) g_critical("cannot open trace %s", a_trace);
lttv_traceset_add(traceset, lttv_trace_new(trace));*/
- if(bt_context_add_trace(lttv_traceset_get_context(traceset),
- a_trace,
- "ctf",
- NULL,
- NULL,
- NULL) < 0) {
- printf("Cannot add trace %s", a_trace);
- }
+
+ if(lttv_traceset_add_path(traceset, trace_path) < 0) {
+ printf("Cannot add trace %s", trace_path);
+ }
}
lttv_context_init(tc, traceset);
+#ifdef BABEL_CLEANUP
syncTraceset(tc);
lttv_state_add_event_hooks(tss);
if(a_stats) lttv_stats_add_event_hooks(tscs);
+#endif
retval= lttv_iattribute_find_by_path(attributes, "filter/expression",
LTTV_POINTER, &value_expression);
G_MAXULONG,
NULL);
- updated_count = lttv_process_traceset_update(tc);
+#ifdef BABEL_CLEANUP
+ updated_count = lttv_process_traceset_update(tc);
+#endif
sleep(a_live_update_period);
- } while(count != 0 || updated_count > 0);
+ } while(count != 0
+#ifdef BABEL_CLEANUP
+ || updated_count > 0
+#endif
+ );
//lttv_traceset_context_remove_hooks(tc,
g_info("BatchAnalysis destroy context");
lttv_filter_destroy(*(value_filter.v_pointer));
+#ifdef BABEL_CLEANUP
lttv_state_remove_event_hooks(tss);
if(a_stats) lttv_stats_remove_event_hooks(tscs);
+#endif
lttv_context_fini(tc);
if (a_stats)
g_object_unref(tscs);
lttv_option_add("trace", 't',
"add a trace to the trace set to analyse",
"pathname of the directory containing the trace",
- LTTV_OPT_STRING, &a_trace, lttv_trace_option, NULL);
+ LTTV_OPT_STRING, &trace_path, lttv_trace_option, NULL);
a_stats = FALSE;
lttv_option_add("stats", 's',
static void destroy()
{
+#ifdef BABEL_CLEANUP
guint i, nb;
LttvTrace *trace;
+#endif
g_info("Destroy batchAnalysis.c");
lttv_hooks_destroy(event_hook);
lttv_hooks_remove_data(main_hooks, process_traceset, NULL);
+#ifdef BABEL_CLEANUP
nb = lttv_traceset_number(traceset);
for(i = 0 ; i < nb ; i++) {
trace = lttv_traceset_get(traceset, i);
ltt_trace_close(lttv_trace(trace));
- /* This will be done by lttv_traceset_destroy */
- //lttv_trace_destroy(trace);
+ lttv_trace_destroy(trace);
}
-
+#endif
lttv_traceset_destroy(traceset);
}