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
, m
;
35 const GraphFunctions
* moduleGraphFunctions
[]= {
36 &syncState
->processingModule
->graphFunctions
,
37 &syncState
->matchingModule
->graphFunctions
,
38 &syncState
->analysisModule
->graphFunctions
,
42 size_t plotsOffsets
[2];
48 offsetof(GraphFunctions
, writeTraceTraceBackPlots
),
49 offsetof(GraphFunctions
, writeTraceTraceForePlots
),
51 offsetof(GraphFunctions
, writeTraceTraceOptions
),
56 offsetof(GraphFunctions
, writeTraceTimeBackPlots
),
57 offsetof(GraphFunctions
, writeTraceTimeForePlots
),
59 offsetof(GraphFunctions
, writeTraceTimeOptions
),
63 fprintf(syncState
->graphsStream
, "\n");
66 pos1
= ftell(syncState
->graphsStream
);
67 for (i
= 0; i
< syncState
->traceNb
; i
++)
69 for (k
= 0; k
< sizeof(moduleGraphFunctions
) /
70 sizeof(*moduleGraphFunctions
); k
++)
72 GraphVariableFunction
** writeVariables
= (void*)
73 moduleGraphFunctions
[k
] + offsetof(GraphFunctions
,
78 (*writeVariables
)(syncState
, i
);
82 fflush(syncState
->graphsStream
);
83 pos2
= ftell(syncState
->graphsStream
);
86 fprintf(syncState
->graphsStream
, "\n");
89 // Write plots and options
90 for (l
= 0; l
< sizeof(graphTypes
) / sizeof(*graphTypes
); l
++)
92 // Cover the upper triangular matrix, i is the reference node.
93 for (i
= 0; i
< syncState
->traceNb
; i
++)
95 for (j
= i
+ 1; j
< syncState
->traceNb
; j
++)
99 fprintf(syncState
->graphsStream
,
101 "set output \"%03d-%03d-%s.eps\"\n"
102 "plot \\\n", i
, j
, graphTypes
[l
].name
);
104 pos1
= ftell(syncState
->graphsStream
);
106 for (m
= 0; m
< sizeof(graphTypes
[l
].plotsOffsets
) /
107 sizeof(*graphTypes
[l
].plotsOffsets
); m
++)
109 for (k
= 0; k
< sizeof(moduleGraphFunctions
) /
110 sizeof(*moduleGraphFunctions
); k
++)
112 GraphFunction
** writePlots
= (void*)
113 moduleGraphFunctions
[k
] +
114 graphTypes
[l
].plotsOffsets
[m
];
118 (*writePlots
)(syncState
, i
, j
);
123 fflush(syncState
->graphsStream
);
124 pos2
= ftell(syncState
->graphsStream
);
127 // Remove the ", \\\n" from the last graph plot line
132 // Remove the "plot \\\n" line to avoid creating an invalid
137 if (ftruncate(fileno(syncState
->graphsStream
), trunc
) == -1)
139 g_error(strerror(errno
));
141 if (fseek(syncState
->graphsStream
, 0, SEEK_END
) == -1)
143 g_error(strerror(errno
));
146 fprintf(syncState
->graphsStream
,
147 "\nset output \"%03d-%03d-%s.eps\"\n"
148 "set title \"\"\n", i
, j
, graphTypes
[l
].name
);
150 for (k
= 0; k
< sizeof(moduleGraphFunctions
) /
151 sizeof(*moduleGraphFunctions
); k
++)
153 GraphFunction
** writeOptions
= (void*)
154 moduleGraphFunctions
[k
] + graphTypes
[l
].optionsOffset
;
158 (*writeOptions
)(syncState
, i
, j
);
164 fprintf(syncState
->graphsStream
, "replot\n\n");
168 fprintf(syncState
->graphsStream
, "\n");
This page took 0.03518 seconds and 5 git commands to generate.