version 1.5, 2018/04/14 15:49:41 |
version 1.5.2.1, 2020/04/08 14:05:40 |
|
|
/* messages.c - error reporter - |
/* messages.c - error reporter - |
Copyright (C) 1987-2016 Free Software Foundation, Inc. |
Copyright (C) 1987-2018 Free Software Foundation, Inc. |
This file is part of GAS, the GNU Assembler. |
This file is part of GAS, the GNU Assembler. |
|
|
GAS is free software; you can redistribute it and/or modify |
GAS is free software; you can redistribute it and/or modify |
|
|
02110-1301, USA. */ |
02110-1301, USA. */ |
|
|
#include "as.h" |
#include "as.h" |
|
#include <signal.h> |
|
|
|
/* If the system doesn't provide strsignal, we get it defined in |
|
libiberty but no declaration is supplied. Because, reasons. */ |
|
#if !defined (HAVE_STRSIGNAL) && !defined (strsignal) |
|
extern const char *strsignal (int); |
|
#endif |
|
|
static void identify (const char *); |
static void identify (const char *); |
static void as_show_where (void); |
static void as_show_where (void); |
static void as_warn_internal (const char *, unsigned int, char *); |
static void as_warn_internal (const char *, unsigned int, char *); |
static void as_bad_internal (const char *, unsigned int, char *); |
static void as_bad_internal (const char *, unsigned int, char *); |
|
static void signal_crash (int) ATTRIBUTE_NORETURN; |
|
|
/* Despite the rest of the comments in this file, (FIXME-SOON), |
/* Despite the rest of the comments in this file, (FIXME-SOON), |
here is the current scheme for error messages etc: |
here is the current scheme for error messages etc: |
Line 58 static void as_bad_internal (const char |
|
Line 66 static void as_bad_internal (const char |
|
as_tsktsk() is used when we see a minor error for which |
as_tsktsk() is used when we see a minor error for which |
our error recovery action is almost certainly correct. |
our error recovery action is almost certainly correct. |
In this case, we print a message and then assembly |
In this case, we print a message and then assembly |
continues as though no error occurred. */ |
continues as though no error occurred. |
|
|
|
as_abort () is used for logic failure (assert or abort, signal). |
|
*/ |
|
|
static void |
static void |
identify (const char *file) |
identify (const char *file) |
Line 286 as_fatal (const char *format, ...) |
|
Line 297 as_fatal (const char *format, ...) |
|
xexit (EXIT_FAILURE); |
xexit (EXIT_FAILURE); |
} |
} |
|
|
/* Indicate assertion failure. |
/* Indicate internal constency error. |
Arguments: Filename, line number, optional function name. */ |
Arguments: Filename, line number, optional function name. |
|
FILENAME may be NULL, which we use for crash-via-signal. */ |
|
|
void |
void |
as_assert (const char *file, int line, const char *fn) |
as_abort (const char *file, int line, const char *fn) |
{ |
{ |
as_show_where (); |
as_show_where (); |
fprintf (stderr, _("Internal error!\n")); |
|
if (fn) |
if (!file) |
fprintf (stderr, _("Assertion failure in %s at %s:%d.\n"), |
fprintf (stderr, _("Internal error (%s).\n"), fn ? fn : "unknown"); |
fn, file, line); |
else if (fn) |
|
fprintf (stderr, _("Internal error in %s at %s:%d.\n"), fn, file, line); |
else |
else |
fprintf (stderr, _("Assertion failure at %s:%d.\n"), file, line); |
fprintf (stderr, _("Internal error at %s:%d.\n"), file, line); |
|
|
fprintf (stderr, _("Please report this bug.\n")); |
fprintf (stderr, _("Please report this bug.\n")); |
|
|
xexit (EXIT_FAILURE); |
xexit (EXIT_FAILURE); |
} |
} |
|
|
/* as_abort: Print a friendly message saying how totally hosed we are, |
/* Handler for fatal signals, such as SIGSEGV. */ |
and exit without producing a core file. */ |
|
|
static void |
|
signal_crash (int signo) |
|
{ |
|
/* Reset, to prevent unbounded recursion. */ |
|
signal (signo, SIG_DFL); |
|
|
|
as_abort (NULL, 0, strsignal (signo)); |
|
} |
|
|
|
/* Register signal handlers, for less abrubt crashes. */ |
|
|
void |
void |
as_abort (const char *file, int line, const char *fn) |
signal_init (void) |
{ |
{ |
as_show_where (); |
#ifdef SIGSEGV |
if (fn) |
signal (SIGSEGV, signal_crash); |
fprintf (stderr, _("Internal error, aborting at %s:%d in %s\n"), |
#endif |
file, line, fn); |
#ifdef SIGILL |
else |
signal (SIGILL, signal_crash); |
fprintf (stderr, _("Internal error, aborting at %s:%d\n"), |
#endif |
file, line); |
#ifdef SIGBUS |
fprintf (stderr, _("Please report this bug.\n")); |
signal (SIGBUS, signal_crash); |
xexit (EXIT_FAILURE); |
#endif |
|
#ifdef SIGABRT |
|
signal (SIGABRT, signal_crash); |
|
#endif |
|
#if defined SIGIOT && (!defined SIGABRT || SIGABRT != SIGIOT) |
|
signal (SIGIOT, signal_crash); |
|
#endif |
|
#ifdef SIGFPE |
|
signal (SIGFPE, signal_crash); |
|
#endif |
} |
} |
|
|
/* Support routines. */ |
/* Support routines. */ |