A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[trace] when destroying a container, remove its references from allContainers
[simgrid.git]
/
src
/
instr
/
instr_paje.c
diff --git
a/src/instr/instr_paje.c
b/src/instr/instr_paje.c
index
0d32eda
..
86eeadf
100644
(file)
--- a/
src/instr/instr_paje.c
+++ b/
src/instr/instr_paje.c
@@
-16,20
+16,39
@@
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 */
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)
{
{
- allContainers = xbt_dict_new ();
- trivaNodeTypes = xbt_dict_new ();
- trivaEdgeTypes = xbt_dict_new ();
rootContainer = root;
}
rootContainer = root;
}
+void instr_paje_free (void)
+{
+ xbt_dict_free (&allContainers);
+ xbt_dict_free (&trivaNodeTypes);
+ xbt_dict_free (&trivaEdgeTypes);
+}
+
static long long int new_type_id (void)
{
static long long int type_id = 0;
return type_id++;
}
static long long int new_type_id (void)
{
static long long int type_id = 0;
return type_id++;
}
+static void destroyValue (void *value)
+{
+ xbt_free(((val_t)value)->name);
+ xbt_free(((val_t)value)->color);
+ xbt_free(((val_t)value)->id);
+ xbt_free(value);
+}
+
static val_t newValue (const char *valuename, const char *color, type_t father)
{
val_t ret = xbt_new0(s_val_t, 1);
static val_t newValue (const char *valuename, const char *color, type_t father)
{
val_t ret = xbt_new0(s_val_t, 1);
@@
-70,8
+89,8
@@
static type_t newType (const char *typename, const char *key, const char *color,
ret->name = xbt_strdup (typename);
ret->father = father;
ret->kind = kind;
ret->name = xbt_strdup (typename);
ret->father = father;
ret->kind = kind;
- ret->children = xbt_dict_new
(
);
- ret->values = xbt_dict_new
(
);
+ ret->children = xbt_dict_new
_homogeneous(NULL
);
+ ret->values = xbt_dict_new
_homogeneous(NULL
);
ret->color = xbt_strdup (color);
char str_id[INSTR_DEFAULT_STR_SIZE];
ret->color = xbt_strdup (color);
char str_id[INSTR_DEFAULT_STR_SIZE];
@@
-215,7
+234,7
@@
container_t newContainer (const char *name, e_container_types kind, container_t
default: xbt_die ("Congratulations, you have found a bug on newContainer function of instr_routing.c"); break;
}
}
default: xbt_die ("Congratulations, you have found a bug on newContainer function of instr_routing.c"); break;
}
}
- new->children = xbt_dict_new
(
);
+ new->children = xbt_dict_new
_homogeneous(NULL
);
if (new->father){
xbt_dict_set(new->father->children, new->name, new, NULL);
new_pajeCreateContainer (new);
if (new->father){
xbt_dict_set(new->father->children, new->name, new, NULL);
new_pajeCreateContainer (new);
@@
-226,13
+245,14
@@
container_t newContainer (const char *name, e_container_types kind, container_t
xbt_dict_set (allContainers, new->name, new, NULL);
//register NODE types for triva configuration
xbt_dict_set (allContainers, new->name, new, NULL);
//register NODE types for triva configuration
- xbt_dict_set (trivaNodeTypes, new->type->name, xbt_strdup("1"),
xbt_free
);
+ xbt_dict_set (trivaNodeTypes, new->type->name, xbt_strdup("1"),
NULL
);
}
return new;
}
static container_t recursiveGetContainer (const char *name, container_t root)
{
}
return new;
}
static container_t recursiveGetContainer (const char *name, container_t root)
{
+ if (name == NULL || root == NULL) return NULL;
if (strcmp (root->name, name) == 0) return root;
xbt_dict_cursor_t cursor = NULL;
if (strcmp (root->name, name) == 0) return root;
xbt_dict_cursor_t cursor = NULL;
@@
-247,9
+267,19
@@
static container_t recursiveGetContainer (const char *name, container_t root)
container_t getContainer (const char *name)
{
container_t getContainer (const char *name)
{
+ if (name == NULL) return NULL;
return recursiveGetContainer(name, rootContainer);
}
return recursiveGetContainer(name, rootContainer);
}
+int knownContainerWithName (const char *name)
+{
+ if (xbt_dict_get_or_null (allContainers, name)){
+ return 1;
+ }else{
+ return 0;
+ }
+}
+
container_t getContainerByName (const char *name)
{
return (container_t)xbt_dict_get (allContainers, name);
container_t getContainerByName (const char *name)
{
return (container_t)xbt_dict_get (allContainers, name);
@@
-272,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;
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) {
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)
}
type_t getType (const char *name, type_t father)
@@
-284,13
+321,19
@@
type_t getType (const char *name, type_t father)
return recursiveGetType (name, father);
}
return recursiveGetType (name, father);
}
-void
destroyContainer (container_t container
)
+void
removeContainerFromParent (container_t child
)
{
{
- //remove me from my father
- if (container->father){
- xbt_dict_remove(container->father->children, container->name);
+ 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);
//obligation to dump previous events because they might
XBT_DEBUG("destroy container %s", container->name);
//obligation to dump previous events because they might
@@
-299,18
+342,25
@@
void destroyContainer (container_t container)
TRACE_paje_dump_buffer(1);
//trace my destruction
TRACE_paje_dump_buffer(1);
//trace my destruction
- new_pajeDestroyContainer(container);
+ if (!TRACE_disable_destroy()){
+ //do not trace the container destruction if user requests
+ new_pajeDestroyContainer(container);
+ }
+
+ //remove it from allContainers data structure
+ xbt_dict_remove (allContainers, container->name);
//free
xbt_free (container->name);
xbt_free (container->id);
//free
xbt_free (container->name);
xbt_free (container->id);
- xbt_
free (
container->children);
+ xbt_
dict_free (&
container->children);
xbt_free (container);
container = NULL;
}
static void recursiveDestroyContainer (container_t container)
{
xbt_free (container);
container = NULL;
}
static void recursiveDestroyContainer (container_t container)
{
+ XBT_DEBUG("recursiveDestroyContainer %s", container->name);
xbt_dict_cursor_t cursor = NULL;
container_t child;
char *child_name;
xbt_dict_cursor_t cursor = NULL;
container_t child;
char *child_name;
@@
-322,6
+372,7
@@
static void recursiveDestroyContainer (container_t container)
static void recursiveDestroyType (type_t type)
{
static void recursiveDestroyType (type_t type)
{
+ XBT_DEBUG("recursiveDestroyType %s", type->name);
xbt_dict_cursor_t cursor = NULL;
type_t child;
char *child_name;
xbt_dict_cursor_t cursor = NULL;
type_t child;
char *child_name;
@@
-330,8
+381,14
@@
static void recursiveDestroyType (type_t type)
}
xbt_free (type->name);
xbt_free (type->id);
}
xbt_free (type->name);
xbt_free (type->id);
- xbt_free (type->children);
- xbt_free (type->values);
+ xbt_free (type->color);
+ xbt_dict_free (&type->children);
+ val_t value;
+ char *value_name;
+ xbt_dict_foreach(type->values, cursor, value_name, value) {
+ destroyValue (value);
+ }
+ xbt_dict_free (&type->values);
xbt_free (type);
type = NULL;
}
xbt_free (type);
type = NULL;
}