X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gdb%2Fgdbtypes.c;h=44827ab96d8dfaba394b49b235f568441c452a66;hb=f09c6a96e688fa371b1b6c066c116b454a710051;hp=99c7c57b08256825bc0b9f653f4e0827b87dc00b;hpb=f6d165855eebd59b95ceb16c48f10c7c927d187c;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 99c7c57b08..44827ab96d 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -74,6 +74,7 @@ alloc_type (objfile) { type = (struct type *) obstack_alloc (&objfile -> type_obstack, sizeof (struct type)); + OBJSTAT (objfile, n_types++); } memset ((char *) type, 0, sizeof (struct type)); @@ -355,8 +356,18 @@ get_discrete_bounds (type, lowp, highp) case TYPE_CODE_ENUM: if (TYPE_NFIELDS (type) > 0) { - *lowp = TYPE_FIELD_BITPOS (type, 0); - *highp = TYPE_FIELD_BITPOS (type, TYPE_NFIELDS (type) - 1); + /* The enums may not be sorted by value, so search all + entries */ + int i; + + *lowp = *highp = TYPE_FIELD_BITPOS (type, 0); + for (i = 0; i < TYPE_NFIELDS (type); i++) + { + if (TYPE_FIELD_BITPOS (type, i) < *lowp) + *lowp = TYPE_FIELD_BITPOS (type, i); + if (TYPE_FIELD_BITPOS (type, i) > *highp) + *highp = TYPE_FIELD_BITPOS (type, i); + } } else { @@ -877,12 +888,19 @@ check_typedef (type) { if (!TYPE_TARGET_TYPE (type)) { - char* name = type_name_no_tag (type); + char* name; + struct symbol *sym; + + /* It is dangerous to call lookup_symbol if we are currently + reading a symtab. Infinite recursion is one danger. */ + if (currently_reading_symtab) + return type; + + name = type_name_no_tag (type); /* FIXME: shouldn't we separately check the TYPE_NAME and the TYPE_TAG_NAME, and look in STRUCT_NAMESPACE and/or VAR_NAMESPACE as appropriate? (this code was written before TYPE_NAME and TYPE_TAG_NAME were separate). */ - struct symbol *sym; if (name == NULL) { complain (&stub_noname_complaint); @@ -898,7 +916,7 @@ check_typedef (type) type = TYPE_TARGET_TYPE (type); } - if (TYPE_FLAGS(type) & TYPE_FLAG_STUB) + if ((TYPE_FLAGS(type) & TYPE_FLAG_STUB) && ! currently_reading_symtab) { char* name = type_name_no_tag (type); /* FIXME: shouldn't we separately check the TYPE_NAME and the @@ -953,6 +971,199 @@ check_typedef (type) return type; } +/* New code added to support parsing of Cfront stabs strings */ +#include +#define INIT_EXTRA { pextras->len=0; pextras->str[0]='\0'; } +#define ADD_EXTRA(c) { pextras->str[pextras->len++]=c; } +struct extra { char str[128]; int len; }; /* maximum extention is 128! FIXME */ +void +add_name(pextras,n) + struct extra * pextras; + char * n; +{ + char lenstr[512]; /* FIXME! hardcoded :-( */ + int nlen, lenstrlen; + if ((nlen = (n ? strlen(n) : 0))==0) + return; + sprintf(pextras->str+pextras->len,"%d%s",nlen,n); + pextras->len=strlen(pextras->str); +} + +void +add_mangled_type(pextras,t) + struct extra * pextras; + struct type * t; +{ + enum type_code tcode; + int tlen, tflags; + char * tname; + + tcode = TYPE_CODE(t); + tlen = TYPE_LENGTH(t); + tflags = TYPE_FLAGS(t); + tname = TYPE_NAME(t); + /* args of "..." seem to get mangled as "e" */ + + switch (tcode) + { + case TYPE_CODE_INT: + if (tflags==1) + ADD_EXTRA('U'); + switch (tlen) + { + case 1: + ADD_EXTRA('c'); + break; + case 2: + ADD_EXTRA('s'); + break; + case 4: + { + char* pname; + if ((pname=strrchr(tname,'l'),pname) && !strcmp(pname,"long")) + ADD_EXTRA('l') + else + ADD_EXTRA('i') + } + break; + default: + { + + static struct complaint msg = {"Bad int type code length x%x\n",0,0}; + + complain (&msg, tlen); + + } + } + break; + case TYPE_CODE_FLT: + switch (tlen) + { + case 4: + ADD_EXTRA('f'); + break; + case 8: + ADD_EXTRA('d'); + break; + case 16: + ADD_EXTRA('r'); + break; + default: + { + static struct complaint msg = {"Bad float type code length x%x\n",0,0}; + complain (&msg, tlen); + } + } + break; + case TYPE_CODE_REF: + ADD_EXTRA('R'); + /* followed by what it's a ref to */ + break; + case TYPE_CODE_PTR: + ADD_EXTRA('P'); + /* followed by what it's a ptr to */ + break; + case TYPE_CODE_TYPEDEF: + { + static struct complaint msg = {"Typedefs in overloaded functions not yet supported\n",0,0}; + complain (&msg); + } + /* followed by type bytes & name */ + break; + case TYPE_CODE_FUNC: + ADD_EXTRA('F'); + /* followed by func's arg '_' & ret types */ + break; + case TYPE_CODE_VOID: + ADD_EXTRA('v'); + break; + case TYPE_CODE_METHOD: + ADD_EXTRA('M'); + /* followed by name of class and func's arg '_' & ret types */ + add_name(pextras,tname); + ADD_EXTRA('F'); /* then mangle function */ + break; + case TYPE_CODE_STRUCT: /* C struct */ + case TYPE_CODE_UNION: /* C union */ + case TYPE_CODE_ENUM: /* Enumeration type */ + /* followed by name of type */ + add_name(pextras,tname); + break; + + /* errors possible types/not supported */ + case TYPE_CODE_CHAR: + case TYPE_CODE_ARRAY: /* Array type */ + case TYPE_CODE_MEMBER: /* Member type */ + case TYPE_CODE_BOOL: + case TYPE_CODE_COMPLEX: /* Complex float */ + case TYPE_CODE_UNDEF: + case TYPE_CODE_SET: /* Pascal sets */ + case TYPE_CODE_RANGE: + case TYPE_CODE_STRING: + case TYPE_CODE_BITSTRING: + case TYPE_CODE_ERROR: + default: + { + static struct complaint msg = {"Unknown type code x%x\n",0,0}; + complain (&msg, tcode); + } + } + if (t->target_type) + add_mangled_type(pextras,t->target_type); +} + +char * +cfront_mangle_name(type, i, j) + struct type *type; + int i; + int j; +{ + struct fn_field *f; + char *mangled_name = gdb_mangle_name (type, i, j); + + f = TYPE_FN_FIELDLIST1 (type, i); /* moved from below */ + + /* kludge to support cfront methods - gdb expects to find "F" for + ARM_mangled names, so when we mangle, we have to add it here */ + if (ARM_DEMANGLING) + { + int k; + char * arm_mangled_name; + struct fn_field *method = &f[j]; + char *field_name = TYPE_FN_FIELDLIST_NAME (type, i); + char *physname = TYPE_FN_FIELD_PHYSNAME (f, j); + char *newname = type_name_no_tag (type); + + struct type *ftype = TYPE_FN_FIELD_TYPE (f, j); + int nargs = TYPE_NFIELDS(ftype); /* number of args */ + struct extra extras, * pextras = &extras; + INIT_EXTRA + + if (TYPE_FN_FIELD_STATIC_P (f, j)) /* j for sublist within this list */ + ADD_EXTRA('S') + ADD_EXTRA('F') + /* add args here! */ + if (nargs <= 1) /* no args besides this */ + ADD_EXTRA('v') + else { + for (k=1; k fundamental_types = (struct type **) obstack_alloc (&objfile -> type_obstack, nbytes); memset ((char *) objfile -> fundamental_types, 0, nbytes); + OBJSTAT (objfile, n_types += FT_NUM_MEMBERS); } /* Look for this particular type in the fundamental type vector. If one is