Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[trace] sanity checks
authorLucas Schnorr <Lucas.Schnorr@imag.fr>
Mon, 23 Jan 2012 12:11:48 +0000 (13:11 +0100)
committerLucas Schnorr <Lucas.Schnorr@imag.fr>
Mon, 23 Jan 2012 12:11:48 +0000 (13:11 +0100)
src/instr/instr_paje.c
src/instr/instr_paje_types.c
src/instr/instr_paje_values.c

index 0ea9147..dee0203 100644 (file)
@@ -42,6 +42,10 @@ void PJ_container_set_root (container_t root)
 
 container_t PJ_container_new (const char *name, e_container_types kind, container_t father)
 {
 
 container_t PJ_container_new (const char *name, e_container_types kind, container_t father)
 {
+  if (name == NULL){
+    THROWF (tracing_error, 0, "can't create a container with a NULL name");
+  }
+
   static long long int container_id = 0;
   char id_str[INSTR_DEFAULT_STR_SIZE];
   snprintf (id_str, INSTR_DEFAULT_STR_SIZE, "%lld", container_id++);
   static long long int container_id = 0;
   char id_str[INSTR_DEFAULT_STR_SIZE];
   snprintf (id_str, INSTR_DEFAULT_STR_SIZE, "%lld", container_id++);
@@ -81,7 +85,7 @@ container_t PJ_container_new (const char *name, e_container_types kind, containe
       case INSTR_SMPI:        snprintf (typename, INSTR_DEFAULT_STR_SIZE, "MPI");         break;
       case INSTR_MSG_PROCESS: snprintf (typename, INSTR_DEFAULT_STR_SIZE, "MSG_PROCESS"); break;
       case INSTR_MSG_TASK:    snprintf (typename, INSTR_DEFAULT_STR_SIZE, "MSG_TASK");    break;
       case INSTR_SMPI:        snprintf (typename, INSTR_DEFAULT_STR_SIZE, "MPI");         break;
       case INSTR_MSG_PROCESS: snprintf (typename, INSTR_DEFAULT_STR_SIZE, "MSG_PROCESS"); break;
       case INSTR_MSG_TASK:    snprintf (typename, INSTR_DEFAULT_STR_SIZE, "MSG_TASK");    break;
-      default: xbt_die ("Congratulations, you have found a bug on newContainer function of instr_routing.c"); break;
+      default: THROWF (tracing_error, 0, "new container kind is unknown."); break;
     }
     type_t type = PJ_type_get (typename, new->father->type);
     if (type == NULL){
     }
     type_t type = PJ_type_get (typename, new->father->type);
     if (type == NULL){
@@ -135,6 +139,10 @@ container_t PJ_container_get_root ()
 
 void PJ_container_remove_from_parent (container_t child)
 {
 
 void PJ_container_remove_from_parent (container_t child)
 {
+  if (child == NULL){
+    THROWF (tracing_error, 0, "can't remove from parent with a NULL child");
+  }
+
   container_t parent = child->father;
   if (parent){
     XBT_DEBUG("removeChildContainer (%s) FromContainer (%s) ",
   container_t parent = child->father;
   if (parent){
     XBT_DEBUG("removeChildContainer (%s) FromContainer (%s) ",
@@ -146,6 +154,9 @@ void PJ_container_remove_from_parent (container_t child)
 
 void PJ_container_free (container_t container)
 {
 
 void PJ_container_free (container_t container)
 {
+  if (container == NULL){
+    THROWF (tracing_error, 0, "trying to free a NULL 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
@@ -172,6 +183,9 @@ void PJ_container_free (container_t container)
 
 static void recursiveDestroyContainer (container_t container)
 {
 
 static void recursiveDestroyContainer (container_t container)
 {
+  if (container == NULL){
+    THROWF (tracing_error, 0, "trying to recursively destroy a NULL container");
+  }
   XBT_DEBUG("recursiveDestroyContainer %s", container->name);
   xbt_dict_cursor_t cursor = NULL;
   container_t child;
   XBT_DEBUG("recursiveDestroyContainer %s", container->name);
   xbt_dict_cursor_t cursor = NULL;
   container_t child;
@@ -184,7 +198,11 @@ static void recursiveDestroyContainer (container_t container)
 
 void PJ_container_free_all ()
 {
 
 void PJ_container_free_all ()
 {
-  if (PJ_container_get_root()) recursiveDestroyContainer (PJ_container_get_root());
+  container_t root = PJ_container_get_root();
+  if (root == NULL){
+    THROWF (tracing_error, 0, "trying to free all containers, but root is NULL");
+  }
+  recursiveDestroyContainer (root);
   rootContainer = NULL;
 
   //checks
   rootContainer = NULL;
 
   //checks
index 5bf0a6c..c8f0ee2 100644 (file)
@@ -31,6 +31,10 @@ type_t PJ_type_get_root ()
 
 static type_t newType (const char *typename, const char *key, const char *color, e_entity_types kind, type_t father)
 {
 
 static type_t newType (const char *typename, const char *key, const char *color, e_entity_types kind, type_t father)
 {
+  if (typename == NULL || key == NULL){
+    THROWF(tracing_error, 0, "can't create a new type with name or key equal NULL");
+  }
+
   type_t ret = xbt_new0(s_type_t, 1);
   ret->name = xbt_strdup (typename);
   ret->father = father;
   type_t ret = xbt_new0(s_type_t, 1);
   ret->name = xbt_strdup (typename);
   ret->father = father;
@@ -96,6 +100,10 @@ void PJ_type_free_all (void)
 
 static type_t recursiveGetType (const char *name, type_t root)
 {
 
 static type_t recursiveGetType (const char *name, type_t root)
 {
+  if (name == NULL || root == NULL){
+    THROWF (tracing_error, 0, "can't get type with a NULL name (or a NULL father given)");
+  }
+
   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;
@@ -122,6 +130,10 @@ type_t PJ_type_get (const char *name, type_t father)
 
 type_t PJ_type_container_new (const char *name, type_t father)
 {
 
 type_t PJ_type_container_new (const char *name, type_t father)
 {
+  if (name == NULL){
+    THROWF (tracing_error, 0, "can't create a container type with a NULL name");
+  }
+
   type_t ret = (type_t)xbt_dict_get_or_null (allTypes, name);
   if (ret){
     THROWF(tracing_error, 1, "container type with name %s already exists", name);
   type_t ret = (type_t)xbt_dict_get_or_null (allTypes, name);
   if (ret){
     THROWF(tracing_error, 1, "container type with name %s already exists", name);
@@ -141,6 +153,10 @@ type_t PJ_type_container_new (const char *name, type_t father)
 
 type_t PJ_type_event_new (const char *name, const char *color, type_t father)
 {
 
 type_t PJ_type_event_new (const char *name, const char *color, type_t father)
 {
+  if (name == NULL){
+    THROWF (tracing_error, 0, "can't create an event type with a NULL name");
+  }
+
   type_t ret = (type_t)xbt_dict_get_or_null (allTypes, name);
   if (ret){
     THROWF(tracing_error, 1, "event type with name %s already exists", name);
   type_t ret = (type_t)xbt_dict_get_or_null (allTypes, name);
   if (ret){
     THROWF(tracing_error, 1, "event type with name %s already exists", name);
@@ -159,6 +175,10 @@ type_t PJ_type_event_new (const char *name, const char *color, type_t father)
 
 type_t PJ_type_variable_new (const char *name, const char *color, type_t father)
 {
 
 type_t PJ_type_variable_new (const char *name, const char *color, type_t father)
 {
+  if (name == NULL){
+    THROWF (tracing_error, 0, "can't create a variable type with a NULL name");
+  }
+
   type_t ret = (type_t)xbt_dict_get_or_null (allTypes, name);
   if (ret){
     THROWF(tracing_error, 1, "variable type with name %s already exists", name);
   type_t ret = (type_t)xbt_dict_get_or_null (allTypes, name);
   if (ret){
     THROWF(tracing_error, 1, "variable type with name %s already exists", name);
@@ -177,6 +197,10 @@ type_t PJ_type_variable_new (const char *name, const char *color, type_t father)
 
 type_t PJ_type_link_new (const char *name, type_t father, type_t source, type_t dest)
 {
 
 type_t PJ_type_link_new (const char *name, type_t father, type_t source, type_t dest)
 {
+  if (name == NULL){
+    THROWF (tracing_error, 0, "can't create a link type with a NULL name");
+  }
+
   type_t ret = (type_t)xbt_dict_get_or_null (allTypes, name);
   if (ret){
     THROWF(tracing_error, 1, "link type with name %s already exists", name);
   type_t ret = (type_t)xbt_dict_get_or_null (allTypes, name);
   if (ret){
     THROWF(tracing_error, 1, "link type with name %s already exists", name);
@@ -192,6 +216,10 @@ type_t PJ_type_link_new (const char *name, type_t father, type_t source, type_t
 
 type_t PJ_type_state_new (const char *name, type_t father)
 {
 
 type_t PJ_type_state_new (const char *name, type_t father)
 {
+  if (name == NULL){
+    THROWF (tracing_error, 0, "can't create a state type with a NULL name");
+  }
+
   type_t ret = (type_t)xbt_dict_get_or_null (allTypes, name);
   if (ret){
     THROWF(tracing_error, 1, "state type with name %s already exists", name);
   type_t ret = (type_t)xbt_dict_get_or_null (allTypes, name);
   if (ret){
     THROWF(tracing_error, 1, "state type with name %s already exists", name);
index da52f14..7058043 100644 (file)
@@ -11,6 +11,10 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_paje_values, instr, "Paje tracing event s
 
 val_t PJ_value_new (const char *name, const char *color, type_t father)
 {
 
 val_t PJ_value_new (const char *name, const char *color, type_t father)
 {
+  if (name == NULL || father == NULL){
+    THROWF (tracing_error, 0, "can't create a value with a NULL name (or a NULL father)");
+  }
+
   val_t ret = xbt_new0(s_val_t, 1);
   ret->name = xbt_strdup (name);
   ret->father = father;
   val_t ret = xbt_new0(s_val_t, 1);
   ret->name = xbt_strdup (name);
   ret->father = father;
@@ -28,6 +32,10 @@ val_t PJ_value_new (const char *name, const char *color, type_t father)
 
 val_t PJ_value_get (const char *name, type_t father)
 {
 
 val_t PJ_value_get (const char *name, type_t father)
 {
+  if (name == NULL || father == NULL){
+    THROWF (tracing_error, 0, "can't get a value with a NULL name (or a NULL father)");
+  }
+
   if (father->kind == TYPE_VARIABLE) return NULL; //Variables can't have different values
   val_t ret = (val_t)xbt_dict_get_or_null (father->values, name);
   if (ret == NULL){
   if (father->kind == TYPE_VARIABLE) return NULL; //Variables can't have different values
   val_t ret = (val_t)xbt_dict_get_or_null (father->values, name);
   if (ret == NULL){