diff --git a/common/utils/itti_analyzer/libbuffers/buffers.c b/common/utils/itti_analyzer/libbuffers/buffers.c index 3e017216c8507c62e554dc940e905cc4dd021e2c..5a165ab7cb396946ddaf1f99a17842cd99901ba8 100644 --- a/common/utils/itti_analyzer/libbuffers/buffers.c +++ b/common/utils/itti_analyzer/libbuffers/buffers.c @@ -43,6 +43,16 @@ uint32_t buffer_get_uint32_t(buffer_t *buffer, uint32_t offset) return value; } +/* Try to fetch 64 bits unsigned from the buffer */ +uint64_t buffer_get_uint64_t(buffer_t *buffer, uint32_t offset) +{ + uint64_t value; + + buffer_fetch(buffer, offset, 8, &value); + + return value; +} + static int buffer_fetch(buffer_t *buffer, uint32_t offset, int size, void *value) { diff --git a/common/utils/itti_analyzer/libbuffers/buffers.h b/common/utils/itti_analyzer/libbuffers/buffers.h index 39b836dc00dc208abeaa1522f7ce36fe7cd71ee1..51799a5e21c00b317b8bf243ada330339b62de38 100644 --- a/common/utils/itti_analyzer/libbuffers/buffers.h +++ b/common/utils/itti_analyzer/libbuffers/buffers.h @@ -25,6 +25,8 @@ uint16_t buffer_get_uint16_t(buffer_t *buffer, uint32_t offset); uint32_t buffer_get_uint32_t(buffer_t *buffer, uint32_t offset); +uint64_t buffer_get_uint64_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); diff --git a/common/utils/itti_analyzer/libparser/fundamental_type.c b/common/utils/itti_analyzer/libparser/fundamental_type.c index 3a4388ccdce6b7d5846f068328cda2bfb504a368..b3291adc6d42671b8a590b9aecdd88320c708dc7 100644 --- a/common/utils/itti_analyzer/libparser/fundamental_type.c +++ b/common/utils/itti_analyzer/libparser/fundamental_type.c @@ -2,26 +2,31 @@ #include <stdlib.h> #include <string.h> #include <ctype.h> +#include <inttypes.h> #include "fundamental_type.h" #include "ui_interface.h" -uint32_t fundamental_read_from_buffer(struct types_s *type, buffer_t *buffer, uint32_t offset, uint32_t parent_offset) { - uint32_t value; +uint64_t fundamental_read_from_buffer(struct types_s *type, buffer_t *buffer, uint32_t offset, uint32_t parent_offset) { + uint64_t value; switch (type->size) { - case 8: { + case 8: value = buffer_get_uint8_t (buffer, offset + parent_offset); - } break; - case 16: { + + case 16: value = buffer_get_uint16_t (buffer, offset + parent_offset); - } break; - case 32: { + + case 32: value = buffer_get_uint32_t (buffer, offset + parent_offset); - } break; + + case 64: + value = buffer_get_uint64_t (buffer, offset + parent_offset); + break; + default: /* ??? */ value = 0; @@ -37,7 +42,10 @@ int fundamental_dissect_from_buffer( int length = 0; char cbuf[200]; int type_unsigned; - uint32_t value; + uint8_t value8; + uint16_t value16; + uint32_t value32; + uint64_t value64; DISPLAY_PARSE_INFO("fundamental", type->name, offset, parent_offset); @@ -45,28 +53,36 @@ int fundamental_dissect_from_buffer( type_unsigned = strstr (type->name, "unsigned") == NULL ? 0 : 1; - value = fundamental_read_from_buffer(type, buffer, offset, parent_offset); + value64 = fundamental_read_from_buffer(type, buffer, offset, parent_offset); if (indent > 0) { DISPLAY_TYPE("Fun"); } switch (type->size) { - case 8: { + case 8: + value8 = (uint8_t) value64; INDENTED_STRING(cbuf, indent, - sprintf(cbuf, type_unsigned ? "(0x%02x) %3u '%c';\n" : "(0x%02x) %4d '%c';\n", value, value, isprint(value) ? value : '.')); - } + sprintf(cbuf, type_unsigned ? "(0x%02" PRIx8 ") %3" PRIu8 " '%c';\n" : "(0x%02" PRIx8 ") %4" PRId8 " '%c';\n", value8, value8, isprint(value8) ? value8 : '.')); break; - case 16: { + + case 16: + value16 = (uint16_t) value64; INDENTED_STRING(cbuf, indent, - sprintf(cbuf, type_unsigned ? "(0x%04x) %5u;\n" : "(0x%04x) %6d;\n", value, value)); - } + sprintf(cbuf, type_unsigned ? "(0x%04" PRIx16 ") %5" PRIu16 ";\n" : "(0x%04" PRIx16 ") %6" PRId16 ";\n", value16, value16)); break; - case 32: { + + case 32: + value32 = (uint32_t) value64; INDENTED_STRING(cbuf, indent, - sprintf(cbuf, type_unsigned ? "(0x%08x) %9u;\n" : "(0x%08x) %10d;\n", value, value)); - } + sprintf(cbuf, type_unsigned ? "(0x%08" PRIx32 ") %9" PRIu32 ";\n" : "(0x%08" PRIx32 ") %10" PRId32 ";\n", value32, value32)); break; + + case 64: + INDENTED_STRING(cbuf, indent, + sprintf(cbuf, type_unsigned ? "(0x%016" PRIx64 ") %20" PRIu64 ";\n" : "(0x%016" PRIx64 ") %20" PRId64 ";\n", value64, value64)); + break; + default: /* ??? */ break; diff --git a/common/utils/itti_analyzer/libparser/fundamental_type.h b/common/utils/itti_analyzer/libparser/fundamental_type.h index 956788a8d2eb87937fe6501de2f111bca668be31..0b58a426fedb7d70e8068ce5adea7ce764bdfec7 100644 --- a/common/utils/itti_analyzer/libparser/fundamental_type.h +++ b/common/utils/itti_analyzer/libparser/fundamental_type.h @@ -3,7 +3,7 @@ #ifndef FUNDAMENTAL_TYPE_H_ #define FUNDAMENTAL_TYPE_H_ -uint32_t fundamental_read_from_buffer(struct types_s *type, buffer_t *buffer, uint32_t offset, uint32_t parent_offset); +uint64_t fundamental_read_from_buffer(struct types_s *type, buffer_t *buffer, uint32_t offset, uint32_t parent_offset); int fundamental_dissect_from_buffer( struct types_s *type, ui_set_signal_text_cb_t ui_set_signal_text_cb, gpointer user_data,