Thu May 21 13:14:25 1998 John Metzler <jmetzler@cygnus.com>
[deliverable/binutils-gdb.git] / gdb / stabsread.c
index e32afd83f208ff58e423dd597c231c7f7876c06d..be562e50a18fc8259de5e99ae51a888c898ed866 100644 (file)
@@ -1,5 +1,5 @@
 /* Support routines for decoding "stabs" debugging information format.
-   Copyright 1986, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 1997
+   Copyright 1986, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 1998
              Free Software Foundation, Inc.
 
 This file is part of GDB.
@@ -1194,7 +1194,8 @@ ref_add (refnum, sym, stabs, value)
     {
       int new_slots = ref_count - ref_chunk * MAX_CHUNK_REFS; 
       int new_chunks = new_slots / MAX_CHUNK_REFS + 1;
-      ref_map = xrealloc (ref_map, REF_MAP_SIZE(ref_chunk + new_chunks));
+      ref_map = (struct ref_map_s *)
+       xrealloc (ref_map, REF_MAP_SIZE(ref_chunk + new_chunks));
       if (!ref_map) 
        error ("no more free slots in chain\n");
       memset (ref_map + REF_MAP_SIZE(ref_chunk), 0, new_chunks * REF_CHUNK_SIZE);
@@ -1615,18 +1616,47 @@ define_symbol (valu, string, desc, type, objfile)
       /* fall into process_prototype_types */
 
     process_prototype_types:
-      /* Sun acc puts declared types of arguments here.  We don't care
-        about their actual types (FIXME -- we should remember the whole
-        function prototype), but the list may define some new types
-        that we have to remember, so we must scan it now.  */
+      /* Sun acc puts declared types of arguments here.  */
       if (*p == ';')
        {
-         TYPE_FLAGS (SYMBOL_TYPE (sym)) |= TYPE_FLAG_PROTOTYPED;
+         struct type *ftype = SYMBOL_TYPE (sym);
+         int nsemi = 0;
+         int nparams = 0;
+         char *p1 = p;
+
+         /* Obtain a worst case guess for the number of arguments
+            by counting the semicolons.  */
+         while (*p1)
+           {
+             if (*p1++ == ';')
+               nsemi++;
+           }
 
-         while (*p == ';') {
-           p++;
-           read_type (&p, objfile);
-         }
+         /* Allocate parameter information fields and fill them in. */
+         TYPE_FIELDS (ftype) = (struct field *)
+           TYPE_ALLOC (ftype, nsemi * sizeof (struct field));
+         while (*p++ == ';')
+           {
+             struct type *ptype;
+
+             /* A type number of zero indicates the start of varargs.
+                FIXME: GDB currently ignores vararg functions.  */
+             if (p[0] == '0' && p[1] == '\0')
+               break;
+             ptype = read_type (&p, objfile);
+
+             /* The Sun compilers mark integer arguments, which should
+                be promoted to the width of the calling conventions, with
+                a type which references itself. This type is turned into
+                a TYPE_CODE_VOID type by read_type, and we have to turn
+                it back into builtin_type_int here.
+                FIXME: Do we need a new builtin_type_promoted_int_arg ?  */
+             if (TYPE_CODE (ptype) == TYPE_CODE_VOID)
+               ptype = builtin_type_int;
+             TYPE_FIELD_TYPE (ftype, nparams++) = ptype;
+           }
+         TYPE_NFIELDS (ftype) = nparams;
+         TYPE_FLAGS (ftype) |= TYPE_FLAG_PROTOTYPED;
        }
       break;
 
@@ -1878,7 +1908,7 @@ define_symbol (valu, string, desc, type, objfile)
       SYMBOL_CLASS (sym) = LOC_STATIC;
       SYMBOL_VALUE_ADDRESS (sym) = valu;
 #ifdef STATIC_TRANSFORM_NAME
-      if (SYMBOL_NAME (sym)[0] == '$')
+      if (IS_STATIC_TRANSFORM_NAME (SYMBOL_NAME (sym)))
       {
        struct minimal_symbol *msym;
        msym = lookup_minimal_symbol (SYMBOL_NAME (sym), NULL, objfile);
@@ -2006,7 +2036,7 @@ define_symbol (valu, string, desc, type, objfile)
       SYMBOL_CLASS (sym) = LOC_STATIC;
       SYMBOL_VALUE_ADDRESS (sym) = valu;
 #ifdef STATIC_TRANSFORM_NAME
-      if (SYMBOL_NAME (sym)[0] == '$')
+      if (IS_STATIC_TRANSFORM_NAME (SYMBOL_NAME (sym)))
       {
        struct minimal_symbol *msym;
        msym = lookup_minimal_symbol (SYMBOL_NAME (sym), NULL, objfile);
@@ -2119,7 +2149,7 @@ define_symbol (valu, string, desc, type, objfile)
     }
 
   /* Is there more to parse?  For example LRS/alias information?  */
-  while (*p && (*p == ';' || *p == ','))
+  while (*p && *p == ';')
     {
       p++;
       if (*p && *p == 'l')
@@ -3403,15 +3433,18 @@ read_one_struct_field (fip, pp, p, type, objfile)
         Note that forward refs cannot be packed,
         and treat enums as if they had the width of ints.  */
 
-      if (TYPE_CODE (FIELD_TYPE (fip->list->field)) != TYPE_CODE_INT
-         && TYPE_CODE (FIELD_TYPE (fip->list->field)) != TYPE_CODE_BOOL
-         && TYPE_CODE (FIELD_TYPE (fip->list->field)) != TYPE_CODE_ENUM)
+      struct type *field_type = check_typedef (FIELD_TYPE (fip->list->field));
+
+      if (TYPE_CODE (field_type) != TYPE_CODE_INT
+         && TYPE_CODE (field_type) != TYPE_CODE_RANGE
+         && TYPE_CODE (field_type) != TYPE_CODE_BOOL
+         && TYPE_CODE (field_type) != TYPE_CODE_ENUM)
        {
          FIELD_BITSIZE (fip->list->field) = 0;
        }
       if ((FIELD_BITSIZE (fip->list->field) 
-          == TARGET_CHAR_BIT * TYPE_LENGTH (FIELD_TYPE (fip->list->field))
-          || (TYPE_CODE (FIELD_TYPE (fip->list->field)) == TYPE_CODE_ENUM
+          == TARGET_CHAR_BIT * TYPE_LENGTH (field_type)
+          || (TYPE_CODE (field_type) == TYPE_CODE_ENUM
               && FIELD_BITSIZE (fip->list->field) == TARGET_INT_BIT )
           )
          &&
This page took 0.024628 seconds and 4 git commands to generate.