X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Fcommon%2Fsignals.c;h=d4cf9532925d6d172a03a95bd09bc8cb2af43e0d;hb=c4b0b099b884e73d883f2b8c3ea8ffc9dc678902;hp=ea0c19a0c2ab52496f7937c7a2b8d39829164de1;hpb=73ba372ccf523876ab4b05993e240a37f99d9633;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/common/signals.c b/gdb/common/signals.c index ea0c19a0c2..d4cf953292 100644 --- a/gdb/common/signals.c +++ b/gdb/common/signals.c @@ -1,5 +1,5 @@ /* Target signal translation functions for GDB. - Copyright (C) 1990-2014 Free Software Foundation, Inc. + Copyright (C) 1990-2015 Free Software Foundation, Inc. Contributed by Cygnus Support. This file is part of GDB. @@ -17,19 +17,13 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifdef GDBSERVER -#include "server.h" -#else -#include "defs.h" -#include -#endif +#include "common-defs.h" #ifdef HAVE_SIGNAL_H #include #endif #include "gdb_signals.h" -#include "gdb_assert.h" struct gdbarch; @@ -121,36 +115,47 @@ gdb_signal_from_name (const char *name) enum gdb_signal gdb_signal_from_host (int hostsig) { - /* A switch statement would make sense but would require special kludges - to deal with the cases where more than one signal has the same number. */ + /* A switch statement would make sense but would require special + kludges to deal with the cases where more than one signal has the + same number. Signals are ordered ANSI-standard signals first, + other signals second, with signals in each block ordered by their + numerical values on a typical POSIX platform. */ if (hostsig == 0) return GDB_SIGNAL_0; + /* SIGINT, SIGILL, SIGABRT, SIGFPE, SIGSEGV and SIGTERM + are ANSI-standard signals and are always available. */ + if (hostsig == SIGINT) + return GDB_SIGNAL_INT; + if (hostsig == SIGILL) + return GDB_SIGNAL_ILL; + if (hostsig == SIGABRT) + return GDB_SIGNAL_ABRT; + if (hostsig == SIGFPE) + return GDB_SIGNAL_FPE; + if (hostsig == SIGSEGV) + return GDB_SIGNAL_SEGV; + if (hostsig == SIGTERM) + return GDB_SIGNAL_TERM; + + /* All other signals need preprocessor conditionals. */ #if defined (SIGHUP) if (hostsig == SIGHUP) return GDB_SIGNAL_HUP; #endif - if (hostsig == SIGINT) - return GDB_SIGNAL_INT; #if defined (SIGQUIT) if (hostsig == SIGQUIT) return GDB_SIGNAL_QUIT; #endif - if (hostsig == SIGILL) - return GDB_SIGNAL_ILL; #if defined (SIGTRAP) if (hostsig == SIGTRAP) return GDB_SIGNAL_TRAP; #endif - if (hostsig == SIGABRT) - return GDB_SIGNAL_ABRT; #if defined (SIGEMT) if (hostsig == SIGEMT) return GDB_SIGNAL_EMT; #endif - if (hostsig == SIGFPE) - return GDB_SIGNAL_FPE; #if defined (SIGKILL) if (hostsig == SIGKILL) return GDB_SIGNAL_KILL; @@ -159,8 +164,6 @@ gdb_signal_from_host (int hostsig) if (hostsig == SIGBUS) return GDB_SIGNAL_BUS; #endif - if (hostsig == SIGSEGV) - return GDB_SIGNAL_SEGV; #if defined (SIGSYS) if (hostsig == SIGSYS) return GDB_SIGNAL_SYS; @@ -173,8 +176,6 @@ gdb_signal_from_host (int hostsig) if (hostsig == SIGALRM) return GDB_SIGNAL_ALRM; #endif - if (hostsig == SIGTERM) - return GDB_SIGNAL_TERM; #if defined (SIGUSR1) if (hostsig == SIGUSR1) return GDB_SIGNAL_USR1; @@ -366,36 +367,48 @@ do_gdb_signal_to_host (enum gdb_signal oursig, do not support signals. */ (void) retsig; + /* Signals are ordered ANSI-standard signals first, other signals + second, with signals in each block ordered by their numerical + values on a typical POSIX platform. */ + *oursig_ok = 1; switch (oursig) { case GDB_SIGNAL_0: return 0; + /* SIGINT, SIGILL, SIGABRT, SIGFPE, SIGSEGV and SIGTERM + are ANSI-standard signals and are always available. */ + case GDB_SIGNAL_INT: + return SIGINT; + case GDB_SIGNAL_ILL: + return SIGILL; + case GDB_SIGNAL_ABRT: + return SIGABRT; + case GDB_SIGNAL_FPE: + return SIGFPE; + case GDB_SIGNAL_SEGV: + return SIGSEGV; + case GDB_SIGNAL_TERM: + return SIGTERM; + + /* All other signals need preprocessor conditionals. */ #if defined (SIGHUP) case GDB_SIGNAL_HUP: return SIGHUP; #endif - case GDB_SIGNAL_INT: - return SIGINT; #if defined (SIGQUIT) case GDB_SIGNAL_QUIT: return SIGQUIT; #endif - case GDB_SIGNAL_ILL: - return SIGILL; #if defined (SIGTRAP) case GDB_SIGNAL_TRAP: return SIGTRAP; #endif - case GDB_SIGNAL_ABRT: - return SIGABRT; #if defined (SIGEMT) case GDB_SIGNAL_EMT: return SIGEMT; #endif - case GDB_SIGNAL_FPE: - return SIGFPE; #if defined (SIGKILL) case GDB_SIGNAL_KILL: return SIGKILL; @@ -404,8 +417,6 @@ do_gdb_signal_to_host (enum gdb_signal oursig, case GDB_SIGNAL_BUS: return SIGBUS; #endif - case GDB_SIGNAL_SEGV: - return SIGSEGV; #if defined (SIGSYS) case GDB_SIGNAL_SYS: return SIGSYS; @@ -418,8 +429,6 @@ do_gdb_signal_to_host (enum gdb_signal oursig, case GDB_SIGNAL_ALRM: return SIGALRM; #endif - case GDB_SIGNAL_TERM: - return SIGTERM; #if defined (SIGUSR1) case GDB_SIGNAL_USR1: return SIGUSR1;