]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* gdb/bsd-uthread.c (bsd_uthread_solib_loaded): Always pass 0 for
authorDaniel Jacobowitz <drow@false.org>
Tue, 9 May 2006 17:46:17 +0000 (17:46 +0000)
committerDaniel Jacobowitz <drow@false.org>
Tue, 9 May 2006 17:46:17 +0000 (17:46 +0000)
from_tty.
* gdb/remote.c (remote_get_shared_libraries): Don't call solib_add.
* gdb/solib.c: Include "exceptions.h".
(solib_map_sections): Throw NOT_FOUND_ERROR if appropriate.
(symbol_add_stub): Delete.
(solib_read_symbols): Use TRY_CATCH.  Inline symbol_add_stub.
Use current from_tty, not a copy from the so_list.  Don't warn
a second time for a missing library.
(update_solib_list): Don't save from_tty.  Use TRY_CATCH.  Print
out a single warning for all missing libraries.
* gdb/solist.h (struct so_list): Remove from_tty.
* gdb/Makefile.in (solib.o): Update.

ChangeLog.csl
gdb/Makefile.in
gdb/bsd-uthread.c
gdb/remote.c
gdb/solib.c
gdb/solist.h

index 0b49e239da296157bd795aefe7cd0e62600140fd..04f61f2f11a47eff413b13a5e5f7294850cc07bd 100644 (file)
@@ -1,3 +1,19 @@
+2006-05-09  Daniel Jacobowitz  <dan@codesourcery.com>
+
+       * gdb/bsd-uthread.c (bsd_uthread_solib_loaded): Always pass 0 for
+       from_tty.
+       * gdb/remote.c (remote_get_shared_libraries): Don't call solib_add.
+       * gdb/solib.c: Include "exceptions.h".
+       (solib_map_sections): Throw NOT_FOUND_ERROR if appropriate.
+       (symbol_add_stub): Delete.
+       (solib_read_symbols): Use TRY_CATCH.  Inline symbol_add_stub.
+       Use current from_tty, not a copy from the so_list.  Don't warn
+       a second time for a missing library.
+       (update_solib_list): Don't save from_tty.  Use TRY_CATCH.  Print
+       out a single warning for all missing libraries.
+       * gdb/solist.h (struct so_list): Remove from_tty.
+       * gdb/Makefile.in (solib.o): Update.
+
 2006-05-08  Daniel Jacobowitz  <dan@codesourcery.com>
 
        * gdb/remote.c (remote_get_shared_libraries): Check for NULL ops.
index cd0834cb9830f87523f62416fa5ec4b90e8570c3..c70993964824e7689b27ead28460f3825a1599a3 100644 (file)
@@ -2623,7 +2623,7 @@ solib.o: solib.c $(defs_h) $(gdb_string_h) $(symtab_h) $(bfd_h) $(symfile_h) \
        $(objfiles_h) $(exceptions_h) $(gdbcore_h) $(command_h) $(target_h) \
        $(frame_h) $(gdb_regex_h) $(inferior_h) $(environ_h) $(language_h) \
        $(gdbcmd_h) $(completer_h) $(filenames_h) $(exec_h) $(solist_h) \
-       $(observer_h) $(readline_h)
+       $(observer_h) $(readline_h) $(exceptions_h)
 solib-frv.o: solib-frv.c $(defs_h) $(gdb_string_h) $(inferior_h) \
        $(gdbcore_h) $(solist_h) $(frv_tdep_h) $(objfiles_h) $(symtab_h) \
        $(language_h) $(command_h) $(gdbcmd_h) $(elf_frv_h)
index 01acd499a7805d5de4ff76f56abadf1a976229f1..fb44b7f13a0ba67c7f96238d4b620e99f01a64a7 100644 (file)
@@ -237,7 +237,7 @@ bsd_uthread_solib_loaded (struct so_list *so)
     {
       if (strncmp (so->so_original_name, *names, strlen (*names)) == 0)
        {
-         solib_read_symbols (so, so->from_tty);
+         solib_read_symbols (so, 0);
 
          if (bsd_uthread_activate (so->objfile))
            {
index 53da04d9810ce834dd535a942c65561c8ce8a9b8..2e8b5ecd5156a41857b961b59ce9aa859a0f848b 100644 (file)
@@ -2098,7 +2098,6 @@ static void
 remote_get_shared_libraries (struct target_ops *ops)
 {
   struct remote_state *rs = get_remote_state ();
-  int added = 0;
 
   /* If this target doesn't support remote DLLs, nothing to do.  */
   if (current_target_so_ops->add_one_solib == NULL)
@@ -2137,8 +2136,6 @@ remote_get_shared_libraries (struct target_ops *ops)
              return;
            }
 
-         added = 1;
-
          if (*p_end == ';')
            p = p_end + 1;
          else
@@ -2155,18 +2152,8 @@ remote_get_shared_libraries (struct target_ops *ops)
       return;
     }
 
-  /* If OPS is set, we were called from the target vector and should handle
-     adding shared libraries now.  If it is NULL, we were called as part of
-     a TARGET_WAITKIND_LOADED event, and the libraries will be added momentarily,
-     so we don't need to do it now.  */
-  if (added && ops != NULL)
-    {
-#ifdef SOLIB_ADD
-      SOLIB_ADD (NULL, 0, &current_target, auto_solib_add);
-#else
-      solib_add (NULL, 0, &current_target, auto_solib_add);
-#endif
-    }
+  /* We don't need to call solib_add here, because we're being called from
+     ->current_sos ().  */
 }
 
 /* Stub for catch_errors.  */
index d6a6f462660db786dab43c73b9df98481d15b780..f55837694b2b78e9c71ee38988a7ee90dcd30a2c 100644 (file)
@@ -45,6 +45,7 @@
 #include "exec.h"
 #include "solist.h"
 #include "observer.h"
+#include "exceptions.h"
 #include "readline/readline.h"
 
 /* Architecture-specific operations.  */
@@ -301,6 +302,11 @@ solib_map_sections (void *arg)
 
   if (scratch_chan < 0)
     {
+      /* Throw a more specific error if the file could not be found, so
+        that we can accumulate messages about missing libraries.  */
+      if (errno == ENOENT)
+       throw_error (NOT_FOUND_ERROR, "%s", safe_strerror (errno));
+
       perror_with_name (filename);
     }
 
@@ -414,31 +420,6 @@ master_so_list (void)
 }
 
 
-/* A small stub to get us past the arg-passing pinhole of catch_errors.  */
-
-static int
-symbol_add_stub (void *arg)
-{
-  struct so_list *so = (struct so_list *) arg;  /* catch_errs bogon */
-  struct section_addr_info *sap;
-
-  /* Have we already loaded this shared object?  */
-  ALL_OBJFILES (so->objfile)
-    {
-      if (strcmp (so->objfile->name, so->so_name) == 0)
-       return 1;
-    }
-
-  sap = build_section_addr_info_from_section_table (so->sections,
-                                                    so->sections_end);
-
-  so->objfile = symbol_file_add (so->so_name, so->from_tty,
-                                sap, 0, OBJF_SHARED);
-  free_section_addr_info (sap);
-
-  return (1);
-}
-
 /* Read in symbols for shared object SO.  If FROM_TTY is non-zero, be
    chatty about it.  Return non-zero if any symbols were actually
    loaded.  */
@@ -453,9 +434,44 @@ solib_read_symbols (struct so_list *so, int from_tty)
     }
   else
     {
-      if (catch_errors (symbol_add_stub, so,
-                       "Error while reading shared library symbols:\n",
-                       RETURN_MASK_ALL))
+      volatile struct gdb_exception e;
+
+      TRY_CATCH (e, RETURN_MASK_ERROR)
+       {
+         struct section_addr_info *sap;
+
+         /* Could we find a file for this shared library?  If we
+            couldn't, don't try to open it again.  */
+         if (so->abfd == NULL)
+           throw_error (NOT_FOUND_ERROR, "%s", safe_strerror (errno));
+
+         /* Have we already loaded this shared object?  */
+         ALL_OBJFILES (so->objfile)
+           {
+             if (strcmp (so->objfile->name, so->so_name) == 0)
+               break;
+           }
+         if (so->objfile != NULL)
+           break;
+
+         sap = build_section_addr_info_from_section_table (so->sections,
+                                                           so->sections_end);
+         so->objfile = symbol_file_add (so->so_name, from_tty,
+                                        sap, 0, OBJF_SHARED);
+         free_section_addr_info (sap);
+       }
+
+      if (e.reason == RETURN_ERROR && e.error == NOT_FOUND_ERROR)
+       /* We've already warned about this library, when trying to
+          open it.  */
+       return 0;
+      else if (e.reason < 0)
+       {
+         if (from_tty)
+           exception_fprintf
+             (gdb_stderr, e, _("Error while reading shared library symbols:\n"));
+       }
+      else
        {
          if (from_tty)
            printf_unfiltered (_("Loaded symbols for %s\n"), so->so_name);
@@ -601,6 +617,9 @@ update_solib_list (int from_tty, struct target_ops *target)
      to GDB's shared object list.  */
   if (inferior)
     {
+      int not_found = 0;
+      const char *not_found_filename = NULL;
+
       struct so_list *i;
 
       /* Add the new shared objects to GDB's list.  */
@@ -609,12 +628,25 @@ update_solib_list (int from_tty, struct target_ops *target)
       /* Fill in the rest of each of the `struct so_list' nodes.  */
       for (i = inferior; i; i = i->next)
        {
-         i->from_tty = from_tty;
+         volatile struct gdb_exception e;
 
-         /* Fill in the rest of the `struct so_list' node.  */
-         catch_errors (solib_map_sections, i,
-                       "Error while mapping shared library sections:\n",
-                       RETURN_MASK_ALL);
+         TRY_CATCH (e, RETURN_MASK_ERROR)
+           {
+             /* Fill in the rest of the `struct so_list' node.  */
+             solib_map_sections (i);
+           }
+
+         if (e.reason == RETURN_ERROR && e.error == NOT_FOUND_ERROR)
+           {
+             not_found++;
+             if (not_found_filename == NULL)
+               not_found_filename = i->so_original_name;
+           }
+         else if (e.reason < 0)
+           {
+             exception_fprintf (gdb_stderr, e,
+                                _("Error while mapping shared library sections:\n"));
+           }
 
          /* If requested, add the shared object's sections to the TARGET's
             section table.  Do this immediately after mapping the object so
@@ -636,6 +668,24 @@ update_solib_list (int from_tty, struct target_ops *target)
              loaded now that we've added it to GDB's tables.  */
          observer_notify_solib_loaded (i);
        }
+
+      /* If a library was not found, issue an appropriate warning
+        message.  We have to use a single call to warning () in case
+        the front end does something special with warnings, e.g.  pop
+        up a dialog box.  It Would Be Nice if we could get a
+        "warning: " prefix on each line in the CLI front end,
+        though - it doesn't stand out well.  */
+
+      if (not_found == 1)
+       warning (_("\
+Could not load shared library symbols for %s.\n\
+Do you need \"set solib-search-path\" or \"set solib-absolute-prefix\"?"),
+                not_found_filename);
+      else if (not_found > 1)
+       warning (_("\
+Could not load shared library symbols for %d libraries, e.g. %s.\n\
+Do you need \"set solib-search-path\" or \"set solib-absolute-prefix\"?"),
+                not_found, not_found_filename);
     }
 }
 
index 79ec0a765abf59e600cf204cd489728cba8d46b8..c65102b5891a46b7dc62423aeabae5d40a7fad0f 100644 (file)
@@ -61,7 +61,6 @@ struct so_list
 
     bfd *abfd;
     char symbols_loaded;       /* flag: symbols read in yet? */
-    char from_tty;             /* flag: print msgs? */
     struct objfile *objfile;   /* objfile for loaded lib */
     struct section_table *sections;
     struct section_table *sections_end;