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