gdb/
[deliverable/binutils-gdb.git] / gdb / dwarf2read.c
index e4f7b942d90477ee9bcdf12ff3f5c1e965257760..9e8c01b67fd46a0165bbf3fb4d1874dfef5ee94e 100644 (file)
@@ -67,6 +67,7 @@
 #include <ctype.h>
 #include "gdb_bfd.h"
 #include "f-lang.h"
+#include "source.h"
 
 #include <fcntl.h>
 #include "gdb_string.h"
@@ -89,12 +90,6 @@ static int check_physname = 0;
 /* When non-zero, do not reject deprecated .gdb_index sections.  */
 static int use_deprecated_index_sections = 0;
 
-/* When set, the file that we're processing is known to have debugging
-   info for C++ namespaces.  GCC 3.3.x did not produce this information,
-   but later versions do.  */
-
-static int processing_has_namespace_info;
-
 static const struct objfile_data *dwarf2_objfile_data_key;
 
 struct dwarf2_section_info
@@ -508,6 +503,12 @@ struct dwarf2_cu
   unsigned int producer_is_gxx_lt_4_6 : 1;
   unsigned int producer_is_gcc_lt_4_3 : 1;
   unsigned int producer_is_icc : 1;
+
+  /* When set, the file that we're processing is known to have
+     debugging info for C++ namespaces.  GCC 3.3.x did not produce
+     this information, but later versions do.  */
+
+  unsigned int processing_has_namespace_info : 1;
 };
 
 /* Persistent data held for a compilation unit, even when not
@@ -3020,8 +3021,7 @@ dw2_forget_cached_source_info (struct objfile *objfile)
 static int
 dw2_map_expand_apply (struct objfile *objfile,
                      struct dwarf2_per_cu_data *per_cu,
-                     const char *name,
-                     const char *full_path, const char *real_path,
+                     const char *name, const char *real_path,
                      int (*callback) (struct symtab *, void *),
                      void *data)
 {
@@ -3035,7 +3035,7 @@ dw2_map_expand_apply (struct objfile *objfile,
      all of them.  */
   dw2_instantiate_symtab (per_cu);
 
-  return iterate_over_some_symtabs (name, full_path, real_path, callback, data,
+  return iterate_over_some_symtabs (name, real_path, callback, data,
                                    objfile->symtabs, last_made);
 }
 
@@ -3043,13 +3043,12 @@ dw2_map_expand_apply (struct objfile *objfile,
 
 static int
 dw2_map_symtabs_matching_filename (struct objfile *objfile, const char *name,
-                                  const char *full_path, const char *real_path,
+                                  const char *real_path,
                                   int (*callback) (struct symtab *, void *),
                                   void *data)
 {
   int i;
   const char *name_basename = lbasename (name);
-  int is_abs = IS_ABSOLUTE_PATH (name);
 
   dw2_setup (objfile);
 
@@ -3074,11 +3073,9 @@ dw2_map_symtabs_matching_filename (struct objfile *objfile, const char *name,
        {
          const char *this_name = file_data->file_names[j];
 
-         if (FILENAME_CMP (name, this_name) == 0
-             || (!is_abs && compare_filenames_for_search (this_name, name)))
+         if (compare_filenames_for_search (this_name, name))
            {
-             if (dw2_map_expand_apply (objfile, per_cu,
-                                       name, full_path, real_path,
+             if (dw2_map_expand_apply (objfile, per_cu, name, real_path,
                                        callback, data))
                return 1;
            }
@@ -3089,37 +3086,17 @@ dw2_map_symtabs_matching_filename (struct objfile *objfile, const char *name,
              && FILENAME_CMP (lbasename (this_name), name_basename) != 0)
            continue;
 
-         if (full_path != NULL)
-           {
-             const char *this_real_name = dw2_get_real_path (objfile,
-                                                             file_data, j);
-
-             if (this_real_name != NULL
-                 && (FILENAME_CMP (full_path, this_real_name) == 0
-                     || (!is_abs
-                         && compare_filenames_for_search (this_real_name,
-                                                          name))))
-               {
-                 if (dw2_map_expand_apply (objfile, per_cu,
-                                           name, full_path, real_path,
-                                           callback, data))
-                   return 1;
-               }
-           }
-
          if (real_path != NULL)
            {
              const char *this_real_name = dw2_get_real_path (objfile,
                                                              file_data, j);
 
+             gdb_assert (IS_ABSOLUTE_PATH (real_path));
+             gdb_assert (IS_ABSOLUTE_PATH (name));
              if (this_real_name != NULL
-                 && (FILENAME_CMP (real_path, this_real_name) == 0
-                     || (!is_abs
-                         && compare_filenames_for_search (this_real_name,
-                                                          name))))
+                 && FILENAME_CMP (real_path, this_real_name) == 0)
                {
-                 if (dw2_map_expand_apply (objfile, per_cu,
-                                           name, full_path, real_path,
+                 if (dw2_map_expand_apply (objfile, per_cu, name, real_path,
                                            callback, data))
                    return 1;
                }
@@ -3367,8 +3344,8 @@ dw2_expand_all_symtabs (struct objfile *objfile)
 }
 
 static void
-dw2_expand_symtabs_with_filename (struct objfile *objfile,
-                                 const char *filename)
+dw2_expand_symtabs_with_fullname (struct objfile *objfile,
+                                 const char *fullname)
 {
   int i;
 
@@ -3395,8 +3372,9 @@ dw2_expand_symtabs_with_filename (struct objfile *objfile,
 
       for (j = 0; j < file_data->num_file_names; ++j)
        {
-         const char *this_name = file_data->file_names[j];
-         if (FILENAME_CMP (this_name, filename) == 0)
+         const char *this_fullname = file_data->file_names[j];
+
+         if (filename_cmp (this_fullname, fullname) == 0)
            {
              dw2_instantiate_symtab (per_cu);
              break;
@@ -3447,7 +3425,10 @@ dw2_find_symbol_file (struct objfile *objfile, const char *name)
          struct symbol *sym = lookup_block_symbol (block, name, VAR_DOMAIN);
 
          if (sym)
-           return SYMBOL_SYMTAB (sym)->filename;
+           {
+             /* Only file extension of returned filename is recognized.  */
+             return SYMBOL_SYMTAB (sym)->filename;
+           }
        }
       return NULL;
     }
@@ -3464,11 +3445,15 @@ dw2_find_symbol_file (struct objfile *objfile, const char *name)
   per_cu = dw2_get_cu (GDB_INDEX_CU_VALUE (MAYBE_SWAP (vec[1])));
 
   if (per_cu->v.quick->symtab != NULL)
-    return per_cu->v.quick->symtab->filename;
+    {
+      /* Only file extension of returned filename is recognized.  */
+      return per_cu->v.quick->symtab->filename;
+    }
 
   init_cutu_and_read_dies (per_cu, NULL, 0, 0,
                           dw2_get_primary_filename_reader, &filename);
 
+  /* Only file extension of returned filename is recognized.  */
   return filename;
 }
 
@@ -3488,7 +3473,7 @@ dw2_map_matching_symbols (const char * name, domain_enum namespace,
 static void
 dw2_expand_symtabs_matching
   (struct objfile *objfile,
-   int (*file_matcher) (const char *, void *),
+   int (*file_matcher) (const char *, void *, int basenames),
    int (*name_matcher) (const char *, void *),
    enum search_domain kind,
    void *data)
@@ -3548,7 +3533,7 @@ dw2_expand_symtabs_matching
 
          for (j = 0; j < file_data->num_file_names; ++j)
            {
-             if (file_matcher (file_data->file_names[j], data))
+             if (file_matcher (file_data->file_names[j], data, 0))
                {
                  per_cu->v.quick->mark = 1;
                  break;
@@ -3767,7 +3752,7 @@ const struct quick_symbol_functions dwarf2_gdb_index_functions =
   dw2_relocate,
   dw2_expand_symtabs_for_function,
   dw2_expand_all_symtabs,
-  dw2_expand_symtabs_with_filename,
+  dw2_expand_symtabs_with_fullname,
   dw2_find_symbol_file,
   dw2_map_matching_symbols,
   dw2_expand_symtabs_matching,
@@ -4069,6 +4054,12 @@ dwarf2_create_include_psymtab (char *name, struct partial_symtab *pst,
 {
   struct partial_symtab *subpst = allocate_psymtab (name, objfile);
 
+  if (!IS_ABSOLUTE_PATH (subpst->filename))
+    {
+      /* It shares objfile->objfile_obstack.  */
+      subpst->dirname = pst->dirname;
+    }
+
   subpst->section_offsets = pst->section_offsets;
   subpst->textlow = 0;
   subpst->texthigh = 0;
@@ -6762,7 +6753,7 @@ compute_delayed_physnames (struct dwarf2_cu *cu)
       const char *physname;
       struct fn_fieldlist *fn_flp
        = &TYPE_FN_FIELDLIST (mi->type, mi->fnfield_index);
-      physname = dwarf2_physname ((char *) mi->name, mi->die, cu);
+      physname = dwarf2_physname (mi->name, mi->die, cu);
       fn_flp->fn_fields[mi->index].physname = physname ? physname : "";
     }
 }
@@ -6806,7 +6797,7 @@ fixup_go_packaging (struct dwarf2_cu *cu)
                    complaint (&symfile_complaints,
                               _("Symtab %s has objects from two different Go packages: %s and %s"),
                               (SYMBOL_SYMTAB (sym)
-                               ? SYMBOL_SYMTAB (sym)->filename
+                         ? symtab_to_filename_for_display (SYMBOL_SYMTAB (sym))
                                : cu->objfile->name),
                               this_package_name, package_name);
                  xfree (this_package_name);
@@ -7229,16 +7220,16 @@ process_die (struct die_info *die, struct dwarf2_cu *cu)
     case DW_TAG_common_inclusion:
       break;
     case DW_TAG_namespace:
-      processing_has_namespace_info = 1;
+      cu->processing_has_namespace_info = 1;
       read_namespace (die, cu);
       break;
     case DW_TAG_module:
-      processing_has_namespace_info = 1;
+      cu->processing_has_namespace_info = 1;
       read_module (die, cu);
       break;
     case DW_TAG_imported_declaration:
     case DW_TAG_imported_module:
-      processing_has_namespace_info = 1;
+      cu->processing_has_namespace_info = 1;
       if (die->child != NULL && (die->tag == DW_TAG_imported_declaration
                                 || cu->language != language_fortran))
        complaint (&symfile_complaints, _("Tag '%s' has unexpected children"),
@@ -9240,7 +9231,6 @@ free_dwo_file (struct dwo_file *dwo_file, struct objfile *objfile)
   int ix;
   struct dwarf2_section_info *section;
 
-  gdb_assert (dwo_file->dbfd != objfile->obfd);
   gdb_bfd_unref (dwo_file->dbfd);
 
   VEC_free (dwarf2_section_info_def, dwo_file->sections.types);
@@ -9565,7 +9555,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
 
   /* For C++, set the block's scope.  */
   if ((cu->language == language_cplus || cu->language == language_fortran)
-      && processing_has_namespace_info)
+      && cu->processing_has_namespace_info)
     block_set_scope (block, determine_prefix (die, cu),
                     &objfile->objfile_obstack);
 
@@ -9809,7 +9799,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
                         "physname, for referencing DIE 0x%x [in module %s]"),
                       die->offset.sect_off, objfile->name);
          else
-           SET_FIELD_PHYSNAME (call_site->target, (char *) target_physname);
+           SET_FIELD_PHYSNAME (call_site->target, target_physname);
        }
       else
        {
@@ -11255,7 +11245,7 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu)
        {
          /* The name is already allocated along with this objfile, so
             we don't need to duplicate it for the type.  */
-         TYPE_TAG_NAME (type) = (char *) name;
+         TYPE_TAG_NAME (type) = name;
          if (die->tag == DW_TAG_class_type)
            TYPE_NAME (type) = TYPE_TAG_NAME (type);
        }
@@ -11558,7 +11548,7 @@ read_enumeration_type (struct die_info *die, struct dwarf2_cu *cu)
   TYPE_CODE (type) = TYPE_CODE_ENUM;
   name = dwarf2_full_name (NULL, die, cu);
   if (name != NULL)
-    TYPE_TAG_NAME (type) = (char *) name;
+    TYPE_TAG_NAME (type) = name;
 
   attr = dwarf2_attr (die, DW_AT_byte_size, cu);
   if (attr)
@@ -12071,7 +12061,7 @@ read_namespace_type (struct die_info *die, struct dwarf2_cu *cu)
   /* Create the type.  */
   type = init_type (TYPE_CODE_NAMESPACE, 0, 0, NULL,
                    objfile);
-  TYPE_NAME (type) = (char *) name;
+  TYPE_NAME (type) = name;
   TYPE_TAG_NAME (type) = TYPE_NAME (type);
 
   return set_die_type (die, type, cu);
@@ -12271,6 +12261,15 @@ read_tag_ptr_to_member_type (struct die_info *die, struct dwarf2_cu *cu)
 
   if (TYPE_CODE (check_typedef (to_type)) == TYPE_CODE_METHOD)
     type = lookup_methodptr_type (to_type);
+  else if (TYPE_CODE (check_typedef (to_type)) == TYPE_CODE_FUNC)
+    {
+      struct type *new_type = alloc_type (cu->objfile);
+
+      smash_to_method_type (new_type, domain, TYPE_TARGET_TYPE (to_type),
+                           TYPE_FIELDS (to_type), TYPE_NFIELDS (to_type),
+                           TYPE_VARARGS (to_type));
+      type = lookup_methodptr_type (new_type);
+    }
   else
     type = lookup_memberptr_type (to_type, domain);
 
@@ -12595,7 +12594,7 @@ read_typedef (struct die_info *die, struct dwarf2_cu *cu)
   name = dwarf2_full_name (NULL, die, cu);
   this_type = init_type (TYPE_CODE_TYPEDEF, 0,
                         TYPE_FLAG_TARGET_STUB, NULL, objfile);
-  TYPE_NAME (this_type) = (char *) name;
+  TYPE_NAME (this_type) = name;
   set_die_type (die, this_type, cu);
   target_type = die_type (die, cu);
   if (target_type != this_type)
@@ -15665,7 +15664,7 @@ dwarf2_start_symtab (struct dwarf2_cu *cu,
   /* We assume that we're processing GCC output.  */
   processing_gcc_compilation = 2;
 
-  processing_has_namespace_info = 0;
+  cu->processing_has_namespace_info = 0;
 }
 
 static void
@@ -16110,7 +16109,7 @@ new_symbol_full (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 
       /* For the benefit of old versions of GCC, check for anonymous
         namespaces based on the demangled name.  */
-      if (!processing_has_namespace_info
+      if (!cu->processing_has_namespace_info
          && cu->language == language_cplus)
        cp_scan_for_anonymous_namespaces (sym, objfile);
     }
This page took 0.032721 seconds and 4 git commands to generate.