diff options
author | Daniel Jacobowitz <dan@debian.org> | 2006-05-09 17:46:17 +0000 |
---|---|---|
committer | Daniel Jacobowitz <dan@debian.org> | 2006-05-09 17:46:17 +0000 |
commit | 5ec66662eacf1140fab0c4e9990fd85691d44e70 (patch) | |
tree | ae682379451dd0c90dd379a62518ec4813803730 | |
parent | 2f9bc7d15ad2856222adc06817b2849fd49a1c72 (diff) | |
download | gdb-5ec66662eacf1140fab0c4e9990fd85691d44e70.tar.gz |
* 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.
-rw-r--r-- | ChangeLog.csl | 16 | ||||
-rw-r--r-- | gdb/Makefile.in | 2 | ||||
-rw-r--r-- | gdb/bsd-uthread.c | 2 | ||||
-rw-r--r-- | gdb/remote.c | 17 | ||||
-rw-r--r-- | gdb/solib.c | 116 | ||||
-rw-r--r-- | gdb/solist.h | 1 |
6 files changed, 103 insertions, 51 deletions
diff --git a/ChangeLog.csl b/ChangeLog.csl index 0b49e239da2..04f61f2f11a 100644 --- a/ChangeLog.csl +++ b/ChangeLog.csl @@ -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. diff --git a/gdb/Makefile.in b/gdb/Makefile.in index cd0834cb983..c7099396482 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -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) diff --git a/gdb/bsd-uthread.c b/gdb/bsd-uthread.c index 01acd499a78..fb44b7f13a0 100644 --- a/gdb/bsd-uthread.c +++ b/gdb/bsd-uthread.c @@ -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)) { diff --git a/gdb/remote.c b/gdb/remote.c index 53da04d9810..2e8b5ecd515 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -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, ¤t_target, auto_solib_add); -#else - solib_add (NULL, 0, ¤t_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. */ diff --git a/gdb/solib.c b/gdb/solib.c index d6a6f462660..f55837694b2 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -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); } } diff --git a/gdb/solist.h b/gdb/solist.h index 79ec0a765ab..c65102b5891 100644 --- a/gdb/solist.h +++ b/gdb/solist.h @@ -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; |