Commit | Line | Data |
---|---|---|
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 | 21 | #include "complaints.h" |
4de283e4 | 22 | #include "command.h" |
c906108c | 23 | #include "gdbcmd.h" |
4de283e4 | 24 | #include <unordered_map> |
c906108c | 25 | |
ff1cf532 | 26 | /* Map format strings to counters. */ |
c906108c | 27 | |
ff1cf532 | 28 | static std::unordered_map<const char *, int> counters; |
c906108c | 29 | |
b9caf505 AC |
30 | /* How many complaints about a particular thing should be printed |
31 | before we stop whining about it? Default is no whining at all, | |
32 | since so many systems have ill-constructed symbol files. */ | |
33 | ||
62d7ae92 | 34 | int stop_whining = 0; |
b9caf505 | 35 | |
de54e1a5 | 36 | /* See complaints.h. */ |
b9caf505 | 37 | |
de54e1a5 TT |
38 | void |
39 | complaint_internal (const char *fmt, ...) | |
b9caf505 | 40 | { |
de54e1a5 | 41 | va_list args; |
c5504eaf | 42 | |
9fdd7193 | 43 | if (++counters[fmt] > stop_whining) |
b9caf505 AC |
44 | return; |
45 | ||
de54e1a5 | 46 | va_start (args, fmt); |
b9caf505 | 47 | |
7ff88174 | 48 | if (deprecated_warning_hook) |
77b64a49 | 49 | (*deprecated_warning_hook) (fmt, args); |
b9caf505 | 50 | else |
c906108c | 51 | { |
5ca8c39f TT |
52 | fputs_filtered (_("During symbol reading: "), gdb_stderr); |
53 | vfprintf_filtered (gdb_stderr, fmt, args); | |
54 | fputs_filtered ("\n", gdb_stderr); | |
c906108c | 55 | } |
c906108c | 56 | |
b9caf505 AC |
57 | va_end (args); |
58 | } | |
59 | ||
5ca8c39f | 60 | /* See complaints.h. */ |
c906108c SS |
61 | |
62 | void | |
5ca8c39f | 63 | clear_complaints () |
c906108c | 64 | { |
ff1cf532 | 65 | counters.clear (); |
c906108c SS |
66 | } |
67 | ||
335cca0d | 68 | static void |
08546159 AC |
69 | complaints_show_value (struct ui_file *file, int from_tty, |
70 | struct cmd_list_element *cmd, const char *value) | |
335cca0d AC |
71 | { |
72 | fprintf_filtered (file, _("Max number of complaints about incorrect" | |
08546159 | 73 | " symbols is %s.\n"), |
335cca0d AC |
74 | value); |
75 | } | |
76 | ||
c906108c | 77 | void |
fba45db2 | 78 | _initialize_complaints (void) |
c906108c | 79 | { |
aff410f1 MS |
80 | add_setshow_zinteger_cmd ("complaints", class_support, |
81 | &stop_whining, _("\ | |
3d263c1d | 82 | Set max number of complaints about incorrect symbols."), _("\ |
335cca0d | 83 | Show max number of complaints about incorrect symbols."), NULL, |
08546159 | 84 | NULL, complaints_show_value, |
b3f42336 | 85 | &setlist, &showlist); |
c906108c | 86 | } |