* configure.in (noconfigdirs) <cris-*-*>: Disable target-newlib
[deliverable/binutils-gdb.git] / gdb / dwarfread.c
index 5c50b991d9a545de95c45604abe13e3b3af0e2cd..0856b899dc54eb7b1e9bd6097d0cca783ca20c29 100644 (file)
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
+/*
+   If you are looking for DWARF-2 support, you are in the wrong file.
+   Go look in dwarf2read.c.  This file is for the original DWARF.
+
+   DWARF (also known as DWARF-1) is headed for obsoletion.
+
+   In gcc 3.2.1, these targets prefer dwarf-1:
+
+     i[34567]86-sequent-ptx4*   # TD-R2
+     i[34567]86-sequent-sysv4*  # TD-R2
+     i[34567]86-dg-dgux*        # obsolete in gcc 3.2.1, to be removed in 3.3
+     m88k-dg-dgux*              # TD-R2
+     mips-sni-sysv4             # TD-R2
+     sparc-hal-solaris2*        # TD-R2
+
+    Configurations marked with "# TD-R2" are on Zach Weinberg's list
+    of "Target Deprecation, Round 2".  This is a candidate list of
+    targets to be deprecated in gcc 3.3 and removed in gcc 3.4.
+
+      http://gcc.gnu.org/ml/gcc/2002-12/msg00702.html
+
+    gcc 2.95.3 had many configurations which prefer dwarf-1.
+    We may have to support dwarf-1 as long as we support gcc 2.95.3.
+    This could use more analysis.
+
+    DG/UX (Data General Unix) used dwarf-1 for its native format.
+    DG/UX uses gcc for its system C compiler, but they have their
+    own linker and their own debuggers.
+
+    Takis Psarogiannakopoulos has a complete gnu toolchain for DG/UX
+    with gcc 2.95.3, gdb 5.1, and debug formats of dwarf-2 and stabs.
+    For more info, see PR gdb/979 and PR gdb/1013; also:
+
+      http://sources.redhat.com/ml/gdb/2003-02/msg00074.html
+
+    There may be non-gcc compilers that still emit dwarf-1.
+
+    -- chastain 2003-02-04
+*/
+
 /*
 
    FIXME: Do we need to generate dependencies in partial symtabs?
@@ -661,7 +701,7 @@ static void
 read_lexical_block_scope (struct dieinfo *dip, char *thisdie, char *enddie,
                          struct objfile *objfile)
 {
-  register struct context_stack *new;
+  struct context_stack *new;
 
   push_context (0, dip->at_low_pc);
   process_dies (thisdie + dip->die_length, enddie, objfile);
@@ -822,7 +862,8 @@ decode_die_type (struct dieinfo *dip)
     }
   else if (dip->at_user_def_type)
     {
-      if ((type = lookup_utype (dip->at_user_def_type)) == NULL)
+      type = lookup_utype (dip->at_user_def_type);
+      if (type == NULL)
        {
          type = alloc_utype (dip->at_user_def_type, NULL);
        }
@@ -876,7 +917,8 @@ struct_type (struct dieinfo *dip, char *thisdie, char *enddie,
   char *nextdie;
   int anonymous_size;
 
-  if ((type = lookup_utype (dip->die_ref)) == NULL)
+  type = lookup_utype (dip->die_ref);
+  if (type == NULL)
     {
       /* No forward references created an empty type, so install one now */
       type = alloc_utype (dip->die_ref, NULL);
@@ -1109,7 +1151,8 @@ decode_array_element_type (char *scan)
   attribute = target_to_host (scan, SIZEOF_ATTRIBUTE, GET_UNSIGNED,
                              current_objfile);
   scan += SIZEOF_ATTRIBUTE;
-  if ((nbytes = attribute_size (attribute)) == -1)
+  nbytes = attribute_size (attribute);
+  if (nbytes == -1)
     {
       bad_array_element_type_complaint (DIE_ID, DIE_NAME, attribute);
       typep = dwarf_fundamental_type (current_objfile, FT_INTEGER);
@@ -1129,7 +1172,8 @@ decode_array_element_type (char *scan)
        case AT_user_def_type:
          die_ref = target_to_host (scan, nbytes, GET_UNSIGNED,
                                    current_objfile);
-         if ((typep = lookup_utype (die_ref)) == NULL)
+         typep = lookup_utype (die_ref);
+         if (typep == NULL)
            {
              typep = alloc_utype (die_ref, NULL);
            }
@@ -1294,14 +1338,16 @@ dwarf_read_array_type (struct dieinfo *dip)
                 "DIE @ 0x%x \"%s\", array not row major; not handled correctly",
                 DIE_ID, DIE_NAME);
     }
-  if ((sub = dip->at_subscr_data) != NULL)
+  sub = dip->at_subscr_data;
+  if (sub != NULL)
     {
       nbytes = attribute_size (AT_subscr_data);
       blocksz = target_to_host (sub, nbytes, GET_UNSIGNED, current_objfile);
       subend = sub + nbytes + blocksz;
       sub += nbytes;
       type = decode_subscript_data_item (sub, subend);
-      if ((utype = lookup_utype (dip->die_ref)) == NULL)
+      utype = lookup_utype (dip->die_ref);
+      if (utype == NULL)
        {
          /* Install user defined type that has not been referenced yet. */
          alloc_utype (dip->die_ref, type);
@@ -1350,7 +1396,8 @@ read_tag_pointer_type (struct dieinfo *dip)
   struct type *utype;
 
   type = decode_die_type (dip);
-  if ((utype = lookup_utype (dip->die_ref)) == NULL)
+  utype = lookup_utype (dip->die_ref);
+  if (utype == NULL)
     {
       utype = lookup_pointer_type (type);
       alloc_utype (dip->die_ref, utype);
@@ -1469,7 +1516,8 @@ read_subroutine_type (struct dieinfo *dip, char *thisdie, char *enddie)
   /* Check to see if we already have a partially constructed user
      defined type for this DIE, from a forward reference. */
 
-  if ((ftype = lookup_utype (dip->die_ref)) == NULL)
+  ftype = lookup_utype (dip->die_ref);
+  if (ftype == NULL)
     {
       /* This is the first reference to one of these types.  Make
          a new one and place it in the user defined types. */
@@ -1549,7 +1597,7 @@ read_enumeration (struct dieinfo *dip, char *thisdie, char *enddie,
    of the enumeration and return a type pointer for the enumeration.
 
    At the same time, for each member of the enumeration, create a
-   symbol for it with namespace VAR_NAMESPACE and class LOC_CONST,
+   symbol for it with domain VAR_DOMAIN and class LOC_CONST,
    and give it the type of the enumeration itself.
 
    NOTES
@@ -1583,7 +1631,8 @@ enum_type (struct dieinfo *dip, struct objfile *objfile)
   int nbytes;
   int unsigned_enum = 1;
 
-  if ((type = lookup_utype (dip->die_ref)) == NULL)
+  type = lookup_utype (dip->die_ref);
+  if (type == NULL)
     {
       /* No forward references created an empty type, so install one now */
       type = alloc_utype (dip->die_ref, NULL);
@@ -1603,7 +1652,8 @@ enum_type (struct dieinfo *dip, struct objfile *objfile)
     {
       TYPE_LENGTH (type) = dip->at_byte_size;
     }
-  if ((scan = dip->at_element_list) != NULL)
+  scan = dip->at_element_list;
+  if (scan != NULL)
     {
       if (dip->short_element_list)
        {
@@ -1636,10 +1686,10 @@ enum_type (struct dieinfo *dip, struct objfile *objfile)
          sym = (struct symbol *) obstack_alloc (&objfile->symbol_obstack,
                                                 sizeof (struct symbol));
          memset (sym, 0, sizeof (struct symbol));
-         SYMBOL_NAME (sym) = create_name (list->field.name,
+         DEPRECATED_SYMBOL_NAME (sym) = create_name (list->field.name,
                                           &objfile->symbol_obstack);
          SYMBOL_INIT_LANGUAGE_SPECIFIC (sym, cu_language);
-         SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
+         SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
          SYMBOL_CLASS (sym) = LOC_CONST;
          SYMBOL_TYPE (sym) = type;
          SYMBOL_VALUE (sym) = FIELD_BITPOS (list->field);
@@ -1694,7 +1744,7 @@ static void
 read_func_scope (struct dieinfo *dip, char *thisdie, char *enddie,
                 struct objfile *objfile)
 {
-  register struct context_stack *new;
+  struct context_stack *new;
 
   /* AT_name is absent if the function is described with an
      AT_abstract_origin tag.
@@ -2298,7 +2348,6 @@ psymtab_to_symtab_1 (struct partial_symtab *pst)
                  wrap_here ("");
                  gdb_flush (gdb_stdout);
                }
-             sort_symtab_syms (pst->symtab);
              do_cleanups (old_chain);
            }
          pst->readin = 1;
@@ -2391,7 +2440,8 @@ add_enum_psymbol (struct dieinfo *dip, struct objfile *objfile)
   unsigned short blocksz;
   int nbytes;
 
-  if ((scan = dip->at_element_list) != NULL)
+  scan = dip->at_element_list;
+  if (scan != NULL)
     {
       if (dip->short_element_list)
        {
@@ -2407,7 +2457,7 @@ add_enum_psymbol (struct dieinfo *dip, struct objfile *objfile)
       while (scan < listend)
        {
          scan += TARGET_FT_LONG_SIZE (objfile);
-         add_psymbol_to_list (scan, strlen (scan), VAR_NAMESPACE, LOC_CONST,
+         add_psymbol_to_list (scan, strlen (scan), VAR_DOMAIN, LOC_CONST,
                               &objfile->static_psymbols, 0, 0, cu_language,
                               objfile);
          scan += strlen (scan) + 1;
@@ -2439,31 +2489,31 @@ add_partial_symbol (struct dieinfo *dip, struct objfile *objfile)
     {
     case TAG_global_subroutine:
       add_psymbol_to_list (dip->at_name, strlen (dip->at_name),
-                          VAR_NAMESPACE, LOC_BLOCK,
+                          VAR_DOMAIN, LOC_BLOCK,
                           &objfile->global_psymbols,
                           0, dip->at_low_pc, cu_language, objfile);
       break;
     case TAG_global_variable:
       add_psymbol_to_list (dip->at_name, strlen (dip->at_name),
-                          VAR_NAMESPACE, LOC_STATIC,
+                          VAR_DOMAIN, LOC_STATIC,
                           &objfile->global_psymbols,
                           0, 0, cu_language, objfile);
       break;
     case TAG_subroutine:
       add_psymbol_to_list (dip->at_name, strlen (dip->at_name),
-                          VAR_NAMESPACE, LOC_BLOCK,
+                          VAR_DOMAIN, LOC_BLOCK,
                           &objfile->static_psymbols,
                           0, dip->at_low_pc, cu_language, objfile);
       break;
     case TAG_local_variable:
       add_psymbol_to_list (dip->at_name, strlen (dip->at_name),
-                          VAR_NAMESPACE, LOC_STATIC,
+                          VAR_DOMAIN, LOC_STATIC,
                           &objfile->static_psymbols,
                           0, 0, cu_language, objfile);
       break;
     case TAG_typedef:
       add_psymbol_to_list (dip->at_name, strlen (dip->at_name),
-                          VAR_NAMESPACE, LOC_TYPEDEF,
+                          VAR_DOMAIN, LOC_TYPEDEF,
                           &objfile->static_psymbols,
                           0, 0, cu_language, objfile);
       break;
@@ -2475,14 +2525,14 @@ add_partial_symbol (struct dieinfo *dip, struct objfile *objfile)
       if (!dip->has_at_byte_size)
        break;
       add_psymbol_to_list (dip->at_name, strlen (dip->at_name),
-                          STRUCT_NAMESPACE, LOC_TYPEDEF,
+                          STRUCT_DOMAIN, LOC_TYPEDEF,
                           &objfile->static_psymbols,
                           0, 0, cu_language, objfile);
       if (cu_language == language_cplus)
        {
          /* For C++, these implicitly act as typedefs as well. */
          add_psymbol_to_list (dip->at_name, strlen (dip->at_name),
-                              VAR_NAMESPACE, LOC_TYPEDEF,
+                              VAR_DOMAIN, LOC_TYPEDEF,
                               &objfile->static_psymbols,
                               0, 0, cu_language, objfile);
        }
@@ -2780,10 +2830,8 @@ new_symbol (struct dieinfo *dip, struct objfile *objfile)
                                             sizeof (struct symbol));
       OBJSTAT (objfile, n_syms++);
       memset (sym, 0, sizeof (struct symbol));
-      SYMBOL_NAME (sym) = create_name (dip->at_name,
-                                      &objfile->symbol_obstack);
       /* default assumptions */
-      SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
+      SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
       SYMBOL_CLASS (sym) = LOC_STATIC;
       SYMBOL_TYPE (sym) = decode_die_type (dip);
 
@@ -2793,7 +2841,7 @@ new_symbol (struct dieinfo *dip, struct objfile *objfile)
          C++ symbol lookups by a factor of about 20. */
 
       SYMBOL_LANGUAGE (sym) = cu_language;
-      SYMBOL_INIT_DEMANGLED_NAME (sym, &objfile->symbol_obstack);
+      SYMBOL_SET_NAMES (sym, dip->at_name, strlen (dip->at_name), objfile);
       switch (dip->die_tag)
        {
        case TAG_label:
@@ -2889,12 +2937,12 @@ new_symbol (struct dieinfo *dip, struct objfile *objfile)
        case TAG_union_type:
        case TAG_enumeration_type:
          SYMBOL_CLASS (sym) = LOC_TYPEDEF;
-         SYMBOL_NAMESPACE (sym) = STRUCT_NAMESPACE;
+         SYMBOL_DOMAIN (sym) = STRUCT_DOMAIN;
          add_symbol_to_list (sym, list_in_scope);
          break;
        case TAG_typedef:
          SYMBOL_CLASS (sym) = LOC_TYPEDEF;
-         SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
+         SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
          add_symbol_to_list (sym, list_in_scope);
          break;
        default:
@@ -2941,12 +2989,12 @@ synthesize_typedef (struct dieinfo *dip, struct objfile *objfile,
        obstack_alloc (&objfile->symbol_obstack, sizeof (struct symbol));
       OBJSTAT (objfile, n_syms++);
       memset (sym, 0, sizeof (struct symbol));
-      SYMBOL_NAME (sym) = create_name (dip->at_name,
+      DEPRECATED_SYMBOL_NAME (sym) = create_name (dip->at_name,
                                       &objfile->symbol_obstack);
       SYMBOL_INIT_LANGUAGE_SPECIFIC (sym, cu_language);
       SYMBOL_TYPE (sym) = type;
       SYMBOL_CLASS (sym) = LOC_TYPEDEF;
-      SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
+      SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
       add_symbol_to_list (sym, list_in_scope);
     }
 }
@@ -3106,7 +3154,8 @@ decode_modified_type (char *modifiers, unsigned int modcount, int mtype)
          nbytes = attribute_size (AT_user_def_type);
          die_ref = target_to_host (modifiers, nbytes, GET_UNSIGNED,
                                    current_objfile);
-         if ((typep = lookup_utype (die_ref)) == NULL)
+         typep = lookup_utype (die_ref);
+         if (typep == NULL)
            {
              typep = alloc_utype (die_ref, NULL);
            }
@@ -3455,7 +3504,8 @@ completedieinfo (struct dieinfo *dip, struct objfile *objfile)
     {
       attr = target_to_host (diep, SIZEOF_ATTRIBUTE, GET_UNSIGNED, objfile);
       diep += SIZEOF_ATTRIBUTE;
-      if ((nbytes = attribute_size (attr)) == -1)
+      nbytes = attribute_size (attr);
+      if (nbytes == -1)
        {
          complaint (&symfile_complaints,
                     "DIE @ 0x%x \"%s\", unknown attribute length, skipped remaining attributes",
This page took 0.051009 seconds and 4 git commands to generate.