* \param ip Instruction pointer
* \return true if the variable is valid
* */
-static bool mc_valid_variable(dw_variable_t var, dw_frame_t scope,
+static bool mc_valid_variable(mc_variable_t var, dw_frame_t scope,
const void *ip)
{
// The variable is not yet valid:
return;
unsigned cursor = 0;
- dw_variable_t current_variable;
+ mc_variable_t current_variable;
xbt_dynar_foreach(scope->variables, cursor, current_variable) {
if (!mc_valid_variable(current_variable, scope, (void *) stack_frame->ip))
if (current_variable->address != NULL) {
new_var.address = current_variable->address;
- } else if (current_variable->locations.size != 0) {
+ } else if (current_variable->location_list.size != 0) {
s_mc_location_t location;
mc_dwarf_resolve_locations(
- &location, ¤t_variable->locations,
+ &location, ¤t_variable->location_list,
current_variable->object_info,
&(stack_frame->unw_cursor),
(void *) stack_frame->frame_base,
else if (region1->contain(simgrid::mc::remote(addr_pointed1))) {
if (!region2->contain(simgrid::mc::remote(addr_pointed2)))
return 1;
- if (type->dw_type_id.empty())
+ if (type->type_id.empty())
return (addr_pointed1 != addr_pointed2);
else {
return compare_areas_with_type(state, process_index,
xbt_dynar_t variables;
int res;
unsigned int cursor = 0;
- dw_variable_t current_var;
+ mc_variable_t current_var;
variables = object_info->global_variables;
if (res == 1) {
XBT_TRACE3(mc, global_diff, -1, -1, current_var->name);
XBT_VERB("Global variable %s (%p) is different between snapshots",
- current_var->name, (char *) current_var->address);
+ current_var->name.c_str(),
+ (char *) current_var->address);
return 1;
}
#include "mc_object_info.h"
#include "mc_private.h"
-static void dw_variable_free(dw_variable_t v);
-static void dw_variable_free_voidp(void *t);
+static void mc_variable_free(mc_variable_t v);
+static void mc_variable_free_voidp(void *t);
-static void MC_dwarf_register_global_variable(mc_object_info_t info, dw_variable_t variable);
-static void MC_register_variable(mc_object_info_t info, dw_frame_t frame, dw_variable_t variable);
-static void MC_dwarf_register_non_global_variable(mc_object_info_t info, dw_frame_t frame, dw_variable_t variable);
-static void MC_dwarf_register_variable(mc_object_info_t info, dw_frame_t frame, dw_variable_t variable);
+static void MC_dwarf_register_global_variable(mc_object_info_t info, mc_variable_t variable);
+static void MC_register_variable(mc_object_info_t info, dw_frame_t frame, mc_variable_t variable);
+static void MC_dwarf_register_non_global_variable(mc_object_info_t info, dw_frame_t frame, mc_variable_t variable);
+static void MC_dwarf_register_variable(mc_object_info_t info, dw_frame_t frame, mc_variable_t variable);
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_dwarf, mc, "DWARF processing");
* \param die DIE
* \return DW_TAG_type attribute as a new string (NULL if none)
*/
-static char *MC_dwarf_at_type(Dwarf_Die * die);
+static std::string MC_dwarf_at_type(Dwarf_Die * die);
/** \brief A class of DWARF tags (DW_TAG_*)
*/
* \param dit the DIE
* \return DW_AT_type reference as a global offset in hexadecimal (or NULL)
*/
-static char *MC_dwarf_at_type(Dwarf_Die * die)
+static
+std::string MC_dwarf_at_type(Dwarf_Die * die)
{
Dwarf_Off offset = MC_dwarf_attr_integrate_dieoffset(die, DW_AT_type);
- return offset == 0 ? NULL : bprintf("%" PRIx64, offset);
+ if (offset == 0)
+ return std::string();
+ char* s = bprintf("%" PRIx64, offset);
+ std::string res(s);
+ free(s);
+ return std::move(res);
}
static uint64_t MC_dwarf_attr_integrate_addr(Dwarf_Die * die, int attribute)
member.byte_size =
MC_dwarf_attr_integrate_uint(&child, DW_AT_byte_size, 0);
member.element_count = -1;
-
- char* type_id = MC_dwarf_at_type(&child);
- if (type_id) {
- member.dw_type_id = type_id;
- free(type_id);
- }
+ member.type_id = MC_dwarf_at_type(&child);
if (dwarf_hasattr(&child, DW_AT_data_bit_offset)) {
xbt_die("Can't groke DW_AT_data_bit_offset.");
MC_dwarf_fill_member_location(type, &member, &child);
- if (member.dw_type_id.empty()) {
+ if (member.type_id.empty()) {
xbt_die("Missing type for member %s of <%" PRIx64 ">%s",
member.name.c_str(),
(uint64_t) type->id, type->name.c_str());
free(full_name);
}
- char* type_id = MC_dwarf_at_type(die);
- if (type_id) {
- type->dw_type_id = type_id;
- free(type_id);
- }
+ type->type_id = MC_dwarf_at_type(die);
// Some compilers do not emit DW_AT_byte_size for pointer_type,
// so we fill this. We currently assume that the model-checked process is in
static int mc_anonymous_variable_index = 0;
-static dw_variable_t MC_die_to_variable(mc_object_info_t info, Dwarf_Die * die,
+static mc_variable_t MC_die_to_variable(mc_object_info_t info, Dwarf_Die * die,
Dwarf_Die * unit, dw_frame_t frame,
const char *ns)
{
return NULL;
}
- dw_variable_t variable = xbt_new0(s_dw_variable_t, 1);
+ simgrid::mc::Variable* variable = new simgrid::mc::Variable();
variable->dwarf_offset = dwarf_dieoffset(die);
variable->global = frame == NULL; // Can be override base on DW_AT_location
variable->object_info = info;
const char *name = MC_dwarf_attr_integrate_string(die, DW_AT_name);
- variable->name = xbt_strdup(name);
-
- variable->type_origin = MC_dwarf_at_type(die);
+ if (name)
+ variable->name = name;
+ variable->type_id = MC_dwarf_at_type(die);
int form = dwarf_whatform(&attr_location);
int klass =
Dwarf_Op *expr;
size_t len;
if (dwarf_getlocation(&attr_location, &expr, &len)) {
- xbt_die
- ("Could not read location expression in DW_AT_location of variable <%"
- PRIx64 ">%s", (uint64_t) variable->dwarf_offset, variable->name);
+ xbt_die(
+ "Could not read location expression in DW_AT_location "
+ "of variable <%" PRIx64 ">%s",
+ (uint64_t) variable->dwarf_offset,
+ variable->name.c_str());
}
if (len == 1 && expr[0].atom == DW_OP_addr) {
uintptr_t base = (uintptr_t) info->base_address();
variable->address = (void *) (base + offset);
} else {
- mc_dwarf_location_list_init_from_expression(&variable->locations, len,
- expr);
+ mc_dwarf_location_list_init_from_expression(
+ &variable->location_list, len,
+ expr);
}
break;
case MC_DW_CLASS_LOCLISTPTR:
case MC_DW_CLASS_CONSTANT:
// Reference to location list:
- mc_dwarf_location_list_init(&variable->locations, info, die,
- &attr_location);
+ mc_dwarf_location_list_init(
+ &variable->location_list, info, die,
+ &attr_location);
break;
default:
- xbt_die("Unexpected form 0x%x (%i), class 0x%x (%i) list for location in <%"
- PRIx64 ">%s", form, form, klass, klass,
- (uint64_t) variable->dwarf_offset, variable->name);
+ xbt_die("Unexpected form 0x%x (%i), class 0x%x (%i) list for location "
+ "in <%" PRIx64 ">%s",
+ form, form, klass, klass,
+ (uint64_t) variable->dwarf_offset,
+ variable->name.c_str());
}
// Handle start_scope:
}
}
- if (ns && variable->global) {
- char *old_name = variable->name;
- variable->name = bprintf("%s::%s", ns, old_name);
- free(old_name);
- }
+ if (ns && variable->global)
+ variable->name =
+ std::string(ns) + "::" + variable->name;
+
// The current code needs a variable name,
// generate a fake one:
- if (!variable->name) {
- variable->name = bprintf("@anonymous#%i", mc_anonymous_variable_index++);
- }
+ if (variable->name.empty())
+ variable->name =
+ "@anonymous#" + std::to_string(mc_anonymous_variable_index++);
return variable;
}
Dwarf_Die * unit, dw_frame_t frame,
const char *ns)
{
- dw_variable_t variable =
+ mc_variable_t variable =
MC_die_to_variable(info, die, unit, frame, ns);
if (variable == NULL)
return;
// Variables are filled in the (recursive) call of MC_dwarf_handle_children:
frame->variables =
- xbt_dynar_new(sizeof(dw_variable_t), dw_variable_free_voidp);
+ xbt_dynar_new(sizeof(mc_variable_t), mc_variable_free_voidp);
// TODO, support DW_AT_ranges
uint64_t low_pc = MC_dwarf_attr_integrate_addr(die, DW_AT_low_pc);
delete t;
}
-void dw_variable_free(dw_variable_t v)
-{
- if (v) {
- xbt_free(v->name);
- xbt_free(v->type_origin);
-
- if (v->locations.locations)
- mc_dwarf_location_list_clear(&v->locations);
- xbt_free(v);
- }
-}
-
-void dw_variable_free_voidp(void *t)
+void mc_variable_free_voidp(void *t)
{
- dw_variable_free((dw_variable_t) * (void **) t);
+ delete *(simgrid::mc::Variable**)t;
}
// ***** object_info
this->end_ro = nullptr;
this->subprograms = xbt_dict_new_homogeneous((void (*)(void *)) mc_frame_free);
this->global_variables =
- xbt_dynar_new(sizeof(dw_variable_t), dw_variable_free_voidp);
+ xbt_dynar_new(sizeof(mc_variable_t), mc_variable_free_voidp);
this->types = xbt_dict_new_homogeneous((void (*)(void *)) dw_type_free);
this->full_types_by_name = xbt_dict_new_homogeneous(NULL);
this->functions_index = nullptr;
static void MC_post_process_variables(mc_object_info_t info)
{
unsigned cursor = 0;
- dw_variable_t variable = NULL;
- xbt_dynar_foreach(info->global_variables, cursor, variable) {
- if (variable->type_origin) {
- variable->type = (mc_type_t) xbt_dict_get_or_null(info->types, variable->type_origin);
- }
- }
+ mc_variable_t variable = nullptr;
+ xbt_dynar_foreach(info->global_variables, cursor, variable)
+ if (!variable->type_id.empty())
+ variable->type = (mc_type_t) xbt_dict_get_or_null(
+ info->types, variable->type_id.c_str());
}
static void mc_post_process_scope(mc_object_info_t info, dw_frame_t scope)
scope->name = xbt_strdup(abstract_origin->name);
}
+
// Direct:
unsigned cursor = 0;
- dw_variable_t variable = NULL;
- xbt_dynar_foreach(scope->variables, cursor, variable) {
- if (variable->type_origin) {
- variable->type = (mc_type_t) xbt_dict_get_or_null(info->types, variable->type_origin);
- }
- }
+ mc_variable_t variable = nullptr;
+ xbt_dynar_foreach(scope->variables, cursor, variable)
+ if (!variable->type_id.empty())
+ variable->type = (mc_type_t) xbt_dict_get_or_null(
+ info->types, variable->type_id.c_str());
// Recursive post-processing of nested-scopes:
- dw_frame_t nested_scope = NULL;
+ dw_frame_t nested_scope = nullptr;
xbt_dynar_foreach(scope->scopes, cursor, nested_scope)
mc_post_process_scope(info, nested_scope);
static void MC_resolve_subtype(mc_object_info_t info, mc_type_t type)
{
- if (type->dw_type_id.empty())
+ if (type->type_id.empty())
return;
type->subtype = (mc_type_t) xbt_dict_get_or_null(
- info->types, type->dw_type_id.c_str());
+ info->types, type->type_id.c_str());
if (type->subtype == NULL)
return;
if (type->subtype->byte_size != 0)
/*************************************************************************/
-static int MC_dwarf_get_variable_index(xbt_dynar_t variables, char *var,
+static int MC_dwarf_get_variable_index(xbt_dynar_t variables, const char *var,
void *address)
{
unsigned int cursor = 0;
int start = 0;
int end = xbt_dynar_length(variables) - 1;
- dw_variable_t var_test = NULL;
+ mc_variable_t var_test = NULL;
while (start <= end) {
cursor = (start + end) / 2;
var_test =
- (dw_variable_t) xbt_dynar_get_as(variables, cursor, dw_variable_t);
- if (strcmp(var_test->name, var) < 0) {
+ (mc_variable_t) xbt_dynar_get_as(variables, cursor, mc_variable_t);
+ if (strcmp(var_test->name.c_str(), var) < 0) {
start = cursor + 1;
- } else if (strcmp(var_test->name, var) > 0) {
+ } else if (strcmp(var_test->name.c_str(), var) > 0) {
end = cursor - 1;
} else {
if (address) { /* global variable */
}
}
- if (strcmp(var_test->name, var) == 0) {
+ if (strcmp(var_test->name.c_str(), var) == 0) {
if (address && var_test->address < address)
return cursor + 1;
else
return cursor;
- } else if (strcmp(var_test->name, var) < 0)
+ } else if (strcmp(var_test->name.c_str(), var) < 0)
return cursor + 1;
else
return cursor;
}
void MC_dwarf_register_global_variable(mc_object_info_t info,
- dw_variable_t variable)
+ mc_variable_t variable)
{
int index =
- MC_dwarf_get_variable_index(info->global_variables, variable->name,
- variable->address);
+ MC_dwarf_get_variable_index(info->global_variables,
+ variable->name.c_str(),
+ variable->address);
if (index != -1)
xbt_dynar_insert_at(info->global_variables, index, &variable);
// TODO, else ?
void MC_dwarf_register_non_global_variable(mc_object_info_t info,
dw_frame_t frame,
- dw_variable_t variable)
+ mc_variable_t variable)
{
xbt_assert(frame, "Frame is NULL");
int index =
- MC_dwarf_get_variable_index(frame->variables, variable->name, NULL);
+ MC_dwarf_get_variable_index(
+ frame->variables, variable->name.c_str(), NULL);
if (index != -1)
xbt_dynar_insert_at(frame->variables, index, &variable);
// TODO, else ?
}
void MC_dwarf_register_variable(mc_object_info_t info, dw_frame_t frame,
- dw_variable_t variable)
+ mc_variable_t variable)
{
if (variable->global)
MC_dwarf_register_global_variable(info, variable);
class Snapshot;
class ObjectInformation;
class Type;
+class Variable;
}
}
typedef ::simgrid::mc::Snapshot s_mc_snapshot_t;
typedef ::simgrid::mc::ObjectInformation s_mc_object_info_t;
typedef ::simgrid::mc::Type s_mc_type_t;
+typedef ::simgrid::mc::Variable s_mc_variable_t;
#else
typedef struct _s_mc_snapshot_t s_mc_snapshot_t;
typedef struct _s_mc_object_info_t s_mc_object_info_t;
typedef struct _s_mc_type_t s_mc_type_t;
+typedef struct _s_mc_variable_t s_mc_variable_t;
#endif
typedef struct s_memory_map s_memory_map_t, *memory_map_t;
-typedef struct s_dw_variable s_dw_variable_t, *dw_variable_t;
typedef struct s_dw_frame s_dw_frame_t, *dw_frame_t;
typedef s_mc_pages_store_t *mc_pages_store_t;
typedef s_mc_snapshot_t *mc_snapshot_t;
typedef s_mc_object_info_t *mc_object_info_t;
typedef s_mc_type_t *mc_type_t;
+typedef s_mc_variable_t *mc_variable_t;
SG_BEGIN_DECL()
extern mc_model_checker_t mc_model_checker;
if (type->subtype == NULL) {
XBT_DEBUG("Missing type for %p (type=%s)",
- pointed, type->dw_type_id.c_str());
+ pointed, type->type_id.c_str());
return;
}
mc_object_info_t info)
{
unsigned int cursor = 0;
- dw_variable_t variable;
+ mc_variable_t variable;
xbt_dynar_foreach(info->global_variables, cursor, variable) {
XBT_DEBUG("Hash global variable %s", variable->name);
- if (variable->type_origin == NULL) {
+ if (variable->type_id == NULL) {
// Nothing
continue;
}
// return; // TEMP
unsigned int cursor = 0;
- dw_variable_t variable;
+ mc_variable_t variable;
xbt_dynar_foreach(frame->variables, cursor, variable) {
- if (variable->type_origin == NULL) {
+ if (variable->type_id == NULL) {
XBT_DEBUG("Hash local variable %s without type", variable->name);
continue;
}
this->full_type = nullptr;
}
+// Type
+
+Variable::Variable()
+{
+ this->dwarf_offset = 0;
+ this->global = 0;
+ this->type = nullptr;
+ this->location_list = {0, nullptr};
+ this->address = nullptr;
+ this->start_scope = 0;
+ this->object_info = nullptr;
+}
+
+Variable::~Variable()
+{
+ if (this->location_list.locations)
+ mc_dwarf_location_list_clear(&this->location_list);
+}
+
// ObjectInformations
dw_frame_t ObjectInformation::find_function(const void *ip) const
return nullptr;
}
-dw_variable_t ObjectInformation::find_variable(const char* name) const
+mc_variable_t ObjectInformation::find_variable(const char* name) const
{
unsigned int cursor = 0;
- dw_variable_t variable;
- xbt_dynar_foreach(this->global_variables, cursor, variable){
- if(!strcmp(name, variable->name))
+ mc_variable_t variable;
+ xbt_dynar_foreach(this->global_variables, cursor, variable)
+ if(variable->name == name)
return variable;
- }
-
return nullptr;
}
std::string name; /* Name of the type */
int byte_size; /* Size in bytes */
int element_count; /* Number of elements for array type */
- std::string dw_type_id; /* DW_AT_type id */
+ std::string type_id; /* DW_AT_type id */
std::vector<Type> members; /* if DW_TAG_structure_type, DW_TAG_class_type, DW_TAG_union_type*/
int is_pointer_type;
char *start_ro;
char *end_ro; // read-only segment
xbt_dict_t subprograms; // xbt_dict_t<origin as hexadecimal string, dw_frame_t>
- xbt_dynar_t global_variables; // xbt_dynar_t<dw_variable_t>
+ xbt_dynar_t global_variables; // xbt_dynar_t<mc_variable_t>
xbt_dict_t types; // xbt_dict_t<origin as hexadecimal string, mc_type_t>
xbt_dict_t full_types_by_name; // xbt_dict_t<name, mc_type_t> (full defined type only)
void* base_address() const;
dw_frame_t find_function(const void *ip) const;
- dw_variable_t find_variable(const char* name) const;
+ mc_variable_t find_variable(const char* name) const;
};
XBT_INTERNAL void* mc_member_resolve(const void* base, mc_type_t type, mc_type_t member, mc_address_space_t snapshot, int process_index);
-struct s_dw_variable{
+namespace simgrid {
+namespace mc {
+
+class Variable {
+public:
+ Variable();
+ ~Variable();
+ Variable(Variable const&) = delete;
+ Variable& operator=(Variable const&) = delete;
+
Dwarf_Off dwarf_offset; /* Global offset of the field. */
int global;
- char *name;
- char *type_origin;
+ std::string name;
+ std::string type_id;
mc_type_t type;
// Use either of:
- s_mc_location_list_t locations;
+ s_mc_location_list_t location_list;
void* address;
size_t start_scope;
};
+}
+}
+
struct s_dw_frame{
int tag;
char *name;
void *low_pc;
void *high_pc;
s_mc_location_list_t frame_base;
- xbt_dynar_t /* <dw_variable_t> */ variables; /* Cannot use dict, there may be several variables with the same name (in different lexical blocks)*/
+ xbt_dynar_t /* <mc_variable_t> */ variables; /* Cannot use dict, there may be several variables with the same name (in different lexical blocks)*/
unsigned long int id; /* DWARF offset of the subprogram */
xbt_dynar_t /* <dw_frame_t> */ scopes;
Dwarf_Off abstract_origin_id;
}
// Read std_heap (is a struct mdesc*):
- dw_variable_t std_heap_var = process->find_variable("__mmalloc_default_mdp");
+ mc_variable_t std_heap_var = process->find_variable("__mmalloc_default_mdp");
if (!std_heap_var)
xbt_die("No heap information in the target process");
if(!std_heap_var->address)
/** Find (one occurence of) the named variable definition
*/
-dw_variable_t Process::find_variable(const char* name) const
+mc_variable_t Process::find_variable(const char* name) const
{
// First lookup the variable in the executable shared object.
// A global variable used directly by the executable code from a library
// We need to look up the variable in the execvutable first.
if (this->binary_info) {
std::shared_ptr<s_mc_object_info_t> const& info = this->binary_info;
- dw_variable_t var = info->find_variable(name);
+ mc_variable_t var = info->find_variable(name);
if (var)
return var;
}
for (std::shared_ptr<s_mc_object_info_t> const& info : this->object_infos) {
- dw_variable_t var = info->find_variable(name);
+ mc_variable_t var = info->find_variable(name);
if (var)
return var;
}
void Process::read_variable(const char* name, void* target, size_t size) const
{
- dw_variable_t var = this->find_variable(name);
+ mc_variable_t var = this->find_variable(name);
if (!var->address)
xbt_die("No simple location for this variable");
if (!var->type->full_type)
std::shared_ptr<s_mc_object_info_t> find_object_info_exec(remote_ptr<void> addr) const;
std::shared_ptr<s_mc_object_info_t> find_object_info_rw(remote_ptr<void> addr) const;
dw_frame_t find_function(remote_ptr<void> ip) const;
- dw_variable_t find_variable(const char* name) const;
+ mc_variable_t find_variable(const char* name) const;
// Heap access:
xbt_mheap_t get_heap()
int end = xbt_dynar_length(info->global_variables) - 1;
while (start <= end) {
unsigned int cursor = (start + end) / 2;
- dw_variable_t current_var =
- (dw_variable_t) xbt_dynar_get_as(info->global_variables,
- cursor, dw_variable_t);
- if (strcmp(current_var->name, name) == 0) {
+ mc_variable_t current_var =
+ (mc_variable_t) xbt_dynar_get_as(info->global_variables,
+ cursor, mc_variable_t);
+ int cmp = strcmp(current_var->name.c_str(), name);
+ if (cmp == 0) {
xbt_dynar_remove_at(info->global_variables, cursor, NULL);
start = 0;
end = xbt_dynar_length(info->global_variables) - 1;
- } else if (strcmp(current_var->name, name) < 0) {
+ } else if (cmp < 0) {
start = cursor + 1;
} else {
end = cursor - 1;
// Dichotomic search:
while (start <= end) {
int cursor = (start + end) / 2;
- dw_variable_t current_var =
- (dw_variable_t) xbt_dynar_get_as(scope->variables, cursor,
- dw_variable_t);
+ mc_variable_t current_var =
+ (mc_variable_t) xbt_dynar_get_as(scope->variables, cursor,
+ mc_variable_t);
- int compare = strcmp(current_var->name, var_name);
+ int compare = strcmp(current_var->name.c_str(), var_name);
if (compare == 0) {
// Variable found, remove it:
xbt_dynar_remove_at(scope->variables, cursor, NULL);
return NULL;
}
-static dw_variable_t find_local_variable(dw_frame_t frame, const char* argument_name) {
+static mc_variable_t find_local_variable(
+ dw_frame_t frame, const char* argument_name) {
unsigned int cursor = 0;
- dw_variable_t variable;
- xbt_dynar_foreach(frame->variables, cursor, variable){
- if(!strcmp(argument_name, variable->name))
+ mc_variable_t variable;
+ xbt_dynar_foreach(frame->variables, cursor, variable)
+ if(argument_name == variable->name)
return variable;
- }
- dw_frame_t scope = NULL;
+ dw_frame_t scope = nullptr;
xbt_dynar_foreach(frame->scopes, cursor, scope) {
variable = find_local_variable(scope, argument_name);
if(variable)
return variable;
}
- return NULL;
+ return nullptr;
}
static void test_local_variable(mc_object_info_t info, const char* function, const char* variable, void* address, unw_cursor_t* cursor) {
assert(subprogram);
// TODO, Lookup frame by IP and test against name instead
- dw_variable_t var = find_local_variable(subprogram, variable);
+ mc_variable_t var = find_local_variable(subprogram, variable);
assert(var);
void* frame_base = mc_find_frame_base(subprogram, info, cursor);
s_mc_location_t location;
mc_dwarf_resolve_locations(&location,
- &var->locations, info, cursor, frame_base, NULL, -1);
+ &var->location_list, info, cursor, frame_base, NULL, -1);
xbt_assert(mc_get_location_type(&location)==MC_LOCATION_TYPE_ADDRESS,
"Unexpected location type for variable %s of %s", variable, function);
}
-static dw_variable_t test_global_variable(mc_process_t process, mc_object_info_t info, const char* name, void* address, long byte_size) {
+static mc_variable_t test_global_variable(mc_process_t process, mc_object_info_t info, const char* name, void* address, long byte_size) {
- dw_variable_t variable = info->find_variable(name);
+ mc_variable_t variable = info->find_variable(name);
xbt_assert(variable, "Global variable %s was not found", name);
- xbt_assert(!strcmp(variable->name, name), "Name mismatch for %s", name);
+ xbt_assert(variable->name == name,
+ "Name mismatch for %s", name);
xbt_assert(variable->global, "Variable %s is not global", name);
xbt_assert(variable->address == address,
- "Address mismatch for %s : %p expected but %p found", name, address, variable->address);
+ "Address mismatch for %s : %p expected but %p found",
+ name, address, variable->address);
- mc_type_t type = (mc_type_t) xbt_dict_get_or_null(process->binary_info->types, variable->type_origin);
+ mc_type_t type = (mc_type_t) xbt_dict_get_or_null(
+ process->binary_info->types, variable->type_id.c_str());
xbt_assert(type!=NULL, "Missing type for %s", name);
xbt_assert(type->byte_size = byte_size, "Byte size mismatch for %s", name);
return variable;
{
SIMIX_global_init(&argc, argv);
- dw_variable_t var;
+ mc_variable_t var;
mc_type_t type;
s_mc_process_t p(getpid(), -1);
var = test_global_variable(process, process->binary_info.get(),
"test_some_array", &test_some_array, sizeof(test_some_array));
- type = (mc_type_t) xbt_dict_get_or_null(process->binary_info->types, var->type_origin);
+ type = (mc_type_t) xbt_dict_get_or_null(
+ process->binary_info->types, var->type_id.c_str());
xbt_assert(type->element_count == 6*5*4, "element_count mismatch in test_some_array : %i / %i", type->element_count, 6*5*4);
var = test_global_variable(process, process->binary_info.get(),
"test_some_struct", &test_some_struct, sizeof(test_some_struct));
- type = (mc_type_t) xbt_dict_get_or_null(process->binary_info->types, var->type_origin);
+ type = (mc_type_t) xbt_dict_get_or_null(
+ process->binary_info->types, var->type_id.c_str());
assert(find_member(process->binary_info.get(), "first", type)->offset() == 0);
assert(find_member(process->binary_info.get(), "second", type)->offset()
== ((const char*)&test_some_struct.second) - (const char*)&test_some_struct);