-
Notifications
You must be signed in to change notification settings - Fork 10
/
BinaryFTraceHeaderElementSize.java
221 lines (191 loc) · 6.35 KB
/
BinaryFTraceHeaderElementSize.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
/*******************************************************************************
* Copyright (c) 2022 Ericsson
*
* All rights reserved. This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0 which
* accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package org.eclipse.tracecompass.incubator.internal.ftrace.core.binary.parser;
import org.eclipse.tracecompass.incubator.internal.ftrace.core.binary.event.BinaryFTraceConstants;
/**
* This file contains the number of bytes reserved for different sections in the
* header of a binary ftrace file.
*
* @author Hoang Thuan Pham
*/
public class BinaryFTraceHeaderElementSize {
private BinaryFTraceHeaderElementSize() {
// Do nothing
}
/**
* The number of bytes used for a section with a large size.
*/
public static final int LARGE_SECTION_SIZE = 8;
/**
* The number of bytes used for a section with a small size.
*/
public static final int SMALL_SECTION_SIZE = 4;
/**
* Each string in the header is terminated by /0. The size of the
* termination character is 1 byte
*/
public static final int STRING_TERMINATOR = 1;
/**
* The magic value at the start of the trace
*/
public static final int MAGIC_VALUE = 3;
/**
* The string tracing that immediately follow the magic values
*/
public static final int TRACING_STRING = 7;
/**
* The number of reserved bytes for the FTrace Version
*/
public static final int FTRACE_VERSION = 1;
/**
* The size of the page header of a binary FTrace CPU data page in bytes
*/
public static final int PAGE_HEADER_SIZE = 16;
/**
* The number of bytes reserved for the endianess of the file. 0 = little
* endian, 1 = big endian
*/
public static final int ENDIANESS_SIZE = 1;
/**
* The number of bytes reserved for the long value size
*/
public static final int LONG_VALUE_SIZE = 1;
/**
* The number of bytes reserved for the host machine page size
*/
public static final int PAGE_SIZE = 4;
/**
* Get the size of the magic value section in bytes.
*
* @return The size of the magic value section in bytes
*/
public static int getMagicValueSectionSize() {
/**
* Make sure that the order of the sum follows the order of each value
* in the trace
*/
return MAGIC_VALUE +
TRACING_STRING +
FTRACE_VERSION +
STRING_TERMINATOR;
}
/**
* Get the size of the header in bytes.
*
* @return The size of the header in bytes
*/
public static int getHeaderSize() {
/**
* Make sure that the order of the sum follows the order of each value
* in the trace to make the code easy to follow
*/
return MAGIC_VALUE +
TRACING_STRING +
FTRACE_VERSION +
STRING_TERMINATOR +
ENDIANESS_SIZE +
LONG_VALUE_SIZE +
PAGE_SIZE;
}
/**
* Number of bytes reserved for the number of events
*/
public static final int EVENT_COUNT = 4;
/**
* Number of bytes reserved for the number of event systems
*/
public static final int EVENT_SYSTEM_COUNT = 4;
/**
* Number of bytes reserved for the size of an event
*/
public static final int EVENT_SIZE = 8;
/**
* The number of bytes reserved for the number of CPUs
*/
public static final int NUMBER_OF_CPUS = 4;
/**
* The number of bytes reserved for the header of each subsection
*/
public static final int SUBSECTION_HEADER = 4;
/**
* The number of bytes reserved for the size of the option section
*/
public static final int OPTION_TYPE = 2;
/**
* The number of bytes reserved for the option size
*/
public static final int OPTION_SIZE = 4;
/**
* The number of bytes reserved for the starting offset of each CPU section
*/
public static final int CPU_SECTION_OFFSET = 8;
/**
* The number of bytes reserved for the size of each CPU section
*/
public static final int CPU_SECTION_SIZE = 8;
/**
* The header for the Options/Fly Record/Latency section. All should be the
* same size
*/
public static final int TRACE_DATA_HEADER_SIZE = 10;
/**
* Get the size (in bytes) of the title of the Header Page section.
*
* @return The size (in bytes) of the title of the Header Page section.
*/
public static int getHeaderPageSectionTitleSize() {
/**
* Make sure that the order of the sum follows the order of each value
* in the trace
*/
return BinaryFTraceConstants.HEADER_PAGE_SECTION_HEADER.length() +
STRING_TERMINATOR;
}
/**
* Get the size (in bytes) of the header of the Header Page section.
*
* @return The size (in bytes) of the header of the Header Page section.
*/
public static int getHeaderPageSectionHeaderSize() {
/**
* Make sure that the order of the sum follows the order of each value
* in the trace
*/
return getHeaderPageSectionTitleSize() +
LARGE_SECTION_SIZE;
}
/**
* Get the size (in bytes) of the title of the Header Page section.
*
* @return The size (in bytes) of the title of the Header Page section.
*/
public static int getHeaderEventSectionTitleSize() {
/**
* Make sure that the order of the sum follows the order of each value
* in the trace
*/
return BinaryFTraceConstants.HEADER_EVENT_SECTION_HEADER.length() +
STRING_TERMINATOR;
}
/**
* Get the size (in bytes) of the header of the Header Event section.
*
* @return The size (in bytes) of the header of the Header Event section.
*/
public static int getHeaderEventSectionHeaderSize() {
/**
* Make sure that the order of the sum follows the order of each value
* in the trace
*/
return getHeaderEventSectionTitleSize() +
LARGE_SECTION_SIZE;
}
}