Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fix invalid read
[simgrid.git] / src / instr / instr_paje_containers.cpp
index 1c8e4b4..0f9b0ce 100644 (file)
@@ -26,19 +26,14 @@ long long int instr_new_paje_id ()
   return type_id++;
 }
 
-container_t PJ_container_get_root()
-{
-  return rootContainer;
-}
+namespace simgrid {
+namespace instr {
 
-void PJ_container_set_root (container_t root)
+container_t Container::getRootContainer()
 {
-  rootContainer = root;
+  return rootContainer;
 }
 
-namespace simgrid {
-namespace instr {
-
 NetZoneContainer::NetZoneContainer(std::string name, unsigned int level, NetZoneContainer* father)
     : Container::Container(name, "", father)
 {
@@ -49,8 +44,8 @@ NetZoneContainer::NetZoneContainer(std::string name, unsigned int level, NetZone
     father_->children_.insert({getName(), this});
     logCreation();
   } else {
-    type_ = Type::createRootType();
-    PJ_container_set_root(this);
+    type_         = new ContainerType("0");
+    rootContainer = this;
   }
 }
 
@@ -116,7 +111,7 @@ Container::~Container()
   TRACE_paje_dump_buffer(true);
 
   // trace my destruction
-  if (not TRACE_disable_destroy() && this != PJ_container_get_root()) {
+  if (not TRACE_disable_destroy() && this != Container::getRootContainer()) {
     // do not trace the container destruction if user requests or if the container is root
     logDestruction();
   }
@@ -153,7 +148,7 @@ void Container::logCreation()
   double timestamp = SIMIX_get_clock();
   std::stringstream stream;
 
-  XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, simgrid::instr::PAJE_CreateContainer, timestamp);
+  XBT_DEBUG("%s: event_type=%u, timestamp=%f", __FUNCTION__, simgrid::instr::PAJE_CreateContainer, timestamp);
 
   if (instr_fmt_type == instr_fmt_paje) {
     stream << std::fixed << std::setprecision(TRACE_precision());
@@ -193,7 +188,6 @@ void Container::logCreation()
       xbt_free(folder_name);
       xbt_free(filename);
     }
-
     tracing_files.insert({this, ti_unique_file});
   } else {
     THROW_IMPOSSIBLE;
@@ -205,7 +199,7 @@ void Container::logDestruction()
   std::stringstream stream;
   double timestamp = SIMIX_get_clock();
 
-  XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, simgrid::instr::PAJE_DestroyContainer, timestamp);
+  XBT_DEBUG("%s: event_type=%u, timestamp=%f", __FUNCTION__, simgrid::instr::PAJE_DestroyContainer, timestamp);
 
   if (instr_fmt_type == instr_fmt_paje) {
     stream << std::fixed << std::setprecision(TRACE_precision());
@@ -231,5 +225,24 @@ void Container::logDestruction()
     THROW_IMPOSSIBLE;
   }
 }
+
+StateType* Container::getState(std::string name)
+{
+  StateType* ret = dynamic_cast<StateType*>(type_->byName(name));
+  ret->setCallingContainer(this);
+  return ret;
+}
+
+LinkType* Container::getLink(std::string name)
+{
+  return dynamic_cast<LinkType*>(type_->byName(name));
+}
+
+VariableType* Container::getVariable(std::string name)
+{
+  VariableType* ret = dynamic_cast<VariableType*>(type_->byName(name));
+  ret->setCallingContainer(this);
+  return ret;
+}
 }
 }