Subversion Repositories shark

Rev

Rev 1677 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1676 tullio 1
\documentclass[english]{report}
2
\usepackage[T1]{fontenc}
3
\usepackage[latin1]{inputenc}
4
\usepackage{geometry}
5
\geometry{verbose,a4paper}
6
\usepackage{float}
7
\usepackage{makeidx}
8
\makeindex
9
\usepackage{graphicx}
10
 
11
\makeatletter
12
 
13
\newenvironment{intest}{\noindent\large\bf\hspace*{1pt}}
14
{\vspace*{-5pt}\\\line(1,0){433}}
15
 
16
\usepackage{babel}
17
\makeatother
18
\begin{document}
19
\thispagestyle{empty}
20
 
21
\begin{center}{\LARGE S.Ha.R.K. User Manual}\end{center}{\LARGE \par}
22
\vfill{}
23
 
24
\begin{center}Volume V\end{center}
25
\begin{center}The S.Ha.R.K. New Tracer\end{center} \vfill{}
26
\begin{center}Written by\end{center}
27
\begin{center}Tullio Facchinetti (tullio.facchinetti at unipv.it)\end{center} \vfill{}
28
\begin{center}\includegraphics[width=2cm]{../common/sssup.ps}\end{center}
29
\begin{center}Scuola Superiore di Studi e Perfezionamento S. Anna\end{center}
30
\begin{center}RETIS Lab\end{center}
31
\begin{center}Via Carducci, 40 - 56100 Pisa\end{center}
32
 
33
\pagebreak
34
 
35
\tableofcontents{}
36
 
37
 
38
\chapter{The S.Ha.R.K. tracer}
39
 
40
The new Tracer is a powerful tool to understand what happens while a
41
S.Ha.R.K. \cite{Gai01} application is executed. The Tracer logs
42
a set of events corresponding with the most important activities
43
within the kernel, such as preemptions, interrupt activations,
44
mutexes blocks and releases, and much more.
45
 
46
During the execution, the kernel logs the sequence of events in
47
memory; such events are then written to disk or sent through the
48
network, typically at the end of the application execution. Each
49
event is made by: a high resolution timestamp (TSC, Time Stamp
50
Counter) corresponding to the instant at which the event has been
51
logged; the event type; 2 optional parameters to add additional
52
information to the event.
53
 
54
The Tracer can also be used to log custom events, since it
55
reserves a number of free event types for user events.
56
 
57
To use the features made available by the Tracer, the Tracer
58
functions must be enabled into the kernel by specifying
59
 
60
~
61
 
62
TRACER = NEW
63
 
64
~
65
 
66
into the \textit{shark.cfg} configuration file. The S.Ha.R.K.
67
kernel must be built with this option set.
68
 
69
%----------------------------------------------------------------------------
1680 boinc 70
\section{Chunk management}
71
%----------------------------------------------------------------------------
72
 
73
Tracer events are stored in memory into buffers called \textbf{chunks}. To be as
74
flexible as possible, it is possible to create many chunks, that can be linked one
75
after the other, using the FTrace\_chunk\_link primitive, to obtain a huge memory
76
buffer where to store tracer events.
77
 
78
Chunks are created using the \textbf{FTrace\_chunk\_create} function. During the
79
chunk creation, the programmer can decide the size of the chunk and its type. There
80
are different types of chunks, which can be specified using the following flags:
81
 
82
\begin{itemize}
83
\item FTRACE\_CHUNK\_FLAG\_FREE;
84
\item FTRACE\_CHUNK\_FLAG\_FULL;
85
\item FTRACE\_CHUNK\_FLAG\_CYC;
86
\item FTRACE\_CHUNK\_FLAG\_JTN;
87
\item FTRACE\_CHUNK\_FLAG\_STOP.
88
\end{itemize}
89
 
90
The available flags condition the behavior of the tracer when a chunk is fullfilled.
91
The FTRACE\_CHUNK\_FLAG\_CYC flag specifies that when the chunk is full, the tracer
92
starts to insert the new events from the beginning of the same chunk. The
93
FTRACE\_CHUNK\_FLAG\_JTN flag (Jump To Next) indicates that, when the current chunk
94
is full, the next event is written at the beginning of the next chunk. The
95
FTRACE\_CHUNK\_FLAG\_STOP makes the tracing engine to stop when the current chunk is
96
full. This function has not been implemented yet.
97
FTRACE\_CHUNK\_FLAG\_FREE and FTRACE\_CHUNK\_FLAG\_FULL only indicate that the chunk
98
is free to be used or is already full.
99
 
100
%----------------------------------------------------------------------------
1676 tullio 101
\chapter{Primitives}
102
%----------------------------------------------------------------------------
103
 
104
\vspace{7mm}
105
 
106
%------------------------------------------------------------
107
\begin{intest}
108
FTrace\_enable \index{FTrace\_enable}
109
\end{intest}
110
 
111
\begin{description}
112
\item [\textbf{int FTrace\_enable();}]
113
\item [\textbf{Description:}] Enable the Tracer. When this function is called, the Tracer starts
114
the event logging.
115
\end{description}
116
 
117
%------------------------------------------------------------
118
\begin{intest}
119
FTrace\_disable \index{FTrace\_disable}
120
\end{intest}
121
 
122
\begin{description}
123
\item [\textbf{int FTrace\_disable();}]
124
\item [\textbf{Description:}] Disable the Tracer. When this function is called, the Tracer stops
125
the event logging.
126
\end{description}
127
 
128
%------------------------------------------------------------
129
\begin{intest}
130
FTrace\_chunk\_create \index{FTrace\_chunk\_create}
131
\end{intest}
132
 
133
\begin{description}
134
\item [\textbf{int FTrace\_chunk\_create(int normal\_size, int emergency\_size, FTrace\_flags flags);}]
135
\item [\textbf{Description:}] Create a new chunk.
1680 boinc 136
\item The following flags can be set to the created chunk:
137
\begin{itemize}
138
\item FTRACE\_CHUNK\_FLAG\_FREE : the chunk is free to use;
139
\item FTRACE\_CHUNK\_FLAG\_FULL : the chunk is full;
140
\item FTRACE\_CHUNK\_FLAG\_CYC : the chunk stores event in a cyclical way (see \textbf{FTrace\_chunk\_link}) ;
141
\item FTRACE\_CHUNK\_FLAG\_JTN : when full the chunk jumps to the next chunk;
142
\item FTRACE\_CHUNK\_FLAG\_STOP : when full the chunk stops. This function has not been implemented yet.
143
\end{itemize}
1676 tullio 144
\end{description}
145
 
146
%------------------------------------------------------------
147
\begin{intest}
148
FTrace\_chunk\_delete \index{FTrace\_chunk\_delete}
149
\end{intest}
150
 
151
\begin{description}
152
\item [\textbf{int FTrace\_chunk\_delete(int number);}]
153
\item [\textbf{Description:}] Delete a Chunk.
154
\end{description}
155
 
156
%------------------------------------------------------------
157
\begin{intest}
158
FTrace\_set\_chunk\_flags \index{FTrace\_set\_chunk\_flags}
159
\end{intest}
160
 
161
\begin{description}
162
\item [\textbf{int FTrace\_set\_chunk\_flags(int number, FTrace\_flags flags);}]
163
\item [\textbf{Description:}] Set the chunk flags.
164
\end{description}
165
 
166
%------------------------------------------------------------
167
\begin{intest}
168
FTrace\_get\_chunk\_flags \index{FTrace\_get\_chunk\_flags}
169
\end{intest}
170
 
171
\begin{description}
172
\item [\textbf{int FTrace\_get\_chunk\_flags(int number, FTrace\_flags *flags);}]
173
\item [\textbf{Description:}] Returns chunk flags.
174
\end{description}
175
 
176
%------------------------------------------------------------
177
\begin{intest}
178
FTrace\_actual\_chunk\_select \index{FTrace\_actual\_chunk\_select}
179
\end{intest}
180
 
181
\begin{description}
182
\item [\textbf{int FTrace\_actual\_chunk\_select(int number);}]
183
\item [\textbf{Description:}] Select the actual chunk.
184
\end{description}
185
 
186
%------------------------------------------------------------
187
\begin{intest}
188
FTrace\_chunk\_link \index{FTrace\_chunk\_link}
189
\end{intest}
190
 
191
\begin{description}
192
\item [\textbf{int FTrace\_chunk\_link(int chunk\_A, int chunk\_B);}]
193
\item [\textbf{Description:}] Link two chunks.
194
\end{description}
195
 
196
%------------------------------------------------------------
197
\begin{intest}
198
FTrace\_get\_first\_chunk \index{FTrace\_get\_first\_chunk}
199
\end{intest}
200
 
201
\begin{description}
202
\item [\textbf{int FTrace\_get\_first\_chunk(FTrace\_flags flags);}]
203
\item [\textbf{Description:}] Find the first chunk with specific flags.
204
\end{description}
205
 
206
%------------------------------------------------------------
207
\begin{intest}
208
FTrace\_get\_chunk\_table \index{FTrace\_get\_chunk\_table}
209
\end{intest}
210
 
211
\begin{description}
212
\item [\textbf{FTrace\_Chunk\_Ptr *FTrace\_get\_chunk\_table();}]
213
\item [\textbf{Description:}] Get chunks status.
214
\end{description}
215
 
216
%------------------------------------------------------------
217
\begin{intest}
218
FTrace\_compress\_chunk \index{FTrace\_compress\_chunk}
219
\end{intest}
220
 
221
\begin{description}
222
\item [\textbf{int FTrace\_compress\_chunk(int number, FTrace\_flags new\_flags);}]
223
\item [\textbf{Description:}] Create a new memory region where the compressed data are stored.
224
\end{description}
225
 
226
%------------------------------------------------------------
227
\begin{intest}
228
FTrace\_send\_chunk \index{FTrace\_send\_chunk}
229
\end{intest}
230
 
231
\begin{description}
232
\item [\textbf{int FTrace\_send\_chunk(int number, int osd\_flags,
233
FTrace\_flags new\_flags);}]
234
\item [\textbf{Description:}] Send the chunk out from the memory.
235
\end{description}
236
 
237
%------------------------------------------------------------
238
\begin{intest}
239
FTrace\_init\_disk\_writer \index{FTrace\_init\_disk\_writer}
240
\end{intest}
241
 
242
\begin{description}
243
\item [\textbf{int FTrace\_init\_disk\_writer(char *fname, int flag,
244
char *l\_ip, char *t\_ip);}]
245
\item [\textbf{Description:}] Initialize the disk Tracer chunk dumper. It sets
246
the internal chunk sender to the function that writes chunks on disk. It
247
initializes the filename that will be used to open the file for saving chunks.
248
\end{description}
249
 
250
%------------------------------------------------------------
251
\begin{intest}
252
FTrace\_disk\_writer \index{FTrace\_disk\_writer}
253
\end{intest}
254
 
255
\begin{description}
256
\item [\textbf{void FTrace\_disk\_writer(FTrace\_Chunk\_Ptr c);}]
257
\item [\textbf{Description:}] This function is called by the application when it
258
asks to write chunk c on disk. It saves the chunk data into the chunk\_to\_disk
259
array. At the runlevel after the exit, all the saved chunks will be written to
260
disk.
261
\end{description}
262
 
263
%------------------------------------------------------------
264
\begin{intest}
265
FTrace\_OSD\_init\_udp \index{FTrace\_OSD\_init\_udp}
266
\end{intest}
267
 
268
\begin{description}
269
\item [\textbf{int FTrace\_OSD\_init\_udp(int flag, char *l\_ip, char *t\_ip);}]
270
\item [\textbf{Description:}] Initialize the Tracer chunk network sender using
271
the UDP protocol supported by S.Ha.R.K. If flag = 1 initializes the network
272
driver, otherwise it considers that the network layer has already been
273
initialized. It also sets the internal chunk sender to the function that
274
initializes the task for sending the chunk.
275
\end{description}
276
 
277
%------------------------------------------------------------
278
\begin{intest}
279
FTrace\_set\_filter \index{FTrace\_set\_filter}
280
\end{intest}
281
 
282
\begin{description}
283
\item [\textbf{void FTrace\_set\_filter(BYTE family, int status);}]
284
\item [\textbf{Description:}] Set the filter for a specific family of events
285
(see Table \ref{tab:filter-events} for a list of all the event families). When
286
the filter is enabled for a given family of events, all the events belonging to
287
that family are not logged.\\
288
While \texttt{status} set to 1 enables the filter, \texttt{status}
289
set to 0 disables the filter.
290
\end{description}
291
 
292
%------------------------------------------------------------
293
\begin{intest}
294
TRACER\_LOGEVENT \index{TRACER\_LOGEVENT}
295
\end{intest}
296
 
297
\begin{description}
298
\item [\textbf{TRACER\_LOGEVENT(WORD type, WORD par1, DWORD par2);}]
299
\item [\textbf{Description:}] Stores a new event of \texttt{type} type into the
300
current chunk, together with the 2 parameters \texttt{par1} (2 bytes) and
301
\texttt{par2} (4 bytes).
302
\end{description}
303
 
304
%----------------------------------------------------------------------------
305
\chapter{Event types description}
306
\label{ch:Event-types-description}
307
%----------------------------------------------------------------------------
308
 
309
This Chapter reports all the available event type codes currently
310
supported by S.Ha.R.K.
311
 
312
\begin{table}
313
\begin{center}
314
\begin{tabular}{|l|c|c|c|}
315
\hline Name & Code & Parameter 1 & Parameter 2 \\ \hline
316
\hline FTrace\_EVT\_empty & 0x00 & . & . \\
317
\hline FTrace\_EVT\_cycles\_per\_msec & 0x10 & .& [clk/msec] \\
318
\hline FTrace\_EVT\_trace\_start& 0x20 & . & . \\
319
\hline FTrace\_EVT\_trace\_stop & 0x30& . & . \\
320
\hline FTrace\_EVT\_blackout\_start & 0x40 & .& . \\
321
\hline FTrace\_EVT\_blackout\_end & 0x50 & .& . \\
322
\hline FTrace\_EVT\_id & 0x60 & context& pid \\
323
\hline FTrace\_EVT\_numevents & 0x70 & .& . \\
324
\hline
325
\end{tabular}
326
\end{center}
327
\caption{General trace events.}
328
\end{table}
329
 
330
 
331
\begin{table}
332
\begin{center}
333
\begin{tabular}{|l|c|c|c|}
334
\hline Name & Code & Parameter 1 & Parameter 2 \\ \hline
335
\hline FTrace\_EVT\_ipoint & 0x01 & number & . \\ \hline
336
\end{tabular}
337
\end{center}
338
\caption{Lightweight tracing events.}
339
\end{table}
340
 
341
 
342
\begin{table}
343
\begin{center}
344
\begin{tabular}{|l|c|c|c|}
345
\hline Name & Code & Parameter 1 & Parameter 2 \\ \hline
346
\hline FTrace\_EVT\_task\_create & 0x02 & context& pid \\
347
\hline FTrace\_EVT\_task\_activate & 0x12 & context & . \\
348
\hline FTrace\_EVT\_task\_dispatch & 0x22 & . & . \\
349
\hline FTrace\_EVT\_task\_epilogue & 0x32 & . & . \\
350
\hline FTrace\_EVT\_task\_end & 0x42 & context & pid \\
351
\hline FTrace\_EVT\_task\_begin\_cycle & 0x52 & . & . \\
352
\hline FTrace\_EVT\_task\_end\_cycle & 0x62 & context & level \\
353
\hline FTrace\_EVT\_task\_sleep & 0x72 & . & . \\
354
\hline FTrace\_EVT\_task\_schedule & 0x82 & exec\_shadow.context & exec.context \\
355
\hline FTrace\_EVT\_task\_timer & 0x92 & context & level \\
356
\hline FTrace\_EVT\_task\_disable& 0xA2 & . & . \\
357
\hline FTrace\_EVT\_task\_deadline\_miss & 0xB2 & context & . \\
358
\hline FTrace\_EVT\_task\_wcet\_violation & 0xC2 & context& . \\
359
\hline
360
\end{tabular}
361
\end{center}
362
\caption{Task related events.}
363
\end{table}
364
 
365
\begin{table}
366
\begin{center}
367
\begin{tabular}{|l|c|c|c|}
368
\hline Name & Code & Parameter 1 & Parameter 2 \\ \hline
369
\hline FTrace\_EVT\_interrupt\_start & 0x03 & int & . \\
370
\hline FTrace\_EVT\_interrupt\_end & 0x13 & int & . \\
371
\hline FTrace\_EVT\_interrupt\_hit & 0x23 &
372
\multicolumn{2}{c|}{Instant where interrupt was hit (no end)} \\
373
\hline FTrace\_EVT\_interrupt\_count & 0x33 &
374
\multicolumn{2}{c|}{Number of interrupts raised since last interrupt\_count} \\
375
\hline
376
\end{tabular}
377
\end{center}
378
\caption{Interrupt events, even more lightweight than ipoints.}
379
\end{table}
380
 
381
\begin{table}
382
\begin{center}
383
\begin{tabular}{|l|c|c|c|}
384
\hline Name & Code & Parameter 1 & Parameter 2 \\ \hline
385
\hline FTrace\_EVT\_to\_real\_mode & 0x04 & . & . \\
386
\hline FTrace\_EVT\_to\_protected\_mode & 0x14 & . & . \\
387
\hline FTrace\_EVT\_CLI & 0x24 & . & . \\ \hline
388
FTrace\_EVT\_STI & 0x34 & . & . \\ \hline
389
\end{tabular}
390
\end{center}
391
\caption{Other CPU specific events.}
392
\end{table}
393
 
394
\begin{table}
395
\begin{center}
396
\begin{tabular}{|l|c|c|c|}
397
\hline Name & Code & Parameter 1 & Parameter 2 \\ \hline
398
\hline FTrace\_EVT\_set\_priority & 0x05 & . & . \\
399
\hline FTrace\_EVT\_context\_switch & 0x15 & context& . \\
400
\hline FTrace\_EVT\_inheritance & 0x25 & exec\_shadow.context & exec.context \\
401
\hline
402
\end{tabular}
403
\end{center}
404
\caption{Changes on task attributes and state.}
405
\end{table}
406
 
407
\begin{table}
408
\begin{center}
409
\begin{tabular}{|l|c|c|c|}
410
\hline Name & Code & Parameter 1 & Parameter 2 \\ \hline
411
\hline FTrace\_EVT\_set\_mutex\_create & 0x06 & . & . \\
412
\hline FTrace\_EVT\_set\_mutex\_lock & 0x16 & context& mutex \\
413
\hline FTrace\_EVT\_set\_mutex\_inherit & 0x26 & . & . \\
414
\hline FTrace\_EVT\_set\_mutex\_unlock & 0x43 & context & mutex \\
415
\hline FTrace\_EVT\_set\_mutex\_wait & 0x46 & context & mutex \\
416
\hline FTrace\_EVT\_set\_mutex\_post & 0x56 & context& mutex \\
417
\hline
418
\end{tabular}
419
\end{center}
420
\caption{Mutex events.}
421
\end{table}
422
 
423
\begin{table}
424
\begin{center}
425
\begin{tabular}{|l|c|c|c|}
426
\hline Name & Code & Parameter 1 & Parameter 2 \\ \hline
427
\hline FTrace\_EVT\_signal & 0x07 & . & . \\
428
\hline
429
\end{tabular}
430
\end{center}
431
\caption{Signal events.}
432
\end{table}
433
 
434
\begin{table}
435
\begin{center}
436
\begin{tabular}{|l|c|c|c|}
437
\hline Name & Code & Parameter 1 & Parameter 2 \\ \hline
438
\hline FTrace\_EVT\_server\_create & 0x08 & . & server \\
439
\hline FTrace\_EVT\_server\_replenish & 0x18 & .& server \\
440
\hline FTrace\_EVT\_server\_exhaust & 0x28 & . & server \\
441
\hline FTrace\_EVT\_server\_reclaiming & 0x38 & . & server \\
442
\hline FTrace\_EVT\_server\_remove & 0x48 & . & server \\
443
\hline FTrace\_EVT\_server\_active & 0x58 & . & server \\
444
\hline FTrace\_EVT\_server\_using\_rec & 0x68 & reclaiming & server \\
445
\hline
446
\end{tabular}
447
\end{center}
448
\caption{Specific server events.}
449
\end{table}
450
 
451
\begin{table}
452
\begin{center}
453
\begin{tabular}{|l|c|c|c|}
454
\hline Name & Code & Parameter 1 & Parameter 2 \\ \hline
455
\hline FTrace\_EVT\_user\_event\_0 & 0x09 & free & free \\
456
\hline FTrace\_EVT\_user\_event\_1 & 0x19 & free & free \\
457
\hline FTrace\_EVT\_user\_event\_2 & 0x29 & free & free \\
458
\hline FTrace\_EVT\_user\_event\_3 & 0x39 & free & free \\
459
\hline FTrace\_EVT\_user\_event\_4 & 0x49 & free & free \\
460
\hline FTrace\_EVT\_user\_event\_5 & 0x59 & free & free \\
461
\hline FTrace\_EVT\_user\_event\_6 & 0x69 & free & free \\
462
\hline FTrace\_EVT\_user\_event\_7 & 0x79 & free & free \\
463
\hline FTrace\_EVT\_user\_event\_8 & 0x89 & free & free \\
464
\hline FTrace\_EVT\_user\_event\_9 & 0x99 & free & free \\
465
\hline FTrace\_EVT\_user\_event\_10 & 0xA9 & free & free \\
466
\hline FTrace\_EVT\_user\_event\_11 & 0xB9 & free & free \\
467
\hline FTrace\_EVT\_user\_event\_12 & 0xC9 & free & free \\
468
\hline FTrace\_EVT\_user\_event\_13 & 0xD9 & free & free \\
469
\hline FTrace\_EVT\_user\_event\_14 & 0xE9 & free & free \\
470
\hline
471
\end{tabular}
472
\end{center}
473
\caption{User defined events.}
474
\end{table}
475
 
476
\begin{table}
477
\begin{center}
478
\begin{tabular}{|l|c|c|c|}
479
\hline Name & Code & Parameter 1 & Parameter 2 \\ \hline
480
\hline FTrace\_EVT\_timer\_post & 0x0B & . & . \\
481
\hline FTrace\_EVT\_timer\_delete & 0x1B & . & . \\
482
\hline FTrace\_EVT\_timer\_wakeup\_start & 0x2B & . & . \\
483
\hline FTrace\_EVT\_timer\_wakeup\_end & 0x3B & context & . \\
484
\hline
485
\end{tabular}
486
\end{center}
487
\caption{Timer events.}
488
\end{table}
489
 
490
\begin{table}
491
\begin{center}
492
\begin{tabular}{|l|c|c|c|}
493
\hline Name & Code & Parameter 1 & Parameter 2 \\ \hline
494
\cline{1-1} \cline{2-2} FTrace\_EVT\_data\_pointer & 0x1A &
495
\multicolumn{2}{c|}{holds a pointer of data from} \\
496
\cline{1-1} \cline{2-2} FTrace\_EVT\_next\_chunk & 0xFF &
497
\multicolumn{2}{c|}{previous event} \\
498
\hline
499
\end{tabular}
500
\end{center}
501
\caption{Generic data events.}
502
\end{table}
503
 
504
\begin{table}
505
\begin{center}
506
\begin{tabular}{|l|c|}
507
\hline Name & Code \\ \hline
508
\hline FTrace\_filter\_trace\_Events & 0xF0 \\
509
\hline FTrace\_filter\_ipoint & 0xF1 \\
510
\hline FTrace\_filter\_task & 0xF2 \\
511
\hline FTrace\_filter\_interrupt & 0xF3 \\
512
\hline FTrace\_filter\_CPU & 0xF4 \\
513
\hline FTrace\_filter\_priority & 0xF5 \\
514
\hline FTrace\_filter\_mutex & 0xF6 \\
515
\hline FTrace\_filter\_signal & 0xF7 \\
516
\hline FTrace\_filter\_server & 0xF8 \\
517
\hline FTrace\_filter\_user & 0xF9 \\
518
\hline FTrace\_filter\_data & 0xFA \\
519
\hline FTrace\_filter\_timer & 0xFB \\
520
\hline FTrace\_family\_mask & 0x0F \\
521
\hline
522
\end{tabular}
523
\end{center}
524
\caption{Filter management.}
525
\label{tab:filter-events}
526
\end{table}
527
 
528
%----------------------------------------------------------------------------
529
\chapter{Example of Tracer usage}
530
%----------------------------------------------------------------------------
531
 
532
\begin{verbatim}
533
/* Declarations */
534
int a,b,c;
535
SYS_FLAGS f;
536
 
537
/* Create 3 chunks for storing the tracer events. */
538
a = FTrace_chunk_create(1000000, 1000000, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_CYC);
539
b = FTrace_chunk_create(1000000, 1000000, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_JTN);
540
c = FTrace_chunk_create(1000000, 1000000, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_CYC);
541
 
542
FTrace_chunk_link(a,b);
543
FTrace_chunk_link(b,c);
544
 
545
/* Select the first chunk for saving the events. */
546
FTrace_actual_chunk_select(a);
547
 
548
/* Start the tracer. */
549
FTrace_enable();
550
 
551
/* Enable filtering for timer related events. */
552
FTrace_set_filter(FTrace_filter_timer, 1);
553
TRACER_LOGEVENT(FTrace_EVT_trace_start, proc_table[exec_shadow].context, clk_per_msec);
554
 
555
for (i = 0; i < 10; i++)
556
  if (proc_table[i].context != 0)
557
    TRACER_LOGEVENT(FTrace_EVT_id, (unsigned short int)proc_table[i].context, i);
558
 
559
/* do something */
560
 
561
/** Enable filtering for timer related events. */
562
FTrace_set_filter(FTrace_filter_timer, 0);
563
 
564
/** Change the chunk where the events are stored. */
565
TRACER_LOGEVENT(FTrace_EVT_next_chunk, 0, 0);
566
TRACER_LOGEVENT(FTrace_EVT_ipoint, 6000, 0);
567
 
568
/* do something */
569
 
570
/* Store a TFrace stop event. */
571
TRACER_LOGEVENT(FTrace_EVT_trace_stop, 0, 0);
572
 
573
/* Stop the tracer. */
574
FTrace_disable();
575
 
576
/* Initialize the network for remotely saving the trace. */
577
FTrace_OSD_init_udp(1, "192.168.1.10", "192.168.1.1");
578
 
579
/*
580
 * If want to save the events to disk, simply change
581
 * the network initialization instruction with the following line:
582
 * FTrace_init_disk_writer("trace.dat", 0, NULL, NULL);
583
 *
584
 */
585
 
586
/* Save the chunk. */
587
FTrace_send_chunk(a, 0, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_CYC);
588
FTrace_send_chunk(b, 0, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_JTN);
589
\end{verbatim}
590
 
591
%----------------------------------------------------------------------------
592
\chapter{Tracer output}
593
%----------------------------------------------------------------------------
594
 
595
When the trace is saved, locally or remotely, into a file, the
596
resulting binary file appears as a sequence of bytes where each
597
event stored within the trace output file is 16 bytes long. The
598
format of each single event is depicted in Table \ref{tab:format}.
599
 
600
The fields have the following meaning:
601
 
602
\begin{itemize}
603
\item Code represents the event type (see Chapter
604
\ref{ch:Event-types-description} for the full list);
605
\item Parameter 1 and 2 are the parameters used when \texttt{TRACER\_LOGEVENT}
606
is invoked;
607
\item TSC is the Time Stamp Counter associated with the event;
608
\end{itemize}
609
 
610
If \texttt{ptr} points to the first byte of an event, the correct TSC value
611
can be obtained with the following instructions:
612
 
613
\begin{verbatim}
614
unsigned long long tsc_value;
615
tsc_value = (unsigned long long)(*(unsigned int *)(ptr + 4)) << 32;
616
tsc_value += (unsigned long long)(*(unsigned int *)(ptr + 8));
617
\end{verbatim}
618
 
619
\begin{table}
620
\begin{center}\begin{tabular}{|c|c|c|c|c|}
621
\hline Code & Parameter 1 & TSC (high part) & TSC (low part) & Parameter 2 \\
622
\hline 2 bytes & 2 bytes & 4 bytes & 4 bytes & 4 bytes \\
623
\hline
624
\end{tabular}\end{center}
625
\caption{Event output file format.}
626
\label{tab:format}
627
\end{table}
628
 
629
\printindex{}
630
 
631
\bibliographystyle{alpha}
632
\bibliography{../common/biblio}
633
 
634
\end{document}