* TODO: Add item suggesting an "info bfd" command.
[deliverable/binutils-gdb.git] / gdb / stabsread.c
index a9ac48045e855b4e4dec739ce1810db3094f8256..be312af7195bd72c33842980644dd0b6944dd27f 100644 (file)
@@ -80,7 +80,7 @@ read_one_struct_field PARAMS ((struct field_info *, char **, char *,
                               struct type *, struct objfile *));
 
 static char * 
-get_substring PARAMS ((char **, char));
+get_substring PARAMS ((char **, int));
 
 static struct type *
 dbx_alloc_type PARAMS ((int [2], struct objfile *));
@@ -344,7 +344,7 @@ Invalid symbol data: type number (%d,%d) out of range at symtab pos %d.",
     {
       real_filenum = this_object_header_files[filenum];
 
-      if (real_filenum >= n_header_files)
+      if (real_filenum >= N_HEADER_FILES (current_objfile))
        {
          struct type *temp_type;
          struct type **temp_type_p;
@@ -358,7 +358,7 @@ Invalid symbol data: type number (%d,%d) out of range at symtab pos %d.",
          return temp_type_p;
        }
 
-      f = &header_files[real_filenum];
+      f = HEADER_FILES (current_objfile) + real_filenum;
 
       f_orig_length = f->length;
       if (index >= f_orig_length)
@@ -538,16 +538,17 @@ read_type_number (pp, typenums)
 
 /* This code added to support parsing of ARM/Cfront stabs strings */
 
-/* get substring from string up to char c 
-   advance string pointer past suibstring */
+/* Get substring from string up to char c, advance string pointer past
+   suibstring. */
+
 static char * 
-get_substring(p, c)
+get_substring (p, c)
   char ** p;
-  char c;
+  int c;
 {
-  char * str;
+  char *str;
   str = *p;
-  *p = strchr(*p,c);
+  *p = strchr (*p, c);
   if (*p) 
     {
       **p = 0;
@@ -558,35 +559,36 @@ get_substring(p, c)
   return str;
 }
 
-/* Physname gets strcat'd onto sname in order to recreate the mangled name
-   (see funtion gdb_mangle_name in gdbtypes.c).  For cfront, make the physname
-   look like that of g++ - take out the initial mangling 
+/* Physname gets strcat'd onto sname in order to recreate the mangled
+   name (see funtion gdb_mangle_name in gdbtypes.c).  For cfront, make
+   the physname look like that of g++ - take out the initial mangling
    eg: for sname="a" and fname="foo__1aFPFs_i" return "FPFs_i" */
+
 static char * 
-get_cfront_method_physname(fname)
-  char * fname;
+get_cfront_method_physname (fname)
+  char *fname;
 {
-  int len=0;
+  int len = 0;
   /* FIXME would like to make this generic for g++ too, but 
      that is already handled in read_member_funcctions */
   char * p = fname;
 
   /* search ahead to find the start of the mangled suffix */
   if (*p == '_' && *(p+1)=='_') /* compiler generated; probably a ctor/dtor */
-    p+=2;              
-  while (p && ((p+1) - fname) < strlen(fname) && *(p+1)!='_')
-    p = strchr(p,'_');
-  if (!(p && *p=='_' && *(p+1)=='_')) 
-    error("Invalid mangled function name %s",fname);
-  p+=2; /* advance past '__' */
+    p += 2;            
+  while (p && ((p+1) - fname) < strlen (fname) && *(p+1) != '_')
+    p = strchr (p, '_');
+  if (!(p && *p == '_' && *(p+1) == '_')) 
+    error ("Invalid mangled function name %s",fname);
+  p += 2; /* advance past '__' */
 
   /* struct name length and name of type should come next; advance past it */
-  while (isdigit(*p))
+  while (isdigit (*p))
     {
-      len = len*10 + (*p - '0');
+      len = len * 10 + (*p - '0');
       p++;
     }
-  p+=len;
+  p += len;
 
   return p;
 }
@@ -598,12 +600,13 @@ get_cfront_method_physname(fname)
        A:ZcA;;foopri__1AFv foopro__1AFv __ct__1AFv __ct__1AFRC1A foopub__1AFv ;;;
              ^
    */
+
 static int
-read_cfront_baseclasses(fip, pp, type, objfile) 
+read_cfront_baseclasses (fip, pp, type, objfile) 
   struct field_info *fip;
-  struct objfile * objfile;
+  struct objfile *objfile;
   char ** pp;
-  struct type * type;
+  struct type *type;
 {
   static struct complaint msg_unknown = {"\
         Unsupported token in stabs string %s.\n",
@@ -611,21 +614,22 @@ read_cfront_baseclasses(fip, pp, type, objfile)
   static struct complaint msg_notfound = {"\
                   Unable to find base type for %s.\n",
                                 0, 0};
-  int bnum=0;
+  int bnum = 0;
   char * p;
   int i;
   struct nextfield *new;
 
-  if (**pp==';')               /* no base classes; return */
+  if (**pp == ';')             /* no base classes; return */
     {
       ++(*pp);
       return 1;
     }
 
   /* first count base classes so we can allocate space before parsing */
-  for (p = *pp; p && *p && *p!=';'; p++)
+  for (p = *pp; p && *p && *p != ';'; p++)
     {
-      if (*p==' ') bnum++;
+      if (*p == ' ')
+       bnum++;
     }
   bnum++;      /* add one more for last one */
 
@@ -638,12 +642,12 @@ read_cfront_baseclasses(fip, pp, type, objfile)
   {
     int num_bytes = B_BYTES (TYPE_N_BASECLASSES (type));
     char *pointer;
+
     pointer = (char *) TYPE_ALLOC (type, num_bytes);
     TYPE_FIELD_VIRTUAL_BITS (type) = (B_TYPE *) pointer;
   }
   B_CLRALL (TYPE_FIELD_VIRTUAL_BITS (type), TYPE_N_BASECLASSES (type));
 
-
   for (i = 0; i < TYPE_N_BASECLASSES (type); i++)
     {
       new = (struct nextfield *) xmalloc (sizeof (struct nextfield));
@@ -1773,21 +1777,25 @@ define_symbol (valu, string, desc, type, objfile)
   /* When passing structures to a function, some systems sometimes pass
      the address in a register, not the structure itself. */
 
-  if (REG_STRUCT_HAS_ADDR (processing_gcc_compilation,
-                             SYMBOL_TYPE (sym))
-      && ((TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT)
-         || (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_UNION)
-         || (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_BITSTRING)
-         || (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_SET)))
+  if (REG_STRUCT_HAS_ADDR (processing_gcc_compilation, SYMBOL_TYPE (sym))
+      && (SYMBOL_CLASS (sym) == LOC_REGPARM || SYMBOL_CLASS (sym) == LOC_ARG))
     {
-      /* If REG_STRUCT_HAS_ADDR yields non-zero we have to
-       convert LOC_REGPARM to LOC_REGPARM_ADDR for structures and unions. */
-      if (SYMBOL_CLASS (sym) == LOC_REGPARM)
-       SYMBOL_CLASS (sym) = LOC_REGPARM_ADDR;
-      /* Likewise for converting LOC_ARG to LOC_REF_ARG (for the 7th and
-        subsequent arguments on the sparc, for example).  */
-      else if (SYMBOL_CLASS (sym) == LOC_ARG)
-       SYMBOL_CLASS (sym) = LOC_REF_ARG;
+      struct type *symbol_type = check_typedef (SYMBOL_TYPE (sym));
+
+      if ((TYPE_CODE (symbol_type) == TYPE_CODE_STRUCT)
+         || (TYPE_CODE (symbol_type) == TYPE_CODE_UNION)
+         || (TYPE_CODE (symbol_type) == TYPE_CODE_BITSTRING)
+         || (TYPE_CODE (symbol_type) == TYPE_CODE_SET))
+       {
+         /* If REG_STRUCT_HAS_ADDR yields non-zero we have to convert
+            LOC_REGPARM to LOC_REGPARM_ADDR for structures and unions. */
+         if (SYMBOL_CLASS (sym) == LOC_REGPARM)
+           SYMBOL_CLASS (sym) = LOC_REGPARM_ADDR;
+         /* Likewise for converting LOC_ARG to LOC_REF_ARG (for the 7th
+            and subsequent arguments on the sparc, for example).  */
+         else if (SYMBOL_CLASS (sym) == LOC_ARG)
+           SYMBOL_CLASS (sym) = LOC_REF_ARG;
+       }
     }
 
   return sym;
This page took 0.030734 seconds and 4 git commands to generate.