Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[trace] debug messages for event buffering and tracing
[simgrid.git] / src / instr / instr_msg_process.c
index 1109d8b..a6e1a95 100644 (file)
@@ -28,18 +28,28 @@ void TRACE_msg_set_process_category(m_process_t process, const char *category, c
       "Process %p(%s). Tracing already knows a process with name %s."
       "The name of each process must be unique.", process, process->name, process->name);
 
+  if (category == NULL) {
+    //if user provides a NULL category, process is no longer traced
+    xbt_free (process->category);
+    process->category = NULL;
+    return;
+  }
+
   //set process category
   process->category = xbt_strdup(category);
   DEBUG3("MSG process %p(%s), category %s", process, process->name, process->category);
 
   m_host_t host = MSG_process_get_host(process);
   container_t host_container = getContainer(host->name);
-  container_t msg = newContainer(process->name, INSTR_MSG, host_container);
+  container_t msg = newContainer(process->name, INSTR_MSG_PROCESS, host_container);
   type_t type = getType (category);
   if (!type){
-    type = newVariableType(category, TYPE_VARIABLE, color, msg->type);
+    type = getVariableType(category, color, msg->type);
   }
-  pajeSetVariable(SIMIX_get_clock(), type->id, msg->id, "1");
+  new_pajeSetVariable (SIMIX_get_clock(), msg, type, 1);
+
+  type = getType ("MSG_PROCESS_STATE");
+  new_pajeSetState (MSG_get_clock(), msg, type, "executing");
 }
 
 /*
@@ -51,13 +61,27 @@ void TRACE_msg_process_change_host(m_process_t process, m_host_t old_host, m_hos
       TRACE_msg_process_is_enabled() &&
       process->category)) return;
 
+  static long long int counter = 0;
+  char key[INSTR_DEFAULT_STR_SIZE];
+  snprintf (key, INSTR_DEFAULT_STR_SIZE, "%lld", counter++);
+
+  //start link
+  container_t msg = getContainer(process->name);
+  type_t type = getType ("MSG_PROCESS_LINK");
+  new_pajeStartLink (MSG_get_clock(), getRootContainer(), type, msg, "M", key);
+
   //destroy existing container of this process
   destroyContainer(getContainer(process->name));
 
   //create new container on the new_host location
-  container_t msg = newContainer(process->name, INSTR_MSG, getContainer(new_host->name));
-  type_t type = getType (process->category);
-  pajeSetVariable(SIMIX_get_clock(), type->id, msg->id, "1");
+  msg = newContainer(process->name, INSTR_MSG_PROCESS, getContainer(new_host->name));
+  type = getType (process->category);
+  new_pajeSetVariable (MSG_get_clock(), msg, type, 1);
+
+  //end link
+  msg = getContainer(process->name);
+  type = getType ("MSG_PROCESS_LINK");
+  new_pajeEndLink (MSG_get_clock(), getRootContainer(), type, msg, "M", key);
 }
 
 void TRACE_msg_process_kill(m_process_t process)
@@ -76,8 +100,9 @@ void TRACE_msg_process_suspend(m_process_t process)
       TRACE_msg_process_is_enabled() &&
       process->category)) return;
 
-  //FIXME
-  //pajeSetState(MSG_get_clock(), "process-state", name, "suspend");
+  container_t process_container = getContainer (process->name);
+  type_t type = getType ("MSG_PROCESS_STATE");
+  new_pajePushState (MSG_get_clock(), process_container, type, "suspend");
 }
 
 void TRACE_msg_process_resume(m_process_t process)
@@ -86,8 +111,9 @@ void TRACE_msg_process_resume(m_process_t process)
       TRACE_msg_process_is_enabled() &&
       process->category)) return;
 
-  //FIXME
-  //pajeSetState(MSG_get_clock(), "process-state", name, "executing");
+  container_t process_container = getContainer (process->name);
+  type_t type = getType ("MSG_PROCESS_STATE");
+  new_pajePopState (MSG_get_clock(), process_container, type);
 }
 
 void TRACE_msg_process_sleep_in(m_process_t process)
@@ -96,8 +122,9 @@ void TRACE_msg_process_sleep_in(m_process_t process)
       TRACE_msg_process_is_enabled() &&
       process->category)) return;
 
-  //FIXME
-  //pajeSetState(MSG_get_clock(), "process-state", name, "sleep");
+  container_t process_container = getContainer (process->name);
+  type_t type = getType ("MSG_PROCESS_STATE");
+  new_pajePushState (MSG_get_clock(), process_container, type, "sleep");
 }
 
 void TRACE_msg_process_sleep_out(m_process_t process)
@@ -106,8 +133,9 @@ void TRACE_msg_process_sleep_out(m_process_t process)
       TRACE_msg_process_is_enabled() &&
       process->category)) return;
 
-  //FIXME
-  //pajeSetState(MSG_get_clock(), "process-state", name, "executing");
+  container_t process_container = getContainer (process->name);
+  type_t type = getType ("MSG_PROCESS_STATE");
+  new_pajePopState (MSG_get_clock(), process_container, type);
 }
 
 void TRACE_msg_process_end(m_process_t process)