gdb/testsuite: don't use source tree as temporary HOME directory
[binutils-gdb.git] / gdb / symfile.c
index d2ea04ed14963d6e132e48106fe0d6acda17ba30..5defc22870d66b8913c611c60a3e26897ed0252d 100644 (file)
@@ -838,10 +838,8 @@ init_entry_point_info (struct objfile *objfile)
 
       /* Make certain that the address points at real code, and not a
         function descriptor.  */
-      entry_point
-       = gdbarch_convert_from_func_ptr_addr (objfile->arch (),
-                                             entry_point,
-                                             current_top_target ());
+      entry_point = gdbarch_convert_from_func_ptr_addr
+       (objfile->arch (), entry_point, current_inferior ()->top_target ());
 
       /* Remove any ISA markers, so that this matches entries in the
         symbol table.  */
@@ -902,8 +900,7 @@ syms_from_objfile_1 (struct objfile *objfile,
   const int mainline = add_flags & SYMFILE_MAINLINE;
 
   objfile_set_sym_fns (objfile, find_sym_fns (objfile->obfd));
-  objfile->reset_psymtabs ();
-  objfile->qf = make_psymbol_functions (objfile->partial_symtabs);
+  objfile->qf.clear ();
 
   if (objfile->sf == NULL)
     {
@@ -2552,8 +2549,7 @@ reread_symbols (void)
             based on whether .gdb_index is present, and we need it to
             start over.  PR symtab/15885  */
          objfile_set_sym_fns (objfile, find_sym_fns (objfile->obfd));
-         objfile->reset_psymtabs ();
-         objfile->qf = make_psymbol_functions (objfile->partial_symtabs);
+         objfile->qf.clear ();
 
          build_objfile_section_table (objfile);
 
@@ -2774,16 +2770,15 @@ allocate_symtab (struct compunit_symtab *cust, const char *filename)
     {
       /* Be a bit clever with debugging messages, and don't print objfile
         every time, only when it changes.  */
-      static char *last_objfile_name = NULL;
+      static std::string last_objfile_name;
+      const char *this_objfile_name = objfile_name (objfile);
 
-      if (last_objfile_name == NULL
-         || strcmp (last_objfile_name, objfile_name (objfile)) != 0)
+      if (last_objfile_name.empty () || last_objfile_name != this_objfile_name)
        {
-         xfree (last_objfile_name);
-         last_objfile_name = xstrdup (objfile_name (objfile));
+         last_objfile_name = this_objfile_name;
          fprintf_filtered (gdb_stdlog,
                            "Creating one or more symtabs for objfile %s ...\n",
-                           last_objfile_name);
+                           this_objfile_name);
        }
       fprintf_filtered (gdb_stdlog,
                        "Created symtab %s for module %s.\n",
@@ -3721,19 +3716,25 @@ symfile_free_objfile (struct objfile *objfile)
    Expand all symtabs that match the specified criteria.
    See quick_symbol_functions.expand_symtabs_matching for details.  */
 
-void
+bool
 expand_symtabs_matching
   (gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher,
    const lookup_name_info &lookup_name,
    gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
    gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
+   block_search_flags search_flags,
    enum search_domain kind)
 {
   for (objfile *objfile : current_program_space->objfiles ())
-    objfile->expand_symtabs_matching (file_matcher,
-                                     &lookup_name,
-                                     symbol_matcher,
-                                     expansion_notify, kind);
+    if (!objfile->expand_symtabs_matching (file_matcher,
+                                          &lookup_name,
+                                          symbol_matcher,
+                                          expansion_notify,
+                                          search_flags,
+                                          UNDEF_DOMAIN,
+                                          kind))
+      return false;
+  return true;
 }
 
 /* Wrapper around the quick_symbol_functions map_symbol_filenames "method".
@@ -3741,11 +3742,11 @@ expand_symtabs_matching
    See quick_symbol_functions.map_symbol_filenames for details.  */
 
 void
-map_symbol_filenames (symbol_filename_ftype *fun, void *data,
-                     int need_fullname)
+map_symbol_filenames (gdb::function_view<symbol_filename_ftype> fun,
+                     bool need_fullname)
 {
   for (objfile *objfile : current_program_space->objfiles ())
-    objfile->map_symbol_filenames (fun, data, need_fullname);
+    objfile->map_symbol_filenames (fun, need_fullname);
 }
 
 #if GDB_SELF_TEST
@@ -3813,7 +3814,7 @@ _initialize_symfile ()
 {
   struct cmd_list_element *c;
 
-  gdb::observers::free_objfile.attach (symfile_free_objfile);
+  gdb::observers::free_objfile.attach (symfile_free_objfile, "symfile");
 
 #define READNOW_READNEVER_HELP \
   "The '-readnow' option will cause GDB to read the entire symbol file\n\