7c6b3cd7 |
1 | #ifndef LTT_H |
2 | #define LTT_H |
975e44c7 |
3 | |
308711e5 |
4 | #include <ltt/time.h> |
cbd41522 |
5 | #include <glib.h> |
975e44c7 |
6 | |
7 | /* A trace is associated with a tracing session run on a single, possibly |
8 | multi-cpu, system. It is defined as a pathname to a directory containing |
9 | all the relevant trace files. All the tracefiles for a trace were |
10 | generated in a single system for the same time period by the same |
290dfc8c |
11 | trace daemon. They simply contain different events. Typically control |
12 | tracefiles contain the important events (process creations and registering |
1b82f325 |
13 | tracing facilities) for all CPUs, and one file for each CPU contains all |
14 | the events for that CPU. All the tracefiles within the same trace directory |
975e44c7 |
15 | then use the exact same id numbers for event types. |
16 | |
290dfc8c |
17 | A tracefile (LttTracefile) contains a list of events (LttEvent) sorted |
975e44c7 |
18 | by time for each CPU; events from different CPUs may be slightly out of |
19 | order, especially using the (possibly drifting) cycle counters as |
20 | time unit. |
21 | |
290dfc8c |
22 | A facility is a list of event types (LttEventType), declared in a special |
23 | eventdefs file. A corresponding checksum differentiates different |
24 | facilities which would have the same name but a different content |
25 | (e.g., different versions). The files are stored within the trace |
26 | directory and are accessed automatically upon opening a trace. |
1b82f325 |
27 | The list of facilities (and associated checksum) used in a trace |
975e44c7 |
28 | must be known in order to properly decode the contained events. An event |
290dfc8c |
29 | is stored in the "facilities" control tracefile to denote each different |
30 | facility used. |
975e44c7 |
31 | |
290dfc8c |
32 | Event types (LttEventType) refer to data types (LttType) describing |
975e44c7 |
33 | their content. The data types supported are integer and unsigned integer |
34 | (of various length), enumerations (a special form of unsigned integer), |
35 | floating point (of various length), fixed size arrays, sequence |
36 | (variable sized arrays), structures and null terminated strings. |
37 | The elements of arrays and sequences, and the data members for |
290dfc8c |
38 | structures, may be of any nested data type (LttType). |
975e44c7 |
39 | |
290dfc8c |
40 | An LttField is a special object to denote a specific, possibly nested, |
975e44c7 |
41 | field within an event type. Suppose an event type socket_connect is a |
1b82f325 |
42 | structure containing two data members, source and destination, of type |
975e44c7 |
43 | socket_address. Type socket_address contains two unsigned integer |
290dfc8c |
44 | data members, ip and port. An LttField is different from a data type |
975e44c7 |
45 | structure member since it can denote a specific nested field, like the |
46 | source port, and store associated access information (byte offset within |
290dfc8c |
47 | the event data). The LttField objects are trace specific since the |
975e44c7 |
48 | contained information (byte offsets) may vary with the architecture |
1b82f325 |
49 | associated to the trace. */ |
975e44c7 |
50 | |
290dfc8c |
51 | typedef struct _LttTrace LttTrace; |
1b82f325 |
52 | |
290dfc8c |
53 | typedef struct _LttTracefile LttTracefile; |
975e44c7 |
54 | |
290dfc8c |
55 | typedef struct _LttFacility LttFacility; |
975e44c7 |
56 | |
290dfc8c |
57 | typedef struct _LttEventType LttEventType; |
975e44c7 |
58 | |
290dfc8c |
59 | typedef struct _LttType LttType; |
975e44c7 |
60 | |
290dfc8c |
61 | typedef struct _LttField LttField; |
975e44c7 |
62 | |
290dfc8c |
63 | typedef struct _LttEvent LttEvent; |
975e44c7 |
64 | |
8a2d0e71 |
65 | typedef struct _LttSystemDescription LttSystemDescription; |
975e44c7 |
66 | |
975e44c7 |
67 | /* Checksums are used to differentiate facilities which have the same name |
68 | but differ. */ |
69 | |
290dfc8c |
70 | typedef unsigned long LttChecksum; |
975e44c7 |
71 | |
72 | |
73 | /* Events are usually stored with the easily obtained CPU clock cycle count, |
308711e5 |
74 | ltt_cycle_count. This can be converted to the real time value, LttTime, |
975e44c7 |
75 | using linear interpolation between regularly sampled values (e.g. a few |
76 | times per second) of the real time clock with their corresponding |
77 | cycle count values. */ |
78 | |
f7afe191 |
79 | |
80 | typedef struct _TimeInterval{ |
81 | LttTime startTime; |
82 | LttTime endTime; |
83 | } TimeInterval; |
84 | |
85 | |
cbd41522 |
86 | typedef guint64 LttCycleCount; |
975e44c7 |
87 | |
fb1a869e |
88 | |
80da81ad |
89 | /* Event positions are used to seek within a tracefile based on |
90 | the block number and event position within the block. */ |
91 | |
92 | typedef struct _LttEventPosition LttEventPosition; |
93 | |
1b82f325 |
94 | |
95 | /* Differences between architectures include word sizes, endianess, |
96 | alignment, floating point format and calling conventions. For a |
97 | packed binary trace, endianess and size matter, assuming that the |
98 | floating point format is standard (and is seldom used anyway). */ |
99 | |
290dfc8c |
100 | typedef enum _LttArchSize |
7c6b3cd7 |
101 | { LTT_LP32, LTT_ILP32, LTT_LP64, LTT_ILP64, LTT_UNKNOWN |
290dfc8c |
102 | } LttArchSize; |
7c6b3cd7 |
103 | |
1b82f325 |
104 | |
290dfc8c |
105 | typedef enum _LttArchEndian |
7c6b3cd7 |
106 | { LTT_LITTLE_ENDIAN, LTT_BIG_ENDIAN |
290dfc8c |
107 | } LttArchEndian; |
975e44c7 |
108 | |
a5dcde2f |
109 | typedef enum _LttTypeEnum |
110 | { LTT_INT, LTT_UINT, LTT_FLOAT, LTT_STRING, LTT_ENUM, LTT_ARRAY, |
111 | LTT_SEQUENCE, LTT_STRUCT, LTT_UNION |
112 | } LttTypeEnum; |
7c6b3cd7 |
113 | |
114 | |
115 | #endif // LTT_H |