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