Sort includes for files gdb/[a-f]*.[chyl].
[deliverable/binutils-gdb.git] / gdb / complaints.c
1 /* Support for complaint handling during symbol reading in GDB.
2
3 Copyright (C) 1990-2019 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
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.
11
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.
16
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/>. */
19
20 #include "defs.h"
21
22 /* Standard C++ includes. */
23 #include <unordered_map>
24
25 /* Local non-gdb includes. */
26 #include "command.h"
27 #include "complaints.h"
28 #include "gdbcmd.h"
29
30 /* Map format strings to counters. */
31
32 static std::unordered_map<const char *, int> counters;
33
34 /* How many complaints about a particular thing should be printed
35 before we stop whining about it? Default is no whining at all,
36 since so many systems have ill-constructed symbol files. */
37
38 int stop_whining = 0;
39
40 /* See complaints.h. */
41
42 void
43 complaint_internal (const char *fmt, ...)
44 {
45 va_list args;
46
47 if (++counters[fmt] > stop_whining)
48 return;
49
50 va_start (args, fmt);
51
52 if (deprecated_warning_hook)
53 (*deprecated_warning_hook) (fmt, args);
54 else
55 {
56 fputs_filtered (_("During symbol reading: "), gdb_stderr);
57 vfprintf_filtered (gdb_stderr, fmt, args);
58 fputs_filtered ("\n", gdb_stderr);
59 }
60
61 va_end (args);
62 }
63
64 /* See complaints.h. */
65
66 void
67 clear_complaints ()
68 {
69 counters.clear ();
70 }
71
72 static void
73 complaints_show_value (struct ui_file *file, int from_tty,
74 struct cmd_list_element *cmd, const char *value)
75 {
76 fprintf_filtered (file, _("Max number of complaints about incorrect"
77 " symbols is %s.\n"),
78 value);
79 }
80
81 void
82 _initialize_complaints (void)
83 {
84 add_setshow_zinteger_cmd ("complaints", class_support,
85 &stop_whining, _("\
86 Set max number of complaints about incorrect symbols."), _("\
87 Show max number of complaints about incorrect symbols."), NULL,
88 NULL, complaints_show_value,
89 &setlist, &showlist);
90 }
This page took 0.037071 seconds and 4 git commands to generate.