From: Francis Deslauriers Date: Thu, 5 Jul 2012 15:04:08 +0000 (-0400) Subject: Remove duplicate field in detailed event view X-Git-Tag: v1.5-beta1~62 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=6db3427f29cace9a1addac5a6277bbc1ce666002;p=lttv.git Remove duplicate field in detailed event view Add option to lttv_event_to_string to select if we add the timestamp and the event name to the returned string (Closes #291) Signed-off-by: Francis Deslauriers Signed-off-by: Yannick Brosseau --- diff --git a/lttv/lttv/print.c b/lttv/lttv/print.c index 5707175c..aa21f77b 100644 --- a/lttv/lttv/print.c +++ b/lttv/lttv/print.c @@ -430,7 +430,8 @@ int getFieldsFromEvent(struct bt_ctf_event *ctf_event, GString* fields, gboolean return ret; } -void lttv_event_to_string(LttvEvent *event, GString *a_string, gboolean field_names) +void lttv_event_to_string(LttvEvent *event, GString *a_string, + gboolean field_names, gboolean long_version) { GString* processInfos = g_string_new(""); GString* fields = g_string_new(""); @@ -441,8 +442,13 @@ void lttv_event_to_string(LttvEvent *event, GString *a_string, gboolean field_na getCPUIdFromEvent(event, cpuId_str); g_string_set_size(a_string,0); - - g_string_append_printf(a_string, "%llu %s: { %s }", bt_ctf_get_timestamp(event->bt_event), bt_ctf_event_name(event->bt_event), cpuId_str->str); + if(long_version){ + g_string_append_printf(a_string, "%llu %s: ", + bt_ctf_get_timestamp(event->bt_event), + bt_ctf_event_name(event->bt_event)); + } + g_string_append_printf(a_string, "{ %s }", cpuId_str->str); + if (strcmp("", processInfos->str) < 0) { g_string_append_printf(a_string, ", { %s }", processInfos->str); } @@ -454,7 +460,11 @@ void lttv_event_to_string(LttvEvent *event, GString *a_string, gboolean field_na g_string_free(processInfos, TRUE); g_string_free(cpuId_str, TRUE); } - +void lttv_event_get_name(LttvEvent *event,GString *a_string) +{ + g_string_set_size(a_string,0); + g_string_append_printf(a_string, " %s", bt_ctf_event_name(event->bt_event)); +} #ifdef BABEL_CLEANUP void lttv_event_to_string(LttEvent *e, GString *s, gboolean mandatory_fields, gboolean field_names, LttvTracefileState *tfs) diff --git a/lttv/lttv/print.h b/lttv/lttv/print.h index 47cfb61c..126fbc2e 100644 --- a/lttv/lttv/print.h +++ b/lttv/lttv/print.h @@ -32,5 +32,9 @@ void lttv_print_field(LttEvent *e, struct marker_field *f, GString *s, void lttv_event_to_string(LttEvent *e, GString *s, gboolean mandatory_fields, gboolean field_names, LttvTracefileState *tfs); #endif -void lttv_event_to_string(LttvEvent *event, GString *a_string, gboolean field_names); +void lttv_event_to_string(LttvEvent *event, + GString *a_string, + gboolean field_names, + gboolean long_version); +void lttv_event_get_name(LttvEvent *event,GString *a_string); diff --git a/lttv/modules/gui/detailedevents/events.c b/lttv/modules/gui/detailedevents/events.c index 585acbc0..ac131149 100644 --- a/lttv/modules/gui/detailedevents/events.c +++ b/lttv/modules/gui/detailedevents/events.c @@ -148,7 +148,6 @@ int event_hook(void *hook_data, void *call_data); enum { TRACE_NAME_COLUMN, - TRACEFILE_NAME_COLUMN, CPUID_COLUMN, EVENT_COLUMN, TIME_S_COLUMN, @@ -252,7 +251,6 @@ gui_events(LttvPluginTab *ptab) event_viewer_data->store_m = gtk_list_store_new ( N_COLUMNS, /* Total number of columns */ G_TYPE_STRING, /* Trace name */ - G_TYPE_STRING, /* Tracefile name */ G_TYPE_UINT, /* CPUID */ G_TYPE_STRING, /* Event */ G_TYPE_UINT, /* Time s */ @@ -321,19 +319,6 @@ gui_events(LttvPluginTab *ptab) G_CALLBACK(header_size_allocate), (gpointer)event_viewer_data); - - - renderer = gtk_cell_renderer_text_new (); - column = gtk_tree_view_column_new_with_attributes ("Tracefile", - renderer, - "text", TRACEFILE_NAME_COLUMN, - NULL); - gtk_tree_view_column_set_alignment (column, 0.0); - gtk_tree_view_column_set_fixed_width (column, 120); - gtk_tree_view_append_column (GTK_TREE_VIEW (event_viewer_data->tree_v), - column); - - renderer = gtk_cell_renderer_text_new (); column = gtk_tree_view_column_new_with_attributes ("CPUID", renderer, @@ -1557,10 +1542,12 @@ int event_hook(void *hook_data, void *call_data) GtkTreeIter iter; GString *desc = g_string_new(""); + GString *name = g_string_new(""); LttvTracesetPosition *pos = lttv_traceset_create_position(traceState->trace->traceset); - lttv_event_to_string(e, desc, TRUE); + lttv_event_to_string(e, desc, TRUE, FALSE); + lttv_event_get_name(e,name); g_info("detail : %s", desc->str); @@ -1568,9 +1555,8 @@ int event_hook(void *hook_data, void *call_data) gtk_list_store_set (event_viewer_data->store_m, &iter, 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)*/, + EVENT_COLUMN,name->str, TIME_S_COLUMN, time.tv_sec, TIME_NS_COLUMN, time.tv_nsec, PID_COLUMN, process->pid, @@ -1581,6 +1567,7 @@ int event_hook(void *hook_data, void *call_data) g_ptr_array_add(event_viewer_data->pos, pos); g_string_free(desc, TRUE); + g_string_free(name, TRUE); if(event_viewer_data->update_cursor) { if(lttv_traceset_position_compare(pos, diff --git a/lttv/modules/text/textDump.c b/lttv/modules/text/textDump.c index a09c8b79..c11db5d9 100644 --- a/lttv/modules/text/textDump.c +++ b/lttv/modules/text/textDump.c @@ -352,7 +352,7 @@ static int write_event_content(void *hook_data, void *call_data) #endif /* TODO 2012-03-12 Add state info */ - lttv_event_to_string(event, a_string, !a_no_field_names); + lttv_event_to_string(event, a_string, !a_no_field_names, TRUE); #ifdef BABEL_CLEANUP if(a_state) {