1 /* Support for complaint handling during symbol reading in GDB. 2 Copyright (C) 1990, 1991, 1992 Free Software Foundation, Inc. 3 4 This file is part of GDB. 5 6 This program is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 2 of the License, or 9 (at your option) any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program; if not, write to the Free Software 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 19 20 #include "defs.h" 21 #include "complaints.h" 22 #include "gdbcmd.h" 23 #ifdef ANSI_PROTOTYPES 24 #include <stdarg.h> 25 #else 26 #include <varargs.h> 27 #endif 28 29 /* Structure to manage complaints about symbol file contents. */ 30 31 struct complaint complaint_root[1] = { 32 { 33 (char *) NULL, /* Complaint message */ 34 0, /* Complaint counter */ 35 complaint_root /* Next complaint. */ 36 } 37 }; 38 39 /* How many complaints about a particular thing should be printed before 40 we stop whining about it? Default is no whining at all, since so many 41 systems have ill-constructed symbol files. */ 42 43 static unsigned int stop_whining = 0; 44 45 /* Should each complaint be self explanatory, or should we assume that 46 a series of complaints is being produced? 47 case 0: self explanatory message. 48 case 1: First message of a series that must start off with explanation. 49 case 2: Subsequent message, when user already knows we are reading 50 symbols and we can just state our piece. */ 51 52 static int complaint_series = 0; 53 54 /* External variables and functions referenced. */ 55 56 extern int info_verbose; 57 58 59 /* Functions to handle complaints during symbol reading. */ 60 61 /* Print a complaint about the input symbols, and link the complaint block 62 into a chain for later handling. */ 63 64 /* VARARGS */ 65 void 66 #ifdef ANSI_PROTOTYPES 67 complain (struct complaint *complaint, ...) 68 #else 69 complain (va_alist) 70 va_dcl 71 #endif 72 { 73 va_list args; 74 #ifdef ANSI_PROTOTYPES 75 va_start (args, complaint); 76 #else 77 struct complaint *complaint; 78 79 va_start (args); 80 complaint = va_arg (args, struct complaint *); 81 #endif 82 83 complaint -> counter++; 84 if (complaint -> next == NULL) 85 { 86 complaint -> next = complaint_root -> next; 87 complaint_root -> next = complaint; 88 } 89 if (complaint -> counter > stop_whining) 90 { 91 return; 92 } 93 wrap_here (""); 94 95 switch (complaint_series + (info_verbose << 1)) 96 { 97 98 /* Isolated messages, must be self-explanatory. */ 99 case 0: 100 begin_line (); 101 puts_filtered ("During symbol reading, "); 102 wrap_here (""); 103 vprintf_filtered (complaint -> message, args); 104 puts_filtered (".\n"); 105 break; 106 107 /* First of a series, without `set verbose'. */ 108 case 1: 109 begin_line (); 110 puts_filtered ("During symbol reading..."); 111 vprintf_filtered (complaint -> message, args); 112 puts_filtered ("..."); 113 wrap_here (""); 114 complaint_series++; 115 break; 116 117 /* Subsequent messages of a series, or messages under `set verbose'. 118 (We'll already have produced a "Reading in symbols for XXX..." 119 message and will clean up at the end with a newline.) */ 120 default: 121 vprintf_filtered (complaint -> message, args); 122 puts_filtered ("..."); 123 wrap_here (""); 124 } 125 /* If GDB dumps core, we'd like to see the complaints first. Presumably 126 GDB will not be sending so many complaints that this becomes a 127 performance hog. */ 128 gdb_flush (gdb_stdout); 129 va_end (args); 130 } 131 132 /* Clear out all complaint counters that have ever been incremented. 133 If sym_reading is 1, be less verbose about successive complaints, 134 since the messages are appearing all together during a command that 135 reads symbols (rather than scattered around as psymtabs get fleshed 136 out into symtabs at random times). If noisy is 1, we are in a 137 noisy symbol reading command, and our caller will print enough 138 context for the user to figure it out. */ 139 140 void 141 clear_complaints (sym_reading, noisy) 142 int sym_reading; 143 int noisy; 144 { 145 struct complaint *p; 146 147 for (p = complaint_root -> next; p != complaint_root; p = p -> next) 148 { 149 p -> counter = 0; 150 } 151 152 if (!sym_reading && !noisy && complaint_series > 1) 153 { 154 /* Terminate previous series, since caller won't. */ 155 puts_filtered ("\n"); 156 } 157 158 complaint_series = sym_reading ? 1 + noisy : 0; 159 } 160 161 void 162 _initialize_complaints () 163 { 164 add_show_from_set 165 (add_set_cmd ("complaints", class_support, var_zinteger, 166 (char *) &stop_whining, 167 "Set max number of complaints about incorrect symbols.", 168 &setlist), 169 &showlist); 170 171 } 172