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