9c312311 |
1 | /* This file is part of the Linux Trace Toolkit trace reading library |
2 | * Copyright (C) 2003-2004 Michel Dagenais |
3 | * |
4 | * This library is free software; you can redistribute it and/or |
5 | * modify it under the terms of the GNU Lesser General Public |
6 | * License Version 2.1 as published by the Free Software Foundation. |
7 | * |
8 | * This library is distributed in the hope that it will be useful, |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
11 | * Lesser General Public License for more details. |
12 | * |
13 | * You should have received a copy of the GNU Lesser General Public |
14 | * License along with this library; if not, write to the |
15 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
16 | * Boston, MA 02111-1307, USA. |
17 | */ |
18 | |
7c6b3cd7 |
19 | #ifndef LTT_H |
20 | #define LTT_H |
975e44c7 |
21 | |
cbd41522 |
22 | #include <glib.h> |
1d1df11d |
23 | #include <ltt/time.h> |
24 | #include <ltt/compiler.h> |
975e44c7 |
25 | |
26 | /* A trace is associated with a tracing session run on a single, possibly |
27 | multi-cpu, system. It is defined as a pathname to a directory containing |
28 | all the relevant trace files. All the tracefiles for a trace were |
29 | generated in a single system for the same time period by the same |
290dfc8c |
30 | trace daemon. They simply contain different events. Typically control |
31 | tracefiles contain the important events (process creations and registering |
1b82f325 |
32 | tracing facilities) for all CPUs, and one file for each CPU contains all |
33 | the events for that CPU. All the tracefiles within the same trace directory |
975e44c7 |
34 | then use the exact same id numbers for event types. |
35 | |
290dfc8c |
36 | A tracefile (LttTracefile) contains a list of events (LttEvent) sorted |
975e44c7 |
37 | by time for each CPU; events from different CPUs may be slightly out of |
38 | order, especially using the (possibly drifting) cycle counters as |
39 | time unit. |
40 | |
290dfc8c |
41 | A facility is a list of event types (LttEventType), declared in a special |
42 | eventdefs file. A corresponding checksum differentiates different |
43 | facilities which would have the same name but a different content |
44 | (e.g., different versions). The files are stored within the trace |
45 | directory and are accessed automatically upon opening a trace. |
1b82f325 |
46 | The list of facilities (and associated checksum) used in a trace |
975e44c7 |
47 | must be known in order to properly decode the contained events. An event |
290dfc8c |
48 | is stored in the "facilities" control tracefile to denote each different |
49 | facility used. |
975e44c7 |
50 | |
290dfc8c |
51 | Event types (LttEventType) refer to data types (LttType) describing |
975e44c7 |
52 | their content. The data types supported are integer and unsigned integer |
53 | (of various length), enumerations (a special form of unsigned integer), |
54 | floating point (of various length), fixed size arrays, sequence |
55 | (variable sized arrays), structures and null terminated strings. |
56 | The elements of arrays and sequences, and the data members for |
290dfc8c |
57 | structures, may be of any nested data type (LttType). |
975e44c7 |
58 | |
290dfc8c |
59 | An LttField is a special object to denote a specific, possibly nested, |
975e44c7 |
60 | field within an event type. Suppose an event type socket_connect is a |
1b82f325 |
61 | structure containing two data members, source and destination, of type |
975e44c7 |
62 | socket_address. Type socket_address contains two unsigned integer |
290dfc8c |
63 | data members, ip and port. An LttField is different from a data type |
975e44c7 |
64 | structure member since it can denote a specific nested field, like the |
65 | source port, and store associated access information (byte offset within |
290dfc8c |
66 | the event data). The LttField objects are trace specific since the |
975e44c7 |
67 | contained information (byte offsets) may vary with the architecture |
1b82f325 |
68 | associated to the trace. */ |
975e44c7 |
69 | |
77175651 |
70 | #define NUM_FACILITIES 256 |
513eefe0 |
71 | #define FACILITIES_BITS 8 |
9d239bd9 |
72 | #define AVG_EVENTS_PER_FACILITIES 10 |
77175651 |
73 | |
290dfc8c |
74 | typedef struct _LttTrace LttTrace; |
1b82f325 |
75 | |
290dfc8c |
76 | typedef struct _LttTracefile LttTracefile; |
975e44c7 |
77 | |
290dfc8c |
78 | typedef struct _LttFacility LttFacility; |
975e44c7 |
79 | |
290dfc8c |
80 | typedef struct _LttEventType LttEventType; |
975e44c7 |
81 | |
290dfc8c |
82 | typedef struct _LttType LttType; |
975e44c7 |
83 | |
290dfc8c |
84 | typedef struct _LttField LttField; |
975e44c7 |
85 | |
290dfc8c |
86 | typedef struct _LttEvent LttEvent; |
975e44c7 |
87 | |
8a2d0e71 |
88 | typedef struct _LttSystemDescription LttSystemDescription; |
975e44c7 |
89 | |
c02ea99f |
90 | |
975e44c7 |
91 | /* Checksums are used to differentiate facilities which have the same name |
92 | but differ. */ |
93 | |
3aee1200 |
94 | //typedef guint32 LttChecksum; |
975e44c7 |
95 | |
96 | |
97 | /* Events are usually stored with the easily obtained CPU clock cycle count, |
308711e5 |
98 | ltt_cycle_count. This can be converted to the real time value, LttTime, |
975e44c7 |
99 | using linear interpolation between regularly sampled values (e.g. a few |
100 | times per second) of the real time clock with their corresponding |
101 | cycle count values. */ |
102 | |
f7afe191 |
103 | |
104 | typedef struct _TimeInterval{ |
04b44e05 |
105 | LttTime start_time; |
106 | LttTime end_time; |
f7afe191 |
107 | } TimeInterval; |
108 | |
109 | |
cbd41522 |
110 | typedef guint64 LttCycleCount; |
975e44c7 |
111 | |
fb1a869e |
112 | |
80da81ad |
113 | /* Event positions are used to seek within a tracefile based on |
114 | the block number and event position within the block. */ |
115 | |
116 | typedef struct _LttEventPosition LttEventPosition; |
117 | |
1b82f325 |
118 | |
119 | /* Differences between architectures include word sizes, endianess, |
120 | alignment, floating point format and calling conventions. For a |
121 | packed binary trace, endianess and size matter, assuming that the |
122 | floating point format is standard (and is seldom used anyway). */ |
123 | |
290dfc8c |
124 | typedef enum _LttArchSize |
7c6b3cd7 |
125 | { LTT_LP32, LTT_ILP32, LTT_LP64, LTT_ILP64, LTT_UNKNOWN |
290dfc8c |
126 | } LttArchSize; |
7c6b3cd7 |
127 | |
1b82f325 |
128 | |
290dfc8c |
129 | typedef enum _LttArchEndian |
7c6b3cd7 |
130 | { LTT_LITTLE_ENDIAN, LTT_BIG_ENDIAN |
290dfc8c |
131 | } LttArchEndian; |
975e44c7 |
132 | |
a5dcde2f |
133 | typedef enum _LttTypeEnum |
3aee1200 |
134 | { LTT_INT, LTT_UINT, LTT_POINTER, LTT_LONG, LTT_ULONG, LTT_SIZE_T, |
135 | LTT_SSIZE_T, LTT_OFF_T, LTT_FLOAT, LTT_STRING, LTT_ENUM, LTT_ARRAY, |
a5dcde2f |
136 | LTT_SEQUENCE, LTT_STRUCT, LTT_UNION |
137 | } LttTypeEnum; |
7c6b3cd7 |
138 | |
1d1df11d |
139 | |
7c6b3cd7 |
140 | #endif // LTT_H |