Sort includes for files gdb/[a-f]*.[chyl].
[deliverable/binutils-gdb.git] / gdb / complaints.c
CommitLineData
c906108c 1/* Support for complaint handling during symbol reading in GDB.
b9caf505 2
42a4f53d 3 Copyright (C) 1990-2019 Free Software Foundation, Inc.
c906108c 4
c5aa993b 5 This file is part of GDB.
c906108c 6
c5aa993b
JM
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
a9762ec7 9 the Free Software Foundation; either version 3 of the License, or
c5aa993b 10 (at your option) any later version.
c906108c 11
c5aa993b
JM
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.
c906108c 16
c5aa993b 17 You should have received a copy of the GNU General Public License
a9762ec7 18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
c906108c
SS
19
20#include "defs.h"
d55e5aa6
TT
21
22/* Standard C++ includes. */
23#include <unordered_map>
24
25/* Local non-gdb includes. */
b9caf505 26#include "command.h"
d55e5aa6 27#include "complaints.h"
c906108c
SS
28#include "gdbcmd.h"
29
ff1cf532 30/* Map format strings to counters. */
c906108c 31
ff1cf532 32static std::unordered_map<const char *, int> counters;
c906108c 33
b9caf505
AC
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
62d7ae92 38int stop_whining = 0;
b9caf505 39
de54e1a5 40/* See complaints.h. */
b9caf505 41
de54e1a5
TT
42void
43complaint_internal (const char *fmt, ...)
b9caf505 44{
de54e1a5 45 va_list args;
c5504eaf 46
9fdd7193 47 if (++counters[fmt] > stop_whining)
b9caf505
AC
48 return;
49
de54e1a5 50 va_start (args, fmt);
b9caf505 51
7ff88174 52 if (deprecated_warning_hook)
77b64a49 53 (*deprecated_warning_hook) (fmt, args);
b9caf505 54 else
c906108c 55 {
5ca8c39f
TT
56 fputs_filtered (_("During symbol reading: "), gdb_stderr);
57 vfprintf_filtered (gdb_stderr, fmt, args);
58 fputs_filtered ("\n", gdb_stderr);
c906108c 59 }
c906108c 60
b9caf505
AC
61 va_end (args);
62}
63
5ca8c39f 64/* See complaints.h. */
c906108c
SS
65
66void
5ca8c39f 67clear_complaints ()
c906108c 68{
ff1cf532 69 counters.clear ();
c906108c
SS
70}
71
335cca0d 72static void
08546159
AC
73complaints_show_value (struct ui_file *file, int from_tty,
74 struct cmd_list_element *cmd, const char *value)
335cca0d
AC
75{
76 fprintf_filtered (file, _("Max number of complaints about incorrect"
08546159 77 " symbols is %s.\n"),
335cca0d
AC
78 value);
79}
80
c906108c 81void
fba45db2 82_initialize_complaints (void)
c906108c 83{
aff410f1
MS
84 add_setshow_zinteger_cmd ("complaints", class_support,
85 &stop_whining, _("\
3d263c1d 86Set max number of complaints about incorrect symbols."), _("\
335cca0d 87Show max number of complaints about incorrect symbols."), NULL,
08546159 88 NULL, complaints_show_value,
b3f42336 89 &setlist, &showlist);
c906108c 90}
This page took 1.404976 seconds and 4 git commands to generate.