Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Check variable size in MC_process_read_variable()
authorGabriel Corona <gabriel.corona@loria.fr>
Tue, 17 Mar 2015 14:12:13 +0000 (15:12 +0100)
committerGabriel Corona <gabriel.corona@loria.fr>
Tue, 17 Mar 2015 15:09:36 +0000 (16:09 +0100)
src/mc/mc_dwarf.c
src/mc/mc_process.c

index a286459..55de42e 100644 (file)
@@ -1373,18 +1373,27 @@ void MC_post_process_object_info(mc_process_t process, mc_object_info_t info)
   dw_type_t type = NULL;
   xbt_dict_foreach(info->types, cursor, key, type) {
 
+    dw_type_t subtype = type;
+    while (subtype->type == DW_TAG_typedef || subtype->type == DW_TAG_volatile_type
+      || subtype->type == DW_TAG_const_type) {
+      if (subtype->subtype)
+        subtype = subtype->subtype;
+      else
+        break;
+    }
+
     // Resolve full_type:
-    if (type->name && type->byte_size == 0) {
+    if (subtype->name && subtype->byte_size == 0) {
       for (size_t i = 0; i != process->object_infos_size; ++i) {
         dw_type_t same_type =
             xbt_dict_get_or_null(process->object_infos[i]->full_types_by_name,
-                                 type->name);
+                                 subtype->name);
         if (same_type && same_type->name && same_type->byte_size) {
           type->full_type = same_type;
           break;
         }
       }
-    }
+    } else type->full_type = subtype;
 
   }
 }
index ba3968c..9c89ada 100644 (file)
@@ -405,6 +405,11 @@ void MC_process_read_variable(mc_process_t process, const char* name, void* targ
   dw_variable_t var = MC_process_find_variable_by_name(process, name);
   if (!var->address)
     xbt_die("No simple location for this variable");
+  if (!var->type->full_type)
+    xbt_die("Partial type for %s, cannot check size", name);
+  if (var->type->full_type->byte_size != size)
+    xbt_die("Unexpected size for %s (expected %zi, was %zi)",
+      name, size, (size_t) var->type->full_type->byte_size);
   MC_process_read(process, MC_PROCESS_NO_FLAG, target, var->address, size,
     MC_PROCESS_INDEX_ANY);
 }