X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=lttv%2Flttv%2Fsync%2Fsync_chain_lttv.c;h=4a70154884a63a59ac703abecc95dca5753a6c76;hb=e072e1abc02d780d84664fcb2c971eb5a317f664;hp=9b2b8fe26f378ebe0ac4adcb8354b971bbcd9d1a;hpb=d6ee500355b870e83d5cdbc431629999ec97794e;p=lttv.git diff --git a/lttv/lttv/sync/sync_chain_lttv.c b/lttv/lttv/sync/sync_chain_lttv.c index 9b2b8fe2..4a701548 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,11 +213,15 @@ 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)); } + fprintf(syncState->graphsStream, + "#!/usr/bin/gnuplot\n\n" + "set terminal postscript eps color size 8in,6in\n"); + retval= chdir(cwd); if (retval == -1) { @@ -235,6 +229,11 @@ void syncTraceset(LttvTracesetContext* const traceSetContext) } free(cwd); } + else + { + syncState->graphsStream= NULL; + syncState->graphsDir= NULL; + } // Identify and initialize modules syncState->processingData= NULL; @@ -284,12 +283,8 @@ void syncTraceset(LttvTracesetContext* const traceSetContext) syncState->processingModule->finalizeProcessing(syncState); // Write graphs file - if (graphsStream != NULL) + if (optionSyncGraphs.present) { - fprintf(graphsStream, - "#!/usr/bin/gnuplot\n\n" - "set terminal postscript eps color size 8in,6in\n"); - // Cover the upper triangular matrix, i is the reference node. for (i= 0; i < syncState->traceNb; i++) { @@ -297,28 +292,29 @@ void syncTraceset(LttvTracesetContext* const traceSetContext) { long pos1, pos2, trunc; - fprintf(graphsStream, - "\nset output \"%03d-%03d.eps\"\n" + fprintf(syncState->graphsStream, + "\nreset\n" + "set 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 +327,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)); }