From d5f14c8f94d2460903a53062ce7cf0438385da75 Mon Sep 17 00:00:00 2001 From: winckel <winckel@eurecom.fr> Date: Wed, 13 Nov 2013 09:31:29 +0000 Subject: [PATCH] Added instances filter support. Instances filter settings are not saved in the filters files! git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4380 818b1a75-f10b-46b9-bf7c-635c3b92a50f --- .../itti_analyzer/libresolver/locate_root.c | 2 +- .../utils/itti_analyzer/libui/ui_callbacks.c | 8 ++- common/utils/itti_analyzer/libui/ui_filters.c | 50 ++++++++++++++++--- common/utils/itti_analyzer/libui/ui_filters.h | 7 ++- .../itti_analyzer/libui/ui_main_screen.h | 1 + .../utils/itti_analyzer/libui/ui_tree_view.c | 30 +++++++++-- 6 files changed, 85 insertions(+), 13 deletions(-) diff --git a/common/utils/itti_analyzer/libresolver/locate_root.c b/common/utils/itti_analyzer/libresolver/locate_root.c index 342560e91..39d8048ab 100644 --- a/common/utils/itti_analyzer/libresolver/locate_root.c +++ b/common/utils/itti_analyzer/libresolver/locate_root.c @@ -104,7 +104,7 @@ char *task_id_to_string(uint32_t task_id_value, types_t *task_id_type) { if (task_id_value < ((uint32_t) ~0)) { - /* Search task id name */ + /* Search task id name */ task_id = enum_type_get_name_from_value (task_id_type->child, task_id_value); } diff --git a/common/utils/itti_analyzer/libui/ui_callbacks.c b/common/utils/itti_analyzer/libui/ui_callbacks.c index a4b50aa72..920562f43 100644 --- a/common/utils/itti_analyzer/libui/ui_callbacks.c +++ b/common/utils/itti_analyzer/libui/ui_callbacks.c @@ -113,6 +113,7 @@ void ui_signal_add_to_list(gpointer data, gpointer user_data) GtkTreeViewColumn *focus_column; uint32_t origin_task_id; uint32_t destination_task_id; + uint32_t instance; gtk_tree_view_get_cursor (GTK_TREE_VIEW(ui_main_data.signalslist), &path, &focus_column); @@ -121,11 +122,12 @@ void ui_signal_add_to_list(gpointer data, gpointer user_data) get_message_id (root, signal_buffer, &signal_buffer->message_id); origin_task_id = get_task_id (signal_buffer, origin_task_id_type); destination_task_id = get_task_id (signal_buffer, destination_task_id_type); + instance = get_instance (signal_buffer); ui_tree_view_new_signal_ind (signal_buffer->message_number, signal_buffer->message_id, message_id_to_string (signal_buffer->message_id), origin_task_id, task_id_to_string (origin_task_id, origin_task_id_type), destination_task_id, task_id_to_string (destination_task_id, destination_task_id_type), - get_instance (signal_buffer), data); + instance, data); /* Increment number of messages */ ui_main_data.nb_message_received++; @@ -411,6 +413,10 @@ gboolean ui_callback_on_tree_column_header_click(GtkWidget *widget, gpointer dat ui_show_filter_menu (&ui_main_data.menu_filter_destination_tasks, &ui_filters.destination_tasks); break; + case COL_INSTANCE: + ui_show_filter_menu (&ui_main_data.menu_filter_instances, &ui_filters.instances); + break; + default: g_warning("Unknown column filter %d in call to ui_callback_on_tree_column_header_click", col); return FALSE; diff --git a/common/utils/itti_analyzer/libui/ui_filters.c b/common/utils/itti_analyzer/libui/ui_filters.c index a69d51b08..28c123339 100644 --- a/common/utils/itti_analyzer/libui/ui_filters.c +++ b/common/utils/itti_analyzer/libui/ui_filters.c @@ -54,6 +54,7 @@ int ui_init_filters(int reset, int clear_ids) ui_init_filter (&ui_filters.messages, reset, clear_ids, "messages"); ui_init_filter (&ui_filters.origin_tasks, reset, clear_ids, "origin_tasks"); ui_init_filter (&ui_filters.destination_tasks, reset, clear_ids, "destination_tasks"); + ui_init_filter (&ui_filters.instances, reset, clear_ids, "instances"); ui_destroy_filter_menus (); @@ -140,6 +141,8 @@ static int ui_filter_add(ui_filter_t *filter, uint32_t value, const char *name, ui_filter_set_enabled (&filter->items[item].enabled, entry_enabled, FALSE); } + g_debug("filter \"%s\" add %d \"%s\" %d", filter->name, value, name, entry_enabled); + return (item); } @@ -159,6 +162,10 @@ void ui_filters_add(ui_filter_e filter, uint32_t value, const char *name, ui_ent ui_filter_add (&ui_filters.destination_tasks, value, name, entry_enabled); break; + case FILTER_INSTANCES: + ui_filter_add (&ui_filters.instances, value, name, entry_enabled); + break; + default: g_warning("unknown filter type %d", filter); break; @@ -181,12 +188,12 @@ static gboolean ui_item_enabled(ui_filter_t *filter, const uint32_t value) return (FALSE); } -gboolean ui_filters_message_enabled(const uint32_t message, const uint32_t origin_task, const uint32_t destination_task) +gboolean ui_filters_message_enabled(const uint32_t message, const uint32_t origin_task, const uint32_t destination_task, const uint32_t instance) { gboolean result; result = ui_item_enabled (&ui_filters.messages, message) && ui_item_enabled (&ui_filters.origin_tasks, origin_task) - && ui_item_enabled (&ui_filters.destination_tasks, destination_task); + && ui_item_enabled (&ui_filters.destination_tasks, destination_task) && ui_item_enabled (&ui_filters.instances, instance); return result; } @@ -205,6 +212,10 @@ static ui_filter_e ui_filter_from_name(const char *name) { return FILTER_DESTINATION_TASKS; } + if (strcmp (name, ui_filters.instances.name) == 0) + { + return FILTER_INSTANCES; + } return FILTER_UNKNOWN; } @@ -447,7 +458,7 @@ static void ui_destroy_filter_menu_item(GtkWidget *widget, gpointer data) } } -static void ui_destroy_filter_menu(GtkWidget **menu, ui_filter_t *filter) +static void ui_destroy_filter_menu_widget(GtkWidget **menu) { if (*menu != NULL) { @@ -460,9 +471,36 @@ static void ui_destroy_filter_menu(GtkWidget **menu, ui_filter_t *filter) void ui_destroy_filter_menus(void) { - ui_destroy_filter_menu (&ui_main_data.menu_filter_messages, &ui_filters.messages); - ui_destroy_filter_menu (&ui_main_data.menu_filter_origin_tasks, &ui_filters.origin_tasks); - ui_destroy_filter_menu (&ui_main_data.menu_filter_destination_tasks, &ui_filters.destination_tasks); + ui_destroy_filter_menu_widget (&ui_main_data.menu_filter_messages); + ui_destroy_filter_menu_widget (&ui_main_data.menu_filter_origin_tasks); + ui_destroy_filter_menu_widget (&ui_main_data.menu_filter_destination_tasks); + ui_destroy_filter_menu_widget (&ui_main_data.menu_filter_instances); +} + +void ui_destroy_filter_menu(ui_filter_e filter) +{ + switch (filter) + { + case FILTER_MESSAGES: + ui_destroy_filter_menu_widget (&ui_main_data.menu_filter_messages); + break; + + case FILTER_ORIGIN_TASKS: + ui_destroy_filter_menu_widget (&ui_main_data.menu_filter_origin_tasks); + break; + + case FILTER_DESTINATION_TASKS: + ui_destroy_filter_menu_widget (&ui_main_data.menu_filter_destination_tasks); + break; + + case FILTER_INSTANCES: + ui_destroy_filter_menu_widget (&ui_main_data.menu_filter_instances); + break; + + default: + g_warning("unknown filter type %d", filter); + break; + } } void ui_show_filter_menu(GtkWidget **menu, ui_filter_t *filter) diff --git a/common/utils/itti_analyzer/libui/ui_filters.h b/common/utils/itti_analyzer/libui/ui_filters.h index fbd17a143..e4706e138 100644 --- a/common/utils/itti_analyzer/libui/ui_filters.h +++ b/common/utils/itti_analyzer/libui/ui_filters.h @@ -7,7 +7,7 @@ typedef enum { - FILTER_UNKNOWN, FILTER_MESSAGES, FILTER_ORIGIN_TASKS, FILTER_DESTINATION_TASKS, + FILTER_UNKNOWN, FILTER_MESSAGES, FILTER_ORIGIN_TASKS, FILTER_DESTINATION_TASKS, FILTER_INSTANCES, } ui_filter_e; typedef enum @@ -35,6 +35,7 @@ typedef struct ui_filter_t messages; ui_filter_t origin_tasks; ui_filter_t destination_tasks; + ui_filter_t instances; } ui_filters_t; extern ui_filters_t ui_filters; @@ -43,7 +44,7 @@ int ui_init_filters(int reset, int clear_ids); void ui_filters_add(ui_filter_e filter, uint32_t value, const char *name, ui_entry_enabled_e entry_enabled); -gboolean ui_filters_message_enabled(const uint32_t message, const uint32_t origin_task, const uint32_t destination_task); +gboolean ui_filters_message_enabled(const uint32_t message, const uint32_t origin_task, const uint32_t destination_task, const uint32_t instance); int ui_filters_read(const char *file_name); @@ -51,6 +52,8 @@ int ui_filters_file_write(const char *file_name); void ui_destroy_filter_menus(void); +void ui_destroy_filter_menu(ui_filter_e filter); + void ui_show_filter_menu(GtkWidget **menu, ui_filter_t *filter); #endif /* UI_FILTERS_H_ */ diff --git a/common/utils/itti_analyzer/libui/ui_main_screen.h b/common/utils/itti_analyzer/libui/ui_main_screen.h index 0bef97e7a..1f9e165cd 100644 --- a/common/utils/itti_analyzer/libui/ui_main_screen.h +++ b/common/utils/itti_analyzer/libui/ui_main_screen.h @@ -45,6 +45,7 @@ typedef struct { GtkWidget *menu_filter_messages; GtkWidget *menu_filter_origin_tasks; GtkWidget *menu_filter_destination_tasks; + GtkWidget *menu_filter_instances; int pipe_fd[2]; } ui_main_data_t; diff --git a/common/utils/itti_analyzer/libui/ui_tree_view.c b/common/utils/itti_analyzer/libui/ui_tree_view.c index 784f949ca..efb26c360 100644 --- a/common/utils/itti_analyzer/libui/ui_tree_view.c +++ b/common/utils/itti_analyzer/libui/ui_tree_view.c @@ -20,6 +20,7 @@ typedef struct GtkTreeModelFilter *filtered; uint32_t filtered_last_msg; uint32_t filtered_msg_number; + uint32_t instance_number; } ui_store_t; static ui_store_t ui_store; @@ -30,20 +31,22 @@ static gboolean ui_tree_filter_messages(GtkTreeModel *model, GtkTreeIter *iter, uint32_t message_id; uint32_t origin_task_id; uint32_t destination_task_id; + uint32_t instance; + gboolean enabled = FALSE; gtk_tree_model_get (model, iter, COL_MSG_NUM, &msg_number, COL_MESSAGE_ID, &message_id, COL_FROM_TASK_ID, &origin_task_id, - COL_TO_TASK_ID, &destination_task_id, -1); + COL_TO_TASK_ID, &destination_task_id, COL_INSTANCE, &instance, -1); if (msg_number != 0) { - enabled = ui_filters_message_enabled (message_id, origin_task_id, destination_task_id); + enabled = ui_filters_message_enabled (message_id, origin_task_id, destination_task_id, instance); if ((enabled) && (ui_store.filtered_last_msg < msg_number)) { ui_store.filtered_last_msg = msg_number; ui_store.filtered_msg_number++; } - g_debug("%p %p %d %d %d %d %d %d", model, iter, msg_number, message_id, origin_task_id, destination_task_id, enabled, ui_store.filtered_msg_number); + g_debug("%p %p %d m:%d o:%d d:%d i:%d %d %d", model, iter, msg_number, message_id, origin_task_id, destination_task_id, instance, enabled, ui_store.filtered_msg_number); } return enabled; @@ -81,6 +84,8 @@ ui_tree_view_init_list(GtkWidget *list) column = gtk_tree_view_column_new_with_attributes( "Ins", renderer, "text", COL_INSTANCE, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(list), column); + g_signal_connect(G_OBJECT(column), "clicked", + G_CALLBACK(ui_callback_on_tree_column_header_click), (gpointer) COL_INSTANCE); ui_store.store = gtk_list_store_new(NUM_COLS, G_TYPE_UINT, // COL_MSG_NUM @@ -143,6 +148,7 @@ void ui_tree_view_destroy_list(GtkWidget *list) gtk_list_store_clear(ui_store.store); ui_store.filtered_last_msg = 0; ui_store.filtered_msg_number = 0; + ui_store.instance_number = 0; /* Reset number of messages */ ui_main_data.nb_message_received = 0; @@ -185,6 +191,10 @@ int ui_tree_view_create(GtkWidget *window, GtkWidget *vbox) gtk_tree_selection_set_select_function(selection, ui_callback_on_select_signal, ui_main_data.text_view, NULL); + ui_store.filtered_last_msg = 0; + ui_store.filtered_msg_number = 0; + ui_store.instance_number = 0; + ui_main_data.selection = selection; return 0; @@ -196,6 +206,20 @@ int ui_tree_view_new_signal_ind(const uint32_t message_number, const uint32_t destination_task_id, const char *destination_task, uint32_t instance, gpointer buffer) { + if(ui_store.instance_number < (instance + 1)) + { + int i; + char name[10]; + + for (i = ui_store.instance_number; i <= instance; i++) + { + sprintf (name, "%d", i); + ui_filters_add (FILTER_INSTANCES, i, name, ENTRY_ENABLED_TRUE); + } + ui_store.instance_number = (instance + 1); + ui_destroy_filter_menu(FILTER_INSTANCES); + } + ui_tree_view_add_to_list(ui_main_data.signalslist, message_number, message_id, message_name, origin_task_id, origin_task, destination_task_id, destination_task, instance, (buffer_t *)buffer); -- GitLab