ca5be5ea1f88558fdea115f919972d7ba8b2087f
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
;
35 const GraphFunctions
* moduleGraphFunctions
[]= {
36 &syncState
->processingModule
->graphFunctions
,
37 &syncState
->matchingModule
->graphFunctions
,
38 &syncState
->analysisModule
->graphFunctions
,
45 {offsetof(GraphFunctions
, writeTraceTracePlots
),
46 offsetof(GraphFunctions
, writeTraceTraceOptions
), "TraceTrace"},
47 {offsetof(GraphFunctions
, writeTraceTimePlots
),
48 offsetof(GraphFunctions
, writeTraceTimeOptions
), "TraceTime"},
51 fprintf(syncState
->graphsStream
, "\n");
52 pos1
= ftell(syncState
->graphsStream
);
53 for (i
= 0; i
< syncState
->traceNb
; i
++)
55 for (k
= 0; k
< sizeof(moduleGraphFunctions
) /
56 sizeof(*moduleGraphFunctions
); k
++)
58 GraphVariableFunction
** writeVariables
= (void*)
59 moduleGraphFunctions
[k
] + offsetof(GraphFunctions
,
64 (*writeVariables
)(syncState
, i
);
68 fflush(syncState
->graphsStream
);
69 pos2
= ftell(syncState
->graphsStream
);
72 fprintf(syncState
->graphsStream
, "\n");
75 for (l
= 0; l
< sizeof(funcTypes
) / sizeof(*funcTypes
); l
++)
77 // Cover the upper triangular matrix, i is the reference node.
78 for (i
= 0; i
< syncState
->traceNb
; i
++)
80 for (j
= i
+ 1; j
< syncState
->traceNb
; j
++)
84 fprintf(syncState
->graphsStream
,
86 "set output \"%03d-%03d-%s.eps\"\n"
87 "plot \\\n", i
, j
, funcTypes
[l
].name
);
89 pos1
= ftell(syncState
->graphsStream
);
91 for (k
= 0; k
< sizeof(moduleGraphFunctions
) /
92 sizeof(*moduleGraphFunctions
); k
++)
94 GraphFunction
** writePlots
= (void*)
95 moduleGraphFunctions
[k
] + funcTypes
[l
].plotsOffset
;
99 (*writePlots
)(syncState
, i
, j
);
103 fflush(syncState
->graphsStream
);
104 pos2
= ftell(syncState
->graphsStream
);
107 // Remove the ", \\\n" from the last graph plot line
112 // Remove the "plot \\\n" line to avoid creating an invalid
117 if (ftruncate(fileno(syncState
->graphsStream
), trunc
) == -1)
119 g_error(strerror(errno
));
121 if (fseek(syncState
->graphsStream
, 0, SEEK_END
) == -1)
123 g_error(strerror(errno
));
126 fprintf(syncState
->graphsStream
,
127 "\nset output \"%03d-%03d-%s.eps\"\n"
128 "set title \"\"\n", i
, j
, funcTypes
[l
].name
);
130 for (k
= 0; k
< sizeof(moduleGraphFunctions
) /
131 sizeof(*moduleGraphFunctions
); k
++)
133 GraphFunction
** writeOptions
= (void*)
134 moduleGraphFunctions
[k
] + funcTypes
[l
].optionsOffset
;
138 (*writeOptions
)(syncState
, i
, j
);
144 fprintf(syncState
->graphsStream
, "replot\n\n");
148 fprintf(syncState
->graphsStream
, "\n");
This page took 0.032273 seconds and 3 git commands to generate.