From: compudj Date: Fri, 19 Aug 2005 23:34:17 +0000 (+0000) Subject: fix header sizes and read trace header X-Git-Tag: v0.12.20~2467 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=16fcbb80a9bc02fc7288d0da626471f49c7c4d9e;p=lttv.git fix header sizes and read trace header git-svn-id: http://ltt.polymtl.ca/svn@1022 04897980-b3bd-0310-b5e0-8ef037075253 --- diff --git a/ltt/branches/poly/ltt/ltt-private.h b/ltt/branches/poly/ltt/ltt-private.h index 8c0308c4..409d0562 100644 --- a/ltt/branches/poly/ltt/ltt-private.h +++ b/ltt/branches/poly/ltt/ltt-private.h @@ -86,7 +86,7 @@ typedef guint16 uint16_t; typedef guint32 uint32_t; typedef guint64 uint64_t; -/* Hardcoded facility load event : this plus an following "name" string */ +/* Hardcoded facility load event : this plus an preceding "name" string */ struct LttFacilityLoad { guint32 checksum; guint32 id; @@ -94,11 +94,11 @@ struct LttFacilityLoad { guint32 pointer_size; guint32 size_t_size; guint32 alignment; -}; +} LTT_PACKED_STRUCT; struct LttFacilityUnload { guint32 id; -}; +} LTT_PACKED_STRUCT; struct LttStateDumpFacilityLoad { guint32 checksum; @@ -107,9 +107,7 @@ struct LttStateDumpFacilityLoad { guint32 pointer_size; guint32 size_t_size; guint32 alignment; -}; - - +} LTT_PACKED_STRUCT; typedef struct _TimeHeartbeat { LttTime time; //Time stamp of this block @@ -121,14 +119,14 @@ struct ltt_event_header_hb { unsigned char facility_id; unsigned char event_id; uint16_t event_size; -} __attribute((aligned(8))); +} LTT_PACKED_STRUCT; struct ltt_event_header_nohb { uint64_t timestamp; unsigned char facility_id; unsigned char event_id; uint16_t event_size; -} __attribute((aligned(8))); +} LTT_PACKED_STRUCT; struct ltt_trace_header { uint32_t magic_number; @@ -142,7 +140,7 @@ struct ltt_trace_header { uint8_t has_heartbeat; uint8_t has_alignment; /* Event header alignment */ uint8_t has_tsc; -} __attribute((aligned(8))); +} LTT_PACKED_STRUCT; struct ltt_block_start_header { @@ -157,7 +155,7 @@ struct ltt_block_start_header { uint32_t lost_size; /* Size unused at the end of the buffer */ uint32_t buf_size; /* The size of this sub-buffer */ struct ltt_trace_header trace; -} __attribute((aligned(8))); +} LTT_PACKED_STRUCT; struct _LttType{ @@ -345,11 +343,14 @@ struct _LttTrace{ /* Points to array of fac_id of all the * facilities that has this name. */ + guint32 arch_type; + guint32 arch_variant; + guint8 arch_size; guint8 ltt_major_version; guint8 ltt_minor_version; guint8 flight_recorder; guint8 has_heartbeat; - // guint8 alignment; + guint8 has_alignment; guint8 has_tsc; GData *tracefiles; //tracefiles groups diff --git a/ltt/branches/poly/ltt/tracefile.c b/ltt/branches/poly/ltt/tracefile.c index 694dadfe..3f1b2abd 100644 --- a/ltt/branches/poly/ltt/tracefile.c +++ b/ltt/branches/poly/ltt/tracefile.c @@ -937,6 +937,7 @@ LttTrace *ltt_trace_open(const gchar *pathname) LttTracefile *tf; GArray *group; int i; + struct ltt_block_start_header *header; t = g_new(LttTrace, 1); if(!t) goto alloc_error; @@ -966,13 +967,26 @@ LttTrace *ltt_trace_open(const gchar *pathname) goto facilities_error; } + /* Get the trace information for the control/facility 0 tracefile */ + g_assert(group->len > 0); + tf = &g_array_index (group, LttTracefile, 0); + header = (struct ltt_block_start_header*)tf->buffer.head; + t->arch_type = ltt_get_uint32(LTT_GET_BO(tf), &header->trace.arch_type); + t->arch_variant = ltt_get_uint32(LTT_GET_BO(tf), &header->trace.arch_variant); + t->arch_size = header->trace.arch_size; + t->ltt_major_version = header->trace.major_version; + t->ltt_minor_version = header->trace.minor_version; + t->flight_recorder = header->trace.flight_recorder; + t->has_heartbeat = header->trace.has_heartbeat; + t->has_alignment = header->trace.has_alignment; + t->has_tsc = header->trace.has_tsc; + + for(i=0; ilen; i++) { tf = &g_array_index (group, LttTracefile, i); if(ltt_process_facility_tracefile(tf)) goto facilities_error; } - - return t; @@ -1451,25 +1465,30 @@ int ltt_tracefile_read_update_event(LttTracefile *tf) //TODO align if(tf->trace->has_tsc) { - event->time.timestamp = ltt_get_uint32(LTT_GET_BO(tf), - pos); - /* 32 bits -> 64 bits tsc */ - /* note : still works for seek and non seek cases. */ - if(event->time.timestamp < (0xFFFFFFFFULL&tf->buffer.tsc)) { - tf->buffer.tsc = ((tf->buffer.tsc&0xFFFFFFFF00000000ULL) - + 0x100000000ULL) - | (guint64)event->time.timestamp; - event->tsc = tf->buffer.tsc; + if(tf->trace->has_heartbeat) { + event->time.timestamp = ltt_get_uint32(LTT_GET_BO(tf), + pos); + /* 32 bits -> 64 bits tsc */ + /* note : still works for seek and non seek cases. */ + if(event->time.timestamp < (0xFFFFFFFFULL&tf->buffer.tsc)) { + tf->buffer.tsc = ((tf->buffer.tsc&0xFFFFFFFF00000000ULL) + + 0x100000000ULL) + | (guint64)event->time.timestamp; + event->tsc = tf->buffer.tsc; + } else { + /* no overflow */ + tf->buffer.tsc = (tf->buffer.tsc&0xFFFFFFFF00000000ULL) + | (guint64)event->time.timestamp; + event->tsc = tf->buffer.tsc; + } + pos += sizeof(guint32); } else { - /* no overflow */ - tf->buffer.tsc = (tf->buffer.tsc&0xFFFFFFFF00000000ULL) - | (guint64)event->time.timestamp; - event->tsc = tf->buffer.tsc; + event->tsc = ltt_get_uint64(LTT_GET_BO(tf), pos); + tf->buffer.tsc = event->tsc; + pos += sizeof(guint64); } - + event->event_time = ltt_interpolate_time(tf, event); - - pos += sizeof(guint32); } else { event->time.delta.tv_sec = 0; event->time.delta.tv_nsec = ltt_get_uint32(LTT_GET_BO(tf),