9b61e1208c2718092587e83f36e413e0340b816c
1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2009 Benjamin Poirier <benjamin.poirier@polymtl.ca>
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;
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.
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,
24 #include <sys/types.h>
27 #include "sync_chain.h"
28 #include "graph_functions.h"
31 void writeGraphsScript(SyncState
* const syncState
)
33 unsigned int i
, j
, k
, l
;
39 {offsetof(GraphFunctions
, writeTraceTracePlots
),
40 offsetof(GraphFunctions
, writeTraceTraceOptions
), "TraceTrace"},
41 {offsetof(GraphFunctions
, writeTraceTimePlots
),
42 offsetof(GraphFunctions
, writeTraceTimeOptions
), "TraceTime"},
45 for (l
= 0; l
< sizeof(funcTypes
) / sizeof(*funcTypes
); l
++)
47 // Cover the upper triangular matrix, i is the reference node.
48 for (i
= 0; i
< syncState
->traceNb
; i
++)
50 for (j
= i
+ 1; j
< syncState
->traceNb
; j
++)
52 long pos1
, pos2
, trunc
;
53 const GraphFunctions
* moduleGraphFunctions
[]= {
54 &syncState
->processingModule
->graphFunctions
,
55 &syncState
->matchingModule
->graphFunctions
,
56 &syncState
->analysisModule
->graphFunctions
,
59 fprintf(syncState
->graphsStream
,
61 "set output \"%03d-%03d-%s.eps\"\n"
62 "plot \\\n", i
, j
, funcTypes
[l
].name
);
64 pos1
= ftell(syncState
->graphsStream
);
66 for (k
= 0; k
< sizeof(moduleGraphFunctions
) /
67 sizeof(*moduleGraphFunctions
); k
++)
69 GraphFunction
** writePlots
= (void*)
70 moduleGraphFunctions
[k
] + funcTypes
[l
].plotsOffset
;
74 (*writePlots
)(syncState
, i
, j
);
78 fflush(syncState
->graphsStream
);
79 pos2
= ftell(syncState
->graphsStream
);
82 // Remove the ", \\\n" from the last graph plot line
87 // Remove the "plot \\\n" line to avoid creating an invalid
92 if (ftruncate(fileno(syncState
->graphsStream
), trunc
) == -1)
94 g_error(strerror(errno
));
96 if (fseek(syncState
->graphsStream
, 0, SEEK_END
) == -1)
98 g_error(strerror(errno
));
101 fprintf(syncState
->graphsStream
,
102 "\nset output \"%03d-%03d-%s.eps\"\n"
103 "set title \"\"\n", i
, j
, funcTypes
[l
].name
);
105 for (k
= 0; k
< sizeof(moduleGraphFunctions
) /
106 sizeof(*moduleGraphFunctions
); k
++)
108 GraphFunction
** writeOptions
= (void*)
109 moduleGraphFunctions
[k
] + funcTypes
[l
].optionsOffset
;
113 (*writeOptions
)(syncState
, i
, j
);
119 fprintf(syncState
->graphsStream
, "replot\n\n");
123 fprintf(syncState
->graphsStream
, "\n");
This page took 0.039978 seconds and 3 git commands to generate.