Fix arm-epoc-pe build problem:
[deliverable/binutils-gdb.git] / gdb / dwarf2read.c
index 6a617b3c6bc3a8961f1b396d4e0d2cd2d63905c1..b6a340f7f4a7f044c9ec97ee422e782194b4ca38 100644 (file)
@@ -27,7 +27,6 @@
 
 #include "defs.h"
 #include "bfd.h"
-#include "elf-bfd.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "symfile.h"
 #include "buildsym.h"
 #include "demangle.h"
 #include "expression.h"
+
 #include "language.h"
 #include "complaints.h"
-
+#include "bcache.h"
 #include <fcntl.h>
 #include "gdb_string.h"
 #include <sys/types.h>
 
-/* .debug_info header for a compilation unit 
+/* .debug_info header for a compilation unit
    Because of alignment constraints, this structure has padding and cannot
    be mapped directly onto the beginning of the .debug_info section.  */
 typedef struct comp_unit_header
@@ -268,6 +268,11 @@ static struct abbrev_info *dwarf2_abbrevs[ABBREV_HASH_SIZE];
 
 static struct die_info *die_ref_table[REF_HASH_SIZE];
 
+#ifndef TYPE_HASH_SIZE
+#define TYPE_HASH_SIZE 4096
+#endif
+static struct type *dwarf2_cached_types[TYPE_HASH_SIZE];
+
 /* Obstack for allocating temporary storage used during symbol reading.  */
 static struct obstack dwarf2_tmp_obstack;
 
@@ -334,7 +339,7 @@ static int islocal;         /* Variable is at the returned offset
 static int frame_base_reg;
 static CORE_ADDR frame_base_offset;
 
-/* This value is added to each symbol value.  FIXME:  Generalize to 
+/* This value is added to each symbol value.  FIXME:  Generalize to
    the section_offsets structure used by dbxread (once this is done,
    pass the appropriate section number to end_symtab).  */
 static CORE_ADDR baseaddr;     /* Add to each symbol value */
@@ -546,225 +551,201 @@ static struct complaint dwarf2_unsupported_const_value_attr =
    whatever scope is currently getting read. */
 static int address_size;
 
-/* Some elf32 object file formats while linked for a 32 bit address
-   space contain debug information that has assumed 64 bit
-   addresses. Eg 64 bit MIPS target produced by GCC/GAS/LD where the
-   symbol table contains 32bit address values while its .debug_info
-   section contains 64 bit address values.
-   ADDRESS_SIGNIFICANT_SIZE specifies the number significant bits in
-   the ADDRESS_SIZE bytes read from the file */
-static int address_significant_size;
-
 /* Externals references.  */
 extern int info_verbose;       /* From main.c; nonzero => verbose */
 
 /* local function prototypes */
 
-static void dwarf2_locate_sections PARAMS ((bfd *, asection *, PTR));
+static void dwarf2_locate_sections (bfd *, asection *, PTR);
 
 #if 0
-static void dwarf2_build_psymtabs_easy PARAMS ((struct objfile *,
-                                               struct section_offsets *,
-                                               int));
+static void dwarf2_build_psymtabs_easy (struct objfile *, int);
 #endif
 
-static void dwarf2_build_psymtabs_hard PARAMS ((struct objfile *,
-                                               struct section_offsets *,
-                                               int));
+static void dwarf2_build_psymtabs_hard (struct objfile *, int);
+
+static char *scan_partial_symbols (char *, struct objfile *,
+                                  CORE_ADDR *, CORE_ADDR *);
 
-static char *scan_partial_symbols PARAMS ((char *, struct objfile *,
-                                          CORE_ADDR *, CORE_ADDR *));
+static void add_partial_symbol (struct partial_die_info *, struct objfile *);
 
-static void add_partial_symbol PARAMS ((struct partial_die_info *,
-                                       struct objfile *));
+static void dwarf2_psymtab_to_symtab (struct partial_symtab *);
 
-static void dwarf2_psymtab_to_symtab PARAMS ((struct partial_symtab *));
+static void psymtab_to_symtab_1 (struct partial_symtab *);
 
-static void psymtab_to_symtab_1 PARAMS ((struct partial_symtab *));
+static char *dwarf2_read_section (struct objfile *, file_ptr, unsigned int);
 
-static char *dwarf2_read_section PARAMS ((struct objfile *, file_ptr,
-                                         unsigned int));
+static void dwarf2_read_abbrevs (bfd *, unsigned int);
 
-static void dwarf2_read_abbrevs PARAMS ((bfd *, unsigned int));
+static void dwarf2_empty_abbrev_table (PTR);
 
-static void dwarf2_empty_abbrev_table PARAMS ((PTR));
+static struct abbrev_info *dwarf2_lookup_abbrev (unsigned int);
 
-static struct abbrev_info *dwarf2_lookup_abbrev PARAMS ((unsigned int));
+static char *read_partial_die (struct partial_die_info *,
+                              bfd *, char *, int *);
 
-static char *read_partial_die PARAMS ((struct partial_die_info *,
-                                      bfd *, char *, int *));
+static char *read_full_die (struct die_info **, bfd *, char *);
 
-static char *read_full_die PARAMS ((struct die_info **, bfd *, char *));
+static char *read_attribute (struct attribute *, struct attr_abbrev *,
+                            bfd *, char *);
 
-static char *read_attribute PARAMS ((struct attribute *, struct attr_abbrev *,
-                                    bfd *, char *));
+static unsigned int read_1_byte (bfd *, char *);
 
-static unsigned int read_1_byte PARAMS ((bfd *, char *));
+static int read_1_signed_byte (bfd *, char *);
 
-static int read_1_signed_byte PARAMS ((bfd *, char *));
+static unsigned int read_2_bytes (bfd *, char *);
 
-static unsigned int read_2_bytes PARAMS ((bfd *, char *));
+static unsigned int read_4_bytes (bfd *, char *);
 
-static unsigned int read_4_bytes PARAMS ((bfd *, char *));
+static unsigned int read_8_bytes (bfd *, char *);
 
-static unsigned int read_8_bytes PARAMS ((bfd *, char *));
+static CORE_ADDR read_address (bfd *, char *);
 
-static CORE_ADDR read_address PARAMS ((bfd *, char *));
+static char *read_n_bytes (bfd *, char *, unsigned int);
 
-static char *read_n_bytes PARAMS ((bfd *, char *, unsigned int));
+static char *read_string (bfd *, char *, unsigned int *);
 
-static char *read_string PARAMS ((bfd *, char *, unsigned int *));
+static unsigned int read_unsigned_leb128 (bfd *, char *, unsigned int *);
 
-static unsigned int read_unsigned_leb128 PARAMS ((bfd *, char *,
-                                                 unsigned int *));
+static int read_signed_leb128 (bfd *, char *, unsigned int *);
 
-static int read_signed_leb128 PARAMS ((bfd *, char *, unsigned int *));
+static void set_cu_language (unsigned int);
 
-static void set_cu_language PARAMS ((unsigned int));
+static struct attribute *dwarf_attr (struct die_info *, unsigned int);
 
-static struct attribute *dwarf_attr PARAMS ((struct die_info *,
-                                            unsigned int));
+static int die_is_declaration (struct die_info *);
 
-static void dwarf_decode_lines PARAMS ((unsigned int, char *, bfd *));
+static void dwarf_decode_lines (unsigned int, char *, bfd *);
 
-static void dwarf2_start_subfile PARAMS ((char *, char *));
+static void dwarf2_start_subfile (char *, char *);
 
-static struct symbol *new_symbol PARAMS ((struct die_info *, struct type *,
-                                         struct objfile *));
+static struct symbol *new_symbol (struct die_info *, struct type *,
+                                 struct objfile *);
 
-static void dwarf2_const_value PARAMS ((struct attribute *, struct symbol *,
-                                       struct objfile *));
+static void dwarf2_const_value (struct attribute *, struct symbol *,
+                               struct objfile *);
 
-static struct type *die_type PARAMS ((struct die_info *, struct objfile *));
+static void dwarf2_const_value_data (struct attribute *attr,
+                                    struct symbol *sym,
+                                    int bits);
 
-static struct type *die_containing_type PARAMS ((struct die_info *,
-                                                struct objfile *));
+static struct type *die_type (struct die_info *, struct objfile *);
+
+static struct type *die_containing_type (struct die_info *, struct objfile *);
 
 #if 0
-static struct type *type_at_offset PARAMS ((unsigned int, struct objfile *));
+static struct type *type_at_offset (unsigned int, struct objfile *);
 #endif
 
-static struct type *tag_type_to_type PARAMS ((struct die_info *,
-                                             struct objfile *));
+static struct type *tag_type_to_type (struct die_info *, struct objfile *);
 
-static void read_type_die PARAMS ((struct die_info *, struct objfile *));
+static void read_type_die (struct die_info *, struct objfile *);
 
-static void read_typedef PARAMS ((struct die_info *, struct objfile *));
+static void read_typedef (struct die_info *, struct objfile *);
 
-static void read_base_type PARAMS ((struct die_info *, struct objfile *));
+static void read_base_type (struct die_info *, struct objfile *);
 
-static void read_file_scope PARAMS ((struct die_info *, struct objfile *));
+static void read_file_scope (struct die_info *, struct objfile *);
 
-static void read_func_scope PARAMS ((struct die_info *, struct objfile *));
+static void read_func_scope (struct die_info *, struct objfile *);
 
-static void read_lexical_block_scope PARAMS ((struct die_info *,
-                                             struct objfile *));
+static void read_lexical_block_scope (struct die_info *, struct objfile *);
 
-static int dwarf2_get_pc_bounds PARAMS ((struct die_info *,
-                                        CORE_ADDR *, CORE_ADDR *,
-                                        struct objfile *));
+static int dwarf2_get_pc_bounds (struct die_info *,
+                                CORE_ADDR *, CORE_ADDR *, struct objfile *);
 
-static void dwarf2_add_field PARAMS ((struct field_info *, struct die_info *,
-                                     struct objfile *));
+static void dwarf2_add_field (struct field_info *, struct die_info *,
+                             struct objfile *);
 
-static void dwarf2_attach_fields_to_type PARAMS ((struct field_info *,
-                                                 struct type *,
-                                                 struct objfile *));
+static void dwarf2_attach_fields_to_type (struct field_info *,
+                                         struct type *, struct objfile *);
 
-static char *skip_member_fn_name PARAMS ((char *));
+static void dwarf2_add_member_fn (struct field_info *,
+                                 struct die_info *, struct type *,
+                                 struct objfile *objfile);
 
-static void dwarf2_add_member_fn PARAMS ((struct field_info *,
-                                         struct die_info *, struct type *,
-                                         struct objfile * objfile));
+static void dwarf2_attach_fn_fields_to_type (struct field_info *,
+                                            struct type *, struct objfile *);
 
-static void dwarf2_attach_fn_fields_to_type PARAMS ((struct field_info *,
-                                                    struct type *,
-                                                    struct objfile *));
+static void read_structure_scope (struct die_info *, struct objfile *);
 
-static void read_structure_scope PARAMS ((struct die_info *, struct objfile *));
+static void read_common_block (struct die_info *, struct objfile *);
 
-static void read_common_block PARAMS ((struct die_info *, struct objfile *));
+static void read_enumeration (struct die_info *, struct objfile *);
 
-static void read_enumeration PARAMS ((struct die_info *, struct objfile *));
+static struct type *dwarf_base_type (int, int, struct objfile *);
 
-static struct type *dwarf_base_type PARAMS ((int, int, struct objfile *));
+static CORE_ADDR decode_locdesc (struct dwarf_block *, struct objfile *);
 
-static CORE_ADDR decode_locdesc PARAMS ((struct dwarf_block *,
-                                        struct objfile *));
+static void read_array_type (struct die_info *, struct objfile *);
 
-static void read_array_type PARAMS ((struct die_info *, struct objfile *));
+static void read_tag_pointer_type (struct die_info *, struct objfile *);
 
-static void read_tag_pointer_type PARAMS ((struct die_info *,
-                                          struct objfile *));
+static void read_tag_ptr_to_member_type (struct die_info *, struct objfile *);
 
-static void read_tag_ptr_to_member_type PARAMS ((struct die_info *,
-                                                struct objfile *));
+static void read_tag_reference_type (struct die_info *, struct objfile *);
 
-static void read_tag_reference_type PARAMS ((struct die_info *,
-                                            struct objfile *));
+static void read_tag_const_type (struct die_info *, struct objfile *);
 
-static void read_tag_const_type PARAMS ((struct die_info *, struct objfile *));
+static void read_tag_volatile_type (struct die_info *, struct objfile *);
 
-static void read_tag_volatile_type PARAMS ((struct die_info *,
-                                           struct objfile *));
+static void read_tag_string_type (struct die_info *, struct objfile *);
 
-static void read_tag_string_type PARAMS ((struct die_info *,
-                                         struct objfile *));
+static void read_subroutine_type (struct die_info *, struct objfile *);
 
-static void read_subroutine_type PARAMS ((struct die_info *,
-                                         struct objfile *));
+struct die_info *read_comp_unit (char *, bfd *);
 
-struct die_info *read_comp_unit PARAMS ((char *, bfd *));
+static void free_die_list (struct die_info *);
 
-static void free_die_list PARAMS ((struct die_info *));
+static struct cleanup *make_cleanup_free_die_list (struct die_info *);
 
-static void process_die PARAMS ((struct die_info *, struct objfile *));
+static void process_die (struct die_info *, struct objfile *);
 
-static char *dwarf2_linkage_name PARAMS ((struct die_info *));
+static char *dwarf2_linkage_name (struct die_info *);
 
-static char *dwarf_tag_name PARAMS ((unsigned int));
+static char *dwarf_tag_name (unsigned int);
 
-static char *dwarf_attr_name PARAMS ((unsigned int));
+static char *dwarf_attr_name (unsigned int);
 
-static char *dwarf_form_name PARAMS ((unsigned int));
+static char *dwarf_form_name (unsigned int);
 
-static char *dwarf_stack_op_name PARAMS ((unsigned int));
+static char *dwarf_stack_op_name (unsigned int);
 
-static char *dwarf_bool_name PARAMS ((unsigned int));
+static char *dwarf_bool_name (unsigned int);
 
-static char *dwarf_type_encoding_name PARAMS ((unsigned int));
+static char *dwarf_type_encoding_name (unsigned int);
 
 #if 0
-static char *dwarf_cfi_name PARAMS ((unsigned int));
+static char *dwarf_cfi_name (unsigned int);
 
-struct die_info *copy_die PARAMS ((struct die_info *));
+struct die_info *copy_die (struct die_info *);
 #endif
 
-struct die_info *sibling_die PARAMS ((struct die_info *));
+struct die_info *sibling_die (struct die_info *);
 
-void dump_die PARAMS ((struct die_info *));
+void dump_die (struct die_info *);
 
-void dump_die_list PARAMS ((struct die_info *));
+void dump_die_list (struct die_info *);
 
-void store_in_ref_table PARAMS ((unsigned int, struct die_info *));
+void store_in_ref_table (unsigned int, struct die_info *);
 
-static void dwarf2_empty_die_ref_table PARAMS ((void));
+static void dwarf2_empty_die_ref_table (void);
 
-static unsigned int dwarf2_get_ref_die_offset PARAMS ((struct attribute *));
+static unsigned int dwarf2_get_ref_die_offset (struct attribute *);
 
-struct die_info *follow_die_ref PARAMS ((unsigned int));
+struct die_info *follow_die_ref (unsigned int);
 
-static struct type *dwarf2_fundamental_type PARAMS ((struct objfile *, int));
+static struct type *dwarf2_fundamental_type (struct objfile *, int);
 
 /* memory allocation interface */
 
-static void dwarf2_free_tmp_obstack PARAMS ((PTR));
+static void dwarf2_free_tmp_obstack (PTR);
 
-static struct dwarf_block *dwarf_alloc_block PARAMS ((void));
+static struct dwarf_block *dwarf_alloc_block (void);
 
-static struct abbrev_info *dwarf_alloc_abbrev PARAMS ((void));
+static struct abbrev_info *dwarf_alloc_abbrev (void);
 
-static struct die_info *dwarf_alloc_die PARAMS ((void));
+static struct die_info *dwarf_alloc_die (void);
 
 /* Try to locate the sections we need for DWARF 2 debugging
    information and return true if we have enough to do something.  */
@@ -840,9 +821,8 @@ dwarf2_locate_sections (ignore_abfd, sectp, ignore_ptr)
 /* Build a partial symbol table.  */
 
 void
-dwarf2_build_psymtabs (objfile, section_offsets, mainline)
+dwarf2_build_psymtabs (objfile, mainline)
      struct objfile *objfile;
-     struct section_offsets *section_offsets;
      int mainline;
 {
 
@@ -867,17 +847,17 @@ dwarf2_build_psymtabs (objfile, section_offsets, mainline)
 #if 0
   if (dwarf_aranges_offset && dwarf_pubnames_offset)
     {
-      /* Things are significanlty easier if we have .debug_aranges and
+      /* Things are significantly easier if we have .debug_aranges and
          .debug_pubnames sections */
 
-      dwarf2_build_psymtabs_easy (objfile, section_offsets, mainline);
+      dwarf2_build_psymtabs_easy (objfile, mainline);
     }
   else
 #endif
     /* only test this case for now */
     {
       /* In this case we have to work a bit harder */
-      dwarf2_build_psymtabs_hard (objfile, section_offsets, mainline);
+      dwarf2_build_psymtabs_hard (objfile, mainline);
     }
 }
 
@@ -886,9 +866,8 @@ dwarf2_build_psymtabs (objfile, section_offsets, mainline)
    .debug_pubnames and .debug_aranges sections.  */
 
 static void
-dwarf2_build_psymtabs_easy (objfile, section_offsets, mainline)
+dwarf2_build_psymtabs_easy (objfile, mainline)
      struct objfile *objfile;
-     struct section_offsets *section_offsets;
      int mainline;
 {
   bfd *abfd = objfile->obfd;
@@ -923,9 +902,8 @@ dwarf2_build_psymtabs_easy (objfile, section_offsets, mainline)
    .debug_info and .debug_abbrev sections.  */
 
 static void
-dwarf2_build_psymtabs_hard (objfile, section_offsets, mainline)
+dwarf2_build_psymtabs_hard (objfile, mainline)
      struct objfile *objfile;
-     struct section_offsets *section_offsets;
      int mainline;
 {
   /* Instead of reading this into a big buffer, we should probably use
@@ -940,9 +918,6 @@ dwarf2_build_psymtabs_hard (objfile, section_offsets, mainline)
   int comp_unit_has_pc_info;
   CORE_ADDR lowpc, highpc;
 
-  /* Number of bytes of any addresses that are signficant */
-  address_significant_size = get_elf_backend_data (abfd)->s->arch_size / 8;
-
   info_ptr = dwarf_info_buffer;
   abbrev_ptr = dwarf_abbrev_buffer;
 
@@ -983,13 +958,6 @@ dwarf2_build_psymtabs_hard (objfile, section_offsets, mainline)
                 (long) (beg_of_comp_unit - dwarf_info_buffer));
          return;
        }
-      if (address_size < address_significant_size)
-       {
-         error ("Dwarf Error: bad address size (%ld) in compilation unit header (offset 0x%lx + 11).",
-                (long) cu_header.addr_size,
-                (long) (beg_of_comp_unit - dwarf_info_buffer));
-       }
-
       /* Read the abbrevs for this compilation unit into a table */
       dwarf2_read_abbrevs (abfd, cu_header.abbrev_offset);
       make_cleanup (dwarf2_empty_abbrev_table, NULL);
@@ -1002,7 +970,7 @@ dwarf2_build_psymtabs_hard (objfile, section_offsets, mainline)
       set_cu_language (comp_unit_die.language);
 
       /* Allocate a new partial symbol table structure */
-      pst = start_psymtab_common (objfile, section_offsets,
+      pst = start_psymtab_common (objfile, objfile->section_offsets,
                                  comp_unit_die.name ? comp_unit_die.name : "",
                                  comp_unit_die.lowpc,
                                  objfile->global_psymbols.next,
@@ -1016,7 +984,7 @@ dwarf2_build_psymtabs_hard (objfile, section_offsets, mainline)
       DWARF_ABBREV_BUFFER (pst) = dwarf_abbrev_buffer;
       DWARF_ABBREV_SIZE (pst) = dwarf_abbrev_size;
       DWARF_LINE_BUFFER (pst) = dwarf_line_buffer;
-      baseaddr = ANOFFSET (section_offsets, 0);
+      baseaddr = ANOFFSET (objfile->section_offsets, 0);
 
       /* Store the function that reads in the rest of the symbol table */
       pst->read_symtab = dwarf2_psymtab_to_symtab;
@@ -1076,7 +1044,7 @@ scan_partial_symbols (info_ptr, objfile, lowpc, highpc)
   int nesting_level = 1;
   int has_pc_info;
 
-  *lowpc = ((CORE_ADDR) - 1);
+  *lowpc = ((CORE_ADDR) -1);
   *highpc = ((CORE_ADDR) 0);
 
   while (nesting_level)
@@ -1156,7 +1124,7 @@ scan_partial_symbols (info_ptr, objfile, lowpc, highpc)
 
   /* If we didn't find a lowpc, set it to highpc to avoid complaints
      from `maint check'.  */
-  if (*lowpc == ((CORE_ADDR) - 1))
+  if (*lowpc == ((CORE_ADDR) -1))
     *lowpc = *highpc;
   return info_ptr;
 }
@@ -1345,7 +1313,7 @@ psymtab_to_symtab_1 (pst)
 
   dies = read_comp_unit (info_ptr, abfd);
 
-  make_cleanup ((make_cleanup_func) free_die_list, dies);
+  make_cleanup_free_die_list (dies);
 
   /* Do line number decoding in read_file_scope () */
   process_die (dies, objfile);
@@ -1468,7 +1436,7 @@ read_file_scope (die, objfile)
      struct objfile *objfile;
 {
   unsigned int line_offset = 0;
-  CORE_ADDR lowpc = ((CORE_ADDR) - 1);
+  CORE_ADDR lowpc = ((CORE_ADDR) -1);
   CORE_ADDR highpc = ((CORE_ADDR) 0);
   struct attribute *attr;
   char *name = "<unknown>";
@@ -1500,7 +1468,7 @@ read_file_scope (die, objfile)
 
   /* If we didn't find a lowpc, set it to highpc to avoid complaints
      from finish_block.  */
-  if (lowpc == ((CORE_ADDR) - 1))
+  if (lowpc == ((CORE_ADDR) -1))
     lowpc = highpc;
   lowpc += baseaddr;
   highpc += baseaddr;
@@ -1604,12 +1572,6 @@ read_func_scope (die, objfile)
       objfile->ei.entry_func_highpc = highpc;
     }
 
-  if (STREQ (name, "main"))    /* FIXME: hardwired name */
-    {
-      objfile->ei.main_func_lowpc = lowpc;
-      objfile->ei.main_func_highpc = highpc;
-    }
-
   /* Decode DW_AT_frame_base location descriptor if present, keep result
      for DW_OP_fbreg operands in decode_locdesc.  */
   frame_base_reg = -1;
@@ -1861,23 +1823,17 @@ dwarf2_add_field (fip, die, objfile)
   else if (die->tag == DW_TAG_variable)
     {
       char *physname;
-      char *cp;
 
       /* C++ static member.
-         Get physical name, extract field name from physical name.  */
-      physname = dwarf2_linkage_name (die);
-      if (physname == NULL)
+        Get name of field.  */
+      attr = dwarf_attr (die, DW_AT_name);
+      if (attr && DW_STRING (attr))
+       fieldname = DW_STRING (attr);
+      else
        return;
 
-      cp = physname;
-      while (*cp && !is_cplus_marker (*cp))
-       cp++;
-      if (*cp)
-       fieldname = cp + 1;
-      if (*fieldname == '\0')
-       {
-         complain (&dwarf2_bad_static_member_name, physname);
-       }
+      /* Get physical name.  */
+      physname = dwarf2_linkage_name (die);
 
       SET_FIELD_PHYSNAME (*fp, obsavestring (physname, strlen (physname),
                                             &objfile->type_obstack));
@@ -1987,37 +1943,6 @@ dwarf2_attach_fields_to_type (fip, type, objfile)
     }
 }
 
-/* Skip to the end of a member function name in a mangled name.  */
-
-static char *
-skip_member_fn_name (physname)
-     char *physname;
-{
-  char *endname = physname;
-
-  /* Skip over leading underscores.  */
-  while (*endname == '_')
-    endname++;
-
-  /* Find two succesive underscores.  */
-  do
-    endname = strchr (endname, '_');
-  while (endname != NULL && *++endname != '_');
-
-  if (endname == NULL)
-    {
-      complain (&dwarf2_bad_member_name_complaint, physname);
-      endname = physname;
-    }
-  else
-    {
-      /* Take care of trailing underscores.  */
-      if (endname[1] != '_')
-       endname--;
-    }
-  return endname;
-}
-
 /* Add a member function to the proper fieldlist.  */
 
 static void
@@ -2035,46 +1960,15 @@ dwarf2_add_member_fn (fip, die, type, objfile)
   char *physname;
   struct nextfnfield *new_fnfield;
 
-  /* Extract member function name from mangled name.  */
-  physname = dwarf2_linkage_name (die);
-  if (physname == NULL)
-    return;
-  if ((physname[0] == '_' && physname[1] == '_'
-       && strchr ("0123456789Qt", physname[2]))
-      || DESTRUCTOR_PREFIX_P (physname))
-    {
-      /* Constructor and destructor field names are set to the name
-         of the class, but without template parameter lists.
-         The name might be missing for anonymous aggregates.  */
-      if (TYPE_TAG_NAME (type))
-       {
-         char *p = strchr (TYPE_TAG_NAME (type), '<');
-
-         if (p == NULL)
-           fieldname = TYPE_TAG_NAME (type);
-         else
-           fieldname = obsavestring (TYPE_TAG_NAME (type),
-                                     p - TYPE_TAG_NAME (type),
-                                     &objfile->type_obstack);
-       }
-      else
-       {
-         char *anon_name = "";
-         fieldname = obsavestring (anon_name, strlen (anon_name),
-                                   &objfile->type_obstack);
-       }
-    }
+  /* Get name of member function.  */
+  attr = dwarf_attr (die, DW_AT_name);
+  if (attr && DW_STRING (attr))
+    fieldname = DW_STRING (attr);
   else
-    {
-      char *endname = skip_member_fn_name (physname);
+    return;
 
-      /* Ignore member function if we were unable not extract the member
-         function name.  */
-      if (endname == physname)
-       return;
-      fieldname = obsavestring (physname, endname - physname,
-                               &objfile->type_obstack);
-    }
+  /* Get the mangled name.  */
+  physname = dwarf2_linkage_name (die);
 
   /* Look up member function name in fieldlist.  */
   for (i = 0; i < fip->nfnfields; i++)
@@ -2095,8 +1989,7 @@ dwarf2_add_member_fn (fip, die, type, objfile)
                      (fip->nfnfields + DW_FIELD_ALLOC_CHUNK)
                      * sizeof (struct fnfieldlist));
          if (fip->nfnfields == 0)
-           make_cleanup ((make_cleanup_func) free_current_contents,
-                         &fip->fnfieldlists);
+           make_cleanup (free_current_contents, &fip->fnfieldlists);
        }
       flp = &fip->fnfieldlists[fip->nfnfields];
       flp->name = fieldname;
@@ -2281,7 +2174,7 @@ read_structure_scope (die, objfile)
      type within the structure itself. */
   die->type = type;
 
-  if (die->has_children)
+  if (die->has_children && ! die_is_declaration (die))
     {
       struct field_info fi;
       struct die_info *child_die;
@@ -2603,8 +2496,7 @@ read_array_type (die, objfile)
                xrealloc (range_types, (ndim + DW_FIELD_ALLOC_CHUNK)
                          * sizeof (struct type *));
              if (ndim == 0)
-               make_cleanup ((make_cleanup_func) free_current_contents,
-                             &range_types);
+               make_cleanup (free_current_contents, &range_types);
            }
          range_types[ndim++] = create_range_type (NULL, index_type, low, high);
        }
@@ -3055,6 +2947,19 @@ free_die_list (dies)
     }
 }
 
+static void
+do_free_die_list_cleanup (void *dies)
+{
+  free_die_list (dies);
+}
+
+static struct cleanup *
+make_cleanup_free_die_list (struct die_info *dies)
+{
+  return make_cleanup (do_free_die_list_cleanup, dies);
+}
+
+
 /* Read the contents of the section at OFFSET and of size SIZE from the
    object file specified by OBJFILE into the psymbol_obstack and return it.  */
 
@@ -3564,6 +3469,9 @@ read_address (abfd, buf)
 
   switch (address_size)
     {
+    case 2:
+      retval = bfd_get_16 (abfd, (bfd_byte *) buf);
+      break;
     case 4:
       retval = bfd_get_32 (abfd, (bfd_byte *) buf);
       break;
@@ -3574,17 +3482,8 @@ read_address (abfd, buf)
       /* *THE* alternative is 8, right? */
       abort ();
     }
-  /* If the address being read is larger than the address that is
-     applicable for the object file format then mask it down to the
-     correct size.  Take care to avoid unnecessary shift or shift
-     overflow */
-  if (address_size > address_significant_size
-      && address_significant_size < sizeof (CORE_ADDR))
-    {
-      CORE_ADDR mask = ((CORE_ADDR) 0) - 1;
-      retval &= ~(mask << (address_significant_size * 8));
-    }
-  return retval;
+
+ return retval;
 }
 
 static char *
@@ -3779,6 +3678,13 @@ dwarf_attr (die, name)
   return NULL;
 }
 
+static int
+die_is_declaration (struct die_info *die)
+{
+  return (dwarf_attr (die, DW_AT_declaration)
+         && ! dwarf_attr (die, DW_AT_specification));
+}
+
 /* Decode the line number information for the compilation unit whose
    line number info is at OFFSET in the .debug_line section.
    The compilation directory of the file is passed in COMP_DIR.  */
@@ -3856,8 +3762,7 @@ dwarf_decode_lines (offset, comp_dir, abfd)
   line_ptr += 1;
   lh.standard_opcode_lengths = (unsigned char *)
     xmalloc (lh.opcode_base * sizeof (unsigned char));
-  back_to = make_cleanup ((make_cleanup_func) free_current_contents,
-                         &lh.standard_opcode_lengths);
+  back_to = make_cleanup (free_current_contents, &lh.standard_opcode_lengths);
 
   lh.standard_opcode_lengths[0] = 1;
   for (i = 1; i < lh.opcode_base; ++i)
@@ -3876,7 +3781,7 @@ dwarf_decode_lines (offset, comp_dir, abfd)
            xrealloc (dirs.dirs,
                      (dirs.num_dirs + DIR_ALLOC_CHUNK) * sizeof (char *));
          if (dirs.num_dirs == 0)
-           make_cleanup ((make_cleanup_func) free_current_contents, &dirs.dirs);
+           make_cleanup (free_current_contents, &dirs.dirs);
        }
       dirs.dirs[dirs.num_dirs++] = cur_dir;
     }
@@ -3893,8 +3798,7 @@ dwarf_decode_lines (offset, comp_dir, abfd)
                      (files.num_files + FILE_ALLOC_CHUNK)
                      * sizeof (struct fileinfo));
          if (files.num_files == 0)
-           make_cleanup ((make_cleanup_func) free_current_contents,
-                         &files.files);
+           make_cleanup (free_current_contents, &files.files);
        }
       files.files[files.num_files].name = cur_file;
       files.files[files.num_files].dir =
@@ -3969,8 +3873,7 @@ dwarf_decode_lines (offset, comp_dir, abfd)
                                  (files.num_files + FILE_ALLOC_CHUNK)
                                  * sizeof (struct fileinfo));
                      if (files.num_files == 0)
-                       make_cleanup ((make_cleanup_func) free_current_contents,
-                                     &files.files);
+                       make_cleanup (free_current_contents, &files.files);
                    }
                  files.files[files.num_files].name = cur_file;
                  files.files[files.num_files].dir =
@@ -4023,8 +3926,14 @@ dwarf_decode_lines (offset, comp_dir, abfd)
            case DW_LNS_set_basic_block:
              basic_block = 1;
              break;
+           /* Add to the address register of the state machine the
+              address increment value corresponding to special opcode
+              255.  Ie, this value is scaled by the minimum instruction
+              length since special opcode 255 would have scaled the
+              the increment.  */
            case DW_LNS_const_add_pc:
-             address += (255 - lh.opcode_base) / lh.line_range;
+             address += (lh.minimum_instruction_length
+                         * ((255 - lh.opcode_base) / lh.line_range));
              break;
            case DW_LNS_fixed_advance_pc:
              address += read_2_bytes (abfd, line_ptr);
@@ -4057,9 +3966,9 @@ done:
 
    DW_AT_name:          /srcdir/list0.c
    DW_AT_comp_dir:              /compdir
-   files.files[0].name: list0.h         
+   files.files[0].name: list0.h
    files.files[0].dir:  /srcdir
-   files.files[1].name: list0.c         
+   files.files[1].name: list0.c
    files.files[1].dir:  /srcdir
 
    The line number information for list0.c has to end up in a single
@@ -4096,8 +4005,7 @@ dwarf2_start_subfile (filename, dirname)
    to make a symbol table entry for it, and if so, create a new entry
    and return a pointer to it.
    If TYPE is NULL, determine symbol type from the die, otherwise
-   used the passed type.
- */
+   used the passed type.  */
 
 static struct symbol *
 new_symbol (die, type, objfile)
@@ -4384,15 +4292,35 @@ dwarf2_const_value (attr, sym, objfile)
       memcpy (SYMBOL_VALUE_BYTES (sym), blk->data, blk->size);
       SYMBOL_CLASS (sym) = LOC_CONST_BYTES;
       break;
+
+      /* The DW_AT_const_value attributes are supposed to carry the
+        symbol's value "represented as it would be on the target
+        architecture."  By the time we get here, it's already been
+        converted to host endianness, so we just need to sign- or
+        zero-extend it as appropriate.  */
+    case DW_FORM_data1:
+      dwarf2_const_value_data (attr, sym, 8);
+      break;
     case DW_FORM_data2:
+      dwarf2_const_value_data (attr, sym, 16);
+      break;
     case DW_FORM_data4:
+      dwarf2_const_value_data (attr, sym, 32);
+      break;
     case DW_FORM_data8:
-    case DW_FORM_data1:
+      dwarf2_const_value_data (attr, sym, 64);
+      break;
+
     case DW_FORM_sdata:
+      SYMBOL_VALUE (sym) = DW_SND (attr);
+      SYMBOL_CLASS (sym) = LOC_CONST;
+      break;
+
     case DW_FORM_udata:
       SYMBOL_VALUE (sym) = DW_UNSND (attr);
       SYMBOL_CLASS (sym) = LOC_CONST;
       break;
+
     default:
       complain (&dwarf2_unsupported_const_value_attr,
                dwarf_form_name (attr->form));
@@ -4402,6 +4330,29 @@ dwarf2_const_value (attr, sym, objfile)
     }
 }
 
+
+/* Given an attr with a DW_FORM_dataN value in host byte order, sign-
+   or zero-extend it as appropriate for the symbol's type.  */
+static void
+dwarf2_const_value_data (struct attribute *attr,
+                        struct symbol *sym,
+                        int bits)
+{
+  LONGEST l = DW_UNSND (attr);
+
+  if (bits < sizeof (l) * 8)
+    {
+      if (TYPE_UNSIGNED (SYMBOL_TYPE (sym)))
+       l &= ((LONGEST) 1 << bits) - 1;
+      else
+       l = (l << (sizeof (l) * 8 - bits)) >> (sizeof (l) * 8 - bits);
+    }
+
+  SYMBOL_VALUE (sym) = l;
+  SYMBOL_CLASS (sym) = LOC_CONST;
+}
+
+
 /* Return the type of the die in question using its DW_AT_type attribute.  */
 
 static struct type *
@@ -4504,7 +4455,38 @@ tag_type_to_type (die, objfile)
     }
   else
     {
-      read_type_die (die, objfile);
+      struct attribute *attr;
+      attr = dwarf_attr (die, DW_AT_name);
+      if (attr && DW_STRING (attr))
+       {
+         char *attrname=DW_STRING (attr);
+         unsigned long hashval=hash(attrname, strlen(attrname)) % TYPE_HASH_SIZE;
+
+         if (dwarf2_cached_types[hashval] != NULL)
+           {
+             const char *nameoftype;
+             nameoftype = TYPE_NAME(dwarf2_cached_types[hashval]) == NULL ? TYPE_TAG_NAME(dwarf2_cached_types[hashval]) : TYPE_NAME(dwarf2_cached_types[hashval]);
+             if (strcmp(attrname, nameoftype) == 0)
+               {
+                 die->type=dwarf2_cached_types[hashval];
+               }
+             else
+               {
+                 read_type_die (die, objfile);
+                 dwarf2_cached_types[hashval] = die->type;
+               }
+           }
+         else
+           {
+             read_type_die (die, objfile);
+             dwarf2_cached_types[hashval] = die->type;
+           }
+       }
+      else
+       {
+         read_type_die (die, objfile);
+       }
+
       if (!die->type)
        {
          dump_die (die);
@@ -5780,6 +5762,14 @@ decode_locdesc (blk, objfile)
          i += bytes_read;
          break;
 
+       case DW_OP_bregx:
+         offreg = 1;
+         basereg = read_unsigned_leb128 (NULL, (data + i), &bytes_read);
+         i += bytes_read;
+         stack[++stacki] = read_signed_leb128 (NULL, (data + i), &bytes_read);
+         i += bytes_read;
+         break;
+
        case DW_OP_fbreg:
          stack[++stacki] = read_signed_leb128 (NULL, (data + i), &bytes_read);
          i += bytes_read;
This page took 0.038096 seconds and 4 git commands to generate.