Commit 27637f8a authored by Cedric Roux's avatar Cedric Roux

- Fixed pointer of function dissection

- Fixed 64bits pointers

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4272 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent fd7dcaf9
......@@ -52,7 +52,7 @@ int buffer_fetch(buffer_t *buffer, uint32_t offset, int size, void *value)
return -1;
if (buffer->size_bytes < ((offset >> 3) + size)) {
g_debug("Not enough data to fetch");
g_warning("Not enough data to fetch");
return -1;
}
......@@ -62,6 +62,17 @@ int buffer_fetch(buffer_t *buffer, uint32_t offset, int size, void *value)
return 0;
}
int buffer_fetch_nbytes(buffer_t *buffer, uint32_t offset, int n_bytes, uint8_t *value)
{
if (buffer->size_bytes < ((offset >> 3) + n_bytes)) {
g_warning("Not enough data to fetch");
return -1;
}
memcpy(&value[0], &buffer->data[offset >> 3], n_bytes);
return 0;
}
int buffer_fetch_bits(buffer_t *buffer, uint32_t offset, int nbits, uint32_t *value)
{
uint32_t temp = 0;
......
......@@ -27,6 +27,8 @@ uint32_t buffer_get_uint32_t(buffer_t *buffer, uint32_t offset);
int buffer_fetch_bits(buffer_t *buffer, uint32_t offset, int nbits, uint32_t *value);
int buffer_fetch_nbytes(buffer_t *buffer, uint32_t offset, int n_bytes, uint8_t *value);
void buffer_dump(buffer_t *buffer, FILE *to);
int buffer_append_data(buffer_t *buffer, const uint8_t *data, const uint32_t length);
......
......@@ -61,7 +61,6 @@ int array_dissect_from_buffer(
length = sprintf(cbuf, "[%d .. %d] ", i, items -1);
// ui_interface.ui_signal_set_text(cpy, length);
ui_set_signal_text_cb(user_data, cbuf, length);
type->child->type_dissect_from_buffer (
type->child, ui_set_signal_text_cb, user_data,
......
......@@ -10,34 +10,42 @@ int pointer_dissect_from_buffer(
struct types_s *type, ui_set_signal_text_cb_t ui_set_signal_text_cb, gpointer user_data,
buffer_t *buffer, uint32_t offset, uint32_t parent_offset, int indent)
{
int length = 0;
int length = 0, i;
char cbuf[200];
uint32_t value;
DISPLAY_PARSE_INFO("pointer", type->name, offset, parent_offset);
memset (cbuf, 0, 200);
value = buffer_get_uint32_t (buffer, parent_offset + offset);
uint8_t value[type->size / 8];
buffer_fetch_nbytes(buffer, parent_offset + offset, type->size / 8, value);
DISPLAY_TYPE("Ptr");
if (type->child->name) {
if (type->child->name && type->child) {
/*
INDENTED(stdout, indent, fprintf(stdout, "<%s>0x%08x</%s>\n",
type->child->name, value, type->child->name));
*/
INDENTED_STRING(cbuf, indent, sprintf(cbuf, "(%s *) 0x%08x;\n", type->child->name, value));
INDENTED_STRING(cbuf, indent, sprintf(cbuf, "(%s *) 0x", type->child->name));
}
else {
/*
INDENTED(stdout, indent, fprintf(stdout, "<Pointer>0x%08x</Pointer>\n",
value));
*/
INDENTED_STRING(cbuf, indent, sprintf(cbuf, "(void *) 0x%08x;\n", value));
INDENTED_STRING(cbuf, indent, sprintf(cbuf, "(void *) 0x"));
}
length = strlen (cbuf);
/* Append the value */
for (i = type->size / 8 - 1; i != 0; i--) {
length += sprintf(&cbuf[length], "%02x", value[i]);
}
length += sprintf(&cbuf[length], ";\n");
ui_set_signal_text_cb(user_data, cbuf, length);
return 0;
......@@ -51,8 +59,15 @@ int pointer_type_file_print(struct types_s *type, int indent, FILE *file) {
INDENTED(file, indent+4, fprintf(file, "Type .......: %d\n", type->type_xml));
INDENTED(file, indent+4, fprintf(file, "Size .......: %d\n", type->size));
INDENTED(file, indent+4, fprintf(file, "Align ......: %d\n", type->align));
if (type->child != NULL)
type->child->type_file_print (type->child, indent + 4, file);
if (type->child != NULL) {
if (type->child->type == TYPE_FUNCTION) {
INDENTED(file, indent+4, fprintf(file, "<Function>\n"));
INDENTED(file, indent+8, fprintf(file, "<Args>To be done</Args>\n"));
INDENTED(file, indent+4, fprintf(file, "</Function>\n"));
} else {
type->child->type_file_print (type->child, indent + 4, file);
}
}
if (type->file_ref != NULL)
type->file_ref->type_file_print (type->file_ref, indent + 4, file);
INDENTED(file, indent, fprintf(file, "</Pointer>\n"));
......@@ -61,18 +76,5 @@ int pointer_type_file_print(struct types_s *type, int indent, FILE *file) {
}
int pointer_type_hr_display(struct types_s *type, int indent) {
if (type == NULL)
return -1;
INDENTED(stdout, indent, printf("<Pointer>\n"));
INDENTED(stdout, indent+4, printf("Id .........: %d\n", type->id));
INDENTED(stdout, indent+4, printf("Type .......: %d\n", type->type_xml));
INDENTED(stdout, indent+4, printf("Size .......: %d\n", type->size));
INDENTED(stdout, indent+4, printf("Align ......: %d\n", type->align));
if (type->child != NULL)
type->child->type_hr_display (type->child, indent + 4);
if (type->file_ref != NULL)
type->file_ref->type_hr_display (type->file_ref, indent + 4);
INDENTED(stdout, indent, printf("</Pointer>\n"));
return 0;
return pointer_type_file_print(type, indent, stdout);
}
......@@ -26,6 +26,9 @@ types_t *type_new(enum type_e type)
new_p->type = type;
switch(type) {
case TYPE_FUNCTION:
/* Nothing to do for now. Display is done by pointer type */
break;
case TYPE_ENUMERATION:
new_p->type_hr_display = enum_type_hr_display;
new_p->type_file_print = enum_type_file_print;
......
......@@ -573,6 +573,21 @@ static int parse_pointer_type(xmlNode *node, types_t **head) {
return 0;
}
static int parse_function_type(xmlNode *node, types_t **head) {
types_t *new;
if (node == NULL)
return -1;
new = type_new (TYPE_FUNCTION);
CHECK_FCT(parse_attribute_id(node, new));
CHECK_FCT(types_insert_tail(head, new));
return 0;
}
/**
* print_element_names:
* @a_node: the initial xml node to consider.
......@@ -620,12 +635,16 @@ static int parse_elements(xmlNode * a_node, types_t **head) {
}
else
if (strcmp ((char *) child_node->name, "ArrayType") == 0) {
CHECK_FCT_DO(parse_array_type(child_node, head), return RC_FAIL);
CHECK_FCT_DO(parse_array_type(child_node, head), return RC_FAIL);
}
else
if (strcmp ((char *) child_node->name, "PointerType") == 0) {
CHECK_FCT_DO(parse_pointer_type(child_node, head), return RC_FAIL);
CHECK_FCT_DO(parse_pointer_type(child_node, head), return RC_FAIL);
}
else
if (strcmp ((char *) child_node->name, "FunctionType") == 0) {
CHECK_FCT_DO(parse_function_type(child_node, head), return RC_FAIL);
}
}
}
}
......@@ -713,6 +732,7 @@ static int xml_parse_doc(xmlDocPtr doc) {
resolve_struct (&head);
resolve_file (&head);
resolve_union (&head);
resolve_function (&head);
/* Locate the root element which corresponds to the MessageDef struct */
CHECK_FCT(locate_root("MessageDef", head, &root));
/* Locate the message id enumeration */
......
......@@ -206,7 +206,7 @@ int resolve_pointer_type(types_t **head)
if (next_type->type != TYPE_POINTER)
continue;
// printf("Trying to resolve pointer id %d with type %d\n",
// g_debug("Trying to resolve pointer id %d with type %d\n",
// next_type->id, next_type->type_xml);
if (search_id(*head, &next_type->child, next_type->type_xml) != RESOLV_OK) {
......@@ -299,6 +299,33 @@ int resolve_array(types_t **head)
return 0;
}
int resolve_function(types_t **head)
{
types_t *next_type;
if (!head) {
g_warning("Empty list detected");
return RESOLV_LIST_EMPTY;
}
for (next_type = *head; next_type; next_type = next_type->next)
{
/* Only resolve typedef */
if (next_type->type != TYPE_FUNCTION)
continue;
// g_debug("Trying to resolve function id %d with type %d\n",
// next_type->id, next_type->type_xml);
if (search_id(*head, &next_type->child, next_type->type_xml) != RESOLV_OK) {
/* We have to remove this reference */
}
// next_type->type_hr_display(next_type, 0);
}
return 0;
}
int resolve_file(types_t **head)
{
types_t *next_type;
......
......@@ -17,6 +17,8 @@ int resolve_union(types_t **head);
int resolve_file(types_t **head);
int resolve_function(types_t **head);
int search_file(types_t *head, types_t **found, int id);
#endif /* RESOLVERS_H_ */
......@@ -238,6 +238,13 @@ gboolean ui_callback_on_connect(GtkWidget *widget,
/* Disable the connect button */
ui_disable_connect_button();
/* Disable buttons to move in the list of signals */
gtk_widget_set_sensitive(GTK_WIDGET(ui_main_data.signals_clear_button), FALSE);
gtk_widget_set_sensitive(GTK_WIDGET(ui_main_data.signals_go_to_button), FALSE);
gtk_widget_set_sensitive(GTK_WIDGET(ui_main_data.signals_go_to_last_button), FALSE);
gtk_widget_set_sensitive(GTK_WIDGET(ui_main_data.signals_go_to_first_button), FALSE);
ui_tree_view_destroy_list(ui_main_data.signalslist);
if (socket_connect_to_remote_host(ip, port, pipe_fd[1]) != 0) {
ui_enable_connect_button();
return FALSE;
......
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