2009-07-10 Doug Evans * NEWS: Remove note on `set print symbol-loading'. Add note about new regex arg to "info sharedlibrary". * main.c (captured_main): Pass !batch for from_tty when calling symbol_file_add_main. * objfiles.h (objfile_has_partial_symbols): Declare. (objfile_has_full_symbols): Declare. * objfiles.c (objfile_has_partial_symbols): New function. (have_partial_symbols): Use it. (objfile_has_full_symbols): New function. (have_full_symbols): Use it. * solib.c (solib_read_symbols): Back out patch of 2008-07-10. Add test for info_verbose for symbol loading messages for consistency with symfile.c. (info_sharedlibrary_command): Handle optional parameter of regex of libraries to list. Inform user of libraries without debugging info. * symfile.c (print_symbol_loading): Delete. (symbol_file_add_with_addrs_or_offsets): Back out patch of 2008-07-10. Print "no debugging symbols found" only if from_tty || info_verbose; and only check file being loaded, not all files. (reread_symbols): Test file being loaded for whether it has symbols, not all files. (__initialize_symfile): Delete `set print symbol-loading'. * symfile.h (print_symbol_loading): Delete. * doc/gdb.texinfo: Delete `set print symbol-loading'. Add note on new optional regex arg to `info sharedlibrary'. Index: NEWS =================================================================== RCS file: /cvs/src/src/gdb/NEWS,v retrieving revision 1.316 diff -u -p -r1.316 NEWS --- NEWS 2 Jul 2009 21:57:27 -0000 1.316 +++ NEWS 10 Jul 2009 21:50:19 -0000 @@ -33,6 +33,9 @@ remote targets. To use this feature, sp with the `remote:' prefix, either via the `set sysroot' command or via the `--with-sysroot' configure-time option. +* "info sharedlibrary" now takes an optional regex of libraries to show, +and it now reports if a shared library has no debugging information. + * Commands `set debug-file-directory', `set solib-search-path' and `set args' now complete on file names. @@ -225,10 +228,6 @@ set sh calling-convention show sh calling-convention Control the calling convention used when calling SH target functions. -set print symbol-loading -show print symbol-loading - Control printing of symbol loading messages. - set debug timestamp show debug timestamp Control display of timestamps with GDB debugging output. Index: main.c =================================================================== RCS file: /cvs/src/src/gdb/main.c,v retrieving revision 1.76 diff -u -p -r1.76 main.c --- main.c 27 Apr 2009 10:24:08 -0000 1.76 +++ main.c 10 Jul 2009 21:50:19 -0000 @@ -801,14 +801,14 @@ Excess command line arguments ignored. ( open it, better only print one error message. catch_command_errors returns non-zero on success! */ if (catch_command_errors (exec_file_attach, execarg, !batch, RETURN_MASK_ALL)) - catch_command_errors (symbol_file_add_main, symarg, 0, RETURN_MASK_ALL); + catch_command_errors (symbol_file_add_main, symarg, !batch, RETURN_MASK_ALL); } else { if (execarg != NULL) catch_command_errors (exec_file_attach, execarg, !batch, RETURN_MASK_ALL); if (symarg != NULL) - catch_command_errors (symbol_file_add_main, symarg, 0, RETURN_MASK_ALL); + catch_command_errors (symbol_file_add_main, symarg, !batch, RETURN_MASK_ALL); } if (corearg && pidarg) Index: objfiles.c =================================================================== RCS file: /cvs/src/src/gdb/objfiles.c,v retrieving revision 1.84 diff -u -p -r1.84 objfiles.c --- objfiles.c 23 Jun 2009 16:28:45 -0000 1.84 +++ objfiles.c 10 Jul 2009 21:50:19 -0000 @@ -677,6 +677,22 @@ objfile_relocate (struct objfile *objfil breakpoint_re_set (); } +/* Return non-zero if OBJFILE has partial symbols. */ + +int +objfile_has_partial_symbols (struct objfile *objfile) +{ + return objfile->psymtabs != NULL; +} + +/* Return non-zero if OBJFILE has full symbols. */ + +int +objfile_has_full_symbols (struct objfile *objfile) +{ + return objfile->symtabs != NULL; +} + /* Many places in gdb want to test just to see if we have any partial symbols available. This function returns zero if none are currently available, nonzero otherwise. */ @@ -688,10 +704,8 @@ have_partial_symbols (void) ALL_OBJFILES (ofp) { - if (ofp->psymtabs != NULL) - { - return 1; - } + if (objfile_has_partial_symbols (ofp)) + return 1; } return 0; } @@ -707,10 +721,8 @@ have_full_symbols (void) ALL_OBJFILES (ofp) { - if (ofp->symtabs != NULL) - { - return 1; - } + if (objfile_has_full_symbols (ofp)) + return 1; } return 0; } Index: objfiles.h =================================================================== RCS file: /cvs/src/src/gdb/objfiles.h,v retrieving revision 1.59 diff -u -p -r1.59 objfiles.h --- objfiles.h 15 Jan 2009 16:35:22 -0000 1.59 +++ objfiles.h 10 Jul 2009 21:50:19 -0000 @@ -478,6 +478,10 @@ extern void free_all_objfiles (void); extern void objfile_relocate (struct objfile *, struct section_offsets *); +extern int objfile_has_partial_symbols (struct objfile *objfile); + +extern int objfile_has_full_symbols (struct objfile *objfile); + extern int have_partial_symbols (void); extern int have_full_symbols (void); Index: solib.c =================================================================== RCS file: /cvs/src/src/gdb/solib.c,v retrieving revision 1.121 diff -u -p -r1.121 solib.c --- solib.c 9 Jul 2009 13:39:17 -0000 1.121 +++ solib.c 10 Jul 2009 21:50:19 -0000 @@ -489,12 +489,12 @@ solib_read_symbols (struct so_list *so, if (so->symbols_loaded) { - if (from_tty) + if (from_tty || info_verbose) printf_unfiltered (_("Symbols already loaded for %s\n"), so->so_name); } else if (so->abfd == NULL) { - if (from_tty) + if (from_tty | info_verbose) printf_unfiltered (_("Symbol file not found for %s\n"), so->so_name); } else @@ -510,7 +510,7 @@ solib_read_symbols (struct so_list *so, "Error while reading shared library symbols:\n"); return 0; } - if (from_tty && print_symbol_loading) + if (from_tty || info_verbose) printf_unfiltered (_("Loaded symbols for %s\n"), so->so_name); so->symbols_loaded = 1; return 1; @@ -801,16 +801,26 @@ solib_add (char *pattern, int from_tty, DESCRIPTION Walk through the shared library list and print information - about each attached library. + about each attached library matching PATTERN. If PATTERN is elided, + print them all. */ static void -info_sharedlibrary_command (char *ignore, int from_tty) +info_sharedlibrary_command (char *pattern, int from_tty) { struct so_list *so = NULL; /* link map state variable */ int header_done = 0; + int so_missing_debug_info = 0; int addr_width; + if (pattern) + { + char *re_err = re_comp (pattern); + + if (re_err) + error (_("Invalid regexp: %s"), re_err); + } + /* "0x", a little whitespace, and two hex digits per byte of pointers. */ addr_width = 4 + (gdbarch_ptr_bit (target_gdbarch) / 4); @@ -820,6 +830,9 @@ info_sharedlibrary_command (char *ignore { if (so->so_name[0]) { + if (pattern && ! re_exec (so->so_name)) + continue; + if (!header_done) { printf_unfiltered ("%-*s%-*s%-12s%s\n", addr_width, "From", @@ -840,14 +853,26 @@ info_sharedlibrary_command (char *ignore (LONGEST) so->addr_high, addr_width - 4) : ""); - printf_unfiltered ("%-12s", so->symbols_loaded ? "Yes" : "No"); + + if (so->symbols_loaded + && !objfile_has_partial_symbols (so->objfile) + && !objfile_has_full_symbols (so->objfile)) + { + so_missing_debug_info = 1; + printf_unfiltered ("%-12s", "Yes (*)"); + } + else + printf_unfiltered ("%-12s", !so->symbols_loaded ? "No" : "Yes"); + printf_unfiltered ("%s\n", so->so_name); } } if (so_list_head == NULL) - { - printf_unfiltered (_("No shared libraries loaded at this time.\n")); - } + printf_unfiltered (_("No shared libraries loaded at this time.\n")); + else if (! header_done && pattern) + printf_unfiltered (_("No shared libraries matched.\n")); + else if (header_done && so_missing_debug_info) + printf_unfiltered (_("(*): Shared library is missing debugging information.\n")); } /* Return 1 if ADDRESS lies within SOLIB. */ Index: symfile.c =================================================================== RCS file: /cvs/src/src/gdb/symfile.c,v retrieving revision 1.237 diff -u -p -r1.237 symfile.c --- symfile.c 2 Jul 2009 17:25:58 -0000 1.237 +++ symfile.c 10 Jul 2009 21:50:19 -0000 @@ -171,13 +171,6 @@ Dynamic symbol table reloading multiple 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 @@ -989,12 +982,9 @@ symbol_file_add_with_addrs_or_offsets (b 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 (b 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,12 @@ symbol_file_add_with_addrs_or_offsets (b xfree (debugfile); } - if (!have_partial_symbols () && !have_full_symbols () - && print_symbol_loading) + if ((from_tty || info_verbose) + && !objfile_has_partial_symbols (objfile) + && !objfile_has_full_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 +1053,7 @@ symbol_file_add_with_addrs_or_offsets (b 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 || @@ -2422,7 +2406,8 @@ 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_partial_symbols (objfile) + && !objfile_has_full_symbols (objfile)) { wrap_here (""); printf_unfiltered (_("(no debugging symbols found)\n")); @@ -4189,12 +4174,4 @@ the global debug-file directory prepende 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); } Index: symfile.h =================================================================== RCS file: /cvs/src/src/gdb/symfile.h,v retrieving revision 1.51 diff -u -p -r1.51 symfile.h --- symfile.h 16 Jun 2009 18:49:25 -0000 1.51 +++ symfile.h 10 Jul 2009 21:50:19 -0000 @@ -284,13 +284,6 @@ extern char *obconcat (struct obstack *o /* Variables */ -/* 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. */ - -extern int print_symbol_loading; - /* 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 Index: doc/gdb.texinfo =================================================================== RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v retrieving revision 1.605 diff -u -p -r1.605 gdb.texinfo --- doc/gdb.texinfo 10 Jul 2009 10:35:17 -0000 1.605 +++ doc/gdb.texinfo 10 Jul 2009 22:00:27 -0000 @@ -12565,22 +12565,6 @@ is printed as follows: @item show opaque-type-resolution Show whether opaque types are resolved or not. -@kindex set print symbol-loading -@cindex print messages when symbols are loaded -@item set print symbol-loading -@itemx set print symbol-loading on -@itemx set print symbol-loading off -The @code{set print symbol-loading} command allows you to enable or -disable printing of messages when @value{GDBN} loads symbols. -By default, these messages will be printed, and normally this is what -you want. Disabling these messages is useful when debugging applications -with lots of shared libraries where the quantity of output can be more -annoying than useful. - -@kindex show print symbol-loading -@item show print symbol-loading -Show whether messages will be printed when @value{GDBN} loads symbols. - @kindex maint print symbols @cindex symbol dump @kindex maint print psymbols @@ -13453,9 +13437,11 @@ command: @table @code @kindex info sharedlibrary @kindex info share -@item info share -@itemx info sharedlibrary -Print the names of the shared libraries which are currently loaded. +@item info share @var{regex} +@itemx info sharedlibrary @var{regex} +Print the names of the shared libraries which are currently loaded +that match @var{regex}. If @var{regex} is omitted then print +all shared libraries that are loaded. @kindex sharedlibrary @kindex share