This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA] Fix too many "no debugging symbols found" warnings.


Hi.

I'd like to return to this patch:

http://sourceware.org/ml/gdb-patches/2008-10/msg00097.html

It's a long-ish thread.  No need to reread it all if you don't want to.
[Apologies for the long-ish email too!  This issue is just full of fun.]
I started appending the important snippets to save having to go
back and reread the thread, but folks mightn't want subsets of their text
cut-n-pasted here so I scratched that.

Basically the gist is that gdb will currently print a lot of noise
on the screen when one debugs applications with dozens or hundreds
of shared libs without debug info (*if* the executable itself
doesn't have debug info).
Currently that's means getting one line of "(no debugging symbols found)"
for every such shared lib, which is really annoying.
NOTE: This is unchanged from 6.8 and earlier.

It seems useful to always print the warning for executables.
This is what 6.8 does.
I'd like to preserve this even when the warning is turned off for shared-libs.
The question is how to turn it off for shared-libs without
turning it off for executables.

Some issues:
- some want the warnings for shared-libs on by default
- some want the warnings for shared-libs off by default
- I'd like to avoid major changes in observed behaviour from 6.8:
  E.g. I don't want 7.0 to start printing
  "no debugging symbols found in /usr/lib/system-library.so" by default).

Note that 6.8 *will* print "(no debugging symbols found)"
messages for *system libraries* (when the main executable is stripped).
The file name is absent from this warning so the user doesn't really know
that these are for system libraries too, but they are.
Normally the main executable has debug info, and because the current source
uses have_{partial,full}_symbols instead of just checking the newly
loaded file, that is sufficient to turn off these warnings for
system libraries.  Blech!

We'd like to avoid adding any new option.
And I'd like to avoid ports having to specify what system libraries are.
That may be ultimately useful, but it seems excessive for the task at hand.
OTOH, "set print symbol-loading off|on" is new for 7.0, so we could
replace it with something else if that's TRTTD.

The high-order bit of what needs to be done here is to be able
to turn off the warnings for shared-libs.  And since
"set print symbol-loading off|on" is new for 7.0 ...

I propose the following:

1) rename "set print symbol-loading" to "set print solib-symbol-loading"
2) always print such messages for the main executable

This way one can turn the messages off and still get the messages
for the main executable.

So far so good, except there's one catch: While we'd like to print
warnings for user libraries if they have no debug info, we don't want
to do so for system libraries, at least to the same extent that 6.8 does.
[Remember 6.8 is broken here too, it's just that users don't see it
because their main executable generally has debug info.]
To resolve this I'm leaving the use of have_{full,partial}_symbols
alone here:

@@ -1050,15 +1051,34 @@ symbol_file_add_with_addrs_or_offsets (b
       xfree (debugfile);
     }
 
-  if (!have_partial_symbols () && !have_full_symbols ()
-      && print_symbol_loading)
+  if ((mainline || print_solib_symbol_loading)
+      && !have_partial_symbols ()
+      && !have_full_symbols ())

I *really* wanted to fix that, but I don't see a way that is a net win
so I'm leaving it alone.

The patch sets the default of solib-symbol-loading to "on" to avoid
changes in the output from 6.8.

This patch also adds the printing of the name of the file that's missing
debug info.  Seeing:

(no debugging symbols found in libfoo.so)
(no debugging symbols found in libbar.so)
[...]
(no debugging symbols found in libbaz.so)

is more useful than seeing:

(no debugging symbols found)
(no debugging symbols found)
[...]
(no debugging symbols found)

This patch also makes the obvious (IMO) change of checking the
file being loaded rather than checking all libraries via
have_{partial,full}_symbols in function reread_symbols.
This avoids the problem where have_{partial,full}_symbols will
always return true once any objfile with debug info is loaded
(and thus, for example, whether one sees the warning depends
on the order the shared libs are loaded in!).
Alas, as I say above I haven't made this change in
symbol_file_add_with_addrs_or_offsets.

Ok to check in?

2009-05-23  Doug Evans  <dje@google.com>

	* 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.
	* symfile.c (print_solib_symbol_loading): Renamed from
	print_symbol_loading.  All uses updated.
	(symbol_file_add_with_addrs_or_offsets): Always print symbol loading
	messages if mainline.  Include file name in "no debugging symbols
	found" message.
	(reread_symbols): Test file being loaded for whether it has symbols,
	not all files.
	* NEWS (set print solib-symbol-loading): Update.

	* doc/gdb.texinfo (print solib-symbol-loading): Renamed from
	`print symbol-loading'.

Index: NEWS
===================================================================
RCS file: /cvs/src/src/gdb/NEWS,v
retrieving revision 1.312
diff -u -p -u -p -r1.312 NEWS
--- NEWS	18 May 2009 13:25:33 -0000	1.312
+++ NEWS	23 May 2009 22:36:12 -0000
@@ -193,9 +193,10 @@ 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 print solib-symbol-loading
+show print solib-symbol-loading
+  Control printing of messages when loading symbols from shared object
+  libraries.
 
 set debug timestamp
 show debug timestamp
Index: objfiles.c
===================================================================
RCS file: /cvs/src/src/gdb/objfiles.c,v
retrieving revision 1.83
diff -u -p -u -p -r1.83 objfiles.c
--- objfiles.c	14 May 2009 23:33:08 -0000	1.83
+++ objfiles.c	23 May 2009 22:36:12 -0000
@@ -677,6 +677,22 @@ objfile_relocate (struct objfile *objfil
   breakpoint_re_set_objfile (objfile);
 }
 
+/* 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 -u -p -r1.59 objfiles.h
--- objfiles.h	15 Jan 2009 16:35:22 -0000	1.59
+++ objfiles.h	23 May 2009 22:36:12 -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.118
diff -u -p -u -p -r1.118 solib.c
--- solib.c	22 May 2009 23:49:13 -0000	1.118
+++ solib.c	23 May 2009 22:36:12 -0000
@@ -497,7 +497,7 @@ solib_read_symbols (struct so_list *so, 
 			"Error while reading shared library symbols:\n",
 			RETURN_MASK_ALL))
 	{
-	  if (from_tty && print_symbol_loading)
+	  if (from_tty && print_solib_symbol_loading)
 	    printf_unfiltered (_("Loaded symbols for %s\n"), so->so_name);
 	  so->symbols_loaded = 1;
 	  return 1;
Index: symfile.c
===================================================================
RCS file: /cvs/src/src/gdb/symfile.c,v
retrieving revision 1.228
diff -u -p -u -p -r1.228 symfile.c
--- symfile.c	22 May 2009 23:49:13 -0000	1.228
+++ symfile.c	23 May 2009 22:36:12 -0000
@@ -172,11 +172,11 @@ Dynamic symbol table reloading multiple 
 }
 
 /* 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;
+   from solibs.  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;
+int print_solib_symbol_loading = 1;
 
 /* If non-zero, shared library symbols will be added automatically
    when the inferior is created, new libraries are loaded, or when
@@ -990,7 +990,7 @@ symbol_file_add_with_addrs_or_offsets (b
 	deprecated_pre_add_symbol_hook (name);
       else
 	{
-          if (print_symbol_loading)
+          if (mainline || print_solib_symbol_loading)
 	    {
 	      printf_unfiltered (_("Reading symbols from %s..."), name);
 	      wrap_here ("");
@@ -1008,7 +1008,8 @@ 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)
+	  && (mainline || print_solib_symbol_loading))
 	{
 	  printf_unfiltered (_("expanding to full symbols..."));
 	  wrap_here ("");
@@ -1050,15 +1051,34 @@ symbol_file_add_with_addrs_or_offsets (b
       xfree (debugfile);
     }
 
-  if (!have_partial_symbols () && !have_full_symbols ()
-      && print_symbol_loading)
+  /* Warn if there are no debugging symbols in OBJFILE.
+     Always warn if this is mainline.
+     Otherwise only warn if print_solib_symbol_loading.
+
+     ??? We'd like to check just OBJFILE, but there's a catch: if it is a
+     system library it's debatable whether the user wants to be told.
+     gdb 6.8 and earlier avoided this issue for two questionable reasons:
+     1) It uses have_partial_symbols/have_full_symbols to do the test.
+        They will return true if *any* objfile has symbols, and generally
+	the main binary has symbols.
+     2) If the main binary doesn't have symbols, the user wouldn't really
+        know s/he is being told about system libraries because gdb would only
+        print "no debugging symbols found" *without* mentioning the file name.
+     To avoid excessive behavioural changes in this area we continue to use
+     have_partial_symbols/have_full_symbols here.  Sigh.  */
+
+  if ((mainline || print_solib_symbol_loading)
+      && !have_partial_symbols ()
+      && !have_full_symbols ())
     {
       wrap_here ("");
-      printf_unfiltered (_("(no debugging symbols found)"));
+      /* There's no need to print the file name if from_tty || info_verbose,
+	 it's already been printed.  And similarily for \n, it will be
+	 printed later.  */
       if (from_tty || info_verbose)
-        printf_unfiltered ("...");
+	printf_unfiltered (_("(no debugging symbols found)..."));
       else
-        printf_unfiltered ("\n");
+	printf_unfiltered (_("(no debugging symbols found in %s)\n"), name);
       wrap_here ("");
     }
 
@@ -1068,7 +1088,7 @@ symbol_file_add_with_addrs_or_offsets (b
 	deprecated_post_add_symbol_hook ();
       else
 	{
-	  if (print_symbol_loading)
+	  if (print_solib_symbol_loading)
 	    printf_unfiltered (_("done.\n"));
 	}
     }
@@ -2424,7 +2444,9 @@ 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"));
@@ -4175,9 +4197,9 @@ the global debug-file directory prepende
 				     &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,
+                           &print_solib_symbol_loading, _("\
+Set printing of symbol loading messages for shared object libraries."), _("\
+Show printing of symbol loading messages for shared object libraries."), NULL,
                            NULL,
                            NULL,
                            &setprintlist, &showprintlist);
Index: symfile.h
===================================================================
RCS file: /cvs/src/src/gdb/symfile.h,v
retrieving revision 1.50
diff -u -p -u -p -r1.50 symfile.h
--- symfile.h	22 May 2009 23:49:14 -0000	1.50
+++ symfile.h	23 May 2009 22:36:12 -0000
@@ -269,11 +269,11 @@ 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;
+   from solibs.  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;
+extern int print_solib_symbol_loading;
 
 /* If non-zero, shared library symbols will be added automatically
    when the inferior is created, new libraries are loaded, or when
Index: doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.593
diff -u -p -u -p -r1.593 gdb.texinfo
--- doc/gdb.texinfo	15 May 2009 16:53:45 -0000	1.593
+++ doc/gdb.texinfo	23 May 2009 22:36:13 -0000
@@ -12443,21 +12443,23 @@ 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.
+@kindex set print solib-symbol-loading
+@cindex print messages when shared object library symbols are loaded
+@item set print solib-symbol-loading
+@itemx set print solib-symbol-loading on
+@itemx set print solib-symbol-loading off
+The @code{set print solib-symbol-loading} command allows you to enable or
+disable printing of messages when @value{GDBN} loads symbols from
+shared object libraries.
 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 show print solib-symbol-loading
+@item show print solib-symbol-loading
+Show whether messages will be printed when @value{GDBN} loads
+shared object library symbols.
 
 @kindex maint print symbols
 @cindex symbol dump


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]