// Try to find a more complete description of the type:
// We need to fix in order to support C++.
- dw_type_t subtype = xbt_dict_get_or_null(info->types_by_name, type->subtype->name);
+ dw_type_t subtype = xbt_dict_get_or_null(info->full_types_by_name, type->subtype->name);
if(subtype!=NULL) {
type->subtype = subtype;
}
// Global Offset
type->id = (void *) dwarf_dieoffset(die);
+ char* prefix = "";
+ switch (type->type) {
+ case DW_TAG_structure_type:
+ prefix = "struct ";
+ break;
+ case DW_TAG_union_type:
+ prefix = "union ";
+ break;
+ case DW_TAG_class_type:
+ prefix = "class ";
+ break;
+ default:
+ prefix = "";
+ }
+
const char* name = MC_dwarf_attr_string(die, DW_AT_name);
if (name!=NULL) {
- type->name = xbt_strdup(name);
+ type->name = namespace ? bprintf("%s%s::%s", prefix, namespace, name) : bprintf("%s%s", prefix, name);
}
XBT_DEBUG("Processing type <%p>%s", type->id, type->name);
case DW_TAG_class_type:
MC_dwarf_add_members(info, die, unit, type);
char* new_namespace = namespace == NULL ? xbt_strdup(type->name)
- : bprintf("%s::%s", namespace, type->name);
+ : bprintf("%s::%s", namespace, name);
MC_dwarf_handle_children(info, die, unit, frame, new_namespace);
free(new_namespace);
break;
xbt_dict_set(info->types, key, type, NULL);
if(type->name && type->byte_size!=0) {
- xbt_dict_set(info->types_by_name, type->name, type, NULL);
+ xbt_dict_set(info->full_types_by_name, type->name, type, NULL);
}
}
res->subprograms = xbt_dynar_new(sizeof(dw_frame_t), NULL);
res->global_variables = xbt_dynar_new(sizeof(dw_variable_t), dw_variable_free_voidp);
res->types = xbt_dict_new_homogeneous(NULL);
- res->types_by_name = xbt_dict_new_homogeneous(NULL);
+ res->full_types_by_name = xbt_dict_new_homogeneous(NULL);
return res;
}
xbt_dynar_free(&(*info)->subprograms);
xbt_dynar_free(&(*info)->global_variables);
xbt_dict_free(&(*info)->types);
- xbt_dict_free(&(*info)->types_by_name);
+ xbt_dict_free(&(*info)->full_types_by_name);
xbt_free(info);
xbt_dynar_free(&(*info)->functions_index);
*info = NULL;
dw_type_t type = NULL;
xbt_dict_foreach(info->types, cursor, key, type){
if(type->name && type->byte_size == 0) {
- type->other_object_same_type = xbt_dict_get_or_null(other_info->types_by_name, type->name);
+ type->other_object_same_type = xbt_dict_get_or_null(other_info->full_types_by_name, type->name);
}
}
}
xbt_dynar_t subprograms; // xbt_dynar_t<dw_frame_t>
xbt_dynar_t global_variables; // xbt_dynar_t<dw_variable_t>
xbt_dict_t types; // xbt_dict_t<origin as hexadecimal string, dw_type_t>
- xbt_dict_t types_by_name; // xbt_dict_t<name, dw_type_t> (full defined type only)
+ xbt_dict_t full_types_by_name; // xbt_dict_t<name, dw_type_t> (full defined type only)
// Here we sort the minimal information for an efficient (and cache-efficient)
// lookup of a function given an instruction pointer.
case DW_TAG_class_type:
case DW_TAG_union_type:
if(subtype->byte_size == 0){ /*declaration of the type, need the complete description */
- subtype = xbt_dict_get_or_null(other_info->types_by_name, subtype->name);
+ subtype = xbt_dict_get_or_null(other_info->full_types_by_name, subtype->name);
switch_types = 1;
}
elm_size = subtype->byte_size;
case DW_TAG_volatile_type:
subsubtype = subtype->subtype;
if(subsubtype->byte_size == 0){ /*declaration of the type, need the complete description */
- subsubtype = xbt_dict_get_or_null(other_info->types_by_name, subtype->name);
+ subsubtype = xbt_dict_get_or_null(other_info->full_types_by_name, subtype->name);
switch_types = 1;
}
elm_size = subsubtype->byte_size;
case DW_TAG_structure_type:
case DW_TAG_class_type:
if(type->byte_size == 0){ /*declaration of the structure, need the complete description */
- dw_type_t full_type = xbt_dict_get_or_null(info->types_by_name, type->name);
+ dw_type_t full_type = xbt_dict_get_or_null(info->full_types_by_name, type->name);
if(full_type){
type = full_type;
}else{
- type = xbt_dict_get_or_null(other_info->types_by_name, type->name);
+ type = xbt_dict_get_or_null(other_info->full_types_by_name, type->name);
switch_types = 1;
}
}
case DW_TAG_class_type:
if(type->byte_size == 0){ /*declaration of the structure, need the complete description */
if(*switch_type == 0){
- dw_type_t full_type = xbt_dict_get_or_null(info->types_by_name, type->name);
+ dw_type_t full_type = xbt_dict_get_or_null(info->full_types_by_name, type->name);
if(full_type){
type = full_type;
}else{
- type = xbt_dict_get_or_null(other_info->types_by_name, type->name);
+ type = xbt_dict_get_or_null(other_info->full_types_by_name, type->name);
*switch_type = 1;
}
}else{
- dw_type_t full_type = xbt_dict_get_or_null(other_info->types_by_name, type->name);
+ dw_type_t full_type = xbt_dict_get_or_null(other_info->full_types_by_name, type->name);
if(full_type){
type = full_type;
}else{
- type = xbt_dict_get_or_null(info->types_by_name, type->name);
+ type = xbt_dict_get_or_null(info->full_types_by_name, type->name);
*switch_type = 0;
}
}
type = xbt_dict_get_or_null(info->types, type_id);
if(type->byte_size == 0){
if(type->subtype == NULL){
- dw_type_t full_type = xbt_dict_get_or_null(info->types_by_name, type->name);
+ dw_type_t full_type = xbt_dict_get_or_null(info->full_types_by_name, type->name);
if(full_type)
type = full_type;
else
- type = xbt_dict_get_or_null(other_info->types_by_name, type->name);
+ type = xbt_dict_get_or_null(other_info->full_types_by_name, type->name);
}else{
type = type->subtype;
}
return variable;
}
-static dw_type_t find_type(mc_object_info_t info, const char* name, dw_type_t type) {
+static dw_type_t find_member(mc_object_info_t info, const char* name, dw_type_t type) {
unsigned int cursor = 0;
dw_type_t member;
xbt_dynar_foreach(type->members, cursor, member){
int some_local_variable = 0;
+typedef struct foo {int i;} s_foo;
+
int main(int argc, char** argv) {
// xbt_init(&argc, argv);
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_type(mc_binary_info, "first", type)->offset == 0);
- assert(find_type(mc_binary_info, "second", type)->offset
+ assert(find_member(mc_binary_info, "first", type)->offset == 0);
+ assert(find_member(mc_binary_info, "second", type)->offset
== ((const char*)&test_some_struct.second) - (const char*)&test_some_struct);
unw_context_t context;
test_local_variable(mc_binary_info, "main", "argc", &argc, &cursor);
+ s_foo my_foo;
+
+ assert(xbt_dict_get_or_null(mc_binary_info->full_types_by_name, "struct foo"));
+
_exit(0);
}