1 /* Copyright (c) 2010. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #include "instr/private.h"
11 static FILE *tracing_file = NULL;
12 int tracing_active = 0;
14 static int pajeDefineContainerTypeId = 0;
15 static int pajeDefineStateTypeId = 1;
16 static int pajeDefineEntityValueId = 2;
17 static int pajeDefineEventTypeId = 3;
18 static int pajeDefineLinkTypeId = 4;
19 static int pajeCreateContainerId = 5;
20 static int pajeSetStateId = 6;
22 static int pajePopStateId = 8;
23 static int pajeDestroyContainerId = 9;
26 static int pajeStartLinkId = 12;
27 static int pajeEndLinkId = 13;
33 static int pajePushStateId = 19;
35 static int pajeDefineVariableTypeWithColorId = 21;
36 static int pajeSetVariableId = 22;
37 static int pajeAddVariableId = 23;
38 static int pajeSubVariableId = 24;
39 static int pajeDefineVariableTypeId = 25;
40 static int pajeStartLinkWithVolumeId = 26;
41 static int pajeNewEventId = 27;
43 #define TRACE_LINE_SIZE 1000
45 void TRACE_paje_start(FILE * file)
51 FILE *TRACE_paje_end(void)
58 void TRACE_paje_create_header(void)
62 fprintf(tracing_file, "\
63 %%EventDef PajeDefineContainerType %d \n\
65 %% ContainerType string \n\
68 %%EventDef PajeDefineStateType %d \n\
70 %% ContainerType string \n\
73 %%EventDef PajeDefineEntityValue %d \n\
75 %% EntityType string \n\
78 %%EventDef PajeDefineEventType %d \n\
80 %% EntityType string \n\
83 %%EventDef PajeDefineLinkType %d \n\
85 %% ContainerType string \n\
86 %% SourceContainerType string \n\
87 %% DestContainerType string \n\
90 %%EventDef PajeCreateContainer %d \n\
94 %% Container string \n\
97 %%EventDef PajeDestroyContainer %d \n\
100 %% Container string \n\
102 %%EventDef PajeSetState %d \n\
104 %% EntityType string \n\
105 %% Container string \n\
108 %%EventDef PajePopState %d \n\
110 %% EntityType string \n\
111 %% Container string \n\
113 %%EventDef PajeStartLink %d \n\
115 %% EntityType string \n\
116 %% Container string \n\
118 %% SourceContainer string \n\
121 %%EventDef PajeEndLink %d \n\
123 %% EntityType string \n\
124 %% Container string \n\
126 %% DestContainer string \n\
129 %%EventDef PajePushState %d \n\
131 %% EntityType string \n\
132 %% Container string \n\
135 %%EventDef PajeSetVariable %d \n\
137 %% EntityType string \n\
138 %% Container string \n\
141 %%EventDef PajeAddVariable %d \n\
143 %% EntityType string \n\
144 %% Container string \n\
147 %%EventDef PajeSubVariable %d \n\
149 %% EntityType string \n\
150 %% Container string \n\
153 %%EventDef PajeDefineVariableType %d \n\
155 %% ContainerType string \n\
158 %%EventDef PajeDefineVariableType %d \n\
160 %% ContainerType string \n\
164 %%EventDef PajeStartLink %d \n\
166 %% EntityType string \n\
167 %% Container string \n\
169 %% SourceContainer string \n\
173 %%EventDef PajeNewEvent %d \n\
175 %% EntityType string \n\
176 %% Container string \n\
178 %%EndEventDef\n", pajeDefineContainerTypeId, pajeDefineStateTypeId, pajeDefineEntityValueId, pajeDefineEventTypeId, pajeDefineLinkTypeId, pajeCreateContainerId, pajeDestroyContainerId, pajeSetStateId, pajePopStateId, pajeStartLinkId, pajeEndLinkId, pajePushStateId, pajeSetVariableId, pajeAddVariableId, pajeSubVariableId, pajeDefineVariableTypeId, pajeDefineVariableTypeWithColorId, pajeStartLinkWithVolumeId, pajeNewEventId);
181 /* internal to this file */
182 static void __pajeCreateContainer(char *output, int len, int eventid,
183 double time, const char *alias,
184 const char *type, const char *container,
187 snprintf(output, len, "%d %lf %s %s %s %s", eventid, time,
188 alias, type, container, name);
191 static void __pajeSetState(char *output, int len, int eventid, double time,
192 const char *entityType, const char *container,
195 snprintf(output, len, "%d %lf %s %s %s", eventid, time, entityType,
199 static void __pajeSetVariable(char *output, int len, int eventid,
200 double time, const char *entityType,
201 const char *container, const char *value)
203 snprintf(output, len, "%d %lf %s %s %s", eventid, time, entityType,
207 static void __pajeStartLink(char *output, int len, int eventid,
208 double time, const char *entityType,
209 const char *container, const char *value,
210 const char *sourceContainer, const char *key)
212 snprintf(output, len, "%d %lf %s %s %s %s %s", eventid, time, entityType,
213 container, value, sourceContainer, key);
216 /* internal do the instrumentation module */
217 void pajeDefineContainerType(const char *alias, const char *containerType,
220 fprintf(tracing_file, "%d %s %s %s\n", pajeDefineContainerTypeId, alias,
221 containerType, name);
224 void pajeDefineStateType(const char *alias, const char *containerType,
227 fprintf(tracing_file, "%d %s %s %s\n", pajeDefineStateTypeId, alias,
228 containerType, name);
231 void pajeDefineEventType(const char *alias, const char *containerType,
234 fprintf(tracing_file, "%d %s %s %s\n", pajeDefineEventTypeId, alias,
235 containerType, name);
238 void pajeDefineLinkType(const char *alias, const char *containerType,
239 const char *sourceContainerType,
240 const char *destContainerType, const char *name)
242 fprintf(tracing_file, "%d %s %s %s %s %s\n", pajeDefineLinkTypeId, alias,
243 containerType, sourceContainerType, destContainerType, name);
246 void pajeCreateContainer(double time, const char *alias, const char *type,
247 const char *container, const char *name)
249 char line[TRACE_LINE_SIZE];
250 __pajeCreateContainer(line, TRACE_LINE_SIZE, pajeCreateContainerId, time,
251 alias, type, container, name);
252 fprintf(tracing_file, "%s\n", line);
255 void pajeDestroyContainer(double time, const char *type,
256 const char *container)
258 fprintf(tracing_file, "%d %lf %s %s\n", pajeDestroyContainerId, time,
262 void pajeSetState(double time, const char *entityType,
263 const char *container, const char *value)
265 char line[TRACE_LINE_SIZE];
266 __pajeSetState(line, TRACE_LINE_SIZE, pajeSetStateId, time, entityType,
268 fprintf(tracing_file, "%s\n", line);
271 void pajePushState(double time, const char *entityType,
272 const char *container, const char *value)
274 char line[TRACE_LINE_SIZE];
275 __pajeSetState(line, TRACE_LINE_SIZE, pajePushStateId, time, entityType,
277 fprintf(tracing_file, "%s\n", line);
280 void pajePopState(double time, const char *entityType,
281 const char *container)
283 fprintf(tracing_file, "%d %lf %s %s\n", pajePopStateId, time, entityType,
287 void pajeStartLink(double time, const char *entityType,
288 const char *container, const char *value,
289 const char *sourceContainer, const char *key)
291 char line[TRACE_LINE_SIZE];
292 __pajeStartLink(line, TRACE_LINE_SIZE, pajeStartLinkId, time, entityType,
293 container, value, sourceContainer, key);
294 fprintf(tracing_file, "%s\n", line);
297 void pajeStartLinkWithVolume(double time, const char *entityType,
298 const char *container, const char *value,
299 const char *sourceContainer, const char *key,
302 char line[TRACE_LINE_SIZE];
303 __pajeStartLink(line, TRACE_LINE_SIZE, pajeStartLinkWithVolumeId, time,
304 entityType, container, value, sourceContainer, key);
305 fprintf(tracing_file, "%s %f\n", line, volume);
308 void pajeEndLink(double time, const char *entityType,
309 const char *container, const char *value,
310 const char *destContainer, const char *key)
312 fprintf(tracing_file, "%d %lf %s %s %s %s %s\n", pajeEndLinkId, time,
313 entityType, container, value, destContainer, key);
316 void pajeDefineVariableType(const char *alias, const char *containerType,
319 fprintf(tracing_file, "%d %s %s %s\n", pajeDefineVariableTypeId, alias,
320 containerType, name);
323 void pajeDefineVariableTypeWithColor(const char *alias, const char *containerType,
324 const char *name, const char *color)
326 fprintf(tracing_file, "%d %s %s %s \"%s\"\n", pajeDefineVariableTypeWithColorId, alias,
327 containerType, name, color);
330 void pajeSetVariable(double time, const char *entityType,
331 const char *container, const char *value)
333 char line[TRACE_LINE_SIZE];
334 __pajeSetVariable(line, TRACE_LINE_SIZE, pajeSetVariableId, time,
335 entityType, container, value);
336 fprintf(tracing_file, "%s\n", line);
339 void pajeAddVariable(double time, const char *entityType,
340 const char *container, const char *value)
342 char line[TRACE_LINE_SIZE];
343 __pajeSetVariable(line, TRACE_LINE_SIZE, pajeAddVariableId, time,
344 entityType, container, value);
345 fprintf(tracing_file, "%s\n", line);
348 void pajeSubVariable(double time, const char *entityType,
349 const char *container, const char *value)
351 char line[TRACE_LINE_SIZE];
352 __pajeSetVariable(line, TRACE_LINE_SIZE, pajeSubVariableId, time,
353 entityType, container, value);
354 fprintf(tracing_file, "%s\n", line);
357 void pajeNewEvent(double time, const char *entityType,
358 const char *container, const char *value)
360 fprintf(tracing_file, "%d %lf %s %s %s\n", pajeNewEventId, time,
361 entityType, container, value);