From 38706bcbe3752535688ea2a5817e20c71315aa28 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Fri, 30 Sep 2005 05:07:01 +0000 Subject: [PATCH 1/1] Name typedefs --- .../structextract/dumpstructures.c | 18 ++++++++++++++---- Repair/RepairCompiler/structextract/typedata.c | 6 ++++++ Repair/RepairCompiler/structextract/typedata.h | 9 +++++---- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/Repair/RepairCompiler/structextract/dumpstructures.c b/Repair/RepairCompiler/structextract/dumpstructures.c index a7bfdf6..01e7d57 100755 --- a/Repair/RepairCompiler/structextract/dumpstructures.c +++ b/Repair/RepairCompiler/structextract/dumpstructures.c @@ -520,8 +520,18 @@ char * printname(dwarf_entry * type,int op) { { tdef * tdef_ptr=(tdef*)type->entry_ptr; if (op==GETTYPE||op==GETJUSTTYPE) { - char *typename=printname(tdef_ptr->target_ptr,op); - return typename; + if (tdef_ptr->target_ptr==NULL) + return tdef_ptr->name; + if (tdef_ptr->target_ptr->tag_name==DW_TAG_union_type|| + tdef_ptr->target_ptr->tag_name==DW_TAG_structure_type) { + collection_type *ctype=(collection_type*)tdef_ptr->target_ptr->entry_ptr; + if (ctype->name!=NULL) + return ctype->name; + ctype->name=tdef_ptr->name; + return tdef_ptr->name; + } + char *typename=printname(tdef_ptr->target_ptr,op); + return typename; } } break; @@ -573,13 +583,13 @@ char * printname(dwarf_entry * type,int op) { collection_type *ctype=(collection_type*)type->entry_ptr; if (op==GETTYPE&&ctype->name==NULL&&assigntype) { ctype->name=(char*)malloc(100); - sprintf(ctype->name,"TYPE%ld",typecount++); + sprintf(ctype->name,"unnamed_0x%lx",type->ID); } if (op==GETTYPE) return ctype->name; if (op==GETJUSTTYPE&&ctype->name==NULL&&assigntype) { ctype->name=(char*)malloc(100); - sprintf(ctype->name,"TYPE%ld",typecount++); + sprintf(ctype->name,"unnamed_0x%lx",type->ID); } if (op==GETJUSTTYPE) return ctype->name; diff --git a/Repair/RepairCompiler/structextract/typedata.c b/Repair/RepairCompiler/structextract/typedata.c index cdeae71..1478fcf 100755 --- a/Repair/RepairCompiler/structextract/typedata.c +++ b/Repair/RepairCompiler/structextract/typedata.c @@ -202,6 +202,7 @@ char entry_is_listening_for_attribute(dwarf_entry* e, unsigned long attr) case DW_AT_name: return (tag_is_collection_type(tag) || tag_is_member(tag) || + tag==DW_TAG_typedef|| tag_is_enumerator(tag) || tag_is_function(tag) || tag_is_formal_parameter(tag) || @@ -439,6 +440,11 @@ char harvest_name(dwarf_entry* e, const char* str) ((enumerator*)e->entry_ptr)->name = strdup(str); return 1; } + else if (tag==DW_TAG_typedef) + { + ((tdef*)e->entry_ptr)->name = strdup(str); + return 1; + } else if (tag_is_collection_type(tag)) { ((collection_type*)e->entry_ptr)->name = strdup(str); diff --git a/Repair/RepairCompiler/structextract/typedata.h b/Repair/RepairCompiler/structextract/typedata.h index c08cfff..45e1ef0 100755 --- a/Repair/RepairCompiler/structextract/typedata.h +++ b/Repair/RepairCompiler/structextract/typedata.h @@ -61,26 +61,27 @@ typedef struct } modifier_type; typedef struct -{ +{ unsigned long target_ID; // ID of the entry that contains the type that this modifies unsigned long upperbound; dwarf_entry* target_ptr; // Type that this entry modifies (DW_AT_type) } array_bound; typedef struct -{ +{ unsigned long target_ID; // ID of the entry that contains the type that this modifies + char *name; dwarf_entry* target_ptr; // Type that this entry modifies (DW_AT_type) } tdef; typedef struct -{ +{ unsigned long target_ID; // ID of the entry that contains the type that this modifies dwarf_entry* target_ptr; // Type that this entry modifies (DW_AT_type) } consttype; typedef struct -{ +{ unsigned long target_ID; // ID of the entry that contains the type that this modifies dwarf_entry* target_ptr; // Type that this entry modifies (DW_AT_type) long data_member_location; // Addr offset relative to struct head -- 2.34.1