gdb/
[deliverable/binutils-gdb.git] / gdb / symfile.c
index e30b613b93fdafafbbbda4e41c675b7a77891d62..75cb0f8e999b6b1c38c263dd4cbbbf52db305a49 100644 (file)
@@ -171,13 +171,6 @@ Dynamic symbol table reloading multiple times in one run is %s.\n"),
                    value);
 }
 
-/* If non-zero, gdb will notify the user when it is loading symbols
-   from a file.  This is almost always what users will want to have happen;
-   but for programs with lots of dynamically linked libraries, the output
-   can be more noise than signal.  */
-
-int print_symbol_loading = 1;
-
 /* If non-zero, shared library symbols will be added automatically
    when the inferior is created, new libraries are loaded, or when
    attaching to the inferior.  This is almost always what users will
@@ -793,7 +786,7 @@ syms_from_objfile (struct objfile *objfile,
       if (symfile_objfile != NULL)
        {
          free_objfile (symfile_objfile);
-         symfile_objfile = NULL;
+         gdb_assert (symfile_objfile == NULL);
        }
 
       /* Currently we keep symbols from the add-symbol-file command.
@@ -989,12 +982,9 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd,
        deprecated_pre_add_symbol_hook (name);
       else
        {
-          if (print_symbol_loading)
-           {
-             printf_unfiltered (_("Reading symbols from %s..."), name);
-             wrap_here ("");
-             gdb_flush (gdb_stdout);
-           }
+         printf_unfiltered (_("Reading symbols from %s..."), name);
+         wrap_here ("");
+         gdb_flush (gdb_stdout);
        }
     }
   syms_from_objfile (objfile, addrs, offsets, num_offsets,
@@ -1007,7 +997,7 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd,
 
   if ((flags & OBJF_READNOW) || readnow_symbol_files)
     {
-      if ((from_tty || info_verbose) && print_symbol_loading)
+      if (from_tty || info_verbose)
        {
          printf_unfiltered (_("expanding to full symbols..."));
          wrap_here ("");
@@ -1049,15 +1039,11 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd,
       xfree (debugfile);
     }
 
-  if (!have_partial_symbols () && !have_full_symbols ()
-      && print_symbol_loading)
+  if ((from_tty || info_verbose)
+      && !objfile_has_symbols (objfile))
     {
       wrap_here ("");
-      printf_unfiltered (_("(no debugging symbols found)"));
-      if (from_tty || info_verbose)
-        printf_unfiltered ("...");
-      else
-        printf_unfiltered ("\n");
+      printf_unfiltered (_("(no debugging symbols found)..."));
       wrap_here ("");
     }
 
@@ -1066,10 +1052,7 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd,
       if (deprecated_post_add_symbol_hook)
        deprecated_post_add_symbol_hook ();
       else
-       {
-         if (print_symbol_loading)
-           printf_unfiltered (_("done.\n"));
-       }
+       printf_unfiltered (_("done.\n"));
     }
 
   /* We print some messages regardless of whether 'from_tty ||
@@ -1166,7 +1149,7 @@ symbol_file_clear (int from_tty)
      descriptors as well.  */
   no_shared_libraries (NULL, from_tty);
 
-  symfile_objfile = NULL;
+  gdb_assert (symfile_objfile == NULL);
   if (from_tty)
     printf_unfiltered (_("No symbol file now.\n"));
 }
@@ -1300,7 +1283,8 @@ get_debug_link_info (struct objfile *objfile, unsigned long *crc32_out)
 }
 
 static int
-separate_debug_file_exists (const char *name, unsigned long crc)
+separate_debug_file_exists (const char *name, unsigned long crc,
+                           const char *parent_name)
 {
   unsigned long file_crc = 0;
   bfd *abfd;
@@ -1320,7 +1304,15 @@ separate_debug_file_exists (const char *name, unsigned long crc)
 
   bfd_close (abfd);
 
-  return crc == file_crc;
+  if (crc != file_crc)
+    {
+      warning (_("the debug information found in \"%s\""
+                " does not match \"%s\" (CRC mismatch).\n"),
+              name, parent_name);
+      return 0;
+    }
+
+  return 1;
 }
 
 char *debug_file_directory = NULL;
@@ -1372,6 +1364,8 @@ find_separate_debug_file (struct objfile *objfile)
   basename = get_debug_link_info (objfile, &crc32);
 
   if (basename == NULL)
+    /* There's no separate debug info, hence there's no way we could
+       load it => no warning.  */
     return NULL;
 
   dir = xstrdup (objfile->name);
@@ -1405,7 +1399,7 @@ find_separate_debug_file (struct objfile *objfile)
   strcpy (debugfile, dir);
   strcat (debugfile, basename);
 
-  if (separate_debug_file_exists (debugfile, crc32))
+  if (separate_debug_file_exists (debugfile, crc32, objfile->name))
     {
       xfree (basename);
       xfree (dir);
@@ -1419,7 +1413,7 @@ find_separate_debug_file (struct objfile *objfile)
   strcat (debugfile, "/");
   strcat (debugfile, basename);
 
-  if (separate_debug_file_exists (debugfile, crc32))
+  if (separate_debug_file_exists (debugfile, crc32, objfile->name))
     {
       xfree (basename);
       xfree (dir);
@@ -1433,7 +1427,7 @@ find_separate_debug_file (struct objfile *objfile)
   strcat (debugfile, dir);
   strcat (debugfile, basename);
 
-  if (separate_debug_file_exists (debugfile, crc32))
+  if (separate_debug_file_exists (debugfile, crc32, objfile->name))
     {
       xfree (basename);
       xfree (dir);
@@ -1452,7 +1446,7 @@ find_separate_debug_file (struct objfile *objfile)
       strcat (debugfile, "/");
       strcat (debugfile, basename);
 
-      if (separate_debug_file_exists (debugfile, crc32))
+      if (separate_debug_file_exists (debugfile, crc32, objfile->name))
        {
          xfree (canon_name);
          xfree (basename);
@@ -2333,6 +2327,8 @@ reread_symbols (void)
                objfile->obfd = bfd_openr (obfd_filename, gnutarget);
              if (objfile->obfd == NULL)
                error (_("Can't open %s to read symbols."), objfile->name);
+             else
+               objfile->obfd = gdb_bfd_ref (objfile->obfd);
              /* bfd_openr sets cacheable to true, which is what we want.  */
              if (!bfd_check_format (objfile->obfd, bfd_object))
                error (_("Can't read symbols from %s: %s."), objfile->name,
@@ -2436,7 +2432,7 @@ reread_symbols (void)
                 zero is OK since dbxread.c also does what it needs to do if
                 objfile->global_psymbols.size is 0.  */
              (*objfile->sf->sym_read) (objfile, 0);
-             if (!have_partial_symbols () && !have_full_symbols ())
+             if (!objfile_has_symbols (objfile))
                {
                  wrap_here ("");
                  printf_unfiltered (_("(no debugging symbols found)\n"));
@@ -2467,13 +2463,13 @@ reread_symbols (void)
 
   if (reread_one)
     {
+      /* Notify objfiles that we've modified objfile sections.  */
+      objfiles_changed ();
+
       clear_symtab_users ();
       /* At least one objfile has changed, so we can consider that
          the executable we're debugging has changed too.  */
       observer_notify_executable_changed ();
-
-      /* Notify objfiles that we've modified objfile sections.  */
-      objfiles_changed ();
     }
 }
 
@@ -2822,7 +2818,7 @@ clear_symtab_users (void)
 
   clear_displays ();
   breakpoint_re_set ();
-  set_default_breakpoint (0, 0, 0, 0);
+  set_default_breakpoint (0, NULL, 0, 0, 0);
   clear_pc_function_cache ();
   observer_notify_new_objfile (NULL);
 
@@ -4205,12 +4201,4 @@ the global debug-file directory prepended."),
                                     NULL,
                                     show_debug_file_directory,
                                     &setlist, &showlist);
-
-  add_setshow_boolean_cmd ("symbol-loading", no_class,
-                           &print_symbol_loading, _("\
-Set printing of symbol loading messages."), _("\
-Show printing of symbol loading messages."), NULL,
-                           NULL,
-                           NULL,
-                           &setprintlist, &showprintlist);
 }
This page took 0.02648 seconds and 4 git commands to generate.