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