guint32 ltt_event_get_unsigned(LttEvent *e, struct marker_field *f)
{
gboolean reverse_byte_order;
+ struct LttField *eventfield;
+ int offset, size;
if(unlikely(f->attributes & LTT_ATTRIBUTE_NETWORK_BYTE_ORDER)) {
reverse_byte_order = (g_ntohs(0x1) != 0x1);
reverse_byte_order = LTT_GET_BO(e->tracefile);
}
- switch(f->size) {
+ eventfield = ltt_event_field(e, marker_field_get_index(f));
+ offset = eventfield->offset;
+ size = eventfield->size;
+ switch(size) {
case 1:
{
- guint8 x = *(guint8 *)(e->data + f->offset);
- return (guint32) x;
+ guint8 x = *(guint8 *)(e->data + offset);
+ return (guint32) x;
}
break;
case 2:
- return (guint32)ltt_get_uint16(reverse_byte_order, e->data + f->offset);
+ return (guint32)ltt_get_uint16(reverse_byte_order, e->data + offset);
break;
case 4:
- return (guint32)ltt_get_uint32(reverse_byte_order, e->data + f->offset);
+ return (guint32)ltt_get_uint32(reverse_byte_order, e->data + offset);
break;
case 8:
default:
- g_critical("ltt_event_get_unsigned : field size %li unknown", f->size);
+ g_critical("ltt_event_get_unsigned : field size %i unknown", size);
return 0;
break;
}
gint32 ltt_event_get_int(LttEvent *e, struct marker_field *f)
{
gboolean reverse_byte_order;
+ struct LttField *eventfield;
+ int offset, size;
+
if(unlikely(f->attributes & LTT_ATTRIBUTE_NETWORK_BYTE_ORDER)) {
reverse_byte_order = (g_ntohs(0x1) != 0x1);
} else {
reverse_byte_order = LTT_GET_BO(e->tracefile);
}
- switch(f->size) {
+ eventfield = ltt_event_field(e, marker_field_get_index(f));
+ offset = eventfield->offset;
+ size = eventfield->size;
+ switch(size) {
case 1:
{
- gint8 x = *(gint8 *)(e->data + f->offset);
- return (gint32) x;
+ gint8 x = *(gint8 *)(e->data + offset);
+ return (gint32) x;
}
break;
case 2:
- return (gint32)ltt_get_int16(reverse_byte_order, e->data + f->offset);
+ return (gint32)ltt_get_int16(reverse_byte_order, e->data + offset);
break;
case 4:
- return (gint32)ltt_get_int32(reverse_byte_order, e->data + f->offset);
+ return (gint32)ltt_get_int32(reverse_byte_order, e->data + offset);
break;
case 8:
default:
- g_critical("ltt_event_get_int : field size %li unknown", f->size);
+ g_critical("ltt_event_get_int : field size %i unknown", size);
return 0;
break;
}
guint64 ltt_event_get_long_unsigned(LttEvent *e, struct marker_field *f)
{
gboolean reverse_byte_order;
+ struct LttField *eventfield;
+ int offset, size;
+
if(unlikely(f->attributes & LTT_ATTRIBUTE_NETWORK_BYTE_ORDER)) {
reverse_byte_order = (g_ntohs(0x1) != 0x1);
} else {
reverse_byte_order = LTT_GET_BO(e->tracefile);
}
- switch(f->size) {
+ eventfield = ltt_event_field(e, marker_field_get_index(f));
+ offset = eventfield->offset;
+ size = eventfield->size;
+ switch(size) {
case 1:
{
- guint8 x = *(guint8 *)(e->data + f->offset);
- return (guint64) x;
+ guint8 x = *(guint8 *)(e->data + offset);
+ return (guint64) x;
}
break;
case 2:
- return (guint64)ltt_get_uint16(reverse_byte_order, e->data + f->offset);
+ return (guint64)ltt_get_uint16(reverse_byte_order, e->data + offset);
break;
case 4:
- return (guint64)ltt_get_uint32(reverse_byte_order, e->data + f->offset);
+ return (guint64)ltt_get_uint32(reverse_byte_order, e->data + offset);
break;
case 8:
- return ltt_get_uint64(reverse_byte_order, e->data + f->offset);
+ return ltt_get_uint64(reverse_byte_order, e->data + offset);
break;
default:
- g_critical("ltt_event_get_long_unsigned : field size %li unknown", f->size);
+ g_critical("ltt_event_get_long_unsigned : field size %i unknown", size);
return 0;
break;
}
gint64 ltt_event_get_long_int(LttEvent *e, struct marker_field *f)
{
gboolean reverse_byte_order;
+ struct LttField *eventfield;
+ int offset, size;
+
if(unlikely(f->attributes & LTT_ATTRIBUTE_NETWORK_BYTE_ORDER)) {
reverse_byte_order = (g_ntohs(0x1) != 0x1);
} else {
reverse_byte_order = LTT_GET_BO(e->tracefile);
}
- switch(f->size) {
+ eventfield = ltt_event_field(e, marker_field_get_index(f));
+ offset = eventfield->offset;
+ size = eventfield->size;
+ switch(size) {
case 1:
{
- gint8 x = *(gint8 *)(e->data + f->offset);
+ gint8 x = *(gint8 *)(e->data + offset);
return (gint64) x;
}
break;
case 2:
- return (gint64)ltt_get_int16(reverse_byte_order, e->data + f->offset);
+ return (gint64)ltt_get_int16(reverse_byte_order, e->data + offset);
break;
case 4:
- return (gint64)ltt_get_int32(reverse_byte_order, e->data + f->offset);
+ return (gint64)ltt_get_int32(reverse_byte_order, e->data + offset);
break;
case 8:
- return ltt_get_int64(reverse_byte_order, e->data + f->offset);
+ return ltt_get_int64(reverse_byte_order, e->data + offset);
break;
default:
- g_critical("ltt_event_get_long_int : field size %li unknown", f->size);
+ g_critical("ltt_event_get_long_int : field size %i unknown", size);
return 0;
break;
}
float ltt_event_get_float(LttEvent *e, struct marker_field *f)
{
gboolean reverse_byte_order;
+ struct LttField *eventfield;
+ int offset, size;
+
if(unlikely(f->attributes & LTT_ATTRIBUTE_NETWORK_BYTE_ORDER)) {
reverse_byte_order = (g_ntohs(0x1) != 0x1);
} else {
reverse_byte_order = LTT_GET_FLOAT_BO(e->tracefile);
}
- g_assert(f->field_type.type_class == LTT_FLOAT && f->size == 4);
+ eventfield = ltt_event_field(e, marker_field_get_index(f));
+ offset = eventfield->offset;
+ size = eventfield->size;
+ g_assert(f->field_type.type_class == LTT_FLOAT && size == 4);
- if(reverse_byte_order == 0) return *(float *)(e->data + f->offset);
+ if(reverse_byte_order == 0) return *(float *)(e->data + offset);
else{
- void *ptr = e->data + f->offset;
+ void *ptr = e->data + offset;
guint32 value = bswap_32(*(guint32*)ptr);
return *(float*)&value;
}
double ltt_event_get_double(LttEvent *e, struct marker_field *f)
{
gboolean reverse_byte_order;
+ struct LttField *eventfield;
+ int offset, size;
+
if(unlikely(f->attributes & LTT_ATTRIBUTE_NETWORK_BYTE_ORDER)) {
reverse_byte_order = (g_ntohs(0x1) != 0x1);
} else {
reverse_byte_order = LTT_GET_FLOAT_BO(e->tracefile);
}
- if(f->size == 4)
+ eventfield = ltt_event_field(e, marker_field_get_index(f));
+ offset = eventfield->offset;
+ size = eventfield->size;
+ if(size == 4)
return ltt_event_get_float(e, f);
- g_assert(f->field_type.type_class == LTT_FLOAT && f->size == 8);
+ g_assert(f->field_type.type_class == LTT_FLOAT && size == 8);
- if(reverse_byte_order == 0) return *(double *)(e->data + f->offset);
+ if(reverse_byte_order == 0) return *(double *)(e->data + offset);
else {
- void *ptr = e->data + f->offset;
+ void *ptr = e->data + offset;
guint64 value = bswap_64(*(guint64*)ptr);
return *(double*)&value;
}
****************************************************************************/
gchar *ltt_event_get_string(LttEvent *e, struct marker_field *f)
{
+ struct LttField *eventfield;
+ int offset;
+
g_assert(f->type == LTT_TYPE_STRING);
//caused memory leaks
//return (gchar*)g_strdup((gchar*)(e->data + f->offset));
- return (gchar*)(e->data + f->offset);
+ eventfield = ltt_event_field(e, marker_field_get_index(f));
+ offset = eventfield->offset;
+ return (gchar*)(e->data + offset);
}
field->name = g_quark_from_string(tmpname);
}
field->type = trace_type;
+ field->index = info->fields->len-1;
field->fmt = g_string_new(field_fmt->str);
switch (trace_type) {
case LTT_TYPE_SIGNED_INT:
case LTT_TYPE_UNSIGNED_INT:
case LTT_TYPE_POINTER:
- field->size = trace_size;
+ field->_size = trace_size;
field->alignment = trace_size;
info->largest_align = max((guint8)field->alignment,
(guint8)info->largest_align);
field->attributes = attributes;
if (offset == -1) {
- field->offset = -1;
+ field->_offset = -1;
field->static_offset = 0;
return -1;
} else {
- field->offset = offset + ltt_align(offset, field->alignment,
+ field->_offset = offset + ltt_align(offset, field->alignment,
info->alignment);
field->static_offset = 1;
- return field->offset + trace_size;
+ return field->_offset + trace_size;
}
case LTT_TYPE_STRING:
- field->offset = offset;
- field->size = 0; /* Variable length, size is 0 */
+ field->_offset = offset;
+ field->_size = 0; /* Variable length, size is 0 */
field->alignment = 1;
if (offset == -1)
field->static_offset = 0;
for (i = info->fields->len - 1; i >= 0; i--) {
field = &g_array_index(info->fields, struct marker_field, i);
if (field->static_offset) {
- offset = field->offset;
+ offset = field->_offset;
break;
}
}
case LTT_TYPE_SIGNED_INT:
case LTT_TYPE_UNSIGNED_INT:
case LTT_TYPE_POINTER:
- field->offset = offset + ltt_align(offset, field->alignment,
+ field->_offset = offset + ltt_align(offset, field->alignment,
info->alignment);
- offset = field->offset + field->size;
+ offset = field->_offset + field->_size;
break;
case LTT_TYPE_STRING:
- field->offset = offset;
+ field->_offset = offset;
offset = offset + strlen(&data[offset]) + 1;
// not aligning on pointer size, breaking genevent backward compatibility.
break;
return offset;
}
+void marker_update_event_fields_offsets(GArray *fields_offsets,
+ struct marker_info *info)
+{
+ unsigned int i;
+
+ g_array_set_size(fields_offsets, info->fields->len);
+ for (i = 0; i < info->fields->len; i++) {
+ struct marker_field *mfield =
+ &g_array_index(info->fields, struct marker_field, i);
+ struct LttField *eventfield =
+ &g_array_index(fields_offsets, struct LttField, i);
+ eventfield->offset = mfield->_offset;
+ eventfield->size = mfield->_size;
+ g_assert(eventfield->offset != -1);
+ g_assert(eventfield->size != -1);
+ }
+}
+
static void format_parse(const char *fmt, struct marker_info *info)
{
char trace_size = 0, c_size = 0; /*