S390: Fix displaced stepping of "basr r,0"
[deliverable/binutils-gdb.git] / gdb / complaints.c
... / ...
CommitLineData
1/* Support for complaint handling during symbol reading in GDB.
2
3 Copyright (C) 1990-2018 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#include "complaints.h"
22#include "command.h"
23#include "gdbcmd.h"
24#include <unordered_map>
25
26/* Should each complaint message be self explanatory, or should we
27 assume that a series of complaints is being produced? */
28
29enum complaint_series {
30 /* Isolated self explanatory message. */
31 ISOLATED_MESSAGE,
32
33 /* First message of a series, but does not need to include any sort
34 of explanation. */
35 SHORT_FIRST_MESSAGE,
36};
37
38/* Map format strings to counters. */
39
40static std::unordered_map<const char *, int> counters;
41
42/* How to print the next complaint. */
43
44static complaint_series series;
45
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. */
49
50int stop_whining = 0;
51
52/* See complaints.h. */
53
54void
55complaint_internal (const char *fmt, ...)
56{
57 va_list args;
58
59 if (counters[fmt]++ > stop_whining)
60 return;
61
62 va_start (args, fmt);
63
64 if (deprecated_warning_hook)
65 (*deprecated_warning_hook) (fmt, args);
66 else
67 {
68 std::string msg = string_vprintf (fmt, args);
69 wrap_here ("");
70 begin_line ();
71 if (series == ISOLATED_MESSAGE)
72 fprintf_filtered (gdb_stderr, "During symbol reading, %s.\n",
73 msg.c_str ());
74 else
75 fprintf_filtered (gdb_stderr, "%s...", msg.c_str ());
76 }
77
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. */
81
82 gdb_flush (gdb_stderr);
83 va_end (args);
84}
85
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). */
91
92void
93clear_complaints (int less_verbose)
94{
95 struct complain *p;
96
97 counters.clear ();
98
99 if (!less_verbose)
100 series = ISOLATED_MESSAGE;
101 else
102 series = SHORT_FIRST_MESSAGE;
103}
104
105static void
106complaints_show_value (struct ui_file *file, int from_tty,
107 struct cmd_list_element *cmd, const char *value)
108{
109 fprintf_filtered (file, _("Max number of complaints about incorrect"
110 " symbols is %s.\n"),
111 value);
112}
113
114void
115_initialize_complaints (void)
116{
117 add_setshow_zinteger_cmd ("complaints", class_support,
118 &stop_whining, _("\
119Set max number of complaints about incorrect symbols."), _("\
120Show max number of complaints about incorrect symbols."), NULL,
121 NULL, complaints_show_value,
122 &setlist, &showlist);
123}
This page took 0.052714 seconds and 4 git commands to generate.