X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/652cac70b147e9868fc5bf60608ee0c327adaf30..3cf08d9c5880b36209423e78cbc1130f8c12893b:/teshsuite/mc/dwarf/dwarf.c diff --git a/teshsuite/mc/dwarf/dwarf.c b/teshsuite/mc/dwarf/dwarf.c index 7378579efd..997771c337 100644 --- a/teshsuite/mc/dwarf/dwarf.c +++ b/teshsuite/mc/dwarf/dwarf.c @@ -15,7 +15,9 @@ #include #include "../../src/include/mc/datatypes.h" +#include "../../src/mc/mc_object_info.h" #include "../../src/mc/mc_private.h" +#include "../../src/mc/mc_model_checker.h" int test_some_array[4][5][6]; struct some_struct { int first; int second[4][5]; } test_some_struct; @@ -32,17 +34,6 @@ static dw_type_t find_type_by_name(mc_object_info_t info, const char* name) { return NULL; } -static dw_variable_t find_global_variable_by_name(mc_object_info_t info, const char* name) { - unsigned int cursor = 0; - dw_variable_t variable; - xbt_dynar_foreach(info->global_variables, cursor, variable){ - if(!strcmp(name, variable->name)) - return variable; - } - - return NULL; -} - static dw_frame_t find_function_by_name(mc_object_info_t info, const char* name) { xbt_dict_cursor_t cursor = 0; dw_frame_t subprogram; @@ -95,15 +86,16 @@ static void test_local_variable(mc_object_info_t info, const char* function, con } -static dw_variable_t test_global_variable(mc_object_info_t info, const char* name, void* address, long byte_size) { - dw_variable_t variable = find_global_variable_by_name(info, name); +static dw_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 = MC_file_object_info_find_variable_by_name(info, 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->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); - dw_type_t type = xbt_dict_get_or_null(mc_binary_info->types, variable->type_origin); + dw_type_t type = xbt_dict_get_or_null(process->binary_info->types, variable->type_origin); xbt_assert(type!=NULL, "Missing type for %s", name); xbt_assert(type->byte_size = byte_size, "Byte size mismatch for %s", name); return variable; @@ -123,30 +115,31 @@ int some_local_variable = 0; typedef struct foo {int i;} s_foo; -static void test_type_by_name(s_foo my_foo) { - assert(xbt_dict_get_or_null(mc_binary_info->full_types_by_name, "struct foo")); +static void test_type_by_name(mc_process_t process, s_foo my_foo) { + assert(xbt_dict_get_or_null(process->binary_info->full_types_by_name, "struct foo")); } -int main(int argc, char** argv) { - - // xbt_init(&argc, argv); +int main(int argc, char** argv) +{ SIMIX_global_init(&argc, argv); - MC_memory_init(); - MC_init(); dw_variable_t var; dw_type_t type; + + s_mc_process_t p; + mc_process_t process = &p; + MC_process_init(&p, getpid()); - test_global_variable(mc_binary_info, "some_local_variable", &some_local_variable, sizeof(int)); + test_global_variable(process, process->binary_info, "some_local_variable", &some_local_variable, sizeof(int)); - var = test_global_variable(mc_binary_info, "test_some_array", &test_some_array, sizeof(test_some_array)); - type = xbt_dict_get_or_null(mc_binary_info->types, var->type_origin); + var = test_global_variable(process, process->binary_info, "test_some_array", &test_some_array, sizeof(test_some_array)); + type = xbt_dict_get_or_null(process->binary_info->types, var->type_origin); 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(mc_binary_info, "test_some_struct", &test_some_struct, sizeof(test_some_struct)); - type = xbt_dict_get_or_null(mc_binary_info->types, var->type_origin); - assert(find_member(mc_binary_info, "first", type)->offset == 0); - assert(find_member(mc_binary_info, "second", type)->offset + var = test_global_variable(process, process->binary_info, "test_some_struct", &test_some_struct, sizeof(test_some_struct)); + type = xbt_dict_get_or_null(process->binary_info->types, var->type_origin); + assert(find_member(process->binary_info, "first", type)->offset == 0); + assert(find_member(process->binary_info, "second", type)->offset == ((const char*)&test_some_struct.second) - (const char*)&test_some_struct); unw_context_t context; @@ -154,15 +147,15 @@ int main(int argc, char** argv) { unw_getcontext(&context); unw_init_local(&cursor, &context); - test_local_variable(mc_binary_info, "main", "argc", &argc, &cursor); + test_local_variable(process->binary_info, "main", "argc", &argc, &cursor); { int lexical_block_variable = 50; - test_local_variable(mc_binary_info, "main", "lexical_block_variable", &lexical_block_variable, &cursor); + test_local_variable(process->binary_info, "main", "lexical_block_variable", &lexical_block_variable, &cursor); } s_foo my_foo; - test_type_by_name(my_foo); + test_type_by_name(process, my_foo); _exit(0); }