1999-04-16 09:35:26 +08:00
|
|
|
|
/* Support for complaint handling during symbol reading in GDB.
|
|
|
|
|
Copyright (C) 1990, 1991, 1992 Free Software Foundation, Inc.
|
|
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
|
This file is part of GDB.
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
(at your option) any later version.
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
|
Boston, MA 02111-1307, USA. */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
|
#include "complaints.h"
|
|
|
|
|
#include "gdbcmd.h"
|
|
|
|
|
|
2000-05-28 09:12:42 +08:00
|
|
|
|
extern void _initialize_complaints (void);
|
1999-05-26 02:09:09 +08:00
|
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
|
/* Structure to manage complaints about symbol file contents. */
|
|
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
|
struct complaint complaint_root[1] =
|
|
|
|
|
{
|
1999-04-16 09:35:26 +08:00
|
|
|
|
{
|
1999-07-08 04:19:36 +08:00
|
|
|
|
(char *) NULL, /* Complaint message */
|
|
|
|
|
0, /* Complaint counter */
|
|
|
|
|
complaint_root /* Next complaint. */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* How many complaints about a particular thing should be printed before
|
|
|
|
|
we stop whining about it? Default is no whining at all, since so many
|
|
|
|
|
systems have ill-constructed symbol files. */
|
|
|
|
|
|
|
|
|
|
static unsigned int stop_whining = 0;
|
|
|
|
|
|
|
|
|
|
/* Should each complaint be self explanatory, or should we assume that
|
|
|
|
|
a series of complaints is being produced?
|
|
|
|
|
case 0: self explanatory message.
|
|
|
|
|
case 1: First message of a series that must start off with explanation.
|
|
|
|
|
case 2: Subsequent message, when user already knows we are reading
|
1999-07-08 04:19:36 +08:00
|
|
|
|
symbols and we can just state our piece. */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
|
|
static int complaint_series = 0;
|
|
|
|
|
|
|
|
|
|
/* External variables and functions referenced. */
|
|
|
|
|
|
|
|
|
|
extern int info_verbose;
|
|
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
|
/* Functions to handle complaints during symbol reading. */
|
|
|
|
|
|
|
|
|
|
/* Print a complaint about the input symbols, and link the complaint block
|
|
|
|
|
into a chain for later handling. */
|
|
|
|
|
|
|
|
|
|
void
|
1999-07-08 04:19:36 +08:00
|
|
|
|
complain (struct complaint *complaint,...)
|
1999-04-16 09:35:26 +08:00
|
|
|
|
{
|
|
|
|
|
va_list args;
|
|
|
|
|
va_start (args, complaint);
|
|
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
|
complaint->counter++;
|
|
|
|
|
if (complaint->next == NULL)
|
1999-04-16 09:35:26 +08:00
|
|
|
|
{
|
1999-07-08 04:19:36 +08:00
|
|
|
|
complaint->next = complaint_root->next;
|
|
|
|
|
complaint_root->next = complaint;
|
1999-04-16 09:35:26 +08:00
|
|
|
|
}
|
1999-07-08 04:19:36 +08:00
|
|
|
|
if (complaint->counter > stop_whining)
|
1999-04-16 09:35:26 +08:00
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
wrap_here ("");
|
|
|
|
|
|
|
|
|
|
switch (complaint_series + (info_verbose << 1))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/* Isolated messages, must be self-explanatory. */
|
1999-07-08 04:19:36 +08:00
|
|
|
|
case 0:
|
2000-12-21 01:32:17 +08:00
|
|
|
|
if (warning_hook)
|
|
|
|
|
(*warning_hook) (complaint->message, args);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
begin_line ();
|
|
|
|
|
fputs_filtered ("During symbol reading, ", gdb_stderr);
|
|
|
|
|
wrap_here ("");
|
|
|
|
|
vfprintf_filtered (gdb_stderr, complaint->message, args);
|
|
|
|
|
fputs_filtered (".\n", gdb_stderr);
|
|
|
|
|
}
|
1999-07-08 04:19:36 +08:00
|
|
|
|
break;
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
|
|
/* First of a series, without `set verbose'. */
|
1999-07-08 04:19:36 +08:00
|
|
|
|
case 1:
|
2000-12-21 01:32:17 +08:00
|
|
|
|
if (warning_hook)
|
|
|
|
|
(*warning_hook) (complaint->message, args);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
begin_line ();
|
|
|
|
|
fputs_filtered ("During symbol reading...", gdb_stderr);
|
|
|
|
|
vfprintf_filtered (gdb_stderr, complaint->message, args);
|
|
|
|
|
fputs_filtered ("...", gdb_stderr);
|
|
|
|
|
wrap_here ("");
|
|
|
|
|
complaint_series++;
|
|
|
|
|
}
|
1999-07-08 04:19:36 +08:00
|
|
|
|
break;
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
|
|
/* Subsequent messages of a series, or messages under `set verbose'.
|
1999-07-08 04:19:36 +08:00
|
|
|
|
(We'll already have produced a "Reading in symbols for XXX..."
|
|
|
|
|
message and will clean up at the end with a newline.) */
|
|
|
|
|
default:
|
2000-12-21 01:32:17 +08:00
|
|
|
|
if (warning_hook)
|
|
|
|
|
(*warning_hook) (complaint->message, args);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
vfprintf_filtered (gdb_stderr, complaint->message, args);
|
|
|
|
|
fputs_filtered ("...", gdb_stderr);
|
|
|
|
|
wrap_here ("");
|
|
|
|
|
}
|
1999-04-16 09:35:26 +08:00
|
|
|
|
}
|
|
|
|
|
/* If GDB dumps core, we'd like to see the complaints first. Presumably
|
|
|
|
|
GDB will not be sending so many complaints that this becomes a
|
|
|
|
|
performance hog. */
|
1999-09-29 05:55:21 +08:00
|
|
|
|
gdb_flush (gdb_stderr);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
va_end (args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Clear out all complaint counters that have ever been incremented.
|
|
|
|
|
If sym_reading is 1, be less verbose about successive complaints,
|
|
|
|
|
since the messages are appearing all together during a command that
|
|
|
|
|
reads symbols (rather than scattered around as psymtabs get fleshed
|
|
|
|
|
out into symtabs at random times). If noisy is 1, we are in a
|
|
|
|
|
noisy symbol reading command, and our caller will print enough
|
|
|
|
|
context for the user to figure it out. */
|
|
|
|
|
|
|
|
|
|
void
|
2000-07-30 09:48:28 +08:00
|
|
|
|
clear_complaints (int sym_reading, int noisy)
|
1999-04-16 09:35:26 +08:00
|
|
|
|
{
|
|
|
|
|
struct complaint *p;
|
|
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
|
for (p = complaint_root->next; p != complaint_root; p = p->next)
|
1999-04-16 09:35:26 +08:00
|
|
|
|
{
|
1999-07-08 04:19:36 +08:00
|
|
|
|
p->counter = 0;
|
1999-04-16 09:35:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
2000-12-21 01:32:17 +08:00
|
|
|
|
if (!sym_reading && !noisy && complaint_series > 1 && !warning_hook)
|
1999-04-16 09:35:26 +08:00
|
|
|
|
{
|
|
|
|
|
/* Terminate previous series, since caller won't. */
|
|
|
|
|
puts_filtered ("\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
complaint_series = sym_reading ? 1 + noisy : 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2000-07-30 09:48:28 +08:00
|
|
|
|
_initialize_complaints (void)
|
1999-04-16 09:35:26 +08:00
|
|
|
|
{
|
|
|
|
|
add_show_from_set
|
|
|
|
|
(add_set_cmd ("complaints", class_support, var_zinteger,
|
|
|
|
|
(char *) &stop_whining,
|
|
|
|
|
"Set max number of complaints about incorrect symbols.",
|
|
|
|
|
&setlist),
|
|
|
|
|
&showlist);
|
|
|
|
|
|
|
|
|
|
}
|