X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Fsymfile.c;h=13a07e4dc0e57eff06680b25d921c5009dc20e07;hb=268a13a5a3f7c6b9b6ffc5ac2d1b24eb41f3fbdc;hp=61483824f63409b6fbf0fbd91908add235e35e9b;hpb=f62318e98d84e79e457920c74515fb73bb013b23;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/symfile.c b/gdb/symfile.c index 61483824f6..13a07e4dc0 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -56,11 +56,11 @@ #include "stack.h" #include "gdb_bfd.h" #include "cli/cli-utils.h" -#include "common/byte-vector.h" -#include "common/pathstuff.h" -#include "common/selftest.h" +#include "gdbsupport/byte-vector.h" +#include "gdbsupport/pathstuff.h" +#include "gdbsupport/selftest.h" #include "cli/cli-style.h" -#include "common/forward-scope-exit.h" +#include "gdbsupport/forward-scope-exit.h" #include #include @@ -1443,11 +1443,33 @@ find_separate_debug_file (const char *dir, = dirnames_to_char_ptr_vec (debug_file_directory); gdb::unique_xmalloc_ptr canon_sysroot = gdb_realpath (gdb_sysroot); + /* MS-Windows/MS-DOS don't allow colons in file names; we must + convert the drive letter into a one-letter directory, so that the + file name resulting from splicing below will be valid. + + FIXME: The below only works when GDB runs on MS-Windows/MS-DOS. + There are various remote-debugging scenarios where such a + transformation of the drive letter might be required when GDB runs + on a Posix host, see + + https://sourceware.org/ml/gdb-patches/2019-04/msg00605.html + + If some of those scenarions need to be supported, we will need to + use a different condition for HAS_DRIVE_SPEC and a different macro + instead of STRIP_DRIVE_SPEC, which work on Posix systems as well. */ + std::string drive; + if (HAS_DRIVE_SPEC (dir_notarget)) + { + drive = dir_notarget[0]; + dir_notarget = STRIP_DRIVE_SPEC (dir_notarget); + } + for (const gdb::unique_xmalloc_ptr &debugdir : debugdir_vec) { debugfile = target_prefix ? "target:" : ""; debugfile += debugdir.get (); debugfile += "/"; + debugfile += drive; debugfile += dir_notarget; debugfile += debuglink; @@ -1650,7 +1672,19 @@ symbol_file_command (const char *args, int from_tty) validate_readnow_readnever (flags); + /* Set SYMFILE_DEFER_BP_RESET because the proper displacement for a PIE + (Position Independent Executable) main symbol file will only be + computed by the solib_create_inferior_hook below. Without it, + breakpoint_re_set would fail to insert the breakpoints with the zero + displacement. */ + add_flags |= SYMFILE_DEFER_BP_RESET; + symbol_file_add_main_1 (name, add_flags, flags, offset); + + solib_create_inferior_hook (from_tty); + + /* Now it's safe to re-add the breakpoints. */ + breakpoint_re_set (); } } @@ -2001,6 +2035,8 @@ static void print_transfer_performance (struct ui_file *stream, unsigned long write_count, std::chrono::steady_clock::duration d); +/* See symfile.h. */ + void generic_load (const char *args, int from_tty) { @@ -2189,12 +2225,6 @@ set_objfile_default_section_offset (struct objfile *objf, /* This function allows the addition of incrementally linked object files. It does not modify any state in the target, only in the debugger. */ -/* Note: ezannoni 2000-04-13 This function/command used to have a - special case syntax for the rombug target (Rombug is the boot - monitor for Microware's OS-9 / OS-9000, see remote-os9k.c). In the - rombug case, the user doesn't need to supply a text address, - instead a call to target_link() (in target.c) would supply the - value to use. We are now discontinuing this type of ad hoc syntax. */ static void add_symbol_file_command (const char *args, int from_tty) @@ -2336,6 +2366,9 @@ add_symbol_file_command (const char *args, int from_tty) objf = symbol_file_add (filename.get (), add_flags, §ion_addrs, flags); + if (!objfile_has_symbols (objf) && objf->per_bfd->minimal_symbol_count <= 0) + warning (_("newly-added symbol file \"%s\" does not provide any symbols"), + filename.get ()); if (seen_offset) set_objfile_default_section_offset (objf, section_addrs, offset); @@ -2427,19 +2460,12 @@ remove_symbol_file_command (const char *args, int from_tty) void reread_symbols (void) { - struct objfile *objfile; long new_modtime; struct stat new_statbuf; int res; std::vector 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; @@ -2556,7 +2582,7 @@ reread_symbols (void) 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 @@ -2580,7 +2606,6 @@ reread_symbols (void) 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. */ @@ -2795,8 +2820,8 @@ allocate_symtab (struct compunit_symtab *cust, const char *filename) = 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); @@ -2902,12 +2927,6 @@ clear_symtab_users (symfile_add_flags add_flags) 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 (); @@ -3869,7 +3888,7 @@ test_set_ext_lang_command () SELF_CHECK (lang == language_unknown); /* Test adding a new extension using the CLI command. */ - gdb::unique_xmalloc_ptr args_holder (xstrdup (".hello rust")); + auto args_holder = make_unique_xstrdup (".hello rust"); ext_args = args_holder.get (); set_ext_lang_command (NULL, 1, NULL);