- if(tf->trace->has_heartbeat) {
- event->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->timestamp < (0xFFFFFFFFULL&tf->buffer.tsc)) {
- tf->buffer.tsc = ((tf->buffer.tsc&0xFFFFFFFF00000000ULL)
- + 0x100000000ULL)
- | (guint64)event->timestamp;
- event->tsc = tf->buffer.tsc;
- } else {
- /* no overflow */
- tf->buffer.tsc = (tf->buffer.tsc&0xFFFFFFFF00000000ULL)
- | (guint64)event->timestamp;
- event->tsc = tf->buffer.tsc;
- }
- pos += sizeof(guint32);
- } else {
- 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);
- event->facility_id = *(guint8*)pos;
- pos += sizeof(guint8);
+ if(tf->has_heartbeat) {
+ event->timestamp = ltt_get_uint32(LTT_GET_BO(tf),
+ pos);
+ if(!tf->compact) {
+ /* 32 bits -> 64 bits tsc */
+ /* note : still works for seek and non seek cases. */
+ if(event->timestamp < (0xFFFFFFFFULL&tf->buffer.tsc)) {
+ tf->buffer.tsc = ((tf->buffer.tsc&0xFFFFFFFF00000000ULL)
+ + 0x100000000ULL)
+ | (guint64)event->timestamp;
+ event->tsc = tf->buffer.tsc;
+ } else {
+ /* no overflow */
+ tf->buffer.tsc = (tf->buffer.tsc&0xFFFFFFFF00000000ULL)
+ | (guint64)event->timestamp;
+ event->tsc = tf->buffer.tsc;
+ event->compact_data = 0;
+ }
+ } else {
+ /* Compact header */
+ /* We keep the LSB of the previous timestamp, to make sure
+ * we never go back */
+ event->event_id = event->timestamp >> tf->tscbits;
+ event->event_id = event->event_id & ((1 << tf->compact_event_bits) - 1);
+ event->compact_data = event->timestamp >>
+ (tf->compact_event_bits + tf->tscbits);
+ //printf("tsc bits %u, ev bits %u init data %u\n",
+ // tf->tscbits, tf->trace->compact_event_bits, event->compact_data);
+ /* Put the compact data back in original endianness */
+ event->compact_data = ltt_get_uint32(LTT_GET_BO(tf), &event->compact_data);
+ event->event_size = 0xFFFF;
+ //printf("Found compact event %d\n", event->event_id);
+ //printf("Compact data %d\n", event->compact_data);
+ event->timestamp = event->timestamp << tf->tsc_lsb_truncate;
+ event->timestamp = event->timestamp & tf->tsc_mask;
+ //printf("timestamp 0x%lX\n", event->timestamp);
+ //printf("mask 0x%llX\n", tf->tsc_mask);
+ //printf("mask_next 0x%llX\n", tf->tsc_mask_next_bit);
+ //printf("previous tsc 0x%llX\n", tf->buffer.tsc);
+ //printf("previous tsc&mask 0x%llX\n", tf->tsc_mask&tf->buffer.tsc);
+ //printf("previous tsc&(~mask) 0x%llX\n", tf->buffer.tsc&(~tf->tsc_mask));
+ if(event->timestamp < (tf->tsc_mask&tf->buffer.tsc)) {
+ //printf("wrap\n");
+ tf->buffer.tsc = ((tf->buffer.tsc&(~tf->tsc_mask))
+ + tf->tsc_mask_next_bit)
+ | (guint64)event->timestamp;
+ event->tsc = tf->buffer.tsc;
+ } else {
+ //printf("no wrap\n");
+ /* no overflow */
+ tf->buffer.tsc = (tf->buffer.tsc&(~tf->tsc_mask))
+ | (guint64)event->timestamp;
+ event->tsc = tf->buffer.tsc;
+ }
+ //printf("current tsc 0x%llX\n", tf->buffer.tsc);
+ }
+ pos += sizeof(guint32);
+ } else {
+ event->tsc = ltt_get_uint64(LTT_GET_BO(tf), pos);
+ tf->buffer.tsc = event->tsc;
+ event->compact_data = 0;
+ pos += sizeof(guint64);
+ }
+ event->event_time = ltt_interpolate_time(tf, event);