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;
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 PajeStartLink %d \n\
160 %% EntityType string \n\
161 %% Container string \n\
163 %% SourceContainer string \n\
167 %%EventDef PajeNewEvent %d \n\
169 %% EntityType string \n\
170 %% Container string \n\
172 %%EndEventDef\n", pajeDefineContainerTypeId, pajeDefineStateTypeId, pajeDefineEntityValueId, pajeDefineEventTypeId, pajeDefineLinkTypeId, pajeCreateContainerId, pajeDestroyContainerId, pajeSetStateId, pajePopStateId, pajeStartLinkId, pajeEndLinkId, pajePushStateId, pajeSetVariableId, pajeAddVariableId, pajeSubVariableId, pajeDefineVariableTypeId, pajeStartLinkWithVolumeId, pajeNewEventId);
175 /* internal to this file */
176 static void __pajeCreateContainer(char *output, int len, int eventid,
177 double time, const char *alias,
178 const char *type, const char *container,
181 snprintf(output, len, "%d %lf %s %s %s %s", eventid, time,
182 alias, type, container, name);
185 static void __pajeSetState(char *output, int len, int eventid, double time,
186 const char *entityType, const char *container,
189 snprintf(output, len, "%d %lf %s %s %s", eventid, time, entityType,
193 static void __pajeSetVariable(char *output, int len, int eventid,
194 double time, const char *entityType,
195 const char *container, const char *value)
197 snprintf(output, len, "%d %lf %s %s %s", eventid, time, entityType,
201 static void __pajeStartLink(char *output, int len, int eventid,
202 double time, const char *entityType,
203 const char *container, const char *value,
204 const char *sourceContainer, const char *key)
206 snprintf(output, len, "%d %lf %s %s %s %s %s", eventid, time, entityType,
207 container, value, sourceContainer, key);
210 /* internal do the instrumentation module */
211 void pajeDefineContainerType(const char *alias, const char *containerType,
214 fprintf(tracing_file, "%d %s %s %s\n", pajeDefineContainerTypeId, alias,
215 containerType, name);
218 void pajeDefineStateType(const char *alias, const char *containerType,
221 fprintf(tracing_file, "%d %s %s %s\n", pajeDefineStateTypeId, alias,
222 containerType, name);
225 void pajeDefineEventType(const char *alias, const char *containerType,
228 fprintf(tracing_file, "%d %s %s %s\n", pajeDefineEventTypeId, alias,
229 containerType, name);
232 void pajeDefineLinkType(const char *alias, const char *containerType,
233 const char *sourceContainerType,
234 const char *destContainerType, const char *name)
236 fprintf(tracing_file, "%d %s %s %s %s %s\n", pajeDefineLinkTypeId, alias,
237 containerType, sourceContainerType, destContainerType, name);
240 void pajeCreateContainer(double time, const char *alias, const char *type,
241 const char *container, const char *name)
243 char line[TRACE_LINE_SIZE];
244 __pajeCreateContainer(line, TRACE_LINE_SIZE, pajeCreateContainerId, time,
245 alias, type, container, name);
246 fprintf(tracing_file, "%s\n", line);
249 void pajeDestroyContainer(double time, const char *type,
250 const char *container)
252 fprintf(tracing_file, "%d %lf %s %s\n", pajeDestroyContainerId, time,
256 void pajeSetState(double time, const char *entityType,
257 const char *container, const char *value)
259 char line[TRACE_LINE_SIZE];
260 __pajeSetState(line, TRACE_LINE_SIZE, pajeSetStateId, time, entityType,
262 fprintf(tracing_file, "%s\n", line);
265 void pajePushState(double time, const char *entityType,
266 const char *container, const char *value)
268 char line[TRACE_LINE_SIZE];
269 __pajeSetState(line, TRACE_LINE_SIZE, pajePushStateId, time, entityType,
271 fprintf(tracing_file, "%s\n", line);
274 void pajePopState(double time, const char *entityType,
275 const char *container)
277 fprintf(tracing_file, "%d %lf %s %s\n", pajePopStateId, time, entityType,
281 void pajeStartLink(double time, const char *entityType,
282 const char *container, const char *value,
283 const char *sourceContainer, const char *key)
285 char line[TRACE_LINE_SIZE];
286 __pajeStartLink(line, TRACE_LINE_SIZE, pajeStartLinkId, time, entityType,
287 container, value, sourceContainer, key);
288 fprintf(tracing_file, "%s\n", line);
291 void pajeStartLinkWithVolume(double time, const char *entityType,
292 const char *container, const char *value,
293 const char *sourceContainer, const char *key,
296 char line[TRACE_LINE_SIZE];
297 __pajeStartLink(line, TRACE_LINE_SIZE, pajeStartLinkWithVolumeId, time,
298 entityType, container, value, sourceContainer, key);
299 fprintf(tracing_file, "%s %f\n", line, volume);
302 void pajeEndLink(double time, const char *entityType,
303 const char *container, const char *value,
304 const char *destContainer, const char *key)
306 fprintf(tracing_file, "%d %lf %s %s %s %s %s\n", pajeEndLinkId, time,
307 entityType, container, value, destContainer, key);
310 void pajeDefineVariableType(const char *alias, const char *containerType,
313 fprintf(tracing_file, "%d %s %s %s\n", pajeDefineVariableTypeId, alias,
314 containerType, name);
317 void pajeSetVariable(double time, const char *entityType,
318 const char *container, const char *value)
320 char line[TRACE_LINE_SIZE];
321 __pajeSetVariable(line, TRACE_LINE_SIZE, pajeSetVariableId, time,
322 entityType, container, value);
323 fprintf(tracing_file, "%s\n", line);
326 void pajeAddVariable(double time, const char *entityType,
327 const char *container, const char *value)
329 char line[TRACE_LINE_SIZE];
330 __pajeSetVariable(line, TRACE_LINE_SIZE, pajeAddVariableId, time,
331 entityType, container, value);
332 fprintf(tracing_file, "%s\n", line);
335 void pajeSubVariable(double time, const char *entityType,
336 const char *container, const char *value)
338 char line[TRACE_LINE_SIZE];
339 __pajeSetVariable(line, TRACE_LINE_SIZE, pajeSubVariableId, time,
340 entityType, container, value);
341 fprintf(tracing_file, "%s\n", line);
344 void pajeNewEvent(double time, const char *entityType,
345 const char *container, const char *value)
347 fprintf(tracing_file, "%d %lf %s %s %s\n", pajeNewEventId, time,
348 entityType, container, value);