Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Doug Evans <dje@google.com>
To: Tom Tromey <tromey@redhat.com>
Cc: Pedro Alves <pedro@codesourcery.com>,
	Eli Zaretskii <eliz@gnu.org>,
	        gdb-patches@sourceware.org
Subject: Re: [RFA] Fix too many "no debugging symbols found" warnings.
Date: Mon, 24 Aug 2009 22:02:00 -0000	[thread overview]
Message-ID: <e394668d0908241413gac76a36j434507ebd7408b1d@mail.gmail.com> (raw)
In-Reply-To: <m37hxujcmv.fsf@fleche.redhat.com>

[-- Attachment #1: Type: text/plain, Size: 2300 bytes --]

On Mon, Jul 27, 2009 at 9:48 AM, Tom Tromey<tromey@redhat.com> wrote:
>>>>>> "Doug" == Doug Evans <dje@google.com> writes:
>
> Doug> Maybe the thing to do is stick with the old format *if* using MI?
> Doug> If/when an MI command is added frontends can then just use that instead.
>
> I think that might be ok if we had a plan to remove the old code after
> some time.  My concern is that we will otherwise end up with multiple
> layers of old formatting code.
>
> This particular function seems overdue for ui-out-ification.
> This would let us keep the old version for MI[12], and then properly
> evolve the output for future versions MI.
>
> Tom
>

Is this what you had in mind?

2009-08-24  Doug Evans  <dje@google.com>

        * NEWS: Add note on "info sharedlibrary".
        Remove note on "set print symbol-loading".
        * 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: Include interps.h.
        (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.
        Rewrite to use ui_out routines to format output.
        * 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'.

[-- Attachment #2: gdb-090824-info-shared-1.patch.txt --]
[-- Type: text/plain, Size: 16908 bytes --]

2009-08-24  Doug Evans  <dje@google.com>

	* NEWS: Add note on "info sharedlibrary".
	Remove note on "set print symbol-loading".
	* 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: Include interps.h.
	(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.
	Rewrite to use ui_out routines to format output.
	* 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.326
diff -u -p -r1.326 NEWS
--- NEWS	20 Aug 2009 18:02:47 -0000	1.326
+++ NEWS	24 Aug 2009 20:08:30 -0000
@@ -48,6 +48,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.
 
@@ -278,10 +281,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	24 Aug 2009 20:08:30 -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.93
diff -u -p -r1.93 objfiles.c
--- objfiles.c	21 Aug 2009 17:57:17 -0000	1.93
+++ objfiles.c	24 Aug 2009 20:08:30 -0000
@@ -700,6 +700,22 @@ objfile_relocate (struct objfile *objfil
   breakpoint_re_set ();
 }
 \f
+/* 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. */
@@ -711,10 +727,8 @@ have_partial_symbols (void)
 
   ALL_OBJFILES (ofp)
   {
-    if (ofp->psymtabs != NULL)
-      {
-	return 1;
-      }
+    if (objfile_has_partial_symbols (ofp))
+      return 1;
   }
   return 0;
 }
@@ -730,10 +744,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.62
diff -u -p -r1.62 objfiles.h
--- objfiles.h	21 Aug 2009 17:57:17 -0000	1.62
+++ objfiles.h	24 Aug 2009 20:08:30 -0000
@@ -472,6 +472,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.125
diff -u -p -r1.125 solib.c
--- solib.c	21 Aug 2009 17:57:17 -0000	1.125
+++ solib.c	24 Aug 2009 20:08:30 -0000
@@ -46,6 +46,7 @@
 #include "readline/readline.h"
 #include "remote.h"
 #include "solib.h"
+#include "interps.h"
 
 /* Architecture-specific operations.  */
 
@@ -472,12 +473,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
@@ -493,7 +494,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;
@@ -784,52 +785,117 @@ 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;
+  int nr_libs;
+  struct cleanup *table_cleanup;
+  struct gdbarch *gdbarch = target_gdbarch;
+
+  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);
+  addr_width = 4 + (gdbarch_ptr_bit (gdbarch) / 4);
 
   update_solib_list (from_tty, 0);
 
-  for (so = so_list_head; so; so = so->next)
+  /* make_cleanup_ui_out_table_begin_end needs to know the number of
+     rows, so we need to make two passes over the libs.  */
+
+  for (nr_libs = 0, so = so_list_head; so; so = so->next)
     {
       if (so->so_name[0])
 	{
-	  if (!header_done)
-	    {
-	      printf_unfiltered ("%-*s%-*s%-12s%s\n", addr_width, "From",
-				 addr_width, "To", "Syms Read",
-				 "Shared Object Library");
-	      header_done++;
-	    }
+	  if (pattern && ! re_exec (so->so_name))
+	    continue;
+	  ++nr_libs;
+	}
+    }
+
+  table_cleanup =
+    make_cleanup_ui_out_table_begin_end (uiout, 4, nr_libs,
+					 "SharedLibraryTable");
+
+  /* The "- 1" is because ui_out adds one space between columns.  */
+  ui_out_table_header (uiout, addr_width - 1, ui_left, "From", "From");
+  ui_out_table_header (uiout, addr_width - 1, ui_left, "To", "To");
+  ui_out_table_header (uiout, 12 - 1, ui_left, "SymsRead", "Syms Read");
+  ui_out_table_header (uiout, 0, ui_noalign,
+		       "Name", "Shared Object Library");
+
+  ui_out_table_body (uiout);
+
+  for (so = so_list_head; so; so = so->next)
+    {
+      struct cleanup *lib_cleanup;
 
-	  printf_unfiltered ("%-*s", addr_width,
-			     so->addr_high != 0
-			       ? hex_string_custom (
-			           (LONGEST) so->addr_low,
-	                           addr_width - 4)
-			       : "");
-	  printf_unfiltered ("%-*s", addr_width,
-			     so->addr_high != 0
-			       ? hex_string_custom (
-			           (LONGEST) so->addr_high,
-	                           addr_width - 4)
-			       : "");
-	  printf_unfiltered ("%-12s", so->symbols_loaded ? "Yes" : "No");
-	  printf_unfiltered ("%s\n", so->so_name);
+      if (! so->so_name[0])
+	continue;
+      if (pattern && ! re_exec (so->so_name))
+	continue;
+
+      lib_cleanup = make_cleanup_ui_out_tuple_begin_end (uiout, "lib");
+
+      if (so->addr_high != 0)
+	{
+	  ui_out_field_core_addr (uiout, "From", gdbarch, so->addr_low);
+	  ui_out_field_core_addr (uiout, "To", gdbarch, so->addr_high);
+	}
+      else
+	{
+	  ui_out_field_string (uiout, "From", "");
+	  ui_out_field_string (uiout, "To", "");
 	}
+
+      if (! ui_out_is_mi_like_p (interp_ui_out (top_level_interpreter ()))
+	  && so->symbols_loaded
+	  && !objfile_has_partial_symbols (so->objfile)
+	  && !objfile_has_full_symbols (so->objfile))
+	{
+	  so_missing_debug_info = 1;
+	  ui_out_field_string (uiout, "SymsRead", "Yes (*)");
+	}
+      else
+	ui_out_field_string (uiout, "SymsRead", 
+			     so->symbols_loaded ? "Yes" : "No");
+
+      ui_out_field_string (uiout, "SymsRead", so->so_name);
+
+      ui_out_text (uiout, "\n");
+
+      do_cleanups (lib_cleanup);
     }
-  if (so_list_head == NULL)
+
+  do_cleanups (table_cleanup);
+
+  if (nr_libs == 0)
+    {
+      if (pattern)
+	ui_out_message (uiout, 0,
+			_("No shared libraries matched.\n"));
+      else
+	ui_out_message (uiout, 0,
+			_("No shared libraries loaded at this time.\n"));
+    }
+  else
     {
-      printf_unfiltered (_("No shared libraries loaded at this time.\n"));
+      if (so_missing_debug_info)
+	ui_out_message (uiout, 0,
+			_("(*): Shared library is missing debugging information.\n"));
     }
 }
 
Index: symfile.c
===================================================================
RCS file: /cvs/src/src/gdb/symfile.c,v
retrieving revision 1.244
diff -u -p -r1.244 symfile.c
--- symfile.c	21 Aug 2009 17:57:17 -0000	1.244
+++ symfile.c	24 Aug 2009 20:08:30 -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 ||
@@ -2438,7 +2422,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"));
@@ -4207,12 +4192,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	24 Aug 2009 20:08:30 -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.616
diff -u -p -r1.616 gdb.texinfo
--- doc/gdb.texinfo	20 Aug 2009 18:02:48 -0000	1.616
+++ doc/gdb.texinfo	24 Aug 2009 20:08:31 -0000
@@ -12614,22 +12614,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
@@ -13502,9 +13486,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

  reply	other threads:[~2009-08-24 21:14 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-23 23:24 Doug Evans
2009-05-25  3:20 ` Eli Zaretskii
2009-05-25 16:07   ` Doug Evans
2009-06-04 20:34     ` Tom Tromey
2009-06-04 21:20       ` Pedro Alves
2009-06-05 18:19         ` Tom Tromey
2009-06-05 18:49           ` Pedro Alves
2009-06-05 22:18             ` Tom Tromey
2009-06-19  0:48               ` Doug Evans
2009-06-22 17:54                 ` Tom Tromey
2009-06-22 19:35                   ` Pedro Alves
2009-06-30 21:49                     ` Doug Evans
2009-06-30 21:55                       ` Pedro Alves
2009-06-30 22:20                         ` Doug Evans
2009-07-01  2:29                           ` Tom Tromey
2009-07-01  3:13                       ` Eli Zaretskii
2009-07-01  3:47                         ` Doug Evans
2009-07-01 17:48                           ` Eli Zaretskii
2009-07-01 17:53                             ` Doug Evans
2009-07-01 18:01                               ` Pedro Alves
2009-07-01 19:55                                 ` Doug Evans
2009-07-02 13:26                                   ` Pedro Alves
2009-07-02 20:08                                     ` Doug Evans
2009-07-02 22:43                                       ` Pedro Alves
2009-07-11  4:22                                         ` Doug Evans
2009-07-20 13:21                                           ` Pedro Alves
2009-07-23 18:57                                             ` Doug Evans
2009-07-27 17:15                                               ` Tom Tromey
2009-08-24 22:02                                                 ` Doug Evans [this message]
2009-08-25  3:47                                                   ` Eli Zaretskii
2009-08-27 19:11                                                   ` Tom Tromey
2009-08-27 23:39                                                     ` Doug Evans

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e394668d0908241413gac76a36j434507ebd7408b1d@mail.gmail.com \
    --to=dje@google.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@codesourcery.com \
    --cc=tromey@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox