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