Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[SMPI/INSTR] Header cleanup.
[simgrid.git] / src / instr / instr_trace.cpp
index 69fdf03..850f75e 100644 (file)
@@ -5,11 +5,12 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "src/instr/instr_private.h"
+#include "src/instr/instr_smpi.h"
+#include "src/smpi/private.hpp"
 #include "xbt/virtu.h" /* sg_cmdline */
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_trace, instr, "tracing event system");
 
-
 FILE *tracing_file = NULL;
 
 void print_NULL(paje_event_t event){}
@@ -118,11 +119,9 @@ static void insert_into_buffer (paje_event_t tbi)
   if (i == 0)
     XBT_DEBUG("%s: inserted at beginning", __FUNCTION__);
   else
-    XBT_DEBUG("%s: inserted at%s %u", __FUNCTION__,
-              (i == xbt_dynar_length(buffer) - 1 ? " end, pos =" : ""), i);
+    XBT_DEBUG("%s: inserted at%s %u", __FUNCTION__, (i == xbt_dynar_length(buffer) - 1 ? " end, pos =" : ""), i);
 }
 
-
 static void free_paje_event (paje_event_t event)
 {
   XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp);
@@ -344,6 +343,12 @@ void new_pajeSetState (double timestamp, container_t container, type_t type, val
   ((setState_t)(event->data))->container = container;
   ((setState_t)(event->data))->value = value;
 
+  if (xbt_cfg_get_boolean("smpi/trace-call-location")) {
+    smpi_trace_call_location_t* loc = smpi_trace_get_call_location();
+    ((setState_t)(event->data))->filename   = loc->filename;
+    ((setState_t)(event->data))->linenumber = loc->linenumber;
+  }
+
   XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp);
 
   insert_into_buffer (event);
@@ -363,6 +368,12 @@ void new_pajePushStateWithExtra (double timestamp, container_t container, type_t
   ((pushState_t)(event->data))->value = value;
   ((pushState_t)(event->data))->extra = extra;
 
+  if (xbt_cfg_get_boolean("smpi/trace-call-location")) {
+    smpi_trace_call_location_t* loc = smpi_trace_get_call_location();
+    ((pushState_t)(event->data))->filename   = loc->filename;
+    ((pushState_t)(event->data))->linenumber = loc->linenumber;
+  }
+
   XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp);
 
   insert_into_buffer (event);
@@ -371,18 +382,7 @@ void new_pajePushStateWithExtra (double timestamp, container_t container, type_t
 
 void new_pajePushState (double timestamp, container_t container, type_t type, val_t value)
 {
-  paje_event_t event = xbt_new0(s_paje_event_t, 1);
-  event->event_type = PAJE_PushState;
-  event->timestamp = timestamp;
-  event->print = active_writer.print_PushState;
-  event->free = free_paje_event;
-  event->data = xbt_new0(s_pushState_t, 1);
-  ((pushState_t)(event->data))->type = type;
-  ((pushState_t)(event->data))->container = container;
-  ((pushState_t)(event->data))->value = value;
-  XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp);
-
-  insert_into_buffer (event);
+  new_pajePushStateWithExtra(timestamp, container, type, value, nullptr);
 }
 
 void new_pajePopState (double timestamp, container_t container, type_t type)
@@ -418,7 +418,8 @@ void new_pajeResetState (double timestamp, container_t container, type_t type)
   insert_into_buffer (event);
 }
 
-void new_pajeStartLink (double timestamp, container_t container, type_t type, container_t sourceContainer, const char *value, const char *key)
+void new_pajeStartLink (double timestamp, container_t container, type_t type, container_t sourceContainer,
+                        const char *value, const char *key)
 {
   paje_event_t event = xbt_new0(s_paje_event_t, 1);
   event->event_type = PAJE_StartLink;
@@ -437,7 +438,8 @@ void new_pajeStartLink (double timestamp, container_t container, type_t type, co
   insert_into_buffer (event);
 }
 
-void new_pajeStartLinkWithSize (double timestamp, container_t container, type_t type, container_t sourceContainer, const char *value, const char *key, int size)
+void new_pajeStartLinkWithSize (double timestamp, container_t container, type_t type, container_t sourceContainer,
+                                const char *value, const char *key, int size)
 {
   paje_event_t event = xbt_new0(s_paje_event_t, 1);
   event->event_type = PAJE_StartLink;
@@ -457,7 +459,8 @@ void new_pajeStartLinkWithSize (double timestamp, container_t container, type_t
   insert_into_buffer (event);
 }
 
-void new_pajeEndLink (double timestamp, container_t container, type_t type, container_t destContainer, const char *value, const char *key)
+void new_pajeEndLink (double timestamp, container_t container, type_t type, container_t destContainer,
+                      const char *value, const char *key)
 {
   paje_event_t event = xbt_new0(s_paje_event_t, 1);
   event->event_type = PAJE_EndLink;