This is the mail archive of the gdb-cvs@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]

[binutils-gdb] Simplify complaints even more


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=5ca8c39f059b30991b7090e7a662e4eb35d11133

commit 5ca8c39f059b30991b7090e7a662e4eb35d11133
Author: Tom Tromey <tom@tromey.com>
Date:   Sun May 27 21:31:14 2018 -0600

    Simplify complaints even more
    
    This removes the SHORT_FIRST_MESSAGE case from complaints, leaving
    only a single case.  This allows for the removal of the last argument
    to clear_complaints, and also simplifies complaint_internal, removing
    an extra allocation in the process.
    
    After this, the "./gdb -iex 'set complaint 1' -nx ./gdb" example will
    show:
    
        Reading symbols from ./gdb...
        During symbol reading: .debug_ranges entry has start address of zero [in module /home/tromey/gdb/build/gdb/gdb]
        During symbol reading: DW_AT_low_pc 0x0 is zero for DIE at 0x17116c1 [in module /home/tromey/gdb/build/gdb/gdb]
        During symbol reading: .debug_line address at offset 0xa22f5 is 0 [in module /home/tromey/gdb/build/gdb/gdb]
        During symbol reading: unsupported tag: 'DW_TAG_unspecified_type'
        During symbol reading: const value length mismatch for 'std::ratio<1, 1000000000>::num', got 8, expected 0
    
    This is a bit wordier but, I think, a bit more clear, as the form of
    the message no longer depends on precisely when it was emitted.  In
    particular if you compare to the output from the 'Clean up "Reading
    symbols" output' patch, you can see that earlier gdb would switch from
    the prefix-less form to the "During symbol reading" form at a point
    that is meaningless to the user (specifically, after psymtab reading
    is done and gdb tries to expand a CU).
    
    2018-10-04  Tom Tromey  <tom@tromey.com>
    
    	* symfile.c (syms_from_objfile_1, finish_new_objfile)
    	(reread_symbols): Update.
    	* complaints.h (clear_complaints): Remove argument.
    	* complaints.c (enum complaint_series): Remove.
    	(series): Remove global.
    	(complaint_internal): Update.
    	(clear_complaints): Remove argument.
    
    gdb/testsuite/ChangeLog
    2018-10-04  Tom Tromey  <tom@tromey.com>
    
    	* gdb.cp/maint.exp (test_invalid_name): Update expected output.
    	* gdb.gdb/complaints.exp (test_short_complaints): Remove.
    	(test_initial_complaints, test_empty_complaints): Update.
    	* gdb.dwarf2/dw2-stack-boundary.exp: Update.

Diff:
---
 gdb/ChangeLog                                   | 10 ++++++
 gdb/complaints.c                                | 45 +++----------------------
 gdb/complaints.h                                | 11 ++----
 gdb/symfile.c                                   |  8 ++---
 gdb/testsuite/ChangeLog                         |  7 ++++
 gdb/testsuite/gdb.cp/maint.exp                  |  2 +-
 gdb/testsuite/gdb.dwarf2/dw2-stack-boundary.exp |  2 +-
 gdb/testsuite/gdb.gdb/complaints.exp            | 33 +++---------------
 8 files changed, 36 insertions(+), 82 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 5e23132..34cf536 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,15 @@
 2018-10-04  Tom Tromey  <tom@tromey.com>
 
+	* symfile.c (syms_from_objfile_1, finish_new_objfile)
+	(reread_symbols): Update.
+	* complaints.h (clear_complaints): Remove argument.
+	* complaints.c (enum complaint_series): Remove.
+	(series): Remove global.
+	(complaint_internal): Update.
+	(clear_complaints): Remove argument.
+
+2018-10-04  Tom Tromey  <tom@tromey.com>
+
 	* symfile.c (symbol_file_add_with_addrs): Do not print "no
 	debugging symbols" message if there is a separate debug objfile.
 
diff --git a/gdb/complaints.c b/gdb/complaints.c
index ab61980..3184c25 100644
--- a/gdb/complaints.c
+++ b/gdb/complaints.c
@@ -23,26 +23,10 @@
 #include "gdbcmd.h"
 #include <unordered_map>
 
-/* Should each complaint message be self explanatory, or should we
-   assume that a series of complaints is being produced?  */
-
-enum complaint_series {
-  /* Isolated self explanatory message.  */
-  ISOLATED_MESSAGE,
-
-  /* First message of a series, but does not need to include any sort
-     of explanation.  */
-  SHORT_FIRST_MESSAGE,
-};
-
 /* Map format strings to counters.  */
 
 static std::unordered_map<const char *, int> counters;
 
-/* How to print the next complaint.  */
-
-static complaint_series series;
-
 /* How many complaints about a particular thing should be printed
    before we stop whining about it?  Default is no whining at all,
    since so many systems have ill-constructed symbol files.  */
@@ -65,39 +49,20 @@ complaint_internal (const char *fmt, ...)
     (*deprecated_warning_hook) (fmt, args);
   else
     {
-      std::string msg = string_vprintf (fmt, args);
-      wrap_here ("");
-      begin_line ();
-      if (series == ISOLATED_MESSAGE)
-	fprintf_filtered (gdb_stderr, "During symbol reading, %s.\n",
-			  msg.c_str ());
-      else
-	fprintf_filtered (gdb_stderr, "%s\n", msg.c_str ());
+      fputs_filtered (_("During symbol reading: "), gdb_stderr);
+      vfprintf_filtered (gdb_stderr, fmt, args);
+      fputs_filtered ("\n", gdb_stderr);
     }
 
-  /* If GDB dumps core, we'd like to see the complaints first.
-     Presumably GDB will not be sending so many complaints that this
-     becomes a performance hog.  */
-
-  gdb_flush (gdb_stderr);
   va_end (args);
 }
 
-/* Clear out / initialize all complaint counters that have ever been
-   incremented.  If LESS_VERBOSE is 1, be less verbose about
-   successive complaints, since the messages are appearing all
-   together during a command that is reporting a contiguous block of
-   complaints (rather than being interleaved with other messages).  */
+/* See complaints.h.  */
 
 void
-clear_complaints (int less_verbose)
+clear_complaints ()
 {
   counters.clear ();
-
-  if (!less_verbose)
-    series = ISOLATED_MESSAGE;
-  else
-    series = SHORT_FIRST_MESSAGE;
 }
 
 static void
diff --git a/gdb/complaints.h b/gdb/complaints.h
index 243eaed..edb007f 100644
--- a/gdb/complaints.h
+++ b/gdb/complaints.h
@@ -40,14 +40,9 @@ extern void complaint_internal (const char *fmt, ...)
   while (0)
 
 /* Clear out / initialize all complaint counters that have ever been
-   incremented.  If LESS_VERBOSE is 1, be less verbose about
-   successive complaints, since the messages are appearing all
-   together during a command that is reporting a contiguous block of
-   complaints (rather than being interleaved with other messages).  If
-   noisy is 1, we are in a noisy command, and our caller will print
-   enough context for the user to figure it out.  */
-
-extern void clear_complaints (int less_verbose);
+   incremented.  */
+
+extern void clear_complaints ();
 
 
 #endif /* !defined (COMPLAINTS_H) */
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 981bf33..6a1140e 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -989,7 +989,7 @@ syms_from_objfile_1 (struct objfile *objfile,
      initial symbol reading for this file.  */
 
   (*objfile->sf->sym_init) (objfile);
-  clear_complaints (1);
+  clear_complaints ();
 
   (*objfile->sf->sym_offsets) (objfile, *addrs);
 
@@ -1036,7 +1036,7 @@ finish_new_objfile (struct objfile *objfile, symfile_add_flags add_flags)
     }
 
   /* We're done reading the symbol file; finish off complaints.  */
-  clear_complaints (0);
+  clear_complaints ();
 }
 
 /* Process a symbol file, as either the main file or as a dynamically
@@ -2540,7 +2540,7 @@ reread_symbols (void)
 	    }
 
 	  (*objfile->sf->sym_init) (objfile);
-	  clear_complaints (1);
+	  clear_complaints ();
 
 	  objfile->flags &= ~OBJF_PSYMTABS_READ;
 
@@ -2570,7 +2570,7 @@ reread_symbols (void)
 	    }
 
 	  /* We're done reading the symbol file; finish off complaints.  */
-	  clear_complaints (0);
+	  clear_complaints ();
 
 	  /* Getting new symbols may change our opinion about what is
 	     frameless.  */
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index b26a242..e088cb6 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,12 @@
 2018-10-04  Tom Tromey  <tom@tromey.com>
 
+	* gdb.cp/maint.exp (test_invalid_name): Update expected output.
+	* gdb.gdb/complaints.exp (test_short_complaints): Remove.
+	(test_initial_complaints, test_empty_complaints): Update.
+	* gdb.dwarf2/dw2-stack-boundary.exp: Update.
+
+2018-10-04  Tom Tromey  <tom@tromey.com>
+
 	PR cli/19551:
 	* lib/mi-support.exp (mi_gdb_file_cmd): Update.
 	* lib/gdb.exp (gdb_file_cmd): Update.
diff --git a/gdb/testsuite/gdb.cp/maint.exp b/gdb/testsuite/gdb.cp/maint.exp
index 72a7524..af5b5be 100644
--- a/gdb/testsuite/gdb.cp/maint.exp
+++ b/gdb/testsuite/gdb.cp/maint.exp
@@ -51,7 +51,7 @@ proc test_single_component {name} {
 proc test_invalid_name {name} {
     set matchname [string_to_regexp "$name"]
     gdb_test "maint cp first_component $name" \
-	"During symbol reading, unexpected demangled name '$matchname'.\r\n$matchname"
+	"During symbol reading: unexpected demangled name '$matchname'\r\n$matchname"
 }
 
 proc test_first_component {} {
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-stack-boundary.exp b/gdb/testsuite/gdb.dwarf2/dw2-stack-boundary.exp
index cce8b4d..e63f9c1 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-stack-boundary.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-stack-boundary.exp
@@ -38,7 +38,7 @@ if [is_remote host] {
     }
 }
 gdb_test_no_output "set complaints 100"
-gdb_test "file $binfile" {Reading symbols from .*\.\.\.\r\nlocation description stack underflow\r\nlocation description stack overflow} "check partial symtab errors"
+gdb_test "file $binfile" {Reading symbols from .*\.\.\.\r\nDuring symbol reading: location description stack underflow\r\nDuring symbol reading: location description stack overflow} "check partial symtab errors"
 
 gdb_test "p underflow" {Asked for position 0 of stack, stack only has 0 elements on it\.}
 gdb_test "p overflow" " = 2"
diff --git a/gdb/testsuite/gdb.gdb/complaints.exp b/gdb/testsuite/gdb.gdb/complaints.exp
index 33ec268..8f573be 100644
--- a/gdb/testsuite/gdb.gdb/complaints.exp
+++ b/gdb/testsuite/gdb.gdb/complaints.exp
@@ -62,37 +62,17 @@ proc test_initial_complaints { } {
     # Prime the system
     gdb_test_stdio \
 	"call complaint_internal (\$cstr)" \
-	"During symbol reading, Register a complaint."
+	"During symbol reading: Register a complaint"
 
     # Re-issue the first message #1
     gdb_test_stdio \
 	"call complaint_internal (\$cstr)" \
-	"During symbol reading, Register a complaint."
+	"During symbol reading: Register a complaint"
 
     # Add a second complaint, expect it
     gdb_test_stdio \
 	"call complaint_internal (\"Testing! Testing! Testing!\")" \
-	"During symbol reading, Testing. Testing. Testing.."
-
-    return 0
-}
-
-# For short complaints, all are the same
-
-proc test_short_complaints { } {
-    gdb_test_exact "call clear_complaints (1)" "" "short start"
-
-    # Prime the system
-    test_complaint \
-	"call complaint_internal (\"short line 1\")" \
-	"short line 1" \
-	"short line 1"
-
-    # Add a second complaint, expect it
-    test_complaint \
-	"call complaint_internal (\"short line 2\")" \
-	"short line 2" \
-	"short line 2"
+	"During symbol reading: Testing. Testing. Testing."
 
     return 0
 }
@@ -123,16 +103,13 @@ proc test_empty_complaint { cmd msg } {
 
 proc test_empty_complaints { } {
 
-    test_empty_complaint "call clear_complaints(0)" \
-	    "empty non-verbose clear"
-    test_empty_complaint "call clear_complaints(1)" \
-	    "empty verbose clear"
+    test_empty_complaint "call clear_complaints()" \
+	    "clear complaints"
 
     return 0
 }
 
 do_self_tests captured_command_loop {
     test_initial_complaints
-    test_short_complaints
     test_empty_complaints
 }


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