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/instr_private.h"
11 static FILE *tracing_file = NULL;
13 static int pajeDefineContainerTypeId = 0;
14 static int pajeDefineStateTypeId = 1;
15 static int pajeDefineEntityValueId = 2;
16 static int pajeDefineEventTypeId = 3;
17 static int pajeDefineLinkTypeId = 4;
18 static int pajeCreateContainerId = 5;
19 static int pajeSetStateId = 6;
21 static int pajePopStateId = 8;
22 static int pajeDestroyContainerId = 9;
25 static int pajeStartLinkId = 12;
26 static int pajeEndLinkId = 13;
32 static int pajePushStateId = 19;
34 static int pajeDefineVariableTypeWithColorId = 21;
35 static int pajeSetVariableId = 22;
36 static int pajeAddVariableId = 23;
37 static int pajeSubVariableId = 24;
38 static int pajeDefineVariableTypeId = 25;
39 static int pajeStartLinkWithVolumeId = 26;
40 static int pajeNewEventId = 27;
42 #define TRACE_LINE_SIZE 1000
44 void TRACE_paje_start(FILE * file)
49 FILE *TRACE_paje_end(void)
55 void TRACE_paje_create_header(void)
57 if (!TRACE_is_active())
59 fprintf(tracing_file, "\
60 %%EventDef PajeDefineContainerType %d \n\
62 %% ContainerType string \n\
65 %%EventDef PajeDefineStateType %d \n\
67 %% ContainerType string \n\
70 %%EventDef PajeDefineEntityValue %d \n\
72 %% EntityType string \n\
75 %%EventDef PajeDefineEventType %d \n\
77 %% EntityType string \n\
80 %%EventDef PajeDefineLinkType %d \n\
82 %% ContainerType string \n\
83 %% SourceContainerType string \n\
84 %% DestContainerType string \n\
87 %%EventDef PajeCreateContainer %d \n\
91 %% Container string \n\
94 %%EventDef PajeDestroyContainer %d \n\
97 %% Container string \n\
99 %%EventDef PajeSetState %d \n\
101 %% EntityType string \n\
102 %% Container string \n\
105 %%EventDef PajePopState %d \n\
107 %% EntityType string \n\
108 %% Container string \n\
110 %%EventDef PajeStartLink %d \n\
112 %% EntityType string \n\
113 %% Container string \n\
115 %% SourceContainer string \n\
118 %%EventDef PajeEndLink %d \n\
120 %% EntityType string \n\
121 %% Container string \n\
123 %% DestContainer string \n\
126 %%EventDef PajePushState %d \n\
128 %% EntityType string \n\
129 %% Container string \n\
132 %%EventDef PajeSetVariable %d \n\
134 %% EntityType string \n\
135 %% Container string \n\
138 %%EventDef PajeAddVariable %d \n\
140 %% EntityType string \n\
141 %% Container string \n\
144 %%EventDef PajeSubVariable %d \n\
146 %% EntityType string \n\
147 %% Container string \n\
150 %%EventDef PajeDefineVariableType %d \n\
152 %% ContainerType string \n\
155 %%EventDef PajeDefineVariableType %d \n\
157 %% ContainerType string \n\
161 %%EventDef PajeStartLink %d \n\
163 %% EntityType string \n\
164 %% Container string \n\
166 %% SourceContainer string \n\
170 %%EventDef PajeNewEvent %d \n\
172 %% EntityType string \n\
173 %% Container string \n\
175 %%EndEventDef\n", pajeDefineContainerTypeId, pajeDefineStateTypeId, pajeDefineEntityValueId, pajeDefineEventTypeId, pajeDefineLinkTypeId, pajeCreateContainerId, pajeDestroyContainerId, pajeSetStateId, pajePopStateId, pajeStartLinkId, pajeEndLinkId, pajePushStateId, pajeSetVariableId, pajeAddVariableId, pajeSubVariableId, pajeDefineVariableTypeId, pajeDefineVariableTypeWithColorId, pajeStartLinkWithVolumeId, pajeNewEventId);
178 /* internal to this file */
179 static void __pajeCreateContainer(char *output, int len, int eventid,
180 double time, const char *alias,
181 const char *type, const char *container,
184 snprintf(output, len, "%d %lf %s %s %s %s", eventid, time,
185 alias, type, container, name);
188 static void __pajeSetState(char *output, int len, int eventid, double time,
189 const char *entityType, const char *container,
192 snprintf(output, len, "%d %lf %s %s %s", eventid, time, entityType,
196 static void __pajeSetVariable(char *output, int len, int eventid,
197 double time, const char *entityType,
198 const char *container, const char *value)
200 snprintf(output, len, "%d %lf %s %s %s", eventid, time, entityType,
204 static void __pajeStartLink(char *output, int len, int eventid,
205 double time, const char *entityType,
206 const char *container, const char *value,
207 const char *sourceContainer, const char *key)
209 snprintf(output, len, "%d %lf %s %s %s %s %s", eventid, time, entityType,
210 container, value, sourceContainer, key);
213 /* internal do the instrumentation module */
214 void pajeDefineContainerType(const char *alias, const char *containerType,
217 fprintf(tracing_file, "%d %s %s %s\n", pajeDefineContainerTypeId, alias,
218 containerType, name);
221 void pajeDefineStateType(const char *alias, const char *containerType,
224 fprintf(tracing_file, "%d %s %s %s\n", pajeDefineStateTypeId, alias,
225 containerType, name);
228 void pajeDefineEventType(const char *alias, const char *containerType,
231 fprintf(tracing_file, "%d %s %s %s\n", pajeDefineEventTypeId, alias,
232 containerType, name);
235 void pajeDefineLinkType(const char *alias, const char *containerType,
236 const char *sourceContainerType,
237 const char *destContainerType, const char *name)
239 fprintf(tracing_file, "%d %s %s %s %s %s\n", pajeDefineLinkTypeId, alias,
240 containerType, sourceContainerType, destContainerType, name);
243 void pajeCreateContainer(double time, const char *alias, const char *type,
244 const char *container, const char *name)
246 char line[TRACE_LINE_SIZE];
247 __pajeCreateContainer(line, TRACE_LINE_SIZE, pajeCreateContainerId, time,
248 alias, type, container, name);
249 fprintf(tracing_file, "%s\n", line);
252 void pajeDestroyContainer(double time, const char *type,
253 const char *container)
255 fprintf(tracing_file, "%d %lf %s %s\n", pajeDestroyContainerId, time,
259 void pajeSetState(double time, const char *entityType,
260 const char *container, const char *value)
262 char line[TRACE_LINE_SIZE];
263 __pajeSetState(line, TRACE_LINE_SIZE, pajeSetStateId, time, entityType,
265 fprintf(tracing_file, "%s\n", line);
268 void pajePushState(double time, const char *entityType,
269 const char *container, const char *value)
271 char line[TRACE_LINE_SIZE];
272 __pajeSetState(line, TRACE_LINE_SIZE, pajePushStateId, time, entityType,
274 fprintf(tracing_file, "%s\n", line);
277 void pajePopState(double time, const char *entityType,
278 const char *container)
280 fprintf(tracing_file, "%d %lf %s %s\n", pajePopStateId, time, entityType,
284 void pajeStartLink(double time, const char *entityType,
285 const char *container, const char *value,
286 const char *sourceContainer, const char *key)
288 char line[TRACE_LINE_SIZE];
289 __pajeStartLink(line, TRACE_LINE_SIZE, pajeStartLinkId, time, entityType,
290 container, value, sourceContainer, key);
291 fprintf(tracing_file, "%s\n", line);
294 void pajeStartLinkWithVolume(double time, const char *entityType,
295 const char *container, const char *value,
296 const char *sourceContainer, const char *key,
299 char line[TRACE_LINE_SIZE];
300 __pajeStartLink(line, TRACE_LINE_SIZE, pajeStartLinkWithVolumeId, time,
301 entityType, container, value, sourceContainer, key);
302 fprintf(tracing_file, "%s %f\n", line, volume);
305 void pajeEndLink(double time, const char *entityType,
306 const char *container, const char *value,
307 const char *destContainer, const char *key)
309 fprintf(tracing_file, "%d %lf %s %s %s %s %s\n", pajeEndLinkId, time,
310 entityType, container, value, destContainer, key);
313 void pajeDefineVariableType(const char *alias, const char *containerType,
316 fprintf(tracing_file, "%d %s %s %s\n", pajeDefineVariableTypeId, alias,
317 containerType, name);
320 void pajeDefineVariableTypeWithColor(const char *alias, const char *containerType,
321 const char *name, const char *color)
323 fprintf(tracing_file, "%d %s %s %s \"%s\"\n", pajeDefineVariableTypeWithColorId, alias,
324 containerType, name, color);
327 void pajeSetVariable(double time, const char *entityType,
328 const char *container, const char *value)
330 char line[TRACE_LINE_SIZE];
331 __pajeSetVariable(line, TRACE_LINE_SIZE, pajeSetVariableId, time,
332 entityType, container, value);
333 fprintf(tracing_file, "%s\n", line);
336 void pajeAddVariable(double time, const char *entityType,
337 const char *container, const char *value)
339 char line[TRACE_LINE_SIZE];
340 __pajeSetVariable(line, TRACE_LINE_SIZE, pajeAddVariableId, time,
341 entityType, container, value);
342 fprintf(tracing_file, "%s\n", line);
345 void pajeSubVariable(double time, const char *entityType,
346 const char *container, const char *value)
348 char line[TRACE_LINE_SIZE];
349 __pajeSetVariable(line, TRACE_LINE_SIZE, pajeSubVariableId, time,
350 entityType, container, value);
351 fprintf(tracing_file, "%s\n", line);
354 void pajeNewEvent(double time, const char *entityType,
355 const char *container, const char *value)
357 fprintf(tracing_file, "%d %lf %s %s %s\n", pajeNewEventId, time,
358 entityType, container, value);
361 #endif /* HAVE_TRACING */