* psymtab.c (PSYMTAB_TO_SYMTAB): Remove.
[deliverable/binutils-gdb.git] / gdb / psymtab.c
index 1f9457f7e3bb6bc0116f60490dd198909094311b..5fb8ad4887ec4e2aa386f3e1172441868f3fa812 100644 (file)
@@ -45,10 +45,6 @@ struct psymbol_bcache
   struct bcache *bcache;
 };
 
-/* A fast way to get from a psymtab to its symtab (after the first time).  */
-#define PSYMTAB_TO_SYMTAB(pst)  \
-    ((pst) -> symtab != NULL ? (pst) -> symtab : psymtab_to_symtab (pst))
-
 static struct partial_symbol *match_partial_symbol (struct partial_symtab *,
                                                    int,
                                                    const char *, domain_enum,
@@ -164,10 +160,14 @@ partial_map_symtabs_matching_filename (struct objfile *objfile,
 {
   struct partial_symtab *pst;
   const char *name_basename = lbasename (name);
+  int name_len = strlen (name);
+  int is_abs = IS_ABSOLUTE_PATH (name);
 
   ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, pst)
   {
-    if (FILENAME_CMP (name, pst->filename) == 0)
+    if (FILENAME_CMP (name, pst->filename) == 0
+       || (!is_abs && compare_filenames_for_search (pst->filename,
+                                                    name, name_len)))
       {
        if (partial_map_expand_apply (objfile, name, full_path, real_path,
                                      pst, callback, data))
@@ -186,7 +186,9 @@ partial_map_symtabs_matching_filename (struct objfile *objfile,
       {
        psymtab_to_fullname (pst);
        if (pst->fullname != NULL
-           && FILENAME_CMP (full_path, pst->fullname) == 0)
+           && (FILENAME_CMP (full_path, pst->fullname) == 0
+               || (!is_abs && compare_filenames_for_search (pst->fullname,
+                                                            name, name_len))))
          {
            if (partial_map_expand_apply (objfile, name, full_path, real_path,
                                          pst, callback, data))
@@ -203,7 +205,10 @@ partial_map_symtabs_matching_filename (struct objfile *objfile,
             rp = gdb_realpath (pst->fullname);
             make_cleanup (xfree, rp);
           }
-       if (rp != NULL && FILENAME_CMP (real_path, rp) == 0)
+       if (rp != NULL
+           && (FILENAME_CMP (real_path, rp) == 0
+               || (!is_abs && compare_filenames_for_search (real_path,
+                                                            name, name_len))))
          {
            if (partial_map_expand_apply (objfile, name, full_path, real_path,
                                          pst, callback, data))
@@ -212,17 +217,6 @@ partial_map_symtabs_matching_filename (struct objfile *objfile,
       }
   }
 
-  /* Now, search for a matching tail (only if name doesn't have any dirs).  */
-
-  if (name_basename == name)
-    ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, pst)
-    {
-      if (FILENAME_CMP (lbasename (pst->filename), name) == 0)
-       if (partial_map_expand_apply (objfile, name, full_path, real_path, pst,
-                                     callback, data))
-         return 1;
-    }
-
   return 0;
 }
 
@@ -394,7 +388,7 @@ find_pc_sect_symtab_from_partial (struct objfile *objfile,
        warning (_("\
 (Internal error: pc %s in read in psymtab, but not in symtab.)\n"),
                 paddress (get_objfile_arch (ps->objfile), pc));
-      return PSYMTAB_TO_SYMTAB (ps);
+      return psymtab_to_symtab (ps);
     }
   return NULL;
 }
@@ -512,7 +506,7 @@ lookup_symbol_aux_psymtabs (struct objfile *objfile,
     if (!ps->readin && lookup_partial_symbol (ps, name, psymtab_index, domain))
       {
        struct symbol *sym = NULL;
-       struct symtab *stab = PSYMTAB_TO_SYMTAB (ps);
+       struct symtab *stab = psymtab_to_symtab (ps);
 
        /* Some caution must be observed with overloaded functions
           and methods, since the psymtab will not contain any overload
@@ -761,9 +755,7 @@ lookup_partial_symbol (struct partial_symtab *pst, const char *name,
 }
 
 /* Get the symbol table that corresponds to a partial_symtab.
-   This is fast after the first time you do it.  In fact, there
-   is an even faster macro PSYMTAB_TO_SYMTAB that does the fast
-   case inline.  */
+   This is fast after the first time you do it.  */
 
 static struct symtab *
 psymtab_to_symtab (struct partial_symtab *pst)
@@ -843,7 +835,7 @@ find_last_source_symtab_from_partial (struct objfile *ofp)
                          "readin pst found and no symtabs."));
        }
       else
-       return PSYMTAB_TO_SYMTAB (cs_pst);
+       return psymtab_to_symtab (cs_pst);
     }
   return NULL;
 }
@@ -1106,7 +1098,7 @@ read_psymtabs_with_filename (struct objfile *objfile, const char *filename)
   ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, p)
     {
       if (filename_cmp (filename, p->filename) == 0)
-       PSYMTAB_TO_SYMTAB (p);
+       psymtab_to_symtab (p);
     }
 }
 
@@ -1133,10 +1125,6 @@ map_symbol_filenames_psymtab (struct objfile *objfile,
     }
 }
 
-int find_and_open_source (const char *filename,
-                         const char *dirname,
-                         char **fullname);
-
 /* Finds the fullname that a partial_symtab represents.
 
    If this functions finds the fullname, it will save it in ps->fullname
@@ -1233,7 +1221,7 @@ map_matching_symbols_psymtab (const char *name, domain_enum namespace,
          || match_partial_symbol (ps, global, name, namespace, match,
                                   ordered_compare))
        {
-         struct symtab *s = PSYMTAB_TO_SYMTAB (ps);
+         struct symtab *s = psymtab_to_symtab (ps);
          struct block *block;
 
          if (s == NULL || !s->primary)
@@ -1252,7 +1240,7 @@ static void
 expand_symtabs_matching_via_partial
   (struct objfile *objfile,
    int (*file_matcher) (const char *, void *),
-   int (*name_matcher) (const struct language_defn *, const char *, void *),
+   int (*name_matcher) (const char *, void *),
    enum search_domain kind,
    void *data)
 {
@@ -1304,10 +1292,9 @@ expand_symtabs_matching_via_partial
                       && SYMBOL_CLASS (*psym) == LOC_BLOCK)
                   || (kind == TYPES_DOMAIN
                       && SYMBOL_CLASS (*psym) == LOC_TYPEDEF))
-                 && (*name_matcher) (current_language,
-                                     SYMBOL_SEARCH_NAME (*psym), data))
+                 && (*name_matcher) (SYMBOL_SEARCH_NAME (*psym), data))
                {
-                 PSYMTAB_TO_SYMTAB (ps);
+                 psymtab_to_symtab (ps);
                  keep_going = 0;
                }
            }
@@ -1569,18 +1556,7 @@ append_psymbol_to_list (struct psymbol_allocation_list *list,
    Since one arg is a struct, we pass in a ptr and deref it (sigh).
    Return the partial symbol that has been added.  */
 
-/* NOTE: carlton/2003-09-11: The reason why we return the partial
-   symbol is so that callers can get access to the symbol's demangled
-   name, which they don't have any cheap way to determine otherwise.
-   (Currenly, dwarf2read.c is the only file who uses that information,
-   though it's possible that other readers might in the future.)
-   Elena wasn't thrilled about that, and I don't blame her, but we
-   couldn't come up with a better way to get that information.  If
-   it's needed in other situations, we could consider breaking up
-   SYMBOL_SET_NAMES to provide access to the demangled name lookup
-   cache.  */
-
-const struct partial_symbol *
+void
 add_psymbol_to_list (const char *name, int namelength, int copy_name,
                     domain_enum domain,
                     enum address_class class,
@@ -1600,11 +1576,10 @@ add_psymbol_to_list (const char *name, int namelength, int copy_name,
   /* Do not duplicate global partial symbols.  */
   if (list == &objfile->global_psymbols
       && !added)
-    return psym;
+    return;
 
   /* Save pointer to partial symbol in psymtab, growing symtab if needed.  */
   append_psymbol_to_list (list, psym, objfile);
-  return psym;
 }
 
 /* Initialize storage for partial symbols.  */
@@ -1874,7 +1849,7 @@ maintenance_check_symtabs (char *ignore, int from_tty)
   {
     struct gdbarch *gdbarch = get_objfile_arch (objfile);
 
-    s = PSYMTAB_TO_SYMTAB (ps);
+    s = psymtab_to_symtab (ps);
     if (s == NULL)
       continue;
     bv = BLOCKVECTOR (s);
@@ -1945,8 +1920,7 @@ maintenance_check_symtabs (char *ignore, int from_tty)
 \f
 
 void
-expand_partial_symbol_names (int (*fun) (const struct language_defn *,
-                                        const char *, void *),
+expand_partial_symbol_names (int (*fun) (const char *, void *),
                             void *data)
 {
   struct objfile *objfile;
This page took 0.026485 seconds and 4 git commands to generate.