1 /* Support for complaint handling during symbol reading in GDB.
3 Copyright (C) 1990-2018 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 #include "complaints.h"
24 #include <unordered_map>
26 /* Should each complaint message be self explanatory, or should we
27 assume that a series of complaints is being produced? */
29 enum complaint_series {
30 /* Isolated self explanatory message. */
33 /* First message of a series, but does not need to include any sort
38 /* Map format strings to counters. */
40 static std::unordered_map<const char *, int> counters;
42 /* How to print the next complaint. */
44 static complaint_series series;
46 /* How many complaints about a particular thing should be printed
47 before we stop whining about it? Default is no whining at all,
48 since so many systems have ill-constructed symbol files. */
52 /* See complaints.h. */
55 complaint_internal (const char *fmt, ...)
59 if (++counters[fmt] > stop_whining)
64 if (deprecated_warning_hook)
65 (*deprecated_warning_hook) (fmt, args);
68 std::string msg = string_vprintf (fmt, args);
71 if (series == ISOLATED_MESSAGE)
72 fprintf_filtered (gdb_stderr, "During symbol reading, %s.\n",
75 fprintf_filtered (gdb_stderr, "%s...", msg.c_str ());
78 /* If GDB dumps core, we'd like to see the complaints first.
79 Presumably GDB will not be sending so many complaints that this
80 becomes a performance hog. */
82 gdb_flush (gdb_stderr);
86 /* Clear out / initialize all complaint counters that have ever been
87 incremented. If LESS_VERBOSE is 1, be less verbose about
88 successive complaints, since the messages are appearing all
89 together during a command that is reporting a contiguous block of
90 complaints (rather than being interleaved with other messages). */
93 clear_complaints (int less_verbose)
98 series = ISOLATED_MESSAGE;
100 series = SHORT_FIRST_MESSAGE;
104 complaints_show_value (struct ui_file *file, int from_tty,
105 struct cmd_list_element *cmd, const char *value)
107 fprintf_filtered (file, _("Max number of complaints about incorrect"
108 " symbols is %s.\n"),
113 _initialize_complaints (void)
115 add_setshow_zinteger_cmd ("complaints", class_support,
117 Set max number of complaints about incorrect symbols."), _("\
118 Show max number of complaints about incorrect symbols."), NULL,
119 NULL, complaints_show_value,
120 &setlist, &showlist);