X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Fsymfile.c;h=8d05173dd9a2ddbb0314760ea214aa09f81025ce;hb=aed57c537116ae91f553ac835b3f96d1f87b3bb0;hp=0767562d5ca6f60b36f18a33c52cfd0bec73094f;hpb=22068491adac735905948fd4c2e9aaacf9e22e06;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/symfile.c b/gdb/symfile.c index 0767562d5c..8d05173dd9 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -1,6 +1,6 @@ /* Generic symbol file reading for the GNU debugger, GDB. - Copyright (C) 1990-2018 Free Software Foundation, Inc. + Copyright (C) 1990-2019 Free Software Foundation, Inc. Contributed by Cygnus Support, using pieces from other GDB modules. @@ -58,6 +58,7 @@ #include "cli/cli-utils.h" #include "common/byte-vector.h" #include "selftest.h" +#include "cli/cli-style.h" #include #include @@ -989,7 +990,7 @@ syms_from_objfile_1 (struct objfile *objfile, initial symbol reading for this file. */ (*objfile->sf->sym_init) (objfile); - clear_complaints (1); + clear_complaints (); (*objfile->sf->sym_offsets) (objfile, *addrs); @@ -1036,7 +1037,7 @@ finish_new_objfile (struct objfile *objfile, symfile_add_flags add_flags) } /* We're done reading the symbol file; finish off complaints. */ - clear_complaints (0); + clear_complaints (); } /* Process a symbol file, as either the main file or as a dynamically @@ -1111,9 +1112,9 @@ symbol_file_add_with_addrs (bfd *abfd, const char *name, deprecated_pre_add_symbol_hook (name); else { - printf_filtered (_("Reading symbols from %s..."), name); - wrap_here (""); - gdb_flush (gdb_stdout); + puts_filtered (_("Reading symbols from ")); + fputs_styled (name, file_name_style.style (), gdb_stdout); + puts_filtered ("...\n"); } } syms_from_objfile (objfile, addrs, add_flags); @@ -1126,29 +1127,24 @@ symbol_file_add_with_addrs (bfd *abfd, const char *name, if ((flags & OBJF_READNOW)) { if (should_print) - { - printf_filtered (_("expanding to full symbols...")); - wrap_here (""); - gdb_flush (gdb_stdout); - } + printf_filtered (_("Expanding full symbols from %s...\n"), name); if (objfile->sf) objfile->sf->qf->expand_all_symtabs (objfile); } - if (should_print && !objfile_has_symbols (objfile)) - { - wrap_here (""); - printf_filtered (_("(no debugging symbols found)...")); - wrap_here (""); - } + /* Note that we only print a message if we have no symbols and have + no separate debug file. If there is a separate debug file which + does not have symbols, we'll have emitted this message for that + file, and so printing it twice is just redundant. */ + if (should_print && !objfile_has_symbols (objfile) + && objfile->separate_debug_objfile == nullptr) + printf_filtered (_("(No debugging symbols found in %s)\n"), name); if (should_print) { if (deprecated_post_add_symbol_hook) deprecated_post_add_symbol_hook (); - else - printf_filtered (_("done.\n")); } /* We print some messages regardless of whether 'from_tty || @@ -1294,12 +1290,20 @@ separate_debug_file_exists (const std::string &name, unsigned long crc, return 0; if (separate_debug_file_debug) - printf_filtered (_(" Trying %s\n"), name.c_str ()); + { + printf_filtered (_(" Trying %s..."), name.c_str ()); + gdb_flush (gdb_stdout); + } gdb_bfd_ref_ptr abfd (gdb_bfd_open (name.c_str (), gnutarget, -1)); if (abfd == NULL) - return 0; + { + if (separate_debug_file_debug) + printf_filtered (_(" no, unable to open.\n")); + + return 0; + } /* Verify symlinks were not the cause of filename_cmp name difference above. @@ -1318,7 +1322,12 @@ separate_debug_file_exists (const std::string &name, unsigned long crc, { if (abfd_stat.st_dev == parent_stat.st_dev && abfd_stat.st_ino == parent_stat.st_ino) - return 0; + { + if (separate_debug_file_debug) + printf_filtered (_(" no, same file as the objfile.\n")); + + return 0; + } verified_as_different = 1; } else @@ -1327,7 +1336,12 @@ separate_debug_file_exists (const std::string &name, unsigned long crc, file_crc_p = gdb_bfd_crc (abfd.get (), &file_crc); if (!file_crc_p) - return 0; + { + if (separate_debug_file_debug) + printf_filtered (_(" no, error computing CRC.\n")); + + return 0; + } if (crc != file_crc) { @@ -1340,7 +1354,12 @@ separate_debug_file_exists (const std::string &name, unsigned long crc, if (!verified_as_different) { if (!gdb_bfd_crc (parent_objfile->obfd, &parent_crc)) - return 0; + { + if (separate_debug_file_debug) + printf_filtered (_(" no, error computing CRC.\n")); + + return 0; + } } if (verified_as_different || parent_crc != file_crc) @@ -1348,9 +1367,15 @@ separate_debug_file_exists (const std::string &name, unsigned long crc, " does not match \"%s\" (CRC mismatch).\n"), name.c_str (), objfile_name (parent_objfile)); + if (separate_debug_file_debug) + printf_filtered (_(" no, CRC doesn't match.\n")); + return 0; } + if (separate_debug_file_debug) + printf_filtered (_(" yes!\n")); + return 1; } @@ -1408,14 +1433,17 @@ find_separate_debug_file (const char *dir, Keep backward compatibility so that DEBUG_FILE_DIRECTORY being "" will cause "/..." lookups. */ + bool target_prefix = startswith (dir, "target:"); + const char *dir_notarget = target_prefix ? dir + strlen ("target:") : dir; std::vector> debugdir_vec = dirnames_to_char_ptr_vec (debug_file_directory); for (const gdb::unique_xmalloc_ptr &debugdir : debugdir_vec) { - debugfile = debugdir.get (); + debugfile = target_prefix ? "target:" : ""; + debugfile += debugdir.get (); debugfile += "/"; - debugfile += dir; + debugfile += dir_notarget; debugfile += debuglink; if (separate_debug_file_exists (debugfile, crc32, objfile)) @@ -1428,7 +1456,8 @@ find_separate_debug_file (const char *dir, strlen (gdb_sysroot)) == 0 && IS_DIR_SEPARATOR (canon_dir[strlen (gdb_sysroot)])) { - debugfile = debugdir.get (); + debugfile = target_prefix ? "target:" : ""; + debugfile += debugdir.get (); debugfile += (canon_dir + strlen (gdb_sysroot)); debugfile += "/"; debugfile += debuglink; @@ -2322,12 +2351,16 @@ remove_symbol_file_command (const char *args, int from_tty) addr = parse_and_eval_address (argv[1]); - ALL_OBJFILES (objf) + for (objfile *objfile : all_objfiles (current_program_space)) { - if ((objf->flags & OBJF_USERLOADED) != 0 - && (objf->flags & OBJF_SHARED) != 0 - && objf->pspace == pspace && is_addr_in_objfile (addr, objf)) - break; + if ((objfile->flags & OBJF_USERLOADED) != 0 + && (objfile->flags & OBJF_SHARED) != 0 + && objfile->pspace == pspace + && is_addr_in_objfile (addr, objfile)) + { + objf = objfile; + break; + } } } else if (argv[0] != NULL) @@ -2339,13 +2372,16 @@ remove_symbol_file_command (const char *args, int from_tty) gdb::unique_xmalloc_ptr filename (tilde_expand (argv[0])); - ALL_OBJFILES (objf) + for (objfile *objfile : all_objfiles (current_program_space)) { - if ((objf->flags & OBJF_USERLOADED) != 0 - && (objf->flags & OBJF_SHARED) != 0 - && objf->pspace == pspace - && filename_cmp (filename.get (), objfile_name (objf)) == 0) - break; + if ((objfile->flags & OBJF_USERLOADED) != 0 + && (objfile->flags & OBJF_SHARED) != 0 + && objfile->pspace == pspace + && filename_cmp (filename.get (), objfile_name (objfile)) == 0) + { + objf = objfile; + break; + } } } @@ -2506,6 +2542,7 @@ reread_symbols (void) objfile->psymtabs_addrmap = NULL; objfile->free_psymtabs = NULL; objfile->template_symbols = NULL; + objfile->static_links = NULL; /* obstack_init also initializes the obstack so it is empty. We could use obstack_specify_allocation but @@ -2549,7 +2586,7 @@ reread_symbols (void) } (*objfile->sf->sym_init) (objfile); - clear_complaints (1); + clear_complaints (); objfile->flags &= ~OBJF_PSYMTABS_READ; @@ -2579,7 +2616,7 @@ reread_symbols (void) } /* We're done reading the symbol file; finish off complaints. */ - clear_complaints (0); + clear_complaints (); /* Getting new symbols may change our opinion about what is frameless. */ @@ -3761,16 +3798,14 @@ expand_symtabs_matching gdb::function_view expansion_notify, enum search_domain kind) { - struct objfile *objfile; - - ALL_OBJFILES (objfile) - { - if (objfile->sf) - objfile->sf->qf->expand_symtabs_matching (objfile, file_matcher, - lookup_name, - symbol_matcher, - expansion_notify, kind); - } + for (objfile *objfile : all_objfiles (current_program_space)) + { + if (objfile->sf) + objfile->sf->qf->expand_symtabs_matching (objfile, file_matcher, + lookup_name, + symbol_matcher, + expansion_notify, kind); + } } /* Wrapper around the quick_symbol_functions map_symbol_filenames "method". @@ -3781,14 +3816,12 @@ void map_symbol_filenames (symbol_filename_ftype *fun, void *data, int need_fullname) { - struct objfile *objfile; - - ALL_OBJFILES (objfile) - { - if (objfile->sf) - objfile->sf->qf->map_symbol_filenames (objfile, fun, data, - need_fullname); - } + for (objfile *objfile : all_objfiles (current_program_space)) + { + if (objfile->sf) + objfile->sf->qf->map_symbol_filenames (objfile, fun, data, + need_fullname); + } } #if GDB_SELF_TEST