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.
This commit is contained in:
Tom Tromey 2018-05-27 21:31:14 -06:00
parent e79497a160
commit 5ca8c39f05
8 changed files with 35 additions and 81 deletions

View File

@ -1,3 +1,13 @@
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

View File

@ -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

View File

@ -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. */
incremented. */
extern void clear_complaints (int less_verbose);
extern void clear_complaints ();
#endif /* !defined (COMPLAINTS_H) */

View File

@ -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. */

View File

@ -1,3 +1,10 @@
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:

View File

@ -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 {} {

View File

@ -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"

View File

@ -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
}