X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Fltt%2Fltt-private.h;h=55374263f0bce980335fac2aca3bbcbcd80d794d;hb=bf33dd5091178cd0ad175b1914d74056db60e7af;hp=25692fae06a488161bc465566b87ad19c1da64b1;hpb=3aee1200b100fe8063661fd2d8eaa5fbbfc1977f;p=lttv.git diff --git a/ltt/branches/poly/ltt/ltt-private.h b/ltt/branches/poly/ltt/ltt-private.h index 25692fae..55374263 100644 --- a/ltt/branches/poly/ltt/ltt-private.h +++ b/ltt/branches/poly/ltt/ltt-private.h @@ -22,6 +22,13 @@ #include #include #include +#include + + +#ifndef max +#define max(a,b) ((a)>(b)?(a):(b)) +#endif + #define LTT_MAGIC_NUMBER 0x00D6B7ED #define LTT_REV_MAGIC_NUMBER 0xEDB7D600 @@ -30,17 +37,22 @@ #define LTT_PACKED_STRUCT __attribute__ ((packed)) -#define NUM_FACILITIES 256 - /* Hardcoded facilities */ #define LTT_FACILITY_CORE 0 + +/* Byte ordering */ +#define LTT_GET_BO(t) ((t)->reverse_bo) + +#define LTT_HAS_FLOAT(t) ((t)->float_word_order!=0) +#define LTT_GET_FLOAT_BO(t) \ + (((t)->float_word_order==__BYTE_ORDER)?0:1) /* Hardcoded core events */ enum ltt_core_events { LTT_EVENT_FACILITY_LOAD, LTT_EVENT_FACILITY_UNLOAD, - LTT_EVENT_STATE_DUMP_FACILITY_LOAD, - LTT_EVENT_HEARTBEAT + LTT_EVENT_HEARTBEAT, + LTT_EVENT_STATE_DUMP_FACILITY_LOAD }; @@ -82,7 +94,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; @@ -90,11 +102,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; @@ -103,9 +115,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 @@ -117,43 +127,85 @@ 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 { + +/* Block and trace headers */ + +struct ltt_trace_header_any { uint32_t magic_number; uint32_t arch_type; uint32_t arch_variant; + uint32_t float_word_order; uint8_t arch_size; - //uint32_t system_type; - uint8_t major_version; - uint8_t minor_version; - uint8_t flight_recorder; - uint8_t has_heartbeat; - uint8_t has_alignment; /* Event header alignment */ - uint8_t has_tsc; -} __attribute((aligned(8))); + uint8_t major_version; + uint8_t minor_version; + uint8_t flight_recorder; + uint8_t has_heartbeat; + uint8_t has_alignment; /* Event header alignment */ + uint8_t has_tsc; +} LTT_PACKED_STRUCT; + + +/* For version 0.3 */ + +struct ltt_trace_header_0_3 { + uint32_t magic_number; + uint32_t arch_type; + uint32_t arch_variant; + uint32_t float_word_order; + uint8_t arch_size; + uint8_t major_version; + uint8_t minor_version; + uint8_t flight_recorder; + uint8_t has_heartbeat; + uint8_t has_alignment; /* Event header alignment */ + uint8_t has_tsc; +} LTT_PACKED_STRUCT; + +/* For version 0.4 */ + +struct ltt_trace_header_0_4 { + uint32_t magic_number; + uint32_t arch_type; + uint32_t arch_variant; + uint32_t float_word_order; + uint8_t arch_size; + uint8_t major_version; + uint8_t minor_version; + uint8_t flight_recorder; + uint8_t has_heartbeat; + uint8_t has_alignment; /* Event header alignment */ + uint8_t has_tsc; + uint64_t start_freq; + uint64_t start_tsc; + uint64_t start_monotonic; + struct timespec start_time; +} LTT_PACKED_STRUCT; struct ltt_block_start_header { struct { - struct timeval timestamp; + uint64_t timestamp; uint64_t cycle_count; + uint64_t freq; } begin; struct { - struct timeval timestamp; + uint64_t timestamp; uint64_t cycle_count; + uint64_t freq; } end; 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))); + struct ltt_trace_header_any trace[0]; +} LTT_PACKED_STRUCT; struct _LttType{ @@ -183,7 +235,7 @@ struct _LttEvent{ /* Begin of LttEventPosition fields */ LttTracefile *tracefile; unsigned int block; - void *offset; + unsigned int offset; /* Timekeeping */ uint64_t tsc; /* Current timestamp counter */ @@ -201,6 +253,9 @@ struct _LttEvent{ LttTime event_time; void * data; //event data + guint data_size; + guint event_size; //event_size field of the header : + //used to verify data_size from facility. int count; //the number of overflow of cycle count gint64 overflow_nsec; //precalculated nsec for overflows @@ -209,7 +264,7 @@ struct _LttEvent{ struct _LttEventPosition{ LttTracefile *tracefile; unsigned int block; - void *offset; + unsigned int offset; /* Timekeeping */ uint64_t tsc; /* Current timestamp counter */ @@ -263,6 +318,7 @@ struct _LttFacility{ guint32 id; //id of the facility guint32 pointer_size; + guint32 long_size; guint32 size_t_size; guint32 alignment; @@ -288,28 +344,36 @@ typedef struct _LttBuffer { struct { LttTime timestamp; uint64_t cycle_count; + uint64_t freq; /* Frequency in khz */ } begin; struct { LttTime timestamp; uint64_t cycle_count; + uint64_t freq; /* Frequency in khz */ } end; uint32_t lost_size; /* Size unused at the end of the buffer */ /* Timekeeping */ uint64_t tsc; /* Current timestamp counter */ - double nsecs_per_cycle; + uint64_t freq; /* Frequency in khz */ + //double nsecs_per_cycle; /* Precalculated from freq */ + guint32 cyc2ns_scale; } LttBuffer; struct _LttTracefile{ gboolean cpu_online; //is the cpu online ? + GQuark long_name; //tracefile complete filename GQuark name; //tracefile name guint cpu_num; //cpu number of the tracefile LttTrace * trace; //trace containing the tracefile int fd; //file descriptor off_t file_size; //file size - unsigned block_size; //block_size + //unsigned block_size; //block_size unsigned int num_blocks; //number of blocks in the file gboolean reverse_bo; //must we reverse byte order ? + gboolean float_word_order; //what is the byte order of floats ? + + size_t buffer_header_size; /* Current event */ LttEvent event; //Event currently accessible in the trace @@ -338,14 +402,23 @@ struct _LttTrace{ GArray *facilities_by_num; /* fac_id as index in array */ GData *facilities_by_name; /* fac name (GQuark) as index */ /* Points to array of fac_id of all the - * facilities that has this name. */ + * facilities that has this name. */ + guint num_cpu; + 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; + uint64_t start_freq; + uint64_t start_tsc; + uint64_t start_monotonic; + LttTime start_time; + LttTime start_time_from_tsc; GData *tracefiles; //tracefiles groups }; @@ -380,7 +453,5 @@ struct _LttSystemDescription { //#define EVENT_ID_SIZE sizeof(guint16) //#define EVENT_HEADER_SIZE (TIMESTAMP_SIZE + EVENT_ID_SIZE) -#define LTT_GET_BO(t) ((t)->reverse_bo) - #endif /* LTT_PRIVATE_H */