Add a batchanalysis module to build and run a sync chain
[lttv.git] / lttv / lttv / sync / event_processing_lttng_standard.c
CommitLineData
70407e86
BP
1/* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2009 Benjamin Poirier <benjamin.poirier@polymtl.ca>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License Version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program 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
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
16 * MA 02111-1307, USA.
17 */
18
19#define _ISOC99_SOURCE
20
21#ifdef HAVE_CONFIG_H
22#include <config.h>
23#endif
24
25#include <linux/if_ether.h>
26#include <math.h>
27#include <netinet/in.h>
28#include <stdint.h>
29#include <stdlib.h>
f6691532 30#include <string.h>
70407e86 31
10341d26
BP
32#include "sync_chain_lttv.h"
33#include "event_processing_lttng_common.h"
70407e86 34
10341d26 35#include "event_processing_lttng_standard.h"
70407e86
BP
36
37
38#ifndef g_info
39#define g_info(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format)
40#endif
41
42
08365995 43// Functions common to all processing modules
70407e86
BP
44static void initProcessingLTTVStandard(SyncState* const syncState,
45 LttvTracesetContext* const traceSetContext);
46static void destroyProcessingLTTVStandard(SyncState* const syncState);
47
48static void finalizeProcessingLTTVStandard(SyncState* const syncState);
49static void printProcessingStatsLTTVStandard(SyncState* const syncState);
08365995
BP
50static void writeProcessingGraphsPlotsLTTVStandard(FILE* stream, SyncState*
51 const syncState, const unsigned int i, const unsigned int j);
52static void writeProcessingGraphsOptionsLTTVStandard(FILE* stream, SyncState*
53 const syncState, const unsigned int i, const unsigned int j);
70407e86
BP
54
55// Functions specific to this module
56static void registerProcessingLTTVStandard() __attribute__((constructor (102)));
57static gboolean processEventLTTVStandard(void* hookData, void* callData);
58static void partialDestroyProcessingLTTVStandard(SyncState* const syncState);
59
60
61static ProcessingModule processingModuleLTTVStandard = {
62 .name= "LTTV-standard",
63 .initProcessing= &initProcessingLTTVStandard,
64 .destroyProcessing= &destroyProcessingLTTVStandard,
65 .finalizeProcessing= &finalizeProcessingLTTVStandard,
66 .printProcessingStats= &printProcessingStatsLTTVStandard,
08365995
BP
67 .writeProcessingGraphsPlots= &writeProcessingGraphsPlotsLTTVStandard,
68 .writeProcessingGraphsOptions= &writeProcessingGraphsOptionsLTTVStandard,
70407e86
BP
69};
70
71
72
73/*
74 * Processing Module registering function
75 */
76static void registerProcessingLTTVStandard()
77{
78 g_queue_push_tail(&processingModules, &processingModuleLTTVStandard);
79
80 createQuarks();
81}
82
83
84/*
85 * Allocate and initialize data structures for synchronizing a traceset.
86 * Register event hooks.
87 *
88 * Args:
89 * syncState: container for synchronization data.
90 * This function allocates these processingData members:
91 * traceNumTable
92 * pendingRecv
93 * hookListList
94 * stats
95 * traceSetContext: set of LTTV traces
96 */
97static void initProcessingLTTVStandard(SyncState* const syncState, LttvTracesetContext*
98 const traceSetContext)
99{
100 unsigned int i;
101 ProcessingDataLTTVStandard* processingData;
102
103 processingData= malloc(sizeof(ProcessingDataLTTVStandard));
104 syncState->processingData= processingData;
105 processingData->traceSetContext= traceSetContext;
106
107 if (syncState->stats)
108 {
109 processingData->stats= calloc(1, sizeof(ProcessingStatsLTTVStandard));
110 }
111 else
112 {
113 processingData->stats= NULL;
114 }
115
116 processingData->traceNumTable= g_hash_table_new(&g_direct_hash, NULL);
117 processingData->hookListList= g_array_sized_new(FALSE, FALSE,
118 sizeof(GArray*), syncState->traceNb);
119 processingData->pendingRecv= malloc(sizeof(GHashTable*) *
120 syncState->traceNb);
121
122 for(i= 0; i < syncState->traceNb; i++)
123 {
124 g_hash_table_insert(processingData->traceNumTable,
125 processingData->traceSetContext->traces[i]->t, (gpointer) i);
126 }
127
128 for(i= 0; i < syncState->traceNb; i++)
129 {
130 processingData->pendingRecv[i]= g_hash_table_new_full(&g_direct_hash,
10341d26 131 NULL, NULL, &gdnDestroyEvent);
70407e86
BP
132 }
133
134 registerHooks(processingData->hookListList, traceSetContext,
f6691532
BP
135 &processEventLTTVStandard, syncState,
136 syncState->matchingModule->canMatch);
70407e86
BP
137}
138
139
140/*
141 * Call the partial processing destroyer, obtain and adjust the factors from
142 * downstream
143 *
144 * Args:
145 * syncState container for synchronization data.
146 */
147static void finalizeProcessingLTTVStandard(SyncState* const syncState)
148{
149 unsigned int i;
150 GArray* factors;
151 double minOffset, minDrift;
152 unsigned int refFreqTrace;
153 ProcessingDataLTTVStandard* processingData;
154
155 processingData= (ProcessingDataLTTVStandard*) syncState->processingData;
156
157 partialDestroyProcessingLTTVStandard(syncState);
158
159 factors= syncState->matchingModule->finalizeMatching(syncState);
160
161 /* The offsets are adjusted so the lowest one is 0. This is done because
162 * of a Lttv specific limitation: events cannot have negative times. By
163 * having non-negative offsets, events cannot be moved backwards to
164 * negative times.
165 */
166 minOffset= 0;
167 for (i= 0; i < syncState->traceNb; i++)
168 {
169 minOffset= MIN(g_array_index(factors, Factors, i).offset, minOffset);
170 }
171
172 for (i= 0; i < syncState->traceNb; i++)
173 {
174 g_array_index(factors, Factors, i).offset-= minOffset;
175 }
176
177 /* Because the timestamps are corrected at the TSC level (not at the
178 * LttTime level) all trace frequencies must be made equal. We choose to
179 * use the frequency of the system with the lowest drift
180 */
181 minDrift= INFINITY;
182 refFreqTrace= 0;
183 for (i= 0; i < syncState->traceNb; i++)
184 {
185 if (g_array_index(factors, Factors, i).drift < minDrift)
186 {
187 minDrift= g_array_index(factors, Factors, i).drift;
188 refFreqTrace= i;
189 }
190 }
191 g_assert(syncState->traceNb == 0 || minDrift != INFINITY);
192
193 // Write the factors to the LttTrace structures
194 for (i= 0; i < syncState->traceNb; i++)
195 {
196 LttTrace* t;
197 Factors* traceFactors;
198
199 t= processingData->traceSetContext->traces[i]->t;
200 traceFactors= &g_array_index(factors, Factors, i);
201
202 t->drift= traceFactors->drift;
203 t->offset= traceFactors->offset;
204 t->start_freq=
205 processingData->traceSetContext->traces[refFreqTrace]->t->start_freq;
206 t->freq_scale=
207 processingData->traceSetContext->traces[refFreqTrace]->t->freq_scale;
208 t->start_time_from_tsc =
209 ltt_time_from_uint64(tsc_to_uint64(t->freq_scale, t->start_freq,
210 t->drift * t->start_tsc + t->offset));
211 }
212
213 g_array_free(factors, TRUE);
214
215 lttv_traceset_context_compute_time_span(processingData->traceSetContext,
216 &processingData->traceSetContext->time_span);
217
218 g_debug("traceset start %ld.%09ld end %ld.%09ld\n",
219 processingData->traceSetContext->time_span.start_time.tv_sec,
220 processingData->traceSetContext->time_span.start_time.tv_nsec,
221 processingData->traceSetContext->time_span.end_time.tv_sec,
222 processingData->traceSetContext->time_span.end_time.tv_nsec);
70407e86
BP
223}
224
225
226/*
227 * Print statistics related to processing and downstream modules. Must be
228 * called after finalizeProcessing.
229 *
230 * Args:
231 * syncState container for synchronization data.
232 */
233static void printProcessingStatsLTTVStandard(SyncState* const syncState)
234{
235 unsigned int i;
236 ProcessingDataLTTVStandard* processingData;
237
238 if (!syncState->stats)
239 {
240 return;
241 }
242
243 processingData= (ProcessingDataLTTVStandard*) syncState->processingData;
244
245 printf("LTTV processing stats:\n");
246 printf("\treceived frames: %d\n", processingData->stats->totRecv);
247 printf("\treceived frames that are IP: %d\n",
248 processingData->stats->totRecvIp);
f6691532
BP
249 if (syncState->matchingModule->canMatch[TCP])
250 {
251 printf("\treceived and processed packets that are TCP: %d\n",
252 processingData->stats->totRecvTCP);
253 }
254 if (syncState->matchingModule->canMatch[UDP])
255 {
256 printf("\treceived and processed packets that are UDP: %d\n",
257 processingData->stats->totRecvUDP);
258 }
259 if (syncState->matchingModule->canMatch[TCP])
260 {
261 printf("\tsent packets that are TCP: %d\n",
262 processingData->stats->totOutE);
263 }
70407e86
BP
264
265 if (syncState->matchingModule->printMatchingStats != NULL)
266 {
267 syncState->matchingModule->printMatchingStats(syncState);
268 }
269
270 printf("Resulting synchronization factors:\n");
271 for (i= 0; i < syncState->traceNb; i++)
272 {
273 LttTrace* t;
274
275 t= processingData->traceSetContext->traces[i]->t;
276
277 printf("\ttrace %u drift= %g offset= %g (%f) start time= %ld.%09ld\n",
278 i, t->drift, t->offset, (double) tsc_to_uint64(t->freq_scale,
279 t->start_freq, t->offset) / NANOSECONDS_PER_SECOND,
280 t->start_time_from_tsc.tv_sec, t->start_time_from_tsc.tv_nsec);
281 }
282}
283
284
285/*
286 * Unregister event hooks. Deallocate processingData.
287 *
288 * Args:
289 * syncState: container for synchronization data.
290 * This function deallocates these processingData members:
291 * stats
292 */
293static void destroyProcessingLTTVStandard(SyncState* const syncState)
294{
295 ProcessingDataLTTVStandard* processingData;
296
297 processingData= (ProcessingDataLTTVStandard*) syncState->processingData;
298
299 if (processingData == NULL)
300 {
301 return;
302 }
303
304 partialDestroyProcessingLTTVStandard(syncState);
305
306 if (syncState->stats)
307 {
308 free(processingData->stats);
309 }
310
311 free(syncState->processingData);
312 syncState->processingData= NULL;
313}
314
315
316/*
317 * Unregister event hooks. Deallocate some of processingData.
318 *
319 * This function can be called right after the events have been processed to
320 * free some data structures that are not needed for finalization.
321 *
322 * Args:
323 * syncState: container for synchronization data.
324 * This function deallocates these members:
325 * traceNumTable
326 * hookListList
327 * pendingRecv
328 */
329static void partialDestroyProcessingLTTVStandard(SyncState* const syncState)
330{
331 unsigned int i;
332 ProcessingDataLTTVStandard* processingData;
333
334 processingData= (ProcessingDataLTTVStandard*) syncState->processingData;
335
336 if (processingData == NULL || processingData->traceNumTable == NULL)
337 {
338 return;
339 }
340
341 g_hash_table_destroy(processingData->traceNumTable);
342 processingData->traceNumTable= NULL;
343
344 for(i= 0; i < syncState->traceNb; i++)
345 {
346
347 g_debug("Cleaning up pendingRecv list\n");
348 g_hash_table_destroy(processingData->pendingRecv[i]);
349 }
350 free(processingData->pendingRecv);
351
352 unregisterHooks(processingData->hookListList,
08365995 353 processingData->traceSetContext);
70407e86
BP
354}
355
356
357/*
358 * Lttv hook function that will be called for network events
359 *
360 * Args:
361 * hookData: LttvTraceHook* for the type of event that generated the call
362 * callData: LttvTracefileContext* at the moment of the event
363 *
364 * Returns:
365 * FALSE Always returns FALSE, meaning to keep processing hooks for
366 * this event
367 */
368static gboolean processEventLTTVStandard(void* hookData, void* callData)
369{
370 LttvTraceHook* traceHook;
371 LttvTracefileContext* tfc;
372 LttEvent* event;
373 LttTime time;
374 LttCycleCount tsc;
375 LttTrace* trace;
376 unsigned long traceNum;
377 struct marker_info* info;
378 SyncState* syncState;
379 ProcessingDataLTTVStandard* processingData;
380
381 traceHook= (LttvTraceHook*) hookData;
382 tfc= (LttvTracefileContext*) callData;
9a9ca632 383 trace= tfc->t_context->t;
70407e86
BP
384 syncState= (SyncState*) traceHook->hook_data;
385 processingData= (ProcessingDataLTTVStandard*) syncState->processingData;
386 event= ltt_tracefile_get_event(tfc->tf);
387 time= ltt_event_time(event);
9a9ca632 388 tsc= trace->drift * ltt_event_cycle_count(event) + trace->offset;
70407e86
BP
389 info= marker_get_info_from_id(tfc->tf->mdata, event->event_id);
390
391 g_assert(g_hash_table_lookup_extended(processingData->traceNumTable,
392 trace, NULL, (gpointer*) &traceNum));
393
394 g_debug("XXXX process event: time: %ld.%09ld trace: %ld (%p) name: %s ",
395 (long) time.tv_sec, time.tv_nsec, traceNum, trace,
396 g_quark_to_string(info->name));
397
fea7219b 398 if (info->name == LTT_EVENT_DEV_XMIT_EXTENDED)
70407e86 399 {
10341d26 400 Event* outE;
70407e86
BP
401
402 if (!ltt_event_get_unsigned(event,
403 lttv_trace_get_hook_field(traceHook, 1)) == ETH_P_IP ||
404 !ltt_event_get_unsigned(event,
405 lttv_trace_get_hook_field(traceHook, 2)) == IPPROTO_TCP)
406 {
407 return FALSE;
408 }
409
f6691532
BP
410 if (!syncState->matchingModule->canMatch[TCP])
411 {
412 return FALSE;
413 }
414
70407e86
BP
415 if (syncState->stats)
416 {
417 processingData->stats->totOutE++;
418 }
419
10341d26 420 outE= malloc(sizeof(Event));
70407e86 421 outE->traceNum= traceNum;
10341d26
BP
422 outE->time= tsc;
423 outE->type= TCP;
424 outE->destroy= &destroyTCPEvent;
425 outE->event.tcpEvent= malloc(sizeof(TCPEvent));
426 outE->event.tcpEvent->direction= OUT;
427 outE->event.tcpEvent->segmentKey= malloc(sizeof(SegmentKey));
428 outE->event.tcpEvent->segmentKey->connectionKey.saddr=
429 ltt_event_get_unsigned(event, lttv_trace_get_hook_field(traceHook,
430 3));
431 outE->event.tcpEvent->segmentKey->connectionKey.daddr=
432 ltt_event_get_unsigned(event, lttv_trace_get_hook_field(traceHook,
433 4));
434 outE->event.tcpEvent->segmentKey->tot_len=
435 ltt_event_get_unsigned(event, lttv_trace_get_hook_field(traceHook,
436 5));
437 outE->event.tcpEvent->segmentKey->ihl= ltt_event_get_unsigned(event,
70407e86 438 lttv_trace_get_hook_field(traceHook, 6));
10341d26
BP
439 outE->event.tcpEvent->segmentKey->connectionKey.source=
440 ltt_event_get_unsigned(event, lttv_trace_get_hook_field(traceHook,
441 7));
442 outE->event.tcpEvent->segmentKey->connectionKey.dest=
443 ltt_event_get_unsigned(event, lttv_trace_get_hook_field(traceHook,
444 8));
445 outE->event.tcpEvent->segmentKey->seq= ltt_event_get_unsigned(event,
70407e86 446 lttv_trace_get_hook_field(traceHook, 9));
10341d26
BP
447 outE->event.tcpEvent->segmentKey->ack_seq=
448 ltt_event_get_unsigned(event, lttv_trace_get_hook_field(traceHook,
449 10));
450 outE->event.tcpEvent->segmentKey->doff= ltt_event_get_unsigned(event,
70407e86 451 lttv_trace_get_hook_field(traceHook, 11));
10341d26 452 outE->event.tcpEvent->segmentKey->ack= ltt_event_get_unsigned(event,
70407e86 453 lttv_trace_get_hook_field(traceHook, 12));
10341d26 454 outE->event.tcpEvent->segmentKey->rst= ltt_event_get_unsigned(event,
70407e86 455 lttv_trace_get_hook_field(traceHook, 13));
10341d26 456 outE->event.tcpEvent->segmentKey->syn= ltt_event_get_unsigned(event,
70407e86 457 lttv_trace_get_hook_field(traceHook, 14));
10341d26 458 outE->event.tcpEvent->segmentKey->fin= ltt_event_get_unsigned(event,
70407e86
BP
459 lttv_trace_get_hook_field(traceHook, 15));
460
10341d26 461 syncState->matchingModule->matchEvent(syncState, outE);
70407e86
BP
462
463 g_debug("Output event done\n");
464 }
465 else if (info->name == LTT_EVENT_DEV_RECEIVE)
466 {
467 guint32 protocol;
468
469 if (syncState->stats)
470 {
471 processingData->stats->totRecv++;
472 }
473
474 protocol= ltt_event_get_unsigned(event,
475 lttv_trace_get_hook_field(traceHook, 1));
476
477 if (protocol == ETH_P_IP)
478 {
10341d26
BP
479 Event* inE;
480 void* skb;
70407e86
BP
481
482 if (syncState->stats)
483 {
484 processingData->stats->totRecvIp++;
485 }
486
10341d26 487 inE= malloc(sizeof(Event));
70407e86 488 inE->traceNum= traceNum;
10341d26
BP
489 inE->time= tsc;
490 inE->event.tcpEvent= NULL;
491 inE->destroy= &destroyEvent;
70407e86 492
10341d26
BP
493 skb= (void*) (long) ltt_event_get_long_unsigned(event,
494 lttv_trace_get_hook_field(traceHook, 0));
495 g_hash_table_replace(processingData->pendingRecv[traceNum], skb,
496 inE);
70407e86 497
10341d26 498 g_debug("Adding inE %p for skb %p to pendingRecv\n", inE, skb);
70407e86
BP
499 }
500 else
501 {
502 g_debug("\n");
503 }
504 }
fea7219b 505 else if (info->name == LTT_EVENT_TCPV4_RCV_EXTENDED)
70407e86 506 {
10341d26 507 Event* inE;
70407e86
BP
508 void* skb;
509
510 // Search pendingRecv for an event with the same skb
511 skb= (void*) (long) ltt_event_get_long_unsigned(event,
512 lttv_trace_get_hook_field(traceHook, 0));
513
10341d26 514 inE= (Event*)
70407e86
BP
515 g_hash_table_lookup(processingData->pendingRecv[traceNum], skb);
516 if (inE == NULL)
517 {
518 // This should only happen in case of lost events
f6691532 519 g_warning("No matching pending receive event found");
70407e86
BP
520 }
521 else
522 {
523 if (syncState->stats)
524 {
f6691532 525 processingData->stats->totRecvTCP++;
70407e86
BP
526 }
527
528 // If it's there, remove it and proceed with a receive event
529 g_hash_table_steal(processingData->pendingRecv[traceNum], skb);
530
10341d26
BP
531 inE->type= TCP;
532 inE->event.tcpEvent= malloc(sizeof(TCPEvent));
533 inE->destroy= &destroyTCPEvent;
534 inE->event.tcpEvent->direction= IN;
535 inE->event.tcpEvent->segmentKey= malloc(sizeof(SegmentKey));
536 inE->event.tcpEvent->segmentKey->connectionKey.saddr=
537 ltt_event_get_unsigned(event,
538 lttv_trace_get_hook_field(traceHook, 1));
539 inE->event.tcpEvent->segmentKey->connectionKey.daddr=
540 ltt_event_get_unsigned(event,
541 lttv_trace_get_hook_field(traceHook, 2));
542 inE->event.tcpEvent->segmentKey->tot_len=
543 ltt_event_get_unsigned(event,
544 lttv_trace_get_hook_field(traceHook, 3));
545 inE->event.tcpEvent->segmentKey->ihl=
546 ltt_event_get_unsigned(event,
547 lttv_trace_get_hook_field(traceHook, 4));
548 inE->event.tcpEvent->segmentKey->connectionKey.source=
549 ltt_event_get_unsigned(event,
550 lttv_trace_get_hook_field(traceHook, 5));
551 inE->event.tcpEvent->segmentKey->connectionKey.dest=
552 ltt_event_get_unsigned(event,
553 lttv_trace_get_hook_field(traceHook, 6));
554 inE->event.tcpEvent->segmentKey->seq=
555 ltt_event_get_unsigned(event,
556 lttv_trace_get_hook_field(traceHook, 7));
557 inE->event.tcpEvent->segmentKey->ack_seq=
558 ltt_event_get_unsigned(event,
559 lttv_trace_get_hook_field(traceHook, 8));
560 inE->event.tcpEvent->segmentKey->doff=
561 ltt_event_get_unsigned(event,
562 lttv_trace_get_hook_field(traceHook, 9));
563 inE->event.tcpEvent->segmentKey->ack=
564 ltt_event_get_unsigned(event,
565 lttv_trace_get_hook_field(traceHook, 10));
566 inE->event.tcpEvent->segmentKey->rst=
567 ltt_event_get_unsigned(event,
568 lttv_trace_get_hook_field(traceHook, 11));
569 inE->event.tcpEvent->segmentKey->syn=
570 ltt_event_get_unsigned(event,
571 lttv_trace_get_hook_field(traceHook, 12));
572 inE->event.tcpEvent->segmentKey->fin=
573 ltt_event_get_unsigned(event,
574 lttv_trace_get_hook_field(traceHook, 13));
575
576 syncState->matchingModule->matchEvent(syncState, inE);
70407e86 577
f6691532 578 g_debug("TCP input event %p for skb %p done\n", inE, skb);
70407e86
BP
579 }
580 }
f6691532 581 else if (info->name == LTT_EVENT_UDPV4_RCV_EXTENDED)
70407e86 582 {
f6691532
BP
583 Event* inE;
584 void* skb;
70407e86 585
f6691532
BP
586 // Search pendingRecv for an event with the same skb
587 skb= (void*) (long) ltt_event_get_long_unsigned(event,
588 lttv_trace_get_hook_field(traceHook, 0));
70407e86 589
f6691532
BP
590 inE= (Event*)
591 g_hash_table_lookup(processingData->pendingRecv[traceNum], skb);
592 if (inE == NULL)
593 {
594 // This should only happen in case of lost events
595 g_warning("No matching pending receive event found");
596 }
597 else
598 {
599 guint64 dataStart;
70407e86 600
f6691532
BP
601 if (syncState->stats)
602 {
603 processingData->stats->totRecvUDP++;
604 }
605
606 // If it's there, remove it and proceed with a receive event
607 g_hash_table_steal(processingData->pendingRecv[traceNum], skb);
608
609 inE->type= UDP;
610 inE->event.udpEvent= malloc(sizeof(UDPEvent));
611 inE->destroy= &destroyUDPEvent;
612 inE->event.udpEvent->direction= IN;
613 inE->event.udpEvent->datagramKey= malloc(sizeof(DatagramKey));
614 inE->event.udpEvent->datagramKey->saddr=
615 ltt_event_get_unsigned(event,
616 lttv_trace_get_hook_field(traceHook, 1));
617 inE->event.udpEvent->datagramKey->daddr=
618 ltt_event_get_unsigned(event,
619 lttv_trace_get_hook_field(traceHook, 2));
620 inE->event.udpEvent->unicast= ltt_event_get_unsigned(event,
621 lttv_trace_get_hook_field(traceHook, 3)) == 0 ? false : true;
622 inE->event.udpEvent->datagramKey->ulen=
623 ltt_event_get_unsigned(event,
624 lttv_trace_get_hook_field(traceHook, 4));
625 inE->event.udpEvent->datagramKey->source=
626 ltt_event_get_unsigned(event,
627 lttv_trace_get_hook_field(traceHook, 5));
628 inE->event.udpEvent->datagramKey->dest=
629 ltt_event_get_unsigned(event,
630 lttv_trace_get_hook_field(traceHook, 6));
631 dataStart= ltt_event_get_long_unsigned(event,
632 lttv_trace_get_hook_field(traceHook, 7));
633 g_assert_cmpuint(sizeof(inE->event.udpEvent->datagramKey->dataKey),
634 ==, sizeof(guint64));
635 if (inE->event.udpEvent->datagramKey->ulen - 8 >=
636 sizeof(inE->event.udpEvent->datagramKey->dataKey))
637 {
638 memcpy(inE->event.udpEvent->datagramKey->dataKey, &dataStart,
639 sizeof(inE->event.udpEvent->datagramKey->dataKey));
640 }
641 else
642 {
643 memset(inE->event.udpEvent->datagramKey->dataKey, 0,
644 sizeof(inE->event.udpEvent->datagramKey->dataKey));
645 memcpy(inE->event.udpEvent->datagramKey->dataKey, &dataStart,
646 inE->event.udpEvent->datagramKey->ulen - 8);
647 }
648
649 syncState->matchingModule->matchEvent(syncState, inE);
650
651 g_debug("UDP input event %p for skb %p done\n", inE, skb);
652 }
70407e86
BP
653 }
654 else
655 {
656 g_assert_not_reached();
657 }
658
659 return FALSE;
660}
08365995
BP
661
662
663/*
664 * Write the processing-specific graph lines in the gnuplot script (none at
665 * the moment). Call the downstream module's graph function.
666 *
667 * Args:
668 * stream: stream where to write the data
669 * syncState: container for synchronization data
670 * i: first trace number
671 * j: second trace number, garanteed to be larger than i
672 */
673static void writeProcessingGraphsPlotsLTTVStandard(FILE* stream, SyncState*
674 const syncState, const unsigned int i, const unsigned int j)
675{
676 if (syncState->matchingModule->writeMatchingGraphsPlots != NULL)
677 {
678 syncState->matchingModule->writeMatchingGraphsPlots(stream, syncState,
679 i, j);
680 }
681}
682
683
684/*
685 * Write the processing-specific options in the gnuplot script. Call the
686 * downstream module's options function.
687 *
688 * Args:
689 * stream: stream where to write the data
690 * syncState: container for synchronization data
691 * i: first trace number
692 * j: second trace number, garanteed to be larger than i
693 */
694static void writeProcessingGraphsOptionsLTTVStandard(FILE* stream, SyncState*
695 const syncState, const unsigned int i, const unsigned int j)
696{
697 ProcessingDataLTTVStandard* processingData;
698 LttTrace* traceI, * traceJ;
699
700 processingData= (ProcessingDataLTTVStandard*) syncState->processingData;
701
702 traceI= processingData->traceSetContext->traces[i]->t;
703 traceJ= processingData->traceSetContext->traces[j]->t;
704
705 fprintf(stream,
706 "set x2label \"Clock %1$d (s)\"\n"
707 "set x2range [GPVAL_X_MIN / %2$.1f : GPVAL_X_MAX / %2$.1f]\n"
708 "set x2tics\n"
709 "set y2label \"Clock %3$d (s)\"\n"
710 "set y2range [GPVAL_Y_MIN / %4$.1f : GPVAL_Y_MAX / %4$.1f]\n"
711 "set y2tics\n", i, (double) traceI->start_freq / traceI->freq_scale,
712 j, (double) traceJ->start_freq / traceJ->freq_scale);
713
714 if (syncState->matchingModule->writeMatchingGraphsOptions != NULL)
715 {
716 syncState->matchingModule->writeMatchingGraphsOptions(stream,
717 syncState, i, j);
718 }
719}
This page took 0.052768 seconds and 4 git commands to generate.