quit menu complete
[lttv.git] / ltt / branches / poly / include / ltt / ltt.h
CommitLineData
7c6b3cd7 1#ifndef LTT_H
2#define LTT_H
975e44c7 3
fcdf0ec2 4#include <ltt/LTTTypes.h>
975e44c7 5
6/* A trace is associated with a tracing session run on a single, possibly
7 multi-cpu, system. It is defined as a pathname to a directory containing
8 all the relevant trace files. All the tracefiles for a trace were
9 generated in a single system for the same time period by the same
290dfc8c 10 trace daemon. They simply contain different events. Typically control
11 tracefiles contain the important events (process creations and registering
1b82f325 12 tracing facilities) for all CPUs, and one file for each CPU contains all
13 the events for that CPU. All the tracefiles within the same trace directory
975e44c7 14 then use the exact same id numbers for event types.
15
290dfc8c 16 A tracefile (LttTracefile) contains a list of events (LttEvent) sorted
975e44c7 17 by time for each CPU; events from different CPUs may be slightly out of
18 order, especially using the (possibly drifting) cycle counters as
19 time unit.
20
290dfc8c 21 A facility is a list of event types (LttEventType), declared in a special
22 eventdefs file. A corresponding checksum differentiates different
23 facilities which would have the same name but a different content
24 (e.g., different versions). The files are stored within the trace
25 directory and are accessed automatically upon opening a trace.
1b82f325 26 The list of facilities (and associated checksum) used in a trace
975e44c7 27 must be known in order to properly decode the contained events. An event
290dfc8c 28 is stored in the "facilities" control tracefile to denote each different
29 facility used.
975e44c7 30
290dfc8c 31 Event types (LttEventType) refer to data types (LttType) describing
975e44c7 32 their content. The data types supported are integer and unsigned integer
33 (of various length), enumerations (a special form of unsigned integer),
34 floating point (of various length), fixed size arrays, sequence
35 (variable sized arrays), structures and null terminated strings.
36 The elements of arrays and sequences, and the data members for
290dfc8c 37 structures, may be of any nested data type (LttType).
975e44c7 38
290dfc8c 39 An LttField is a special object to denote a specific, possibly nested,
975e44c7 40 field within an event type. Suppose an event type socket_connect is a
1b82f325 41 structure containing two data members, source and destination, of type
975e44c7 42 socket_address. Type socket_address contains two unsigned integer
290dfc8c 43 data members, ip and port. An LttField is different from a data type
975e44c7 44 structure member since it can denote a specific nested field, like the
45 source port, and store associated access information (byte offset within
290dfc8c 46 the event data). The LttField objects are trace specific since the
975e44c7 47 contained information (byte offsets) may vary with the architecture
1b82f325 48 associated to the trace. */
975e44c7 49
290dfc8c 50typedef struct _LttTrace LttTrace;
1b82f325 51
290dfc8c 52typedef struct _LttTracefile LttTracefile;
975e44c7 53
290dfc8c 54typedef struct _LttFacility LttFacility;
975e44c7 55
290dfc8c 56typedef struct _LttEventType LttEventType;
975e44c7 57
290dfc8c 58typedef struct _LttType LttType;
975e44c7 59
290dfc8c 60typedef struct _LttField LttField;
975e44c7 61
290dfc8c 62typedef struct _LttEvent LttEvent;
975e44c7 63
8a2d0e71 64typedef struct _LttSystemDescription LttSystemDescription;
975e44c7 65
975e44c7 66/* Checksums are used to differentiate facilities which have the same name
67 but differ. */
68
290dfc8c 69typedef unsigned long LttChecksum;
975e44c7 70
71
72/* Events are usually stored with the easily obtained CPU clock cycle count,
73 ltt_cycle_count. This can be converted to the real time value, ltt_time,
74 using linear interpolation between regularly sampled values (e.g. a few
75 times per second) of the real time clock with their corresponding
76 cycle count values. */
77
5fb21f61 78typedef struct _LttTime {
79 unsigned long tv_sec;
80 unsigned long tv_nsec;
81} LttTime;
975e44c7 82
290dfc8c 83typedef uint64_t LttCycleCount;
975e44c7 84
fb1a869e 85#define NANSECOND_CONST 1000000000
86
80da81ad 87/* Event positions are used to seek within a tracefile based on
88 the block number and event position within the block. */
89
90typedef struct _LttEventPosition LttEventPosition;
91
1b82f325 92
93/* Differences between architectures include word sizes, endianess,
94 alignment, floating point format and calling conventions. For a
95 packed binary trace, endianess and size matter, assuming that the
96 floating point format is standard (and is seldom used anyway). */
97
290dfc8c 98typedef enum _LttArchSize
7c6b3cd7 99{ LTT_LP32, LTT_ILP32, LTT_LP64, LTT_ILP64, LTT_UNKNOWN
290dfc8c 100} LttArchSize;
7c6b3cd7 101
1b82f325 102
290dfc8c 103typedef enum _LttArchEndian
7c6b3cd7 104{ LTT_LITTLE_ENDIAN, LTT_BIG_ENDIAN
290dfc8c 105} LttArchEndian;
975e44c7 106
370dd87e 107/* Time operation macros for LttTime (struct timespec) */
108/* (T3 = T2 - T1) */
109#define TimeSub(T3, T2, T1) \
110do \
111{\
112 (T3).tv_sec = (T2).tv_sec - (T1).tv_sec; \
fb1a869e 113 if((T2).tv_nsec < (T1).tv_nsec)\
370dd87e 114 {\
115 (T3).tv_sec--;\
fb1a869e 116 (T3).tv_nsec = NANSECOND_CONST - (T1).tv_nsec + (T2).tv_nsec;\
117 }\
118 else\
119 {\
120 (T3).tv_nsec = (T2).tv_nsec - (T1).tv_nsec;\
370dd87e 121 }\
122} while(0)
123
124/* (T3 = T2 + T1) */
125#define TimeAdd(T3, T2, T1) \
126do \
127{\
128 (T3).tv_sec = (T2).tv_sec + (T1).tv_sec; \
129 (T3).tv_nsec = (T2).tv_nsec + (T1).tv_nsec; \
fb1a869e 130 if((T3).tv_nsec >= NANSECOND_CONST)\
370dd87e 131 {\
fb1a869e 132 (T3).tv_sec += (T3).tv_nsec / NANSECOND_CONST;\
133 (T3).tv_nsec = (T3).tv_nsec % NANSECOND_CONST;\
370dd87e 134 }\
135} while(0)
136
fc17f7eb 137/* (T2 = T1 * FLOAT) */
138/* WARNING : use this multiplicator carefully : on 32 bits, multiplying
139 * by more than 4 could overflow the tv_nsec.
140 */
141#define TimeMul(T2, T1, FLOAT) \
142do \
143{\
144 (T2).tv_sec = (T1).tv_sec * (FLOAT); \
145 (T2).tv_nsec = (T1).tv_nsec * (FLOAT); \
fb1a869e 146 if((T2).tv_nsec >= NANSECOND_CONST)\
fc17f7eb 147 {\
fb1a869e 148 (T2).tv_sec += (T2).tv_nsec / NANSECOND_CONST;\
149 (T2).tv_nsec = (T2).tv_nsec % NANSECOND_CONST;\
fc17f7eb 150 }\
151} while(0)
152
153
975e44c7 154
155
7c6b3cd7 156#include <ltt/ltt-private.h>
157
158
159#endif // LTT_H
This page took 0.032848 seconds and 4 git commands to generate.