Add convex hull algorithm-based synchronization
[lttv.git] / lttv / lttv / sync / event_processing_lttv_standard.c
index cef9f2b970f2a5f8712bb6b7355045ae931ff76a..b981d3a80ade8fe44ba3cb752250bbaedd8a517b 100644 (file)
 #endif
 
 
-// Functions common to all matching modules
+// Functions common to all processing modules
 static void initProcessingLTTVStandard(SyncState* const syncState,
        LttvTracesetContext* const traceSetContext);
 static void destroyProcessingLTTVStandard(SyncState* const syncState);
 
 static void finalizeProcessingLTTVStandard(SyncState* const syncState);
 static void printProcessingStatsLTTVStandard(SyncState* const syncState);
+static void writeProcessingGraphsPlotsLTTVStandard(FILE* stream, SyncState*
+       const syncState, const unsigned int i, const unsigned int j);
+static void writeProcessingGraphsOptionsLTTVStandard(FILE* stream, SyncState*
+       const syncState, const unsigned int i, const unsigned int j);
 
 // Functions specific to this module
 static void registerProcessingLTTVStandard() __attribute__((constructor (102)));
@@ -59,6 +63,8 @@ static ProcessingModule processingModuleLTTVStandard = {
        .destroyProcessing= &destroyProcessingLTTVStandard,
        .finalizeProcessing= &finalizeProcessingLTTVStandard,
        .printProcessingStats= &printProcessingStatsLTTVStandard,
+       .writeProcessingGraphsPlots= &writeProcessingGraphsPlotsLTTVStandard,
+       .writeProcessingGraphsOptions= &writeProcessingGraphsOptionsLTTVStandard,
 };
 
 
@@ -125,7 +131,7 @@ static void initProcessingLTTVStandard(SyncState* const syncState, LttvTracesetC
        }
 
        registerHooks(processingData->hookListList, traceSetContext,
-               syncState->traceNb, &processEventLTTVStandard, syncState);
+               &processEventLTTVStandard, syncState);
 }
 
 
@@ -333,7 +339,7 @@ static void partialDestroyProcessingLTTVStandard(SyncState* const syncState)
        free(processingData->pendingRecv);
 
        unregisterHooks(processingData->hookListList,
-               processingData->traceSetContext, syncState->traceNb);
+               processingData->traceSetContext);
 }
 
 
@@ -461,7 +467,7 @@ static gboolean processEventLTTVStandard(void* hookData, void* callData)
                                lttv_trace_get_hook_field(traceHook, 0));
                        inE->packetKey= NULL;
 
-                       g_hash_table_insert(processingData->pendingRecv[traceNum],
+                       g_hash_table_replace(processingData->pendingRecv[traceNum],
                                inE->skb, inE);
 
                        g_debug("Adding inE %p for skb %p to pendingRecv\n", inE, inE->skb);
@@ -531,27 +537,6 @@ static gboolean processEventLTTVStandard(void* hookData, void* callData)
                        g_debug("Input event %p for skb %p done\n", inE, skb);
                }
        }
-       else if (info->name == LTT_EVENT_PKFREE_SKB)
-       {
-               gboolean result;
-               void* skb;
-
-               // Search pendingRecv for an event with the same skb
-               skb= (void*) (long) ltt_event_get_long_unsigned(event,
-                       lttv_trace_get_hook_field(traceHook, 0));
-
-               result= g_hash_table_remove(processingData->pendingRecv[traceNum],
-                       skb);
-               if (result == FALSE)
-               {
-                       g_debug("No matching pending receive event found, \"shaddow"
-                               "skb\" %p\n", skb);
-               }
-               else
-               {
-                       g_debug("Non-TCP skb %p\n", skb);
-               }
-       }
        else if (info->name == LTT_EVENT_NETWORK_IPV4_INTERFACE)
        {
                char* name;
@@ -580,3 +565,62 @@ static gboolean processEventLTTVStandard(void* hookData, void* callData)
 
        return FALSE;
 }
+
+
+/*
+ * Write the processing-specific graph lines in the gnuplot script (none at
+ * the moment). Call the downstream module's graph function.
+ *
+ * Args:
+ *   stream:       stream where to write the data
+ *   syncState:    container for synchronization data
+ *   i:            first trace number
+ *   j:            second trace number, garanteed to be larger than i
+ */
+static void writeProcessingGraphsPlotsLTTVStandard(FILE* stream, SyncState*
+       const syncState, const unsigned int i, const unsigned int j)
+{
+       if (syncState->matchingModule->writeMatchingGraphsPlots != NULL)
+       {
+               syncState->matchingModule->writeMatchingGraphsPlots(stream, syncState,
+                       i, j);
+       }
+}
+
+
+/*
+ * Write the processing-specific options in the gnuplot script. Call the
+ * downstream module's options function.
+ *
+ * Args:
+ *   stream:       stream where to write the data
+ *   syncState:    container for synchronization data
+ *   i:            first trace number
+ *   j:            second trace number, garanteed to be larger than i
+ */
+static void writeProcessingGraphsOptionsLTTVStandard(FILE* stream, SyncState*
+       const syncState, const unsigned int i, const unsigned int j)
+{
+       ProcessingDataLTTVStandard* processingData;
+       LttTrace* traceI, * traceJ;
+
+       processingData= (ProcessingDataLTTVStandard*) syncState->processingData;
+
+       traceI= processingData->traceSetContext->traces[i]->t;
+       traceJ= processingData->traceSetContext->traces[j]->t;
+
+       fprintf(stream,
+               "set x2label \"Clock %1$d (s)\"\n"
+               "set x2range [GPVAL_X_MIN / %2$.1f : GPVAL_X_MAX / %2$.1f]\n"
+               "set x2tics\n"
+               "set y2label \"Clock %3$d (s)\"\n"
+               "set y2range [GPVAL_Y_MIN / %4$.1f : GPVAL_Y_MAX / %4$.1f]\n"
+               "set y2tics\n", i, (double) traceI->start_freq / traceI->freq_scale,
+               j, (double) traceJ->start_freq / traceJ->freq_scale);
+
+       if (syncState->matchingModule->writeMatchingGraphsOptions != NULL)
+       {
+               syncState->matchingModule->writeMatchingGraphsOptions(stream,
+                       syncState, i, j);
+       }
+}
This page took 0.024901 seconds and 4 git commands to generate.