Commit | Line | Data |
---|---|---|
c906108c | 1 | /* Support for complaint handling during symbol reading in GDB. |
b6ba6518 KB |
2 | Copyright 1990, 1991, 1992, 1993, 1995, 1998, 1999, 2000 |
3 | 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 | |
9 | the Free Software Foundation; either version 2 of the License, or | |
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 JM |
17 | You should have received a copy of the GNU General Public License |
18 | along with this program; if not, write to the Free Software | |
19 | Foundation, Inc., 59 Temple Place - Suite 330, | |
20 | Boston, MA 02111-1307, USA. */ | |
c906108c SS |
21 | |
22 | #include "defs.h" | |
23 | #include "complaints.h" | |
24 | #include "gdbcmd.h" | |
25 | ||
a14ed312 | 26 | extern void _initialize_complaints (void); |
392a587b | 27 | |
c906108c SS |
28 | /* Structure to manage complaints about symbol file contents. */ |
29 | ||
c5aa993b JM |
30 | struct complaint complaint_root[1] = |
31 | { | |
c906108c | 32 | { |
c5aa993b JM |
33 | (char *) NULL, /* Complaint message */ |
34 | 0, /* Complaint counter */ | |
35 | complaint_root /* Next complaint. */ | |
c906108c SS |
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 | |
c5aa993b | 50 | symbols and we can just state our piece. */ |
c906108c SS |
51 | |
52 | static int complaint_series = 0; | |
53 | ||
54 | /* External variables and functions referenced. */ | |
55 | ||
56 | extern int info_verbose; | |
c906108c | 57 | \f |
c5aa993b | 58 | |
c906108c SS |
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 | ||
c906108c | 64 | void |
c5aa993b | 65 | complain (struct complaint *complaint,...) |
c906108c SS |
66 | { |
67 | va_list args; | |
c906108c | 68 | va_start (args, complaint); |
c906108c | 69 | |
c5aa993b JM |
70 | complaint->counter++; |
71 | if (complaint->next == NULL) | |
c906108c | 72 | { |
c5aa993b JM |
73 | complaint->next = complaint_root->next; |
74 | complaint_root->next = complaint; | |
c906108c | 75 | } |
c5aa993b | 76 | if (complaint->counter > stop_whining) |
c906108c SS |
77 | { |
78 | return; | |
79 | } | |
80 | wrap_here (""); | |
81 | ||
82 | switch (complaint_series + (info_verbose << 1)) | |
83 | { | |
84 | ||
85 | /* Isolated messages, must be self-explanatory. */ | |
c5aa993b | 86 | case 0: |
22d15040 FN |
87 | if (warning_hook) |
88 | (*warning_hook) (complaint->message, args); | |
89 | else | |
90 | { | |
91 | begin_line (); | |
92 | fputs_filtered ("During symbol reading, ", gdb_stderr); | |
93 | wrap_here (""); | |
94 | vfprintf_filtered (gdb_stderr, complaint->message, args); | |
95 | fputs_filtered (".\n", gdb_stderr); | |
96 | } | |
c5aa993b | 97 | break; |
c906108c SS |
98 | |
99 | /* First of a series, without `set verbose'. */ | |
c5aa993b | 100 | case 1: |
22d15040 FN |
101 | if (warning_hook) |
102 | (*warning_hook) (complaint->message, args); | |
103 | else | |
104 | { | |
105 | begin_line (); | |
106 | fputs_filtered ("During symbol reading...", gdb_stderr); | |
107 | vfprintf_filtered (gdb_stderr, complaint->message, args); | |
108 | fputs_filtered ("...", gdb_stderr); | |
109 | wrap_here (""); | |
110 | complaint_series++; | |
111 | } | |
c5aa993b | 112 | break; |
c906108c SS |
113 | |
114 | /* Subsequent messages of a series, or messages under `set verbose'. | |
c5aa993b JM |
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: | |
22d15040 FN |
118 | if (warning_hook) |
119 | (*warning_hook) (complaint->message, args); | |
120 | else | |
121 | { | |
122 | vfprintf_filtered (gdb_stderr, complaint->message, args); | |
123 | fputs_filtered ("...", gdb_stderr); | |
124 | wrap_here (""); | |
125 | } | |
c906108c SS |
126 | } |
127 | /* If GDB dumps core, we'd like to see the complaints first. Presumably | |
128 | GDB will not be sending so many complaints that this becomes a | |
129 | performance hog. */ | |
6426a772 | 130 | gdb_flush (gdb_stderr); |
c906108c SS |
131 | va_end (args); |
132 | } | |
133 | ||
134 | /* Clear out all complaint counters that have ever been incremented. | |
135 | If sym_reading is 1, be less verbose about successive complaints, | |
136 | since the messages are appearing all together during a command that | |
137 | reads symbols (rather than scattered around as psymtabs get fleshed | |
138 | out into symtabs at random times). If noisy is 1, we are in a | |
139 | noisy symbol reading command, and our caller will print enough | |
140 | context for the user to figure it out. */ | |
141 | ||
142 | void | |
fba45db2 | 143 | clear_complaints (int sym_reading, int noisy) |
c906108c SS |
144 | { |
145 | struct complaint *p; | |
146 | ||
c5aa993b | 147 | for (p = complaint_root->next; p != complaint_root; p = p->next) |
c906108c | 148 | { |
c5aa993b | 149 | p->counter = 0; |
c906108c SS |
150 | } |
151 | ||
22d15040 | 152 | if (!sym_reading && !noisy && complaint_series > 1 && !warning_hook) |
c906108c SS |
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 | |
fba45db2 | 162 | _initialize_complaints (void) |
c906108c SS |
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 | } |