2004-02-14 Elena Zannoni <ezannoni@redhat.com>
[deliverable/binutils-gdb.git] / gdb / dwarfread.c
index 38b5d927de6138660c77d8f3795e9bda41dcd220..c245108c08eb48ef47ce281192fa9b2019a42343 100644 (file)
@@ -1,7 +1,7 @@
 /* DWARF debugging format support for GDB.
 
    Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+   2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
 
    Written by Fred Fish at Cygnus Support.  Portions based on dbxread.c,
    mipsread.c, coffread.c, and dwarfread.c from a Data General SVR4 gdb port.
 
 /*
    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
+   Go look in dwarf2read.c.  This file is for the original DWARF,
+   also known as DWARF-1.
+
+   DWARF-1 is slowly headed for obsoletion.
+
+   In gcc HEAD 2003-11-29 16:28:31 UTC, no targets prefer dwarf-1.
+
+   In gcc 3.3.2, these targets prefer dwarf-1:
+
+     i[34567]86-sequent-ptx4*
+     i[34567]86-sequent-sysv4*
+     mips-sni-sysv4
+     sparc-hal-solaris2*
+
+   In gcc 3.2.2, these targets prefer dwarf-1:
+
+     i[34567]86-dg-dgux*
+     i[34567]86-sequent-ptx4*
+     i[34567]86-sequent-sysv4*
+     m88k-dg-dgux*
+     mips-sni-sysv4
+     sparc-hal-solaris2*
+
+   In gcc 2.95.3, these targets prefer dwarf-1:
+
+     i[34567]86-dg-dgux*
+     i[34567]86-ncr-sysv4*
+     i[34567]86-sequent-ptx4*
+     i[34567]86-sequent-sysv4*
+     i[34567]86-*-osf1*
+     i[34567]86-*-sco3.2v5*
+     i[34567]86-*-sysv4*
+     i860-alliant-*
+     i860-*-sysv4*
+     m68k-atari-sysv4*
+     m68k-cbm-sysv4*
+     m68k-*-sysv4*
+     m88k-dg-dgux*
+     m88k-*-sysv4*
+     mips-sni-sysv4
+     mips-*-gnu*
+     sh-*-elf*
+     sh-*-rtemself*
+     sparc-hal-solaris2*
+     sparc-*-sysv4*
+
+   Some non-gcc compilers produce dwarf-1: 
+
+     PR gdb/1179 was from a user with Diab C++ 4.3.
+     Other users have also reported using Diab compilers with dwarf-1.
+     On 2003-06-09 the gdb list received a report from a user
+       with Absoft ProFortran f77 which is dwarf-1.
+
+   -- chastain 2003-12-01
 */
 
 /*
 #include "defs.h"
 #include "symtab.h"
 #include "gdbtypes.h"
-#include "symfile.h"
 #include "objfiles.h"
 #include "elf/dwarf.h"
 #include "buildsym.h"
@@ -950,7 +967,7 @@ struct_type (struct dieinfo *dip, char *thisdie, char *enddie,
       && *dip->at_name != '~'
       && *dip->at_name != '.')
     {
-      TYPE_TAG_NAME (type) = obconcat (&objfile->type_obstack,
+      TYPE_TAG_NAME (type) = obconcat (&objfile->objfile_obstack,
                                       "", "", dip->at_name);
     }
   /* Use whatever size is known.  Zero is a valid size.  We might however
@@ -979,6 +996,13 @@ struct_type (struct dieinfo *dip, char *thisdie, char *enddie,
       switch (mbr.die_tag)
        {
        case TAG_member:
+         /* Static fields can be either TAG_global_variable (GCC) or else
+            TAG_member with no location (Diab).  We could treat the latter like
+            the former... but since we don't support the former, just avoid
+            crashing on the latter for now.  */
+         if (mbr.at_location == NULL)
+           break;
+
          /* Get space to record the next field's data.  */
          new = (struct nextfield *) alloca (sizeof (struct nextfield));
          new->next = list;
@@ -986,7 +1010,7 @@ struct_type (struct dieinfo *dip, char *thisdie, char *enddie,
          /* Save the data.  */
          list->field.name =
            obsavestring (mbr.at_name, strlen (mbr.at_name),
-                         &objfile->type_obstack);
+                         &objfile->objfile_obstack);
          FIELD_TYPE (list->field) = decode_die_type (&mbr);
          FIELD_BITPOS (list->field) = 8 * locval (&mbr);
          FIELD_STATIC_KIND (list->field) = 0;
@@ -1645,7 +1669,7 @@ enum_type (struct dieinfo *dip, struct objfile *objfile)
       && *dip->at_name != '~'
       && *dip->at_name != '.')
     {
-      TYPE_TAG_NAME (type) = obconcat (&objfile->type_obstack,
+      TYPE_TAG_NAME (type) = obconcat (&objfile->objfile_obstack,
                                       "", "", dip->at_name);
     }
   if (dip->at_byte_size != 0)
@@ -1679,15 +1703,15 @@ enum_type (struct dieinfo *dip, struct objfile *objfile)
                            objfile);
          scan += TARGET_FT_LONG_SIZE (objfile);
          list->field.name = obsavestring (scan, strlen (scan),
-                                          &objfile->type_obstack);
+                                          &objfile->objfile_obstack);
          scan += strlen (scan) + 1;
          nfields++;
          /* Handcraft a new symbol for this enum member. */
-         sym = (struct symbol *) obstack_alloc (&objfile->symbol_obstack,
+         sym = (struct symbol *) obstack_alloc (&objfile->objfile_obstack,
                                                 sizeof (struct symbol));
          memset (sym, 0, sizeof (struct symbol));
          DEPRECATED_SYMBOL_NAME (sym) = create_name (list->field.name,
-                                          &objfile->symbol_obstack);
+                                          &objfile->objfile_obstack);
          SYMBOL_INIT_LANGUAGE_SPECIFIC (sym, cu_language);
          SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
          SYMBOL_CLASS (sym) = LOC_CONST;
@@ -1708,7 +1732,7 @@ enum_type (struct dieinfo *dip, struct objfile *objfile)
            TYPE_FLAGS (type) |= TYPE_FLAG_UNSIGNED;
          TYPE_NFIELDS (type) = nfields;
          TYPE_FIELDS (type) = (struct field *)
-           obstack_alloc (&objfile->symbol_obstack, sizeof (struct field) * nfields);
+           obstack_alloc (&objfile->objfile_obstack, sizeof (struct field) * nfields);
          /* Copy the saved-up fields into the field vector.  */
          for (n = 0; (n < nfields) && (list != NULL); list = list->next)
            {
@@ -1795,7 +1819,7 @@ handle_producer (char *producer)
   /* If this compilation unit was compiled with g++ or gcc, then set the
      processing_gcc_compilation flag. */
 
-  if (STREQN (producer, GCC_PRODUCER, strlen (GCC_PRODUCER)))
+  if (DEPRECATED_STREQN (producer, GCC_PRODUCER, strlen (GCC_PRODUCER)))
     {
       char version = producer[strlen (GCC_PRODUCER)];
       processing_gcc_compilation = (version == '2' ? 2 : 1);
@@ -1803,7 +1827,7 @@ handle_producer (char *producer)
   else
     {
       processing_gcc_compilation =
-       STREQN (producer, GPLUS_PRODUCER, strlen (GPLUS_PRODUCER));
+       strncmp (producer, GPLUS_PRODUCER, strlen (GPLUS_PRODUCER)) == 0;
     }
 
   /* Select a demangling style if we can identify the producer and if
@@ -1813,7 +1837,7 @@ handle_producer (char *producer)
 
   if (AUTO_DEMANGLING)
     {
-      if (STREQN (producer, GPLUS_PRODUCER, strlen (GPLUS_PRODUCER)))
+      if (DEPRECATED_STREQN (producer, GPLUS_PRODUCER, strlen (GPLUS_PRODUCER)))
        {
 #if 0
          /* For now, stay with AUTO_DEMANGLING for g++ output, as we don't
@@ -1821,7 +1845,7 @@ handle_producer (char *producer)
          set_demangling_style (GNU_DEMANGLING_STYLE_STRING);
 #endif
        }
-      else if (STREQN (producer, LCC_PRODUCER, strlen (LCC_PRODUCER)))
+      else if (DEPRECATED_STREQN (producer, LCC_PRODUCER, strlen (LCC_PRODUCER)))
        {
          set_demangling_style (LUCID_DEMANGLING_STYLE_STRING);
        }
@@ -1861,8 +1885,8 @@ read_file_scope (struct dieinfo *dip, char *thisdie, char *enddie,
   if (objfile->ei.entry_point >= dip->at_low_pc &&
       objfile->ei.entry_point < dip->at_high_pc)
     {
-      objfile->ei.entry_file_lowpc = dip->at_low_pc;
-      objfile->ei.entry_file_highpc = dip->at_high_pc;
+      objfile->ei.deprecated_entry_file_lowpc = dip->at_low_pc;
+      objfile->ei.deprecated_entry_file_highpc = dip->at_high_pc;
     }
   set_cu_language (dip);
   if (dip->at_producer != NULL)
@@ -2348,7 +2372,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;
@@ -2776,7 +2799,7 @@ scan_compilation_units (char *thisdie, char *enddie, file_ptr dbfoff,
 
          pst->texthigh = di.at_high_pc;
          pst->read_symtab_private = (char *)
-           obstack_alloc (&objfile->psymbol_obstack,
+           obstack_alloc (&objfile->objfile_obstack,
                           sizeof (struct dwfinfo));
          DBFOFF (pst) = dbfoff;
          DBROFF (pst) = curoff;
@@ -2827,7 +2850,7 @@ new_symbol (struct dieinfo *dip, struct objfile *objfile)
 
   if (dip->at_name != NULL)
     {
-      sym = (struct symbol *) obstack_alloc (&objfile->symbol_obstack,
+      sym = (struct symbol *) obstack_alloc (&objfile->objfile_obstack,
                                             sizeof (struct symbol));
       OBJSTAT (objfile, n_syms++);
       memset (sym, 0, sizeof (struct symbol));
@@ -2987,11 +3010,11 @@ synthesize_typedef (struct dieinfo *dip, struct objfile *objfile,
   if (dip->at_name != NULL)
     {
       sym = (struct symbol *)
-       obstack_alloc (&objfile->symbol_obstack, sizeof (struct symbol));
+       obstack_alloc (&objfile->objfile_obstack, sizeof (struct symbol));
       OBJSTAT (objfile, n_syms++);
       memset (sym, 0, sizeof (struct symbol));
       DEPRECATED_SYMBOL_NAME (sym) = create_name (dip->at_name,
-                                      &objfile->symbol_obstack);
+                                      &objfile->objfile_obstack);
       SYMBOL_INIT_LANGUAGE_SPECIFIC (sym, cu_language);
       SYMBOL_TYPE (sym) = type;
       SYMBOL_CLASS (sym) = LOC_TYPEDEF;
@@ -3192,8 +3215,12 @@ decode_modified_type (char *modifiers, unsigned int modcount, int mtype)
                     DIE_ID, DIE_NAME); /* FIXME */
          break;
        default:
-         if (!(MOD_lo_user <= (unsigned char) modifier
+         if (!(MOD_lo_user <= (unsigned char) modifier))
+#if 0
+/* This part of the test would always be true, and it triggers a compiler
+   warning.  */
                && (unsigned char) modifier <= MOD_hi_user))
+#endif
            {
              complaint (&symfile_complaints,
                         "DIE @ 0x%x \"%s\", unknown type modifier %u", DIE_ID,
This page took 0.028373 seconds and 4 git commands to generate.