From: bdemsky Date: Wed, 14 Jul 2004 19:37:57 +0000 (+0000) Subject: Changes: X-Git-Url: http://plrg.eecs.uci.edu/git/?p=repair.git;a=commitdiff_plain;h=202f42f08243277d9c252e6560f8366780c5478b Changes: 1) structextract escapes '.' in fieldnames...(internal pointers were causing problems) 2) compiler no longer requires types of pointers to be declared... --- diff --git a/Repair/RepairCompiler/MCC/Compiler.java b/Repair/RepairCompiler/MCC/Compiler.java index 5e184b4..59609e9 100755 --- a/Repair/RepairCompiler/MCC/Compiler.java +++ b/Repair/RepairCompiler/MCC/Compiler.java @@ -196,8 +196,8 @@ public class Compiler { System.err.println("Unable to open file: " + state.infile + ".struct"); System.exit(-1); } catch (Exception e) { - // System.out.println(e); - // e.printStackTrace(); + System.out.println(e); + e.printStackTrace(); return false; } @@ -214,8 +214,8 @@ public class Compiler { System.err.println("Unable to open file: " + state.infile + ".model"); System.exit(-1); } catch (Exception e) { - // System.out.println(e); - // e.printStackTrace(); + System.out.println(e); + e.printStackTrace(); return false; } @@ -250,8 +250,8 @@ public class Compiler { System.err.println("Unable to open file: " + state.infile + ".constraints"); System.exit(-1); } catch (Exception e) { - // System.out.println(e); - // e.printStackTrace(); + System.out.println(e); + e.printStackTrace(); return false; } diff --git a/Repair/RepairCompiler/MCC/IR/DotExpr.java b/Repair/RepairCompiler/MCC/IR/DotExpr.java index f116cbf..9fba88f 100755 --- a/Repair/RepairCompiler/MCC/IR/DotExpr.java +++ b/Repair/RepairCompiler/MCC/IR/DotExpr.java @@ -372,6 +372,8 @@ public class DotExpr extends Expr { intindex=index; } this.fd=fd; + if (fieldtype instanceof MissingTypeDescriptor) + throw new Error(fieldtype.getSymbol()+" type undefined!"); } if ((lefttype == null) || (index != null && indextype == null)) { diff --git a/Repair/RepairCompiler/MCC/IR/SemanticChecker.java b/Repair/RepairCompiler/MCC/IR/SemanticChecker.java index 4dacc0b..66e5744 100755 --- a/Repair/RepairCompiler/MCC/IR/SemanticChecker.java +++ b/Repair/RepairCompiler/MCC/IR/SemanticChecker.java @@ -921,13 +921,17 @@ public class SemanticChecker { if (newtype == null) { // type never defined // #TBD#: replace new ParseNode with original parsenode - er.report(null, "Undefined type '" + fieldtype.getSymbol() + "'"); - ok = false; + + if (!field.getPtr()) { + /* Pointer types don't have to be defined */ + er.report(null, "Undefined type '" + fieldtype.getSymbol() + "'"); + ok = false; + } } else { assert newtype != null; field.setType(newtype); } - } + } } Iterator labels = type.getLabels(); diff --git a/Repair/RepairCompiler/structextract/common.c b/Repair/RepairCompiler/structextract/common.c index a047e8b..e685108 100755 --- a/Repair/RepairCompiler/structextract/common.c +++ b/Repair/RepairCompiler/structextract/common.c @@ -17,6 +17,22 @@ char * copystr(const char *buf) { } } +char * escapestr(const char *buf) { + int i,j; + if (buf==NULL) + return NULL; + for(i=0;;i++) + if (buf[i]==0) { + char *ptr=(char*)malloc(i+1); + for(j=0;j<=i;j++) { + ptr[j]=buf[j]; + if (ptr[j]=='.') + ptr[j]='_'; + } + return ptr; + } +} + unsigned int hashstring(char *strptr) { unsigned int hashcode=0; diff --git a/Repair/RepairCompiler/structextract/common.h b/Repair/RepairCompiler/structextract/common.h index e9b2034..26b5600 100755 --- a/Repair/RepairCompiler/structextract/common.h +++ b/Repair/RepairCompiler/structextract/common.h @@ -2,6 +2,7 @@ #define COMMON_H char * copystr(const char *buf); +char * escapestr(const char *buf); unsigned int hashstring(char *strptr); int equivalentstrings(char *str1, char *str2); #endif diff --git a/Repair/RepairCompiler/structextract/dumpstructures.c b/Repair/RepairCompiler/structextract/dumpstructures.c index 3907c13..67d4ada 100755 --- a/Repair/RepairCompiler/structextract/dumpstructures.c +++ b/Repair/RepairCompiler/structextract/dumpstructures.c @@ -22,11 +22,12 @@ #include "typedata.h" #include "elf/dwarf2.h" - #define GETTYPE 1 #define POSTNAME 2 #define GETJUSTTYPE 3 +int FOLLOW_PTRS=0; + int process_elf_binary_data(char* filename); char *rootfile=NULL; @@ -226,7 +227,7 @@ void initializeTypeArray() dwarf_entry *typeptr=in_ptr->target_ptr; collection_type* sub_ptr = (collection_type*)(typeptr->entry_ptr); if (j==0) - printf("subclasses "); + printf("subclass of "); else printf(", "); printf("%s ",sub_ptr->name); @@ -253,13 +254,15 @@ void initializeTypeArray() dwarf_entry *type=member_ptr->type_ptr; char *typestr=printname(type,GETTYPE); char *poststr=printname(type,POSTNAME); + char *newname=NULL; if (member_ptr->data_member_location>offset) { printf(" reserved byte[%ld];\n",member_ptr->data_member_location-offset); offset=member_ptr->data_member_location; } offset+=getsize(type); - - printf(" %s %s%s;\n",typestr,name,poststr); + newname=escapestr(name); + printf(" %s %s%s;\n",typestr,newname,poststr); + free(newname); } } if (offsetbyte_size) @@ -298,6 +301,7 @@ int printtype(collection_type *collection_ptr,struct genhashtable *ght) } else { member * member_ptr=(member *)entry->entry_ptr; char *name=member_ptr->name; + char *newname=NULL; dwarf_entry *type=member_ptr->type_ptr; char *typestr=printname(type,GETTYPE); char *poststr=printname(type,POSTNAME); @@ -307,14 +311,14 @@ int printtype(collection_type *collection_ptr,struct genhashtable *ght) } offset+=getsize(type); - printf(" %s %s%s;\n",typestr,name,poststr); + newname=escapestr(name); + printf(" %s %s%s;\n",typestr,newname,poststr); + free(newname); } } return offset; } - - int getsize(dwarf_entry *type) { if (type==NULL) return 0; @@ -444,6 +448,9 @@ char * printname(dwarf_entry * type,int op) { return newptr; } } else if (op==GETJUSTTYPE) { + if (!FOLLOW_PTRS) + return NULL; + if (modifier_ptr->target_ptr==NULL) return NULL; {