[patch/rfc] complain() -> complaint()
Andrew Cagney
ac131313@ges.redhat.com
Sun Aug 11 13:07:00 GMT 2002
Hello,
The files complaints.[hc] implement a mechanism for supressing warning
messages that occure more than a small number of times. GDB's debug
readers use this mechanism to supress all but the first few warnings
generated when reading an object file.
The current implementation stores the warning message string in a
structure vis:
struct complaint argument_complaint = { "Argument '%d'", };
DOUBLEST argument;
complain (&argument_complaint, "argument");
complain (&argument_complaint, argument);
complain (&argument_complaint, &argument);
The problem I see with this is that there is nothing (other than the
human eye) checking for consistency between the format string and the call.
I'd like to propose a new complaints interface:
void complaint (const char *fmt, ...);
(with a format printf attribute) so that the compiler (GCC with
-Wformat) can check, at build time, the consistency of the format string
and its parameter list. To issue the same complaint from multiple
points in the code, a wrapper function can be used:
argument_complaint (int argument)
{
complaint ("Argument '%d'", argument);
}
The process of updating the above should flush out a few bugs :-)
This change would help eliminate problems such as:
http://sources.redhat.com/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gdb&pr=211
--
I don't use the most efficient of algorithms when detecting duplicate
complaints. But then, I don't know how often complaints are occuring
and my objective is to fix the format miss-match.
The complaint() interface should probably be documented along with
error() and warning().
Should this be called symtab_complaint(), or perhaphs, should
complaint() take an extra parameter (the complaint class) so that other
code can use this mechanism?
--
thoughts?
Andrew
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: diffs
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20020811/abc2ebde/attachment.ksh>
More information about the Gdb-patches
mailing list