Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[trace] debug messages for recursive destruction of containers and types
[simgrid.git] / src / instr / instr_paje.c
index 8d6cf31..c749648 100644 (file)
@@ -16,11 +16,15 @@ static xbt_dict_t allContainers = NULL;     /* all created containers indexed by
 xbt_dict_t trivaNodeTypes = NULL;     /* all link types defined */
 xbt_dict_t trivaEdgeTypes = NULL;     /* all host types defined */
 
-void instr_paje_init (container_t root)
+void instr_paje_init (void)
 {
   allContainers = xbt_dict_new_homogeneous(NULL);
   trivaNodeTypes = xbt_dict_new_homogeneous(xbt_free);
   trivaEdgeTypes = xbt_dict_new_homogeneous(xbt_free);
+}
+
+void instr_paje_set_root (container_t root)
+{
   rootContainer = root;
 }
 
@@ -298,11 +302,18 @@ static type_t recursiveGetType (const char *name, type_t root)
   xbt_dict_cursor_t cursor = NULL;
   type_t child;
   char *child_name;
+  type_t ret = NULL;
   xbt_dict_foreach(root->children, cursor, child_name, child) {
-    type_t ret = recursiveGetType(name, child);
-    if (ret) return ret;
+    type_t found = recursiveGetType(name, child);
+    if (found){
+      if (ret == NULL){
+        ret = found;
+      }else{
+        XBT_CRITICAL("[tracing] found two types with the same name");
+      }
+    }
   }
-  return NULL;
+  return ret;
 }
 
 type_t getType (const char *name, type_t father)
@@ -310,6 +321,17 @@ type_t getType (const char *name, type_t father)
   return recursiveGetType (name, father);
 }
 
+void removeContainerFromParent (container_t child)
+{
+  container_t parent = child->father;
+  if (parent){
+    XBT_DEBUG("removeChildContainer (%s) FromContainer (%s) ",
+        child->name,
+        parent->name);
+    xbt_dict_remove (parent->children, child->name);
+  }
+}
+
 void destroyContainer (container_t container)
 {
   XBT_DEBUG("destroy container %s", container->name);
@@ -335,6 +357,7 @@ void destroyContainer (container_t container)
 
 static void recursiveDestroyContainer (container_t container)
 {
+  XBT_DEBUG("recursiveDestroyContainer %s", container->name);
   xbt_dict_cursor_t cursor = NULL;
   container_t child;
   char *child_name;
@@ -346,6 +369,7 @@ static void recursiveDestroyContainer (container_t container)
 
 static void recursiveDestroyType (type_t type)
 {
+  XBT_DEBUG("recursiveDestroyType %s", type->name);
   xbt_dict_cursor_t cursor = NULL;
   type_t child;
   char *child_name;