Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[trace] assertions to point out errors on tracing
[simgrid.git] / src / instr / instr_paje.c
index de8945d..9bb9f8a 100644 (file)
@@ -8,6 +8,8 @@
 
 #ifdef HAVE_TRACING
 
 
 #ifdef HAVE_TRACING
 
+#define INSTR_PAJE_ASSERT(str) {xbt_assert1(str!=NULL&&strlen(str)>0, "'%s' is NULL or length is zero", #str);}
+
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_paje, instr, "Paje tracing event system");
 
 static FILE *tracing_file = NULL;
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_paje, instr, "Paje tracing event system");
 
 static FILE *tracing_file = NULL;
@@ -32,7 +34,7 @@ static int pajeEndLinkId = 13;
 #define UNUSED009 17
 #define UNUSED005 18
 static int pajePushStateId = 19;
 #define UNUSED009 17
 #define UNUSED005 18
 static int pajePushStateId = 19;
-#define UNUSED001 20
+static int pajeDefineEventTypeWithColorId = 20;
 static int pajeDefineVariableTypeWithColorId = 21;
 static int pajeSetVariableId = 22;
 static int pajeAddVariableId = 23;
 static int pajeDefineVariableTypeWithColorId = 21;
 static int pajeSetVariableId = 22;
 static int pajeAddVariableId = 23;
@@ -85,6 +87,12 @@ void TRACE_paje_create_header(void)
 %%       Alias string \n\
 %%       EntityType string \n\
 %%       Name string \n\
 %%       Alias string \n\
 %%       EntityType string \n\
 %%       Name string \n\
+%%       Color color \n\
+%%EndEventDef \n\
+%%EventDef PajeDefineEventType %d \n\
+%%       Alias string \n\
+%%       EntityType string \n\
+%%       Name string \n\
 %%EndEventDef \n\
 %%EventDef PajeDefineLinkType %d \n\
 %%       Alias string \n\
 %%EndEventDef \n\
 %%EventDef PajeDefineLinkType %d \n\
 %%       Alias string \n\
@@ -181,7 +189,7 @@ void TRACE_paje_create_header(void)
 %%       EntityType string \n\
 %%       Container string \n\
 %%       Value string \n\
 %%       EntityType string \n\
 %%       Container string \n\
 %%       Value string \n\
-%%EndEventDef\n", pajeDefineContainerTypeId, pajeDefineStateTypeId, pajeDefineEntityValueId, pajeDefineEventTypeId, pajeDefineLinkTypeId, pajeCreateContainerId, pajeDestroyContainerId, pajeSetStateId, pajePopStateId, pajeStartLinkId, pajeEndLinkId, pajePushStateId, pajeSetVariableId, pajeAddVariableId, pajeSubVariableId, pajeDefineVariableTypeId, pajeDefineVariableTypeWithColorId, pajeStartLinkWithVolumeId, pajeNewEventId);
+%%EndEventDef\n", pajeDefineContainerTypeId, pajeDefineStateTypeId, pajeDefineEntityValueId, pajeDefineEventTypeWithColorId, pajeDefineEventTypeId, pajeDefineLinkTypeId, pajeCreateContainerId, pajeDestroyContainerId, pajeSetStateId, pajePopStateId, pajeStartLinkId, pajeEndLinkId, pajePushStateId, pajeSetVariableId, pajeAddVariableId, pajeSubVariableId, pajeDefineVariableTypeId, pajeDefineVariableTypeWithColorId, pajeStartLinkWithVolumeId, pajeNewEventId);
 }
 
 /* internal to this file */
 }
 
 /* internal to this file */
@@ -243,6 +251,10 @@ static void __pajeStartLink(char *output, int len, int eventid,
 void pajeDefineContainerType(const char *alias, const char *containerType,
                              const char *name)
 {
 void pajeDefineContainerType(const char *alias, const char *containerType,
                              const char *name)
 {
+  INSTR_PAJE_ASSERT(alias);
+  INSTR_PAJE_ASSERT(containerType);
+  INSTR_PAJE_ASSERT(name);
+
   fprintf(tracing_file, "%d %s %s %s\n", pajeDefineContainerTypeId, alias,
           containerType, name);
 }
   fprintf(tracing_file, "%d %s %s %s\n", pajeDefineContainerTypeId, alias,
           containerType, name);
 }
@@ -250,13 +262,33 @@ void pajeDefineContainerType(const char *alias, const char *containerType,
 void pajeDefineStateType(const char *alias, const char *containerType,
                          const char *name)
 {
 void pajeDefineStateType(const char *alias, const char *containerType,
                          const char *name)
 {
+  INSTR_PAJE_ASSERT(alias);
+  INSTR_PAJE_ASSERT(containerType);
+  INSTR_PAJE_ASSERT(name);
+
   fprintf(tracing_file, "%d %s %s %s\n", pajeDefineStateTypeId, alias,
           containerType, name);
 }
 
   fprintf(tracing_file, "%d %s %s %s\n", pajeDefineStateTypeId, alias,
           containerType, name);
 }
 
+void pajeDefineEventTypeWithColor(const char *alias, const char *containerType,
+                         const char *name, const char *color)
+{
+  INSTR_PAJE_ASSERT(alias);
+  INSTR_PAJE_ASSERT(containerType);
+  INSTR_PAJE_ASSERT(name);
+  INSTR_PAJE_ASSERT(name);
+
+  fprintf(tracing_file, "%d %s %s %s %s\n", pajeDefineEventTypeWithColorId, alias,
+          containerType, name, color);
+}
+
 void pajeDefineEventType(const char *alias, const char *containerType,
                          const char *name)
 {
 void pajeDefineEventType(const char *alias, const char *containerType,
                          const char *name)
 {
+  INSTR_PAJE_ASSERT(alias);
+  INSTR_PAJE_ASSERT(containerType);
+  INSTR_PAJE_ASSERT(name);
+
   fprintf(tracing_file, "%d %s %s %s\n", pajeDefineEventTypeId, alias,
           containerType, name);
 }
   fprintf(tracing_file, "%d %s %s %s\n", pajeDefineEventTypeId, alias,
           containerType, name);
 }
@@ -265,6 +297,12 @@ void pajeDefineLinkType(const char *alias, const char *containerType,
                         const char *sourceContainerType,
                         const char *destContainerType, const char *name)
 {
                         const char *sourceContainerType,
                         const char *destContainerType, const char *name)
 {
+  INSTR_PAJE_ASSERT(alias);
+  INSTR_PAJE_ASSERT(containerType);
+  INSTR_PAJE_ASSERT(sourceContainerType);
+  INSTR_PAJE_ASSERT(destContainerType);
+  INSTR_PAJE_ASSERT(name);
+
   fprintf(tracing_file, "%d %s %s %s %s %s\n", pajeDefineLinkTypeId, alias,
           containerType, sourceContainerType, destContainerType, name);
 }
   fprintf(tracing_file, "%d %s %s %s %s %s\n", pajeDefineLinkTypeId, alias,
           containerType, sourceContainerType, destContainerType, name);
 }
@@ -272,6 +310,11 @@ void pajeDefineLinkType(const char *alias, const char *containerType,
 void pajeCreateContainer(double time, const char *alias, const char *type,
                          const char *container, const char *name)
 {
 void pajeCreateContainer(double time, const char *alias, const char *type,
                          const char *container, const char *name)
 {
+  INSTR_PAJE_ASSERT(alias);
+  INSTR_PAJE_ASSERT(type);
+  INSTR_PAJE_ASSERT(container);
+  INSTR_PAJE_ASSERT(name);
+
   char line[TRACE_LINE_SIZE];
   __pajeCreateContainer(line, TRACE_LINE_SIZE, pajeCreateContainerId, time,
                         alias, type, container, name);
   char line[TRACE_LINE_SIZE];
   __pajeCreateContainer(line, TRACE_LINE_SIZE, pajeCreateContainerId, time,
                         alias, type, container, name);
@@ -281,6 +324,9 @@ void pajeCreateContainer(double time, const char *alias, const char *type,
 void pajeDestroyContainer(double time, const char *type,
                           const char *container)
 {
 void pajeDestroyContainer(double time, const char *type,
                           const char *container)
 {
+  INSTR_PAJE_ASSERT(type);
+  INSTR_PAJE_ASSERT(container);
+
   if (time == 0){
     fprintf(tracing_file, "%d 0 %s %s\n", pajeDestroyContainerId,
           type, container);
   if (time == 0){
     fprintf(tracing_file, "%d 0 %s %s\n", pajeDestroyContainerId,
           type, container);
@@ -293,6 +339,10 @@ void pajeDestroyContainer(double time, const char *type,
 void pajeSetState(double time, const char *entityType,
                   const char *container, const char *value)
 {
 void pajeSetState(double time, const char *entityType,
                   const char *container, const char *value)
 {
+  INSTR_PAJE_ASSERT(entityType);
+  INSTR_PAJE_ASSERT(container);
+  INSTR_PAJE_ASSERT(value);
+
   char line[TRACE_LINE_SIZE];
   __pajeSetState(line, TRACE_LINE_SIZE, pajeSetStateId, time, entityType,
                  container, value);
   char line[TRACE_LINE_SIZE];
   __pajeSetState(line, TRACE_LINE_SIZE, pajeSetStateId, time, entityType,
                  container, value);
@@ -302,6 +352,10 @@ void pajeSetState(double time, const char *entityType,
 void pajePushState(double time, const char *entityType,
                    const char *container, const char *value)
 {
 void pajePushState(double time, const char *entityType,
                    const char *container, const char *value)
 {
+  INSTR_PAJE_ASSERT(entityType);
+  INSTR_PAJE_ASSERT(container);
+  INSTR_PAJE_ASSERT(value);
+
   char line[TRACE_LINE_SIZE];
   __pajeSetState(line, TRACE_LINE_SIZE, pajePushStateId, time, entityType,
                  container, value);
   char line[TRACE_LINE_SIZE];
   __pajeSetState(line, TRACE_LINE_SIZE, pajePushStateId, time, entityType,
                  container, value);
@@ -311,6 +365,9 @@ void pajePushState(double time, const char *entityType,
 void pajePopState(double time, const char *entityType,
                   const char *container)
 {
 void pajePopState(double time, const char *entityType,
                   const char *container)
 {
+  INSTR_PAJE_ASSERT(entityType);
+  INSTR_PAJE_ASSERT(container);
+
   fprintf(tracing_file, "%d %lf %s %s\n", pajePopStateId, time, entityType,
           container);
 }
   fprintf(tracing_file, "%d %lf %s %s\n", pajePopStateId, time, entityType,
           container);
 }
@@ -319,6 +376,12 @@ void pajeStartLink(double time, const char *entityType,
                    const char *container, const char *value,
                    const char *sourceContainer, const char *key)
 {
                    const char *container, const char *value,
                    const char *sourceContainer, const char *key)
 {
+  INSTR_PAJE_ASSERT(entityType);
+  INSTR_PAJE_ASSERT(container);
+  INSTR_PAJE_ASSERT(value);
+  INSTR_PAJE_ASSERT(sourceContainer);
+  INSTR_PAJE_ASSERT(key);
+
   char line[TRACE_LINE_SIZE];
   __pajeStartLink(line, TRACE_LINE_SIZE, pajeStartLinkId, time, entityType,
                   container, value, sourceContainer, key);
   char line[TRACE_LINE_SIZE];
   __pajeStartLink(line, TRACE_LINE_SIZE, pajeStartLinkId, time, entityType,
                   container, value, sourceContainer, key);
@@ -330,6 +393,12 @@ void pajeStartLinkWithVolume(double time, const char *entityType,
                              const char *sourceContainer, const char *key,
                              double volume)
 {
                              const char *sourceContainer, const char *key,
                              double volume)
 {
+  INSTR_PAJE_ASSERT(entityType);
+  INSTR_PAJE_ASSERT(container);
+  INSTR_PAJE_ASSERT(value);
+  INSTR_PAJE_ASSERT(sourceContainer);
+  INSTR_PAJE_ASSERT(key);
+
   char line[TRACE_LINE_SIZE];
   __pajeStartLink(line, TRACE_LINE_SIZE, pajeStartLinkWithVolumeId, time,
                   entityType, container, value, sourceContainer, key);
   char line[TRACE_LINE_SIZE];
   __pajeStartLink(line, TRACE_LINE_SIZE, pajeStartLinkWithVolumeId, time,
                   entityType, container, value, sourceContainer, key);
@@ -340,6 +409,12 @@ void pajeEndLink(double time, const char *entityType,
                  const char *container, const char *value,
                  const char *destContainer, const char *key)
 {
                  const char *container, const char *value,
                  const char *destContainer, const char *key)
 {
+  INSTR_PAJE_ASSERT(entityType);
+  INSTR_PAJE_ASSERT(container);
+  INSTR_PAJE_ASSERT(value);
+  INSTR_PAJE_ASSERT(destContainer);
+  INSTR_PAJE_ASSERT(key);
+
   if (time == 0){
     fprintf(tracing_file, "%d 0 %s %s %s %s %s\n", pajeEndLinkId,
             entityType, container, value, destContainer, key);
   if (time == 0){
     fprintf(tracing_file, "%d 0 %s %s %s %s %s\n", pajeEndLinkId,
             entityType, container, value, destContainer, key);
@@ -352,6 +427,10 @@ void pajeEndLink(double time, const char *entityType,
 void pajeDefineVariableType(const char *alias, const char *containerType,
                             const char *name)
 {
 void pajeDefineVariableType(const char *alias, const char *containerType,
                             const char *name)
 {
+  INSTR_PAJE_ASSERT(alias);
+  INSTR_PAJE_ASSERT(containerType);
+  INSTR_PAJE_ASSERT(name);
+
   fprintf(tracing_file, "%d %s %s %s\n", pajeDefineVariableTypeId, alias,
           containerType, name);
 }
   fprintf(tracing_file, "%d %s %s %s\n", pajeDefineVariableTypeId, alias,
           containerType, name);
 }
@@ -359,6 +438,11 @@ void pajeDefineVariableType(const char *alias, const char *containerType,
 void pajeDefineVariableTypeWithColor(const char *alias, const char *containerType,
                             const char *name, const char *color)
 {
 void pajeDefineVariableTypeWithColor(const char *alias, const char *containerType,
                             const char *name, const char *color)
 {
+  INSTR_PAJE_ASSERT(alias);
+  INSTR_PAJE_ASSERT(containerType);
+  INSTR_PAJE_ASSERT(name);
+  INSTR_PAJE_ASSERT(color);
+
   fprintf(tracing_file, "%d %s %s %s \"%s\"\n", pajeDefineVariableTypeWithColorId, alias,
           containerType, name, color);
 }
   fprintf(tracing_file, "%d %s %s %s \"%s\"\n", pajeDefineVariableTypeWithColorId, alias,
           containerType, name, color);
 }
@@ -366,6 +450,10 @@ void pajeDefineVariableTypeWithColor(const char *alias, const char *containerTyp
 void pajeSetVariable(double time, const char *entityType,
                      const char *container, const char *value)
 {
 void pajeSetVariable(double time, const char *entityType,
                      const char *container, const char *value)
 {
+  INSTR_PAJE_ASSERT(entityType);
+  INSTR_PAJE_ASSERT(container);
+  INSTR_PAJE_ASSERT(value);
+
   char line[TRACE_LINE_SIZE];
   __pajeSetVariable(line, TRACE_LINE_SIZE, pajeSetVariableId, time,
                     entityType, container, value);
   char line[TRACE_LINE_SIZE];
   __pajeSetVariable(line, TRACE_LINE_SIZE, pajeSetVariableId, time,
                     entityType, container, value);
@@ -375,6 +463,10 @@ void pajeSetVariable(double time, const char *entityType,
 void pajeAddVariable(double time, const char *entityType,
                      const char *container, const char *value)
 {
 void pajeAddVariable(double time, const char *entityType,
                      const char *container, const char *value)
 {
+  INSTR_PAJE_ASSERT(entityType);
+  INSTR_PAJE_ASSERT(container);
+  INSTR_PAJE_ASSERT(value);
+
   char line[TRACE_LINE_SIZE];
   __pajeSetVariable(line, TRACE_LINE_SIZE, pajeAddVariableId, time,
                     entityType, container, value);
   char line[TRACE_LINE_SIZE];
   __pajeSetVariable(line, TRACE_LINE_SIZE, pajeAddVariableId, time,
                     entityType, container, value);
@@ -384,6 +476,10 @@ void pajeAddVariable(double time, const char *entityType,
 void pajeSubVariable(double time, const char *entityType,
                      const char *container, const char *value)
 {
 void pajeSubVariable(double time, const char *entityType,
                      const char *container, const char *value)
 {
+  INSTR_PAJE_ASSERT(entityType);
+  INSTR_PAJE_ASSERT(container);
+  INSTR_PAJE_ASSERT(value);
+
   char line[TRACE_LINE_SIZE];
   __pajeSetVariable(line, TRACE_LINE_SIZE, pajeSubVariableId, time,
                     entityType, container, value);
   char line[TRACE_LINE_SIZE];
   __pajeSetVariable(line, TRACE_LINE_SIZE, pajeSubVariableId, time,
                     entityType, container, value);
@@ -393,6 +489,10 @@ void pajeSubVariable(double time, const char *entityType,
 void pajeNewEvent(double time, const char *entityType,
                   const char *container, const char *value)
 {
 void pajeNewEvent(double time, const char *entityType,
                   const char *container, const char *value)
 {
+  INSTR_PAJE_ASSERT(entityType);
+  INSTR_PAJE_ASSERT(container);
+  INSTR_PAJE_ASSERT(value);
+
   if (time == 0){
     fprintf(tracing_file, "%d 0 %s %s %s\n", pajeNewEventId,
           entityType, container, value);
   if (time == 0){
     fprintf(tracing_file, "%d 0 %s %s %s\n", pajeNewEventId,
           entityType, container, value);