| 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ |
| 19 | |
| 20 | #include "defs.h" |
| 21 | #include "complaints.h" |
| 22 | #include "gdbcmd.h" |
| 23 | #include <varargs.h> |
| 24 | |
| 25 | /* Structure to manage complaints about symbol file contents. */ |
| 26 | |
| 27 | struct complaint complaint_root[1] = { |
| 28 | { |
| 29 | (char *) NULL, /* Complaint message */ |
| 30 | 0, /* Complaint counter */ |
| 31 | complaint_root /* Next complaint. */ |
| 32 | } |
| 33 | }; |
| 34 | |
| 35 | /* How many complaints about a particular thing should be printed before |
| 36 | we stop whining about it? Default is no whining at all, since so many |
| 37 | systems have ill-constructed symbol files. */ |
| 38 | |
| 39 | static unsigned int stop_whining = 0; |
| 40 | |
| 41 | /* Should each complaint be self explanatory, or should we assume that |
| 42 | a series of complaints is being produced? |
| 43 | case 0: self explanatory message. |
| 44 | case 1: First message of a series that must start off with explanation. |
| 45 | case 2: Subsequent message, when user already knows we are reading |
| 46 | symbols and we can just state our piece. */ |
| 47 | |
| 48 | static int complaint_series = 0; |
| 49 | |
| 50 | /* External variables and functions referenced. */ |
| 51 | |
| 52 | extern int info_verbose; |
| 53 | |
| 54 | \f |
| 55 | /* Functions to handle complaints during symbol reading. */ |
| 56 | |
| 57 | /* Print a complaint about the input symbols, and link the complaint block |
| 58 | into a chain for later handling. */ |
| 59 | |
| 60 | /* VARARGS */ |
| 61 | void |
| 62 | complain (va_alist) |
| 63 | va_dcl |
| 64 | { |
| 65 | va_list args; |
| 66 | struct complaint *complaint; |
| 67 | |
| 68 | va_start (args); |
| 69 | complaint = va_arg (args, struct complaint *); |
| 70 | complaint -> counter++; |
| 71 | if (complaint -> next == NULL) |
| 72 | { |
| 73 | complaint -> next = complaint_root -> next; |
| 74 | complaint_root -> next = complaint; |
| 75 | } |
| 76 | if (complaint -> counter > stop_whining) |
| 77 | { |
| 78 | return; |
| 79 | } |
| 80 | wrap_here (""); |
| 81 | |
| 82 | switch (complaint_series + (info_verbose << 1)) |
| 83 | { |
| 84 | |
| 85 | /* Isolated messages, must be self-explanatory. */ |
| 86 | case 0: |
| 87 | begin_line (); |
| 88 | puts_filtered ("During symbol reading, "); |
| 89 | wrap_here (""); |
| 90 | vprintf_filtered (complaint -> message, args); |
| 91 | puts_filtered (".\n"); |
| 92 | break; |
| 93 | |
| 94 | /* First of a series, without `set verbose'. */ |
| 95 | case 1: |
| 96 | begin_line (); |
| 97 | puts_filtered ("During symbol reading..."); |
| 98 | vprintf_filtered (complaint -> message, args); |
| 99 | puts_filtered ("..."); |
| 100 | wrap_here (""); |
| 101 | complaint_series++; |
| 102 | break; |
| 103 | |
| 104 | /* Subsequent messages of a series, or messages under `set verbose'. |
| 105 | (We'll already have produced a "Reading in symbols for XXX..." |
| 106 | message and will clean up at the end with a newline.) */ |
| 107 | default: |
| 108 | vprintf_filtered (complaint -> message, args); |
| 109 | puts_filtered ("..."); |
| 110 | wrap_here (""); |
| 111 | } |
| 112 | va_end (args); |
| 113 | } |
| 114 | |
| 115 | /* Clear out all complaint counters that have ever been incremented. |
| 116 | If sym_reading is 1, be less verbose about successive complaints, |
| 117 | since the messages are appearing all together during a command that |
| 118 | reads symbols (rather than scattered around as psymtabs get fleshed |
| 119 | out into symtabs at random times). If noisy is 1, we are in a |
| 120 | noisy symbol reading command, and our caller will print enough |
| 121 | context for the user to figure it out. */ |
| 122 | |
| 123 | void |
| 124 | clear_complaints (sym_reading, noisy) |
| 125 | int sym_reading; |
| 126 | int noisy; |
| 127 | { |
| 128 | struct complaint *p; |
| 129 | |
| 130 | for (p = complaint_root -> next; p != complaint_root; p = p -> next) |
| 131 | { |
| 132 | p -> counter = 0; |
| 133 | } |
| 134 | |
| 135 | if (!sym_reading && !noisy && complaint_series > 1) |
| 136 | { |
| 137 | /* Terminate previous series, since caller won't. */ |
| 138 | puts_filtered ("\n"); |
| 139 | } |
| 140 | |
| 141 | complaint_series = sym_reading ? 1 + noisy : 0; |
| 142 | } |
| 143 | |
| 144 | void |
| 145 | _initialize_complaints () |
| 146 | { |
| 147 | add_show_from_set |
| 148 | (add_set_cmd ("complaints", class_support, var_zinteger, |
| 149 | (char *) &stop_whining, |
| 150 | "Set max number of complaints about incorrect symbols.", |
| 151 | &setlist), |
| 152 | &showlist); |
| 153 | |
| 154 | } |