Correctly display the trace name in the events view.
Only the part different for all the traces is displayed
Signed-off-by: Yannick Brosseau <yannick.brosseau@gmail.com>
ts = g_new(LttvTraceset, 1);
ts->filename = NULL;
+ ts->common_path = NULL;
ts->traces = g_ptr_array_new();
ts->context = bt_context_create();
ts->a = g_object_new(LTTV_ATTRIBUTE_TYPE, NULL);
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;
+ /* Find common path */
+ if (ts->common_path == NULL) {
+ ts->common_path = strdup(path);
+ } else {
+ /* TODO ybrosseau 2013-05-24: consider put that in a function */
+ int i,j;
+ for (i = 0;
+ ts->common_path != '\0';
+ i++) {
+ if (path[i] != ts->common_path[i]) {
+ /* The common path has changed, redo the other traces */
+ for(j = 0; j < ts->traces->len; j++) {
+ LttvTrace *t = g_ptr_array_index(ts->traces, j);
+ strncpy(t->short_name, t->full_path+i, TRACE_NAME_SIZE);
+ }
+
+ break;
+ }
+ }
+ strncpy(new_trace->short_name, path+i, TRACE_NAME_SIZE);
+ }
+ new_trace->full_path = strdup(path);
+
return new_trace;
}
s = g_new(LttvTraceset, 1);
s->filename = NULL;
+ s->common_path = strdup(s_orig->common_path);
s->traces = g_ptr_array_new();
s->state_trace_handle_index = g_ptr_array_new();
for(i=0;i<s_orig->traces->len;i++)
if(lttv_trace_get_ref_number(trace) == 0)
lttv_trace_destroy(trace);
}
+ free(s->common_path);
g_ptr_array_free(s->traces, TRUE);
bt_context_put(s->context);
g_object_unref(s->a);
void lttv_trace_destroy(LttvTrace *t)
{
+ free(t->full_path);
g_object_unref(t->a);
g_free(t);
}
g_ptr_array_add(s->traces, t);
}
+int lttv_traceset_get_trace_index_from_event(LttvEvent *event)
+{
+ LttvTraceset *ts = event->state->trace->traceset;
+
+ return lttv_traceset_get_trace_index_from_handle_id(ts, bt_ctf_event_get_handle_id(event->bt_event));
+}
+
+int lttv_traceset_get_trace_index_from_handle_id(LttvTraceset *ts, int handle_id)
+{
+ int i;
+
+ /* TODO ybrosseau 2013-05-22: use a map to speedup the lookup */
+
+ for(i = 0; i < ts->traces->len; i++) {
+ LttvTrace *t = g_ptr_array_index(ts->traces, i);
+ if (t && t->id == handle_id) {
+ return i;
+ }
+ }
+
+ /* Handle id not found */
+ return -1;
+
+}
+
int lttv_traceset_add_path(LttvTraceset *ts, char *trace_path)
{
int ret = -1;
GPtrArray *state_trace_handle_index;
gboolean has_precomputed_states;
TimeInterval time_span;
+ char *common_path;
};
+#define TRACE_NAME_SIZE 100
+
struct _LttvTrace {
// Trace id for babeltrace
LttvTraceset *traceset; /* container traceset */
LttvAttribute *a;
guint ref_count;
LttvTraceState *state;
+ char short_name[TRACE_NAME_SIZE];
+ char *full_path;
};
/* In babeltrace, the position concept is an iterator. */
void lttv_traceset_remove(LttvTraceset *s, unsigned i);
+int lttv_traceset_get_trace_index_from_event(LttvEvent *event);
+
+int lttv_traceset_get_trace_index_from_handle_id(LttvTraceset *ts, int handle_id);
+
/* An attributes table is attached to the set and to each trace in the set. */
LttvAttribute *lttv_traceset_attribute(LttvTraceset *s);
* draw items from the beginning of the read for it. If it is not
* present, it's a new process and it was not present : it will
* be added after the state update. TOCHECK: What does that last para mean? */
- guint trace_num = 0; /*TODO ybrosseau 2012-08-23: use right number */
+ guint trace_num = lttv_traceset_get_trace_index_from_event(event);
LttvProcessState *process = lttv_state_find_process(ts, woken_cpu, woken_pid);
if(process != NULL) {
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");
- guint trace_number = 0;//TODO fdeslauriers 2012-07-17: // Use trace handle to know trace number
+ guint trace_number = lttv_traceset_get_trace_index_from_event(event);
process = lttv_state_find_process(ts,cpu,pid_out);
evtime = lttv_event_get_timestamp(event);
//process_in = lttv_state_find_process(ts, ANY_CPU, pid_in);
//process_in = tfs->process;
guint cpu = lttv_traceset_get_cpuid_from_event(event);
- guint trace_num = 0; /* TODO set right trace number */
+ guint trace_num = lttv_traceset_get_trace_index_from_event(event);
process_in = ts->running_process[cpu];
/* It should exist, because we are after the state update. */
#ifdef EXTRA_CHECK
cpu = lttv_traceset_get_cpuid_from_event(event);
ts = event->state;
- guint trace_number = 0;//TODO fdeslauriers 2012-07-17: // Use trace handle to know trace number
+ guint trace_number = lttv_traceset_get_trace_index_from_event(event);
//TODO ybrosseau 2013-04-09 validate that using the running process is the right choice
//process = lttv_state_find_process(ts ,cpu ,pid);
/* Add process to process list (if not present) */
//LttvProcessState *process = tfs->process;
guint cpu = lttv_traceset_get_cpuid_from_event(event);
- guint trace_num = 0; /* TODO set right trace number */
+ guint trace_num = lttv_traceset_get_trace_index_from_event(event);
LttvProcessState *process = ts->running_process[cpu];
guint pid = process->pid;
LttTime evtime = lttv_event_get_timestamp(event);
- guint trace_num = 0; /* TODO set right trace number */
+ guint trace_num = lttv_traceset_get_trace_index_from_event(event);
guint pid;
{
/* It should exist, because we are after the state update. */
g_assert(process_child != NULL);
- guint trace_num = 0; /* TODO put right */
+ guint trace_num = lttv_traceset_get_trace_index_from_event(event);
/* Cannot use current process, because this action is done by the parent
* on its child. */
/* Add process to process list (if not present) */
//LttvProcessState *process = tfs->process;
guint cpu = lttv_traceset_get_cpuid_from_event(event);
- guint trace_num = 0; /* TODO set right trace number */
+ guint trace_num = lttv_traceset_get_trace_index_from_event(event);
LttvProcessState *process = ts->running_process[cpu];
/* It should exist, because we are after the state update. */
HashedProcessData *hashed_process_data_in = NULL;
ProcessList *process_list = control_flow_data->process_list;
- guint trace_num = 0; /* TODO put right trace number */
+ guint trace_num = lttv_traceset_get_trace_index_from_event(event);
guint pid_in;
{
#ifdef EXTRA_CHECK
g_assert(lttv_traceset_number(tsc->ts) > 0);
#endif //EXTRA_CHECK
- //TODO Fdeslauriers 2012-07-17: adapt for multiple traces
- LttvTrace *trace = lttv_traceset_get(ts,0);
+
+ LttvTrace *trace = lttv_traceset_get(ts, process_info->trace_num);
LttvTraceState *trace_state = trace->state;
#if 0
gtk_list_store_append (event_viewer_data->store_m, &iter);
gtk_list_store_set (event_viewer_data->store_m, &iter,
- TRACE_NAME_COLUMN, "TraceName",
+ TRACE_NAME_COLUMN, traceState->trace->short_name,
CPUID_COLUMN, cpu,
EVENT_COLUMN,name->str,
TIME_S_COLUMN, time.tv_sec,
ptab = (LttvPluginTab *)g_object_get_data(G_OBJECT(page), "Tab_Plugin");
tab = ptab->tab;
}
+#if 0
//TODO fdeslauriers 2012-07-06: Remove this popup when we support multiple traces
traceset = lttvwindow_get_traceset(tab);
if(traceset != NULL && lttv_traceset_number(traceset) > 0){
gtk_widget_destroy(dialogue);
return;
}
-
+#endif
/* Create a new traceset*/
- traceset = lttv_traceset_new();
+ traceset = tab->traceset_info->traceset;
+ if(traceset == NULL) {
+ traceset = lttv_traceset_new();
+ }
/* File open dialog management */
#ifdef BABEL_CLEANUP
GtkWidget *extra_live_button;
guint cpu = lttv_traceset_get_cpuid_from_event(event);
ts = event->state;
- guint trace_num = 0;//TODO fdeslauriers 2012-07-17: // Use trace handle to know trace number
+ guint trace_num = lttv_traceset_get_trace_index_from_event(event);
+
/* Add process to process list (if not present) */
HashedResourceData *hashed_process_data = NULL;
//process_in = lttv_state_find_process(ts, ANY_CPU, pid_in);
//process_in = tfs->process;
guint cpu = lttv_traceset_get_cpuid_from_event(event);
- guint trace_num = 0; /* TODO set right trace number */
+ guint trace_num = lttv_traceset_get_trace_index_from_event(event);
process_in = ts->running_process[cpu];
/* It should exist, because we are after the state update. */
#ifdef EXTRA_CHECK
cpu = lttv_traceset_get_cpuid_from_event(event);
ts = event->state;
- guint trace_num = 0;//TODO fdeslauriers 2012-07-17: // Use trace handle to know trace number
+ guint trace_num = lttv_traceset_get_trace_index_from_event(event);
process = ts->running_process[cpu];
g_assert(process != NULL);
} else
return 0;
- guint trace_num = 0;//TODO fdeslauriers 2012-07-17: // Use trace handle to know trace number
+ guint trace_num = lttv_traceset_get_trace_index_from_event(event);
/* Well, the process_out existed : we must get it in the process hash
* or add it, and draw its items.
LttvTraceset *traceSet = lttvwindow_get_traceset(resourceview_data->tab);
guint cpu = lttv_traceset_get_cpuid_from_event(event);
ts = event->state;
- guint trace_num = 0;//TODO change it to the right value;
+ guint trace_num = lttv_traceset_get_trace_index_from_event(event);
/* Well, the process_out existed : we must get it in the process hash
* or add it, and draw its items.
guint8 minor = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 1));
gint devcode_gint = MKDEV(major,minor);
- guint trace_num = 0; //TODO put the real trace_num;
+ guint trace_num = lttv_traceset_get_trace_index_from_event(event);
LttvBdevState *bdev = g_hash_table_lookup(ts->bdev_states, &devcode_gint);
/* the result of the lookup might be NULL. that's ok, the rest of the function
#ifdef EXTRA_CHECK
g_assert(lttv_traceset_number(tsc->ts) > 0);
#endif //EXTRA_CHECK
- //TODO Fdeslauriers 2012-07-17: adapt for multiple traces
- LttvTrace *trace = lttv_traceset_get(ts,0);
+
+ LttvTrace *trace = lttv_traceset_get(ts,process_info->trace_num);
LttvTraceState *ts = trace->state;
/* Only draw for processes that are currently in the trace states */