From 8d7d16dd4f5f6ae09f556a9b0b477baaa93d468c Mon Sep 17 00:00:00 2001 From: Benjamin Poirier Date: Thu, 5 Nov 2009 15:27:54 -0500 Subject: [PATCH] Add graphStream field to syncState So that modules can create their own individual graphs, independently of the write[...]GraphsPlots()/Options() mechanism. Signed-off-by: Benjamin Poirier --- lttv/lttv/sync/event_analysis.h | 8 +-- lttv/lttv/sync/event_analysis_chull.c | 41 ++++++------ lttv/lttv/sync/event_analysis_eval.c | 36 +++++----- lttv/lttv/sync/event_analysis_linreg.c | 11 ++-- lttv/lttv/sync/event_matching.h | 8 +-- lttv/lttv/sync/event_matching_distributor.c | 29 ++++----- lttv/lttv/sync/event_matching_tcp.c | 21 +++--- lttv/lttv/sync/event_processing.h | 8 +-- .../sync/event_processing_lttng_standard.c | 11 ++-- lttv/lttv/sync/sync_chain.h | 5 +- lttv/lttv/sync/sync_chain_lttv.c | 65 +++++++++---------- lttv/modules/text/sync_chain_batch.c | 51 +++++++-------- 12 files changed, 138 insertions(+), 156 deletions(-) diff --git a/lttv/lttv/sync/event_analysis.h b/lttv/lttv/sync/event_analysis.h index 0838f28c..0a32fe1c 100644 --- a/lttv/lttv/sync/event_analysis.h +++ b/lttv/lttv/sync/event_analysis.h @@ -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 diff --git a/lttv/lttv/sync/event_analysis_chull.c b/lttv/lttv/sync/event_analysis_chull.c index 41fdbca4..1dc995b1 100644 --- a/lttv/lttv/sync/event_analysis_chull.c +++ b/lttv/lttv/sync/event_analysis_chull.c @@ -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", diff --git a/lttv/lttv/sync/event_analysis_eval.c b/lttv/lttv/sync/event_analysis_eval.c index b63fa54f..57ee73ec 100644 --- a/lttv/lttv/sync/event_analysis_eval.c +++ b/lttv/lttv/sync/event_analysis_eval.c @@ -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"); } diff --git a/lttv/lttv/sync/event_analysis_linreg.c b/lttv/lttv/sync/event_analysis_linreg.c index cdff7f37..3e88c71c 100644 --- a/lttv/lttv/sync/event_analysis_linreg.c +++ b/lttv/lttv/sync/event_analysis_linreg.c @@ -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", diff --git a/lttv/lttv/sync/event_matching.h b/lttv/lttv/sync/event_matching.h index e30cda8e..103d8138 100644 --- a/lttv/lttv/sync/event_matching.h +++ b/lttv/lttv/sync/event_matching.h @@ -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 diff --git a/lttv/lttv/sync/event_matching_distributor.c b/lttv/lttv/sync/event_matching_distributor.c index b9d74051..4523ec53 100644 --- a/lttv/lttv/sync/event_matching_distributor.c +++ b/lttv/lttv/sync/event_matching_distributor.c @@ -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); } } diff --git a/lttv/lttv/sync/event_matching_tcp.c b/lttv/lttv/sync/event_matching_tcp.c index 0202380c..9c3e6a9d 100644 --- a/lttv/lttv/sync/event_matching_tcp.c +++ b/lttv/lttv/sync/event_matching_tcp.c @@ -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" diff --git a/lttv/lttv/sync/event_processing.h b/lttv/lttv/sync/event_processing.h index 44a2c4cf..18642408 100644 --- a/lttv/lttv/sync/event_processing.h +++ b/lttv/lttv/sync/event_processing.h @@ -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 diff --git a/lttv/lttv/sync/event_processing_lttng_standard.c b/lttv/lttv/sync/event_processing_lttng_standard.c index 8c20f975..414d3ebb 100644 --- a/lttv/lttv/sync/event_processing_lttng_standard.c +++ b/lttv/lttv/sync/event_processing_lttng_standard.c @@ -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" diff --git a/lttv/lttv/sync/sync_chain.h b/lttv/lttv/sync/sync_chain.h index fa39b966..c64fa93e 100644 --- a/lttv/lttv/sync/sync_chain.h +++ b/lttv/lttv/sync/sync_chain.h @@ -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 diff --git a/lttv/lttv/sync/sync_chain_lttv.c b/lttv/lttv/sync/sync_chain_lttv.c index 9b2b8fe2..48a2be58 100644 --- a/lttv/lttv/sync/sync_chain_lttv.c +++ b/lttv/lttv/sync/sync_chain_lttv.c @@ -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)); } diff --git a/lttv/modules/text/sync_chain_batch.c b/lttv/modules/text/sync_chain_batch.c index b3f873ca..86d4a2aa 100644 --- a/lttv/modules/text/sync_chain_batch.c +++ b/lttv/modules/text/sync_chain_batch.c @@ -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)); } -- 2.34.1