1 /* Support for complaint handling during symbol reading in GDB. 2 3 Copyright (C) 1990-2020 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 /* Map format strings to counters. */ 27 28 static std::unordered_map<const char *, int> counters; 29 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 34 int stop_whining = 0; 35 36 /* See complaints.h. */ 37 38 void 39 complaint_internal (const char *fmt, ...) 40 { 41 va_list args; 42 43 if (++counters[fmt] > stop_whining) 44 return; 45 46 va_start (args, fmt); 47 48 if (deprecated_warning_hook) 49 (*deprecated_warning_hook) (fmt, args); 50 else 51 { 52 fputs_filtered (_("During symbol reading: "), gdb_stderr); 53 vfprintf_filtered (gdb_stderr, fmt, args); 54 fputs_filtered ("\n", gdb_stderr); 55 } 56 57 va_end (args); 58 } 59 60 /* See complaints.h. */ 61 62 void 63 clear_complaints () 64 { 65 counters.clear (); 66 } 67 68 static void 69 complaints_show_value (struct ui_file *file, int from_tty, 70 struct cmd_list_element *cmd, const char *value) 71 { 72 fprintf_filtered (file, _("Max number of complaints about incorrect" 73 " symbols is %s.\n"), 74 value); 75 } 76 77 void _initialize_complaints (); 78 void 79 _initialize_complaints () 80 { 81 add_setshow_zinteger_cmd ("complaints", class_support, 82 &stop_whining, _("\ 83 Set max number of complaints about incorrect symbols."), _("\ 84 Show max number of complaints about incorrect symbols."), NULL, 85 NULL, complaints_show_value, 86 &setlist, &showlist); 87 } 88