Re: [PATCH 01/15 v3] Introduce common/errors.h

Gary Benson
2014-07-18T10:44:52Z

Doug Evans wrote:
> On Fri, Jul 18, 2014 at 10:06 AM, Gary Benson <gbenson@redhat.com> wrote:
> > [...]
> > /* Throw a fatal error, constructing the message using a printf-style
> > format string and a printf- or vprintf-style argument list. This
> > function does not return. The application will exit. */
> >
> > extern void fatal (const char *fmt, ...)
> > ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 2);
> >
> > extern void vfatal (const char *fmt, va_list args)
> > ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 0);
> > [...]
>
> Remember gdb doesn't exit on fatal().
> fatal() in gdb is essentially ^c (quit() calls fatal()!).
>
> Can I repeat my request to please document this in the function
> comment.

I wanted to avoid putting implementation details here, but I see this
isn't going to happen. Is the attached ok?

Cheers,
Gary

--
/* Display a warning message to the user. The message is constructed
using a printf-style format string and a printf- or vprintf-style
argument list. */

extern void warning (const char *fmt, ...) ATTRIBUTE_PRINTF (1, 2);

extern void vwarning (const char *fmt, va_list args)
ATTRIBUTE_PRINTF (1, 0);

/* Throw a generic error, constructing the message using a printf-
style format string and a printf- or vprintf-style argument list.
This function does not return. */

extern void error (const char *fmt, ...)
ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 2);

extern void verror (const char *fmt, va_list args)
ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 0);

/* Throw a generic error, constructing the message by combining STRING
with the system error message for errno. This function does not
return. */

extern void perror_with_name (const char *string) ATTRIBUTE_NORETURN;

/* Throw a fatal error, constructing the message using a printf-style
format string and a printf- or vprintf-style argument list. This
function does not return. Fatal errors cause GDB to return to the
command level. Fatal errors cause gdbserver to exit. */

extern void fatal (const char *fmt, ...)
ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 2);

extern void vfatal (const char *fmt, va_list args)
ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 0);

/* Throw an internal error, constructing the message using a printf-
style format string and a printf- or vprintf-style argument list.
This function does not return. */

extern void internal_error (const char *file, int line,
const char *fmt, ...)
ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (3, 4);

extern void internal_verror (const char *file, int line,
const char *fmt, va_list args)
ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (3, 0);

/* A special case of internal error used to handle memory allocation
failures. */

extern void malloc_failure (long size) ATTRIBUTE_NORETURN;