Add graphStream field to syncState
authorBenjamin Poirier <benjamin.poirier@polymtl.ca>
Thu, 5 Nov 2009 20:27:54 +0000 (15:27 -0500)
committerBenjamin Poirier <benjamin.poirier@polymtl.ca>
Fri, 18 Dec 2009 19:04:16 +0000 (14:04 -0500)
So that modules can create their own individual graphs, independently of the
write[...]GraphsPlots()/Options() mechanism.

Signed-off-by: Benjamin Poirier <benjamin.poirier@polymtl.ca>
12 files changed:
lttv/lttv/sync/event_analysis.h
lttv/lttv/sync/event_analysis_chull.c
lttv/lttv/sync/event_analysis_eval.c
lttv/lttv/sync/event_analysis_linreg.c
lttv/lttv/sync/event_matching.h
lttv/lttv/sync/event_matching_distributor.c
lttv/lttv/sync/event_matching_tcp.c
lttv/lttv/sync/event_processing.h
lttv/lttv/sync/event_processing_lttng_standard.c
lttv/lttv/sync/sync_chain.h
lttv/lttv/sync/sync_chain_lttv.c
lttv/modules/text/sync_chain_batch.c

index 0838f28c1ad45c545f280fd2549aef5444036177..0a32fe1c65bf790713034c2dd846d31750e97c45 100644 (file)
@@ -42,10 +42,10 @@ typedef struct
                broadcast);
        GArray* (*finalizeAnalysis)(struct _SyncState* const syncState);
        void (*printAnalysisStats)(struct _SyncState* const syncState);
-       void (*writeAnalysisGraphsPlots)(FILE* stream, struct _SyncState* const
-               syncState, const unsigned int i, const unsigned int j);
-       void (*writeAnalysisGraphsOptions)(FILE* stream, struct _SyncState* const
-               syncState, const unsigned int i, const unsigned int j);
+       void (*writeAnalysisGraphsPlots)(struct _SyncState* const syncState, const
+               unsigned int i, const unsigned int j);
+       void (*writeAnalysisGraphsOptions)(struct _SyncState* const syncState,
+               const unsigned int i, const unsigned int j);
 } AnalysisModule;
 
 #endif
index 41fdbca4c7764a45d19ed463232f8199c7bab709..1dc995b17da63a406b850cb317ce06d034837dac 100644 (file)
@@ -60,8 +60,8 @@ static void analyzeMessageCHull(SyncState* const syncState, Message* const
        message);
 static GArray* finalizeAnalysisCHull(SyncState* const syncState);
 static void printAnalysisStatsCHull(SyncState* const syncState);
-static void writeAnalysisGraphsPlotsCHull(FILE* stream, SyncState* const
-       syncState, const unsigned int i, const unsigned int j);
+static void writeAnalysisGraphsPlotsCHull(SyncState* const syncState, const
+       unsigned int i, const unsigned int j);
 
 // Functions specific to this module
 static void registerAnalysisCHull() __attribute__((constructor (101)));
@@ -167,7 +167,7 @@ static void initAnalysisCHull(SyncState* const syncState)
                analysisData->stats->allFactors= NULL;
        }
 
-       if (syncState->graphs)
+       if (syncState->graphsStream)
        {
                analysisData->graphsData= malloc(sizeof(AnalysisGraphsDataCHull));
                openGraphFiles(syncState);
@@ -193,7 +193,7 @@ static void openGraphFiles(SyncState* const syncState)
 
        analysisData= (AnalysisDataCHull*) syncState->analysisData;
 
-       cwd= changeToGraphDir(syncState->graphs);
+       cwd= changeToGraphDir(syncState->graphsDir);
 
        analysisData->graphsData->hullPoints= malloc(syncState->traceNb *
                sizeof(FILE**));
@@ -357,7 +357,7 @@ static void destroyAnalysisCHull(SyncState* const syncState)
                free(analysisData->stats);
        }
 
-       if (syncState->graphs)
+       if (syncState->graphsStream)
        {
                if (analysisData->graphsData->hullPoints != NULL)
                {
@@ -510,7 +510,7 @@ static GArray* finalizeAnalysisCHull(SyncState* const syncState)
 
        analysisData= (AnalysisDataCHull*) syncState->analysisData;
 
-       if (syncState->graphs && analysisData->graphsData->hullPoints != NULL)
+       if (syncState->graphsStream && analysisData->graphsData->hullPoints != NULL)
        {
                writeGraphFiles(syncState);
                closeGraphFiles(syncState);
@@ -520,14 +520,14 @@ static GArray* finalizeAnalysisCHull(SyncState* const syncState)
 
        factors= reduceFactors(syncState, allFactors);
 
-       if (syncState->stats || syncState->graphs)
+       if (syncState->stats || syncState->graphsStream)
        {
                if (syncState->stats)
                {
                        analysisData->stats->allFactors= allFactors;
                }
 
-               if (syncState->graphs)
+               if (syncState->graphsStream)
                {
                        analysisData->graphsData->allFactors= allFactors;
                }
@@ -1522,20 +1522,19 @@ static void getFactors(FactorsCHull** const allFactors, unsigned int** const
  * Write the analysis-specific graph lines in the gnuplot script.
  *
  * 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
  */
-void writeAnalysisGraphsPlotsCHull(FILE* stream, SyncState* const syncState,
-       const unsigned int i, const unsigned int j)
+void writeAnalysisGraphsPlotsCHull(SyncState* const syncState, const unsigned
+       int i, const unsigned int j)
 {
        AnalysisDataCHull* analysisData;
        FactorsCHull* factorsCHull;
 
        analysisData= (AnalysisDataCHull*) syncState->analysisData;
 
-       fprintf(stream,
+       fprintf(syncState->graphsStream,
                "\t\"analysis_chull-%1$03d_to_%2$03d.data\" "
                        "title \"Lower half-hull\" with linespoints "
                        "linecolor rgb \"#015a01\" linetype 4 pointtype 8 pointsize 0.8, \\\n"
@@ -1547,7 +1546,7 @@ void writeAnalysisGraphsPlotsCHull(FILE* stream, SyncState* const syncState,
        factorsCHull= &analysisData->graphsData->allFactors[j][i];
        if (factorsCHull->type == EXACT)
        {
-               fprintf(stream,
+               fprintf(syncState->graphsStream,
                        "\t%7g + %7g * x "
                                "title \"Exact conversion\" with lines "
                                "linecolor rgb \"black\" linetype 1, \\\n",
@@ -1555,17 +1554,17 @@ void writeAnalysisGraphsPlotsCHull(FILE* stream, SyncState* const syncState,
        }
        else if (factorsCHull->type == MIDDLE)
        {
-               fprintf(stream,
+               fprintf(syncState->graphsStream,
                        "\t%.2f + %.10f * x "
                                "title \"Min conversion\" with lines "
                                "linecolor rgb \"black\" linetype 5, \\\n",
                                factorsCHull->min->offset, factorsCHull->min->drift);
-               fprintf(stream,
+               fprintf(syncState->graphsStream,
                        "\t%.2f + %.10f * x "
                                "title \"Max conversion\" with lines "
                                "linecolor rgb \"black\" linetype 8, \\\n",
                                factorsCHull->max->offset, factorsCHull->max->drift);
-               fprintf(stream,
+               fprintf(syncState->graphsStream,
                        "\t%.2f + %.10f * x "
                                "title \"Middle conversion\" with lines "
                                "linecolor rgb \"gray60\" linetype 1, \\\n",
@@ -1573,7 +1572,7 @@ void writeAnalysisGraphsPlotsCHull(FILE* stream, SyncState* const syncState,
        }
        else if (factorsCHull->type == FALLBACK)
        {
-               fprintf(stream,
+               fprintf(syncState->graphsStream,
                        "\t%.2f + %.10f * x "
                                "title \"Fallback conversion\" with lines "
                                "linecolor rgb \"gray60\" linetype 1, \\\n",
@@ -1583,7 +1582,7 @@ void writeAnalysisGraphsPlotsCHull(FILE* stream, SyncState* const syncState,
        {
                if (factorsCHull->min->drift != -INFINITY)
                {
-                       fprintf(stream,
+                       fprintf(syncState->graphsStream,
                                "\t%.2f + %.10f * x "
                                        "title \"Min conversion\" with lines "
                                        "linecolor rgb \"black\" linetype 5, \\\n",
@@ -1592,7 +1591,7 @@ void writeAnalysisGraphsPlotsCHull(FILE* stream, SyncState* const syncState,
 
                if (factorsCHull->max->drift != INFINITY)
                {
-                       fprintf(stream,
+                       fprintf(syncState->graphsStream,
                                "\t%.2f + %.10f * x "
                                        "title \"Max conversion\" with lines "
                                        "linecolor rgb \"black\" linetype 8, \\\n",
@@ -1603,7 +1602,7 @@ void writeAnalysisGraphsPlotsCHull(FILE* stream, SyncState* const syncState,
        {
                if (factorsCHull->min != NULL && factorsCHull->min->drift != -INFINITY)
                {
-                       fprintf(stream,
+                       fprintf(syncState->graphsStream,
                                "\t%.2f + %.10f * x "
                                        "title \"Min conversion\" with lines "
                                        "linecolor rgb \"black\" linetype 5, \\\n",
@@ -1612,7 +1611,7 @@ void writeAnalysisGraphsPlotsCHull(FILE* stream, SyncState* const syncState,
 
                if (factorsCHull->max != NULL && factorsCHull->max->drift != INFINITY)
                {
-                       fprintf(stream,
+                       fprintf(syncState->graphsStream,
                                "\t%.2f + %.10f * x "
                                        "title \"Max conversion\" with lines "
                                        "linecolor rgb \"black\" linetype 8, \\\n",
index b63fa54f91b49ab12fc761d4e906a9250103a33d..57ee73ec7a9fdead2f6312d12811a9bf9d32ff18 100644 (file)
@@ -52,10 +52,10 @@ static void analyzeBroadcastEval(SyncState* const syncState, Broadcast* const
        broadcast);
 static GArray* finalizeAnalysisEval(SyncState* const syncState);
 static void printAnalysisStatsEval(SyncState* const syncState);
-static void writeAnalysisGraphsPlotsEval(FILE* stream, SyncState* const
-       syncState, const unsigned int i, const unsigned int j);
-static void writeAnalysisGraphsOptionsEval(FILE* stream, SyncState*
-    const syncState, const unsigned int i, const unsigned int j);
+static void writeAnalysisGraphsPlotsEval(SyncState* const syncState, const
+       unsigned int i, const unsigned int j);
+static void writeAnalysisGraphsOptionsEval(SyncState* const syncState, const
+       unsigned int i, const unsigned int j);
 
 // Functions specific to this module
 static void registerAnalysisEval() __attribute__((constructor (102)));
@@ -172,7 +172,7 @@ static void initAnalysisEval(SyncState* const syncState)
                                &gdnDestroyRttKey, &gdnDestroyDouble);
        }
 
-       if (syncState->graphs)
+       if (syncState->graphsStream)
        {
                binBase= exp10(6. / (binNb - 2));
                analysisData->graphs= malloc(sizeof(AnalysisGraphsEval));
@@ -198,7 +198,7 @@ static void initGraphs(SyncState* const syncState)
        char name[36];
        AnalysisDataEval* analysisData= syncState->analysisData;
 
-       cwd= changeToGraphDir(syncState->graphs);
+       cwd= changeToGraphDir(syncState->graphsDir);
 
        analysisData->graphs->ttPoints= malloc(syncState->traceNb *
                sizeof(FILE**));
@@ -438,7 +438,7 @@ static void destroyAnalysisEval(SyncState* const syncState)
                free(analysisData->stats);
        }
 
-       if (syncState->graphs && analysisData->graphs)
+       if (syncState->graphsStream && analysisData->graphs)
        {
                destroyGraphs(syncState);
                free(analysisData->graphs);
@@ -482,7 +482,7 @@ static void analyzeMessageEval(SyncState* const syncState, Message* const messag
        {
                messageStats->inversionNb++;
        }
-       else if (syncState->graphs)
+       else if (syncState->graphsStream)
        {
                analysisData->graphs->ttBinsArray[message->outE->traceNum][message->inE->traceNum][binNum(tt)]++;
                analysisData->graphs->ttBinsTotal[message->outE->traceNum][message->inE->traceNum]++;
@@ -539,7 +539,7 @@ static void analyzeExchangeEval(SyncState* const syncState, Exchange* const exch
        *rtt= wallTimeSub(&m1->inE->wallTime, &m1->outE->wallTime) -
                wallTimeSub(&m2->outE->wallTime, &m2->inE->wallTime);
 
-       if (syncState->graphs)
+       if (syncState->graphsStream)
        {
                unsigned int row= MAX(m1->inE->traceNum, m1->outE->traceNum);
                unsigned int col= MIN(m1->inE->traceNum, m1->outE->traceNum);
@@ -627,7 +627,7 @@ static GArray* finalizeAnalysisEval(SyncState* const syncState)
        unsigned int i;
        AnalysisDataEval* analysisData= syncState->analysisData;
 
-       if (syncState->graphs && analysisData->graphs)
+       if (syncState->graphsStream && analysisData->graphs)
        {
                writeGraphFiles(syncState);
                destroyGraphs(syncState);
@@ -1088,15 +1088,14 @@ static double binEnd(const unsigned int binNum)
  * Write the analysis-specific graph lines in the gnuplot script.
  *
  * 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 writeAnalysisGraphsPlotsEval(FILE* stream, SyncState* const
-       syncState, const unsigned int i, const unsigned int j)
+static void writeAnalysisGraphsPlotsEval(SyncState* const syncState, const
+       unsigned int i, const unsigned int j)
 {
-       fprintf(stream,
+       fprintf(syncState->graphsStream,
                "\t\"analysis_eval_hrtt-%2$03d_and_%1$03d.data\" "
                        "title \"RTT/2\" with boxes linetype 1 linewidth 3 "
                        "linecolor rgb \"black\" fill transparent solid 0.75, \\\n"
@@ -1108,7 +1107,7 @@ static void writeAnalysisGraphsPlotsEval(FILE* stream, SyncState* const
                        "linecolor rgb \"black\" fill transparent solid 0.25, \\\n"*/
                        , i, j);
        /*
-       fprintf(stream,
+       fprintf(syncState->graphsStream,
                "\t\"analysis_eval_hrtt-%2$03d_and_%1$03d.data\" "
                        "title \"RTT/2\" with linespoints linetype 1 linewidth 3 "
                        "linecolor rgb \"black\", \\\n"
@@ -1126,15 +1125,14 @@ static void writeAnalysisGraphsPlotsEval(FILE* stream, SyncState* const
  * Write the analysis-specific options in the gnuplot script.
  *
  * 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 writeAnalysisGraphsOptionsEval(FILE* stream, SyncState*
-    const syncState, const unsigned int i, const unsigned int j)
+static void writeAnalysisGraphsOptionsEval(SyncState* const syncState, const
+       unsigned int i, const unsigned int j)
 {
-       fprintf(stream,
+       fprintf(syncState->graphsStream,
                "set xlabel \"Message Latency (s)\"\n"
                "set ylabel \"Proportion of messages per second\"\n");
 }
index cdff7f370cc001ca8323b979715e626d0a6d1cb2..3e88c71c28fbe283a85c237fcc047714c0b1f49d 100644 (file)
@@ -44,8 +44,8 @@ static void destroyAnalysisLinReg(SyncState* const syncState);
 static void analyzeExchangeLinReg(SyncState* const syncState, Exchange* const exchange);
 static GArray* finalizeAnalysisLinReg(SyncState* const syncState);
 static void printAnalysisStatsLinReg(SyncState* const syncState);
-static void writeAnalysisGraphsPlotsLinReg(FILE* stream, SyncState* const
-       syncState, const unsigned int i, const unsigned int j);
+static void writeAnalysisGraphsPlotsLinReg(SyncState* const syncState, const
+       unsigned int i, const unsigned int j);
 
 // Functions specific to this module
 static void registerAnalysisLinReg() __attribute__((constructor (102)));
@@ -745,13 +745,12 @@ static gint gcfGraphTraceCompare(gconstpointer a, gconstpointer b)
  * Write the analysis-specific graph lines in the gnuplot script.
  *
  * Args:
- *   stream:       stream where to write the data
  *   syncState:    container for synchronization data
  *   i:            first trace number, on the x axis
  *   j:            second trace number, garanteed to be larger than i
  */
-void writeAnalysisGraphsPlotsLinReg(FILE* stream, SyncState* const syncState,
-       const unsigned int i, const unsigned int j)
+void writeAnalysisGraphsPlotsLinReg(SyncState* const syncState, const unsigned
+       int i, const unsigned int j)
 {
        AnalysisDataLinReg* analysisData;
        Fit* fit;
@@ -759,7 +758,7 @@ void writeAnalysisGraphsPlotsLinReg(FILE* stream, SyncState* const syncState,
        analysisData= (AnalysisDataLinReg*) syncState->analysisData;
        fit= &analysisData->fitArray[j][i];
 
-       fprintf(stream,
+       fprintf(syncState->graphsStream,
                "\t%7g + %7g * x "
                "title \"Linreg conversion\" with lines "
                "linecolor rgb \"gray60\" linetype 1, \\\n",
index e30cda8e15fd0defe8b56010a72570283011daa0..103d813870fee2166a8f2be0bf68fb5f1127b340 100644 (file)
@@ -38,10 +38,10 @@ typedef struct
                event);
        GArray* (*finalizeMatching)(struct _SyncState* const syncState);
        void (*printMatchingStats)(struct _SyncState* const syncState);
-       void (*writeMatchingGraphsPlots)(FILE* stream, struct _SyncState* const
-               syncState, const unsigned int i, const unsigned int j);
-       void (*writeMatchingGraphsOptions)(FILE* stream, struct _SyncState* const
-               syncState, const unsigned int i, const unsigned int j);
+       void (*writeMatchingGraphsPlots)(struct _SyncState* const syncState, const
+               unsigned int i, const unsigned int j);
+       void (*writeMatchingGraphsOptions)(struct _SyncState* const syncState,
+               const unsigned int i, const unsigned int j);
 } MatchingModule;
 
 #endif
index b9d740515c494e62b65ffcd05e995efc9a59027d..4523ec530ec5e7b00a46200decfd959194643ba0 100644 (file)
@@ -42,7 +42,6 @@ struct GraphAggregate
        /* Offset whithin Matching module of the field* containing the function
         * pointer */
        size_t offset;
-       FILE* stream;
        unsigned int i, j;
 };
 
@@ -55,10 +54,10 @@ static void matchEventDistributor(SyncState* const syncState, Event* const
        event);
 static GArray* finalizeMatchingDistributor(SyncState* const syncState);
 static void printMatchingStatsDistributor(SyncState* const syncState);
-static void writeMatchingGraphsPlotsDistributor(FILE* stream, SyncState* const
-       syncState, const unsigned int i, const unsigned int j);
-static void writeMatchingGraphsOptionsDistributor(FILE* stream, SyncState*
-       const syncState, const unsigned int i, const unsigned int j);
+static void writeMatchingGraphsPlotsDistributor(SyncState* const syncState,
+       const unsigned int i, const unsigned int j);
+static void writeMatchingGraphsOptionsDistributor(SyncState* const syncState,
+       const unsigned int i, const unsigned int j);
 
 // Functions specific to this module
 static void registerMatchingDistributor() __attribute__((constructor (101)));
@@ -207,19 +206,18 @@ static void printMatchingStatsDistributor(SyncState* const syncState)
  * Call the distributed graph lines functions (when they exist).
  *
  * 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 writeMatchingGraphsPlotsDistributor(FILE* stream, SyncState* const
-       syncState, const unsigned int i, const unsigned int j)
+static void writeMatchingGraphsPlotsDistributor(SyncState* const syncState,
+       const unsigned int i, const unsigned int j)
 {
        MatchingDataDistributor* matchingData= syncState->matchingData;
 
        g_queue_foreach(matchingData->distributedModules, &gfGraphFunctionCall,
                &(struct GraphAggregate) {offsetof(MatchingModule,
-                       writeMatchingGraphsPlots), stream, i, j});
+                       writeMatchingGraphsPlots), i, j});
 }
 
 
@@ -227,19 +225,18 @@ static void writeMatchingGraphsPlotsDistributor(FILE* stream, SyncState* const
  * Call the distributed graph options functions (when they exist).
  *
  * 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 writeMatchingGraphsOptionsDistributor(FILE* stream, SyncState*
-       const syncState, const unsigned int i, const unsigned int j)
+static void writeMatchingGraphsOptionsDistributor(SyncState* const syncState,
+       const unsigned int i, const unsigned int j)
 {
        MatchingDataDistributor* matchingData= syncState->matchingData;
 
        g_queue_foreach(matchingData->distributedModules, &gfGraphFunctionCall,
                &(struct GraphAggregate) {offsetof(MatchingModule,
-                       writeMatchingGraphsOptions), stream, i, j});
+                       writeMatchingGraphsOptions), i, j});
 }
 
 
@@ -359,11 +356,11 @@ void gfGraphFunctionCall(gpointer data, gpointer user_data)
 {
        SyncState* parallelSS= data;
        struct GraphAggregate* aggregate= user_data;
-       void (*graphFunction)(FILE* , struct _SyncState*, const unsigned int,
-               const unsigned int)= (void*) data + (size_t) aggregate->offset;
+       void (*graphFunction)(struct _SyncState*, const unsigned int, const
+               unsigned int)= (void*) data + (size_t) aggregate->offset;
 
        if (graphFunction != NULL)
        {
-               graphFunction(aggregate->stream, parallelSS, aggregate->i, aggregate->j);
+               graphFunction(parallelSS, aggregate->i, aggregate->j);
        }
 }
index 0202380ccb6f2dca652c6cbe6702d9cba5bee65a..9c3e6a9d3606bef458b2782160b8e4fb0ae46546 100644 (file)
@@ -43,8 +43,8 @@ static void destroyMatchingTCP(SyncState* const syncState);
 static void matchEventTCP(SyncState* const syncState, Event* const event);
 static GArray* finalizeMatchingTCP(SyncState* const syncState);
 static void printMatchingStatsTCP(SyncState* const syncState);
-static void writeMatchingGraphsPlotsTCP(FILE* stream, SyncState* const
-       syncState, const unsigned int i, const unsigned int j);
+static void writeMatchingGraphsPlotsTCP(SyncState* const syncState, const
+       unsigned int i, const unsigned int j);
 
 // Functions specific to this module
 static void registerMatchingTCP() __attribute__((constructor (101)));
@@ -137,7 +137,7 @@ static void initMatchingTCP(SyncState* const syncState)
                matchingData->stats= NULL;
        }
 
-       if (syncState->graphs)
+       if (syncState->graphsStream)
        {
                openGraphDataFiles(syncState);
        }
@@ -217,7 +217,7 @@ static void partialDestroyMatchingTCP(SyncState* const syncState)
        g_hash_table_destroy(matchingData->unMatchedOutE);
        g_hash_table_destroy(matchingData->unAcked);
 
-       if (syncState->graphs && matchingData->messagePoints)
+       if (syncState->graphsStream && matchingData->messagePoints)
        {
                closeGraphDataFiles(syncState);
        }
@@ -372,7 +372,7 @@ static void matchEvents(SyncState* const syncState, Event* const event,
                        return;
                }
 
-               if (syncState->graphs)
+               if (syncState->graphsStream)
                {
                        writeMessagePoint(matchingData->messagePoints[packet->inE->traceNum][packet->outE->traceNum],
                                packet);
@@ -590,7 +590,7 @@ static void openGraphDataFiles(SyncState* const syncState)
 
        matchingData= (MatchingDataTCP*) syncState->matchingData;
 
-       cwd= changeToGraphDir(syncState->graphs);
+       cwd= changeToGraphDir(syncState->graphsDir);
 
        matchingData->messagePoints= malloc(syncState->traceNb * sizeof(FILE**));
        for (i= 0; i < syncState->traceNb; i++)
@@ -630,7 +630,7 @@ static void openGraphDataFiles(SyncState* const syncState)
  *
  * Args:
  *   stream:       FILE*, file pointer where to write the point
- *   message:       message for which to write the point
+ *   message:      message for which to write the point
  */
 static void writeMessagePoint(FILE* stream, const Message* const message)
 {
@@ -698,15 +698,14 @@ static void closeGraphDataFiles(SyncState* const syncState)
  * Write the matching-specific graph lines in the gnuplot script.
  *
  * 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 writeMatchingGraphsPlotsTCP(FILE* stream, SyncState* const
-       syncState, const unsigned int i, const unsigned int j)
+static void writeMatchingGraphsPlotsTCP(SyncState* const syncState, const
+       unsigned int i, const unsigned int j)
 {
-       fprintf(stream,
+       fprintf(syncState->graphsStream,
                "\t\"matching_tcp-%1$03d_to_%2$03d.data\" "
                        "title \"Sent messages\" with points linetype 4 "
                        "linecolor rgb \"#98fc66\" pointtype 9 pointsize 2, \\\n"
index 44a2c4cf43701150e8b1eab9c8059321a7f2e0d6..18642408233682b7ac30ef861a3e888265b424b4 100644 (file)
@@ -45,10 +45,10 @@ typedef struct
         * graphs to be created at all. If it provides the next function, it must
         * also provide the second next function.
         */
-       void (*writeProcessingGraphsPlots)(FILE* stream, struct _SyncState* const
-               syncState, const unsigned int i, const unsigned int j);
-       void (*writeProcessingGraphsOptions)(FILE* stream, struct _SyncState*
-               const syncState, const unsigned int i, const unsigned int j);
+       void (*writeProcessingGraphsPlots)(struct _SyncState* const syncState,
+               const unsigned int i, const unsigned int j);
+       void (*writeProcessingGraphsOptions)(struct _SyncState* const syncState,
+               const unsigned int i, const unsigned int j);
 } ProcessingModule;
 
 #endif
index 8c20f975d4bdf054acb3b38455abc9feaa5934bd..414d3ebbda8e34c9d02229f1dbe0b19b19503d54 100644 (file)
@@ -47,8 +47,8 @@ static void destroyProcessingLTTVStandard(SyncState* const syncState);
 
 static void finalizeProcessingLTTVStandard(SyncState* const syncState);
 static void printProcessingStatsLTTVStandard(SyncState* const syncState);
-static void writeProcessingGraphsOptionsLTTVStandard(FILE* stream, SyncState*
-       const syncState, const unsigned int i, const unsigned int j);
+static void writeProcessingGraphsOptionsLTTVStandard(SyncState* const
+       syncState, const unsigned int i, const unsigned int j);
 
 // Functions specific to this module
 static void registerProcessingLTTVStandard() __attribute__((constructor (102)));
@@ -652,13 +652,12 @@ static gboolean processEventLTTVStandard(void* hookData, void* callData)
  * Write the processing-specific options in the gnuplot script.
  *
  * 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)
+static void writeProcessingGraphsOptionsLTTVStandard(SyncState* const
+       syncState, const unsigned int i, const unsigned int j)
 {
        ProcessingDataLTTVStandard* processingData;
        LttTrace* traceI, * traceJ;
@@ -668,7 +667,7 @@ static void writeProcessingGraphsOptionsLTTVStandard(FILE* stream, SyncState*
        traceI= processingData->traceSetContext->traces[i]->t;
        traceJ= processingData->traceSetContext->traces[j]->t;
 
-       fprintf(stream,
+       fprintf(syncState->graphsStream,
         "set key inside right bottom\n"
         "set xlabel \"Clock %1$u\"\n"
         "set xtics nomirror\n"
index fa39b966d2323406eb85ddeee7c9d4b93b0141ef..c64fa93ef29dbd3a28f2de68c0788a28d1cbf52f 100644 (file)
@@ -30,7 +30,8 @@ typedef struct _SyncState
 {
        unsigned int traceNb;
        bool stats;
-       const char* graphs;
+       FILE* graphsStream;
+       const char* graphsDir;
 
        const ProcessingModule* processingModule;
        void* processingData;
@@ -46,7 +47,7 @@ typedef struct
        enum {
                NO_ARG,
                REQUIRED_ARG,
-               //OPTIONAL_ARG,
+               //OPTIONAL_ARG, // Not yet implemented because not supported by LTTV
                HAS_ARG_COUNT // This must be the last field
        } hasArg;
        union
index 9b2b8fe26f378ebe0ac4adcb8354b971bbcd9d1a..48a2be5884eb695d6e467e3106be63ff57621e59 100644 (file)
@@ -169,7 +169,6 @@ void syncTraceset(LttvTracesetContext* const traceSetContext)
        struct timeval startTime, endTime;
        struct rusage startUsage, endUsage;
        GList* result;
-       FILE* graphsStream;
        unsigned int i, j;
        int retval;
 
@@ -199,23 +198,14 @@ void syncTraceset(LttvTracesetContext* const traceSetContext)
        }
 
        if (optionSyncGraphs.present)
-       {
-               syncState->graphs= optionSyncGraphsDir.arg;
-       }
-       else
-       {
-               syncState->graphs= NULL;
-       }
-
-       graphsStream= NULL;
-       if (syncState->graphs)
        {
                char* cwd;
                int graphsFp;
 
                // Create the graph directory right away in case the module initialization
                // functions have something to write in it.
-               cwd= changeToGraphDir(syncState->graphs);
+               syncState->graphsDir= optionSyncGraphsDir.arg;
+               cwd= changeToGraphDir(optionSyncGraphsDir.arg);
 
                if ((graphsFp= open("graphs.gnu", O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR |
                                S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH
@@ -223,7 +213,7 @@ void syncTraceset(LttvTracesetContext* const traceSetContext)
                {
                        g_error(strerror(errno));
                }
-               if ((graphsStream= fdopen(graphsFp, "w")) == NULL)
+               if ((syncState->graphsStream= fdopen(graphsFp, "w")) == NULL)
                {
                        g_error(strerror(errno));
                }
@@ -235,6 +225,11 @@ void syncTraceset(LttvTracesetContext* const traceSetContext)
                }
                free(cwd);
        }
+       else
+       {
+               syncState->graphsStream= NULL;
+               syncState->graphsDir= NULL;
+       }
 
        // Identify and initialize modules
        syncState->processingData= NULL;
@@ -284,9 +279,9 @@ void syncTraceset(LttvTracesetContext* const traceSetContext)
        syncState->processingModule->finalizeProcessing(syncState);
 
        // Write graphs file
-       if (graphsStream != NULL)
+       if (optionSyncGraphs.present)
        {
-               fprintf(graphsStream,
+               fprintf(syncState->graphsStream,
                        "#!/usr/bin/gnuplot\n\n"
                        "set terminal postscript eps color size 8in,6in\n");
 
@@ -297,28 +292,28 @@ void syncTraceset(LttvTracesetContext* const traceSetContext)
                        {
                                long pos1, pos2, trunc;
 
-                               fprintf(graphsStream,
+                               fprintf(syncState->graphsStream,
                                        "\nset output \"%03d-%03d.eps\"\n"
                                        "plot \\\n", i, j);
 
                                if (syncState->processingModule->writeProcessingGraphsPlots)
                                {
-                                       syncState->processingModule->writeProcessingGraphsPlots(graphsStream,
-                                               syncState, i, j);
+                                       syncState->processingModule->writeProcessingGraphsPlots(syncState,
+                                               i, j);
                                }
                                if (syncState->matchingModule->writeMatchingGraphsPlots)
                                {
-                                       syncState->matchingModule->writeMatchingGraphsPlots(graphsStream,
-                                               syncState, i, j);
+                                       syncState->matchingModule->writeMatchingGraphsPlots(syncState,
+                                               i, j);
                                }
                                if (syncState->analysisModule->writeAnalysisGraphsPlots)
                                {
-                                       syncState->analysisModule->writeAnalysisGraphsPlots(graphsStream,
-                                               syncState, i, j);
+                                       syncState->analysisModule->writeAnalysisGraphsPlots(syncState,
+                                               i, j);
                                }
 
-                               fflush(graphsStream);
-                               pos2= ftell(graphsStream);
+                               fflush(syncState->graphsStream);
+                               pos2= ftell(syncState->graphsStream);
                                if (pos1 != pos2)
                                {
                                        // Remove the ", \\\n" from the last graph plot line
@@ -331,43 +326,43 @@ void syncTraceset(LttvTracesetContext* const traceSetContext)
                                        trunc= pos2 - 7;
                                }
 
-                               if (ftruncate(fileno(graphsStream), trunc) == -1)
+                               if (ftruncate(fileno(syncState->graphsStream), trunc) == -1)
                                {
                                        g_error(strerror(errno));
                                }
-                               if (fseek(graphsStream, 0, SEEK_END) == -1)
+                               if (fseek(syncState->graphsStream, 0, SEEK_END) == -1)
                                {
                                        g_error(strerror(errno));
                                }
 
-                               fprintf(graphsStream,
+                               fprintf(syncState->graphsStream,
                                        "\nset output \"%03d-%03d.eps\"\n"
                                        "set title \"\"\n", i, j);
 
                                if (syncState->processingModule->writeProcessingGraphsOptions)
                                {
-                                       syncState->processingModule->writeProcessingGraphsOptions(graphsStream,
-                                               syncState, i, j);
+                                       syncState->processingModule->writeProcessingGraphsOptions(syncState,
+                                               i, j);
                                }
                                if (syncState->matchingModule->writeMatchingGraphsOptions)
                                {
-                                       syncState->matchingModule->writeMatchingGraphsOptions(graphsStream,
-                                               syncState, i, j);
+                                       syncState->matchingModule->writeMatchingGraphsOptions(syncState,
+                                               i, j);
                                }
                                if (syncState->analysisModule->writeAnalysisGraphsOptions)
                                {
-                                       syncState->analysisModule->writeAnalysisGraphsOptions(graphsStream,
-                                               syncState, i, j);
+                                       syncState->analysisModule->writeAnalysisGraphsOptions(syncState,
+                                               i, j);
                                }
 
                                if (pos1 != pos2)
                                {
-                                       fprintf(graphsStream, "replot\n");
+                                       fprintf(syncState->graphsStream, "replot\n");
                                }
                        }
                }
 
-               if (fclose(graphsStream) != 0)
+               if (fclose(syncState->graphsStream) != 0)
                {
                        g_error(strerror(errno));
                }
index b3f873ca76eceeb4719f9022c39e472265c02b8c..86d4a2aa710c7794e68029b4a52aff0de07d3f1e 100644 (file)
@@ -54,7 +54,6 @@ struct TracesetChainState {
        SyncState* syncState;
        struct timeval startTime;
        struct rusage startUsage;
-       FILE* graphsStream;
 };
 
 static LttvHooks* before_traceset, * before_trace, * event_hook, * after_traceset;
@@ -295,23 +294,14 @@ void setupSyncChain(LttvTracesetContext* const traceSetContext)
        syncState->stats= true;
 
        if (optionEvalGraphs)
-       {
-               syncState->graphs= optionEvalGraphsDir;
-       }
-       else
-       {
-               syncState->graphs= NULL;
-       }
-
-       tracesetChainState->graphsStream= NULL;
-       if (syncState->graphs)
        {
                char* cwd;
                int graphsFp;
 
                // Create the graph directory right away in case the module initialization
                // functions have something to write in it.
-               cwd= changeToGraphDir(syncState->graphs);
+               syncState->graphsDir= optionEvalGraphsDir;
+               cwd= changeToGraphDir(optionEvalGraphsDir);
 
                if ((graphsFp= open("graphs.gnu", O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR |
                                S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH
@@ -319,7 +309,7 @@ void setupSyncChain(LttvTracesetContext* const traceSetContext)
                {
                        g_error(strerror(errno));
                }
-               if ((tracesetChainState->graphsStream= fdopen(graphsFp, "w")) == NULL)
+               if ((syncState->graphsStream= fdopen(graphsFp, "w")) == NULL)
                {
                        g_error(strerror(errno));
                }
@@ -331,6 +321,11 @@ void setupSyncChain(LttvTracesetContext* const traceSetContext)
                }
                free(cwd);
        }
+       else
+       {
+               syncState->graphsStream= NULL;
+               syncState->graphsDir= NULL;
+       }
 
        syncState->analysisData= NULL;
        result= g_queue_find_custom(&analysisModules, "eval",
@@ -373,9 +368,9 @@ void teardownSyncChain(LttvTracesetContext* const traceSetContext)
        syncState->processingModule->finalizeProcessing(syncState);
 
        // Write graphs file
-       if (tracesetChainState->graphsStream != NULL)
+       if (optionEvalGraphs)
        {
-               fprintf(tracesetChainState->graphsStream,
+               fprintf(syncState->graphsStream,
                        "#!/usr/bin/gnuplot\n\n"
                        "set terminal postscript eps color size 8in,6in\n");
 
@@ -386,19 +381,19 @@ void teardownSyncChain(LttvTracesetContext* const traceSetContext)
                        {
                                long pos1, pos2, trunc;
 
-                               fprintf(tracesetChainState->graphsStream,
+                               fprintf(syncState->graphsStream,
                                        "\nset output \"%03d-%03d.eps\"\n"
                                        "plot \\\n", i, j);
-                               pos1= ftell(tracesetChainState->graphsStream);
+                               pos1= ftell(syncState->graphsStream);
 
                                if (syncState->analysisModule->writeAnalysisGraphsPlots)
                                {
-                                       syncState->analysisModule->writeAnalysisGraphsPlots(tracesetChainState->graphsStream,
-                                               syncState, i, j);
+                                       syncState->analysisModule->writeAnalysisGraphsPlots(syncState,
+                                               i, j);
                                }
 
-                               fflush(tracesetChainState->graphsStream);
-                               pos2= ftell(tracesetChainState->graphsStream);
+                               fflush(syncState->graphsStream);
+                               pos2= ftell(syncState->graphsStream);
                                if (pos1 != pos2)
                                {
                                        // Remove the ", \\\n" from the last graph plot line
@@ -411,33 +406,33 @@ void teardownSyncChain(LttvTracesetContext* const traceSetContext)
                                        trunc= pos2 - 7;
                                }
 
-                               if (ftruncate(fileno(tracesetChainState->graphsStream), trunc) == -1)
+                               if (ftruncate(fileno(syncState->graphsStream), trunc) == -1)
                                {
                                        g_error(strerror(errno));
                                }
-                               if (fseek(tracesetChainState->graphsStream, 0, SEEK_END) == -1)
+                               if (fseek(syncState->graphsStream, 0, SEEK_END) == -1)
                                {
                                        g_error(strerror(errno));
                                }
 
-                               fprintf(tracesetChainState->graphsStream,
+                               fprintf(syncState->graphsStream,
                                        "\nset output \"%1$03d-%2$03d.eps\"\n"
                                        "set title \"\"\n", i, j);
 
                                if (syncState->analysisModule->writeAnalysisGraphsOptions)
                                {
-                                       syncState->analysisModule->writeAnalysisGraphsOptions(tracesetChainState->graphsStream,
-                                               syncState, i, j);
+                                       syncState->analysisModule->writeAnalysisGraphsOptions(syncState,
+                                               i, j);
                                }
 
                                if (pos1 != pos2)
                                {
-                                       fprintf(tracesetChainState->graphsStream, "replot\n");
+                                       fprintf(syncState->graphsStream, "replot\n");
                                }
                        }
                }
 
-               if (fclose(tracesetChainState->graphsStream) != 0)
+               if (fclose(syncState->graphsStream) != 0)
                {
                        g_error(strerror(errno));
                }
This page took 0.042268 seconds and 4 git commands to generate.