Commit 0b31d140 authored by winckel's avatar winckel

Modified ITTI log file format:

- removed signal_name.
- added message start and end markers.
Added a "cancel" button for some dialog box.

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4861 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 744030f4
......@@ -55,6 +55,7 @@
#include "assertions.h"
#include "liblfds611.h"
#include "itti_types.h"
#include "intertask_interface.h"
#include "intertask_interface_dump.h"
......@@ -62,8 +63,6 @@
#include "vcd_signal_dumper.h"
#endif
#define SIGNAL_NAME_LENGTH 48
static const int itti_dump_debug = 0; // 0x8 | 0x4 | 0x2;
#ifdef RTAI
......@@ -80,18 +79,10 @@ static const int itti_dump_debug = 0; // 0x8 | 0x4 | 0x2;
# define KERNEL_VERSION_PRE_2_6_30 1
#endif
/* Message sent is an intertask dump type */
#define ITTI_DUMP_MESSAGE_TYPE 0x1
#define ITTI_STATISTIC_MESSAGE_TYPE 0x2
#define ITTI_DUMP_XML_DEFINITION 0x3
/* This signal is not meant to be used by remote analyzer */
#define ITTI_DUMP_EXIT_SIGNAL 0x4
typedef struct itti_dump_queue_item_s {
MessageDef *data;
uint32_t data_size;
uint32_t message_number;
char message_name[SIGNAL_NAME_LENGTH];
uint32_t message_type;
uint32_t message_size;
} itti_dump_queue_item_t;
......@@ -128,25 +119,20 @@ typedef struct itti_desc_s {
} itti_desc_t;
typedef struct {
/* The size of this structure */
uint32_t message_size;
uint32_t message_type;
} itti_socket_header_t;
itti_socket_header_t socket_header;
typedef struct {
itti_socket_header_t header;
uint32_t message_number;
char signal_name[SIGNAL_NAME_LENGTH];
itti_signal_header_t signal_header;
/* Message payload is added here, this struct is used as an header */
} itti_dump_message_t;
typedef struct {
itti_socket_header_t header;
itti_socket_header_t socket_header;
} itti_statistic_message_t;
static const itti_message_types_t itti_dump_xml_definition_end = ITTI_DUMP_XML_DEFINITION_END;
static const itti_message_types_t itti_dump_message_type_end = ITTI_DUMP_MESSAGE_TYPE_END;
static itti_desc_t itti_dump_queue;
static FILE *dump_file = NULL;
static int itti_dump_running = 1;
......@@ -161,24 +147,24 @@ static int itti_dump_send_message(int sd, itti_dump_queue_item_t *message)
uint8_t *data_ptr;
/* Allocate memory for message header and payload */
size_t size = sizeof(itti_dump_message_t) + message->data_size;
size_t size = sizeof(itti_dump_message_t) + message->data_size + sizeof(itti_message_types_t);
AssertFatal (sd > 0, "Socket descriptor (%d) is invalid!\n", sd);
AssertFatal (message != NULL, "Message is NULL!\n");
new_message = calloc(1, size);
new_message = malloc(size);
AssertFatal (new_message != NULL, "New message allocation failed!\n");
/* Preparing the header */
new_message->header.message_size = size;
new_message->header.message_type = ITTI_DUMP_MESSAGE_TYPE;
new_message->socket_header.message_size = size;
new_message->socket_header.message_type = ITTI_DUMP_MESSAGE_TYPE;
new_message->message_number = message->message_number;
/* Copy the name, but leaves last byte set to 0 in case name is too long */
memcpy(new_message->signal_name, message->message_name, SIGNAL_NAME_LENGTH - 1);
new_message->signal_header.message_number = message->message_number;
/* Appends message payload */
memcpy(&new_message[1], message->data, message->data_size);
memcpy(((void *) &new_message[1]) + message->data_size, &itti_dump_message_type_end, sizeof(itti_message_types_t));
data_ptr = (uint8_t *)&new_message[0];
do {
......@@ -202,13 +188,13 @@ static int itti_dump_fwrite_message(itti_dump_queue_item_t *message)
if ((dump_file != NULL) && (message != NULL)) {
header.message_size = message->message_size + sizeof(itti_dump_message_t);
header.message_size = message->message_size + sizeof(itti_dump_message_t) + sizeof(itti_message_types_t);
header.message_type = message->message_type;
fwrite (&header, sizeof(itti_socket_header_t), 1, dump_file);
fwrite (&message->message_number, sizeof(message->message_number), 1, dump_file);
fwrite (message->message_name, sizeof(message->message_name), 1, dump_file);
fwrite (message->data, message->data_size, 1, dump_file);
fwrite (&itti_dump_message_type_end, sizeof(itti_message_types_t), 1, dump_file);
// #if !defined(RTAI)
fflush (dump_file);
// #endif
......@@ -229,7 +215,7 @@ static int itti_dump_send_xml_definition(const int sd, const char *message_defin
AssertFatal (sd > 0, "Socket descriptor (%d) is invalid!\n", sd);
AssertFatal (message_definition_xml != NULL, "Message definition XML is NULL!\n");
itti_dump_message_size = sizeof(itti_socket_header_t) + message_definition_xml_length;
itti_dump_message_size = sizeof(itti_socket_header_t) + message_definition_xml_length + sizeof(itti_message_types_t);
itti_dump_message = calloc(1, itti_dump_message_size);
......@@ -240,7 +226,8 @@ static int itti_dump_send_xml_definition(const int sd, const char *message_defin
itti_dump_message->message_type = ITTI_DUMP_XML_DEFINITION;
/* Copying message definition */
memcpy(&itti_dump_message[1], message_definition_xml, message_definition_xml_length);
memcpy (&itti_dump_message[1], message_definition_xml, message_definition_xml_length);
memcpy (((void *) &itti_dump_message[1]) + message_definition_xml_length, &itti_dump_xml_definition_end, sizeof(itti_message_types_t));
data_ptr = (uint8_t *)&itti_dump_message[0];
......@@ -743,7 +730,6 @@ int itti_dump_queue_message(task_id_t sender_task,
if (itti_dump_running)
{
itti_dump_queue_item_t *new;
size_t message_name_length;
AssertFatal (message_name != NULL, "Message name is NULL!\n");
AssertFatal (message_p != NULL, "Message is NULL!\n");
......@@ -768,10 +754,6 @@ int itti_dump_queue_message(task_id_t sender_task,
new->data_size = message_size;
new->message_number = message_number;
message_name_length = strlen(message_name) + 1;
AssertError (message_name_length <= SIGNAL_NAME_LENGTH, {}, "Message name too long (%d/%d)!\n", (int) message_name_length, SIGNAL_NAME_LENGTH);
memcpy(new->message_name, message_name, message_name_length);
itti_dump_enqueue_message(new, message_size, ITTI_DUMP_MESSAGE_TYPE);
}
......@@ -805,11 +787,12 @@ int itti_dump_init(const char * const messages_definition_xml, const char * cons
uint32_t message_size = strlen(messages_definition_xml) + 1;
itti_socket_header_t header;
header.message_size = sizeof(itti_socket_header_t) + message_size;
header.message_size = sizeof(itti_socket_header_t) + message_size + sizeof(itti_message_types_t);
header.message_type = ITTI_DUMP_XML_DEFINITION;
fwrite (&header, sizeof(itti_socket_header_t), 1, dump_file);
fwrite (messages_definition_xml, message_size, 1, dump_file);
fwrite (&itti_dump_xml_definition_end, sizeof(itti_message_types_t), 1, dump_file);
fflush (dump_file);
}
}
......
../../itti/itti_types.h
\ No newline at end of file
......@@ -110,7 +110,7 @@ static int socket_read_itti_message(socket_data_t *socket_data,
}
/* Create the new buffer */
if (buffer_new_from_data(&buffer, data, data_length, 1) != RC_OK) {
if (buffer_new_from_data(&buffer, data, data_length - sizeof(itti_message_types_t), 1) != RC_OK) {
g_error("Failed to create new buffer");
g_assert_not_reached();
}
......@@ -162,7 +162,7 @@ static int socket_read_xml_definition(socket_data_t *socket_data,
} while (total_data_read != xml_definition_length);
pipe_xml_definition_message.xml_definition = xml_definition;
pipe_xml_definition_message.xml_definition_length = xml_definition_length;
pipe_xml_definition_message.xml_definition_length = xml_definition_length - sizeof(itti_message_types_t);
g_debug("Received XML definition of size %zu, effectively read %zu bytes",
xml_definition_length, total_data_read);
......@@ -186,12 +186,14 @@ static int socket_read(socket_data_t *socket_data)
}
switch(message_header.message_type) {
case ITTI_DUMP_MESSAGE_TYPE:
socket_read_itti_message(socket_data, &message_header);
break;
case ITTI_DUMP_XML_DEFINITION:
socket_read_xml_definition(socket_data, &message_header);
break;
case ITTI_DUMP_MESSAGE_TYPE:
socket_read_itti_message(socket_data, &message_header);
break;
case ITTI_STATISTIC_MESSAGE_TYPE:
default:
g_warning("Received unknow (or not implemented) message from socket type: %d",
......
......@@ -712,7 +712,7 @@ int xml_parse_buffer(char *xml_buffer, const int size) {
if (doc == NULL) {
g_warning("Failed to parse XML buffer: %s", xml_buffer);
ui_notification_dialog(GTK_MESSAGE_ERROR, "parse messages format definition", "Fail to parse XML buffer");
ui_notification_dialog(GTK_MESSAGE_ERROR, FALSE, "parse messages format definition", "Fail to parse XML buffer");
return RC_FAIL;
}
......@@ -730,7 +730,7 @@ int xml_parse_file(const char *filename) {
doc = xmlReadFile (filename, NULL, 0);
if (doc == NULL) {
ui_notification_dialog(GTK_MESSAGE_ERROR, "parse messages format definition", "Failed to parse file \"%s\"", filename);
ui_notification_dialog(GTK_MESSAGE_ERROR, FALSE, "parse messages format definition", "Failed to parse file \"%s\"", filename);
return RC_FAIL;
}
......
......@@ -125,9 +125,9 @@ gboolean ui_callback_on_enable_filters(GtkWidget *widget, gpointer data)
gboolean ui_callback_on_about(GtkWidget *widget, gpointer data)
{
#if defined(PACKAGE_STRING)
ui_notification_dialog (GTK_MESSAGE_INFO, "about", "Eurecom %s", PACKAGE_STRING);
ui_notification_dialog (GTK_MESSAGE_INFO, FALSE, "about", "Eurecom %s", PACKAGE_STRING);
#else
ui_notification_dialog (GTK_MESSAGE_INFO, "about", "Eurecom itti_analyzer");
ui_notification_dialog (GTK_MESSAGE_INFO, FALSE, "about", "Eurecom itti_analyzer");
#endif
return TRUE;
......@@ -533,12 +533,16 @@ gboolean ui_pipe_callback(gint source, gpointer user_data)
{
case UI_PIPE_CONNECTION_FAILED:
return ui_handle_socket_connection_failed (source);
case UI_PIPE_XML_DEFINITION:
return ui_handle_socket_xml_definition (source, input_data, input_data_length);
case UI_PIPE_CONNECTION_LOST:
return ui_handle_socket_connection_lost (source);
case UI_PIPE_XML_DEFINITION:
return ui_handle_socket_xml_definition (source, input_data, input_data_length);
case UI_PIPE_UPDATE_SIGNAL_LIST:
return ui_handle_update_signal_list (source, input_data, input_data_length);
default:
g_warning("[gui] Unhandled message type %u", input_header.message_type);
g_assert_not_reached();
......@@ -560,13 +564,13 @@ gboolean ui_callback_on_connect(GtkWidget *widget, gpointer data)
if (strlen (ip) == 0)
{
ui_notification_dialog (GTK_MESSAGE_WARNING, "Connect", "Empty host ip address");
ui_notification_dialog (GTK_MESSAGE_WARNING, FALSE, "Connect", "Empty host ip address");
return FALSE;
}
if (port == 0)
{
ui_notification_dialog (GTK_MESSAGE_WARNING, "Connect", "Invalid host port value");
ui_notification_dialog (GTK_MESSAGE_WARNING, FALSE, "Connect", "Invalid host port value");
return FALSE;
}
......
......@@ -376,14 +376,14 @@ int ui_filters_read(const char *file_name)
doc = xmlReadFile (file_name, NULL, 0);
if (doc == NULL)
{
ui_notification_dialog (GTK_MESSAGE_ERROR, "open filters", "Failed to parse file \"%s\"", file_name);
ui_notification_dialog (GTK_MESSAGE_ERROR, FALSE, "open filters", "Failed to parse file \"%s\"", file_name);
return RC_FAIL;
}
ret = xml_parse_filters (doc, file_name);
if (ret != RC_OK)
{
ui_notification_dialog (GTK_MESSAGE_WARNING, "open filters", "Found no filter definitions in \"%s\"",
ui_notification_dialog (GTK_MESSAGE_WARNING, FALSE, "open filters", "Found no filter definitions in \"%s\"",
file_name);
return RC_FAIL;
}
......@@ -427,7 +427,7 @@ int ui_filters_file_write(const char *file_name)
filter_file = fopen (file_name, "w");
if (filter_file == NULL)
{
g_warning("Failed to open file \"%s\": %s", file_name, g_strerror (errno));
ui_notification_dialog (GTK_MESSAGE_ERROR, FALSE, "Failed to open file \"%s\": %s", file_name, g_strerror (errno));
return RC_FAIL;
}
......
......@@ -5,6 +5,7 @@
#include "itti_types.h"
#define SIGNAL_NAME_LENGTH 100
#define COLOR_SIZE 10
typedef enum
......
......@@ -8,11 +8,12 @@
static const char * const title_type[] =
{"Info", "Warning", "Question", "Error", "Other"};
int ui_notification_dialog(GtkMessageType type, const char *title, const char *fmt, ...)
int ui_notification_dialog(GtkMessageType type, gboolean cancel, const char *title, const char *fmt, ...)
{
va_list args;
GtkWidget *dialogbox;
char buffer[200];
int result = RC_OK;
va_start(args, fmt);
......@@ -20,17 +21,22 @@ int ui_notification_dialog(GtkMessageType type, const char *title, const char *f
g_warning("%s", buffer);
dialogbox = gtk_message_dialog_new (GTK_WINDOW(ui_main_data.window), GTK_DIALOG_MODAL, type, GTK_BUTTONS_OK, "%s",
dialogbox = gtk_message_dialog_new (GTK_WINDOW(ui_main_data.window), GTK_DIALOG_MODAL, type,
cancel ? GTK_BUTTONS_OK_CANCEL : GTK_BUTTONS_OK, "%s",
buffer);
gtk_dialog_set_default_response (GTK_DIALOG(dialogbox), GTK_RESPONSE_OK);
snprintf (buffer, sizeof(buffer), "%s: %s", title_type[type], title);
gtk_window_set_title (GTK_WINDOW(dialogbox), buffer);
gtk_dialog_run (GTK_DIALOG (dialogbox));
if (gtk_dialog_run (GTK_DIALOG (dialogbox)) == GTK_RESPONSE_CANCEL)
{
result = RC_FAIL;
}
gtk_widget_destroy (dialogbox);
va_end(args);
return RC_OK;
return result;
}
......@@ -3,6 +3,6 @@
#ifndef UI_NOTIF_DLG_H_
#define UI_NOTIF_DLG_H_
extern int ui_notification_dialog(GtkMessageType type, const char *title, const char *fmt, ...);
extern int ui_notification_dialog(GtkMessageType type, gboolean cancel, const char *title, const char *fmt, ...);
#endif /* UI_NOTIF_DLG_H_ */
......@@ -107,7 +107,7 @@ static void ui_tree_view_init_list(GtkWidget *list)
column = gtk_tree_view_column_new_with_attributes ("Message", renderer_left, "text", COL_MESSAGE, "foreground",
COL_FOREGROUND, "background", COL_BACKGROUND, "strikethrough",
COL_STRIKETHROUGH, NULL);
COL_STRIKETHROUGH, "style", COL_STYLE, "weight", COL_WEIGHT, "underline", COL_UNDERLINE, NULL);
gtk_tree_view_column_set_resizable (column, TRUE);
gtk_tree_view_column_set_alignment (column, 0.5);
gtk_tree_view_append_column (GTK_TREE_VIEW(list), column);
......@@ -151,6 +151,9 @@ static void ui_tree_view_init_list(GtkWidget *list)
G_TYPE_STRING, // COL_FOREGROUND
G_TYPE_STRING, // COL_BACKGROUND
G_TYPE_BOOLEAN, // COL_STRIKETHROUGH
G_TYPE_UINT,
G_TYPE_UINT,
G_TYPE_UINT,
// Reference to the buffer here to avoid maintaining multiple lists.
G_TYPE_POINTER);
......@@ -173,6 +176,8 @@ static void ui_tree_view_add_to_list(GtkWidget *list, const gchar *lte_time, con
const char *origin_task_name, const uint32_t destination_task_id,
const char *destination_task_name, uint32_t instance_id, const char *instance_name, gpointer buffer)
{
static int counter = 0;
GtkTreeIter iter;
gboolean enabled;
int message_index;
......@@ -193,8 +198,15 @@ static void ui_tree_view_add_to_list(GtkWidget *list, const gchar *lte_time, con
COL_FROM_TASK_ID, origin_task_id, COL_TO_TASK_ID, destination_task_id, COL_INSTANCE_ID, instance_id,
COL_BUFFER, buffer, COL_FOREGROUND, ui_filters.messages.items[message_index].foreground, COL_BACKGROUND,
ui_filters.messages.items[message_index].background, COL_STRIKETHROUGH, !enabled,
// COL_STYLE, (counter % 2) == 0 ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL,
// COL_WEIGHT, ((counter + 2) % 4) < 2 ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL,
// COL_UNDERLINE, ((counter + 4) % 8) < 4 ?PANGO_UNDERLINE_SINGLE : PANGO_UNDERLINE_NONE,
COL_STYLE, PANGO_STYLE_NORMAL,
COL_WEIGHT, PANGO_WEIGHT_NORMAL,
COL_UNDERLINE, PANGO_UNDERLINE_NONE,
/* End of columns */
-1);
counter++;
}
void ui_tree_view_destroy_list(GtkWidget *list)
......
......@@ -20,6 +20,9 @@ typedef enum col_type_e
COL_FOREGROUND,
COL_BACKGROUND,
COL_STRIKETHROUGH,
COL_STYLE,
COL_WEIGHT,
COL_UNDERLINE,
COL_BUFFER,
NUM_COLS
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment