#include "gdb_bfd.h"
#include "cli/cli-utils.h"
#include "common/byte-vector.h"
-#include "selftest.h"
+#include "common/pathstuff.h"
+#include "common/selftest.h"
#include "cli/cli-style.h"
#include "common/forward-scope-exit.h"
const char *dir_notarget = target_prefix ? dir + strlen ("target:") : dir;
std::vector<gdb::unique_xmalloc_ptr<char>> debugdir_vec
= dirnames_to_char_ptr_vec (debug_file_directory);
+ gdb::unique_xmalloc_ptr<char> canon_sysroot = gdb_realpath (gdb_sysroot);
for (const gdb::unique_xmalloc_ptr<char> &debugdir : debugdir_vec)
{
if (separate_debug_file_exists (debugfile, crc32, objfile))
return debugfile;
- /* If the file is in the sysroot, try using its base path in the
- global debugfile directory. */
- if (canon_dir != NULL
- && filename_ncmp (canon_dir, gdb_sysroot,
- strlen (gdb_sysroot)) == 0
- && IS_DIR_SEPARATOR (canon_dir[strlen (gdb_sysroot)]))
+ const char *base_path = NULL;
+ if (canon_dir != NULL)
{
+ if (canon_sysroot.get () != NULL)
+ base_path = child_path (canon_sysroot.get (), canon_dir);
+ else
+ base_path = child_path (gdb_sysroot, canon_dir);
+ }
+ if (base_path != NULL)
+ {
+ /* If the file is in the sysroot, try using its base path in
+ the global debugfile directory. */
+ debugfile = target_prefix ? "target:" : "";
+ debugfile += debugdir.get ();
+ debugfile += "/";
+ debugfile += base_path;
+ debugfile += "/";
+ debugfile += debuglink;
+
+ if (separate_debug_file_exists (debugfile, crc32, objfile))
+ return debugfile;
+
+ /* If the file is in the sysroot, try using its base path in
+ the sysroot's global debugfile directory. */
debugfile = target_prefix ? "target:" : "";
+ debugfile += gdb_sysroot;
debugfile += debugdir.get ();
- debugfile += (canon_dir + strlen (gdb_sysroot));
+ debugfile += "/";
+ debugfile += base_path;
debugfile += "/";
debugfile += debuglink;
if (separate_debug_file_exists (debugfile, crc32, objfile))
return debugfile;
}
+
}
return std::string ();
void
reread_symbols (void)
{
- struct objfile *objfile;
long new_modtime;
struct stat new_statbuf;
int res;
std::vector<struct objfile *> new_objfiles;
- /* With the addition of shared libraries, this should be modified,
- the load time should be saved in the partial symbol tables, since
- different tables may come from different source files. FIXME.
- This routine should then walk down each partial symbol table
- and see if the symbol table that it originates from has been changed. */
-
- for (objfile = object_files; objfile; objfile = objfile->next)
+ for (objfile *objfile : current_program_space->objfiles ())
{
if (objfile->obfd == NULL)
continue;
objfile->sections = NULL;
objfile->compunit_symtabs = NULL;
objfile->template_symbols = NULL;
- objfile->static_links = NULL;
+ objfile->static_links.reset (nullptr);
/* obstack_init also initializes the obstack so it is
empty. We could use obstack_specify_allocation but
objfile_set_sym_fns (objfile, find_sym_fns (objfile->obfd));
build_objfile_section_table (objfile);
- terminate_minimal_symbol_table (objfile);
/* We use the same section offsets as from last time. I'm not
sure whether that is always correct for shared libraries. */
= OBSTACK_ZALLOC (&objfile->objfile_obstack, struct symtab);
symtab->filename
- = (const char *) bcache (filename, strlen (filename) + 1,
- objfile->per_bfd->filename_cache);
+ = ((const char *) objfile->per_bfd->filename_cache.insert
+ (filename, strlen (filename) + 1));
symtab->fullname = NULL;
symtab->language = deduce_language_from_filename (filename);
clear_pc_function_cache ();
gdb::observers::new_objfile.notify (NULL);
- /* Clear globals which might have pointed into a removed objfile.
- FIXME: It's not clear which of these are supposed to persist
- between expressions and which ought to be reset each time. */
- expression_context_block = NULL;
- innermost_block.reset ();
-
/* Varobj may refer to old symbols, perform a cleanup. */
varobj_invalidate ();