[4/7] Make complaint output prettier

Message ID 20180923150957.5798-5-tom@tromey.com
State New, archived
Headers

Commit Message

Tom Tromey Sept. 23, 2018, 3:09 p.m. UTC
  Currently complaints are not always printed with a newline.  For
example, when I run gdb on itself, I see output like:

    (gdb) set complaints 5
    (gdb) file ./gdb/gdb
    Reading symbols from ./gdb/gdb...DW_AT_low_pc 0x0 is zero for DIE at 0x437dd4 [in module /home/tromey/gdb/build/gdb/gdb]....debug_line address at offset 0x21bf9 is 0 [in module /home/tromey/gdb/build/gdb/gdb]...DW_AT_low_pc 0x0 is zero for DIE at 0x5a85dd [in module /home/tromey/gdb/build/gdb/gdb]....debug_line address at offset 0x2dc2d is 0 [in module /home/tromey/gdb/build/gdb/gdb]...DW_AT_low_pc 0x0 is zero for DIE at 0xab6033 [in module /home/tromey/gdb/build/gdb/gdb]....debug_line address at offset 0x4f683 is 0 [in module /home/tromey/gdb/build/gdb/gdb]...DW_AT_low_pc 0x0 is zero for DIE at 0x10028f0 [in module /home/tromey/gdb/build/gdb/gdb]....debug_line address at offset 0x75edf is 0 [in module /home/tromey/gdb/build/gdb/gdb]...DW_AT_low_pc 0x0 is zero for DIE at 0x1021364 [in module /home/tromey/gdb/build/gdb/gdb]....debug_line address at offset 0x76f62 is 0 [in module /home/tromey/gdb/build/gdb/gdb]...done.

That's one very long line.  I find it quite difficult to read that,
and I thought it would be better with some newlines, which is what
this patch does.  Now the output looks like:

    (gdb) file ./gdb
    Reading symbols from ./gdb...
    DW_AT_low_pc 0x0 is zero for DIE at 0x437dd4 [in module /home/tromey/gdb/build/gdb/gdb]
    .debug_line address at offset 0x21bf9 is 0 [in module /home/tromey/gdb/build/gdb/gdb]
    DW_AT_low_pc 0x0 is zero for DIE at 0x5a85dd [in module /home/tromey/gdb/build/gdb/gdb]
    .debug_line address at offset 0x2dc2d is 0 [in module /home/tromey/gdb/build/gdb/gdb]
    done.

gdb/ChangeLog
2018-09-23  Tom Tromey  <tom@tromey.com>

	PR cli/22234:
	* complaints.c: Emit \n.

gdb/testsuite/ChangeLog
2018-09-23  Tom Tromey  <tom@tromey.com>

	PR cli/22234:
	* gdb.dwarf2/dw2-stack-boundary.exp: Update expected output.
	* gdb.gdb/complaints.exp (test_short_complaints): Update expected
	output.
---
 gdb/ChangeLog                                   | 5 +++++
 gdb/complaints.c                                | 2 +-
 gdb/testsuite/ChangeLog                         | 7 +++++++
 gdb/testsuite/gdb.dwarf2/dw2-stack-boundary.exp | 2 +-
 gdb/testsuite/gdb.gdb/complaints.exp            | 4 ++--
 5 files changed, 16 insertions(+), 4 deletions(-)
  

Patch

diff --git a/gdb/complaints.c b/gdb/complaints.c
index 43ea7a18a7..ab61980b62 100644
--- a/gdb/complaints.c
+++ b/gdb/complaints.c
@@ -72,7 +72,7 @@  complaint_internal (const char *fmt, ...)
 	fprintf_filtered (gdb_stderr, "During symbol reading, %s.\n",
 			  msg.c_str ());
       else
-	fprintf_filtered (gdb_stderr, "%s...", msg.c_str ());
+	fprintf_filtered (gdb_stderr, "%s\n", msg.c_str ());
     }
 
   /* If GDB dumps core, we'd like to see the complaints first.
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-stack-boundary.exp b/gdb/testsuite/gdb.dwarf2/dw2-stack-boundary.exp
index b38a579fe5..5be51f4356 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 .*\.\.\.location description stack underflow\.\.\.location description stack overflow\.\.\..*done\.} "check partial symtab errors"
+gdb_test "file $binfile" {Reading symbols from .*\.\.\.location description stack underflow\r\nlocation description stack overflow\r\ndone\.} "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 65b6bdc281..33ec268949 100644
--- a/gdb/testsuite/gdb.gdb/complaints.exp
+++ b/gdb/testsuite/gdb.gdb/complaints.exp
@@ -85,13 +85,13 @@  proc test_short_complaints { } {
     # Prime the system
     test_complaint \
 	"call complaint_internal (\"short line 1\")" \
-	"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" \
 	"short line 2"
 
     return 0