This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch 1/9]#2 Rename `enum target_signal' to target_signal_t


On Wednesday 01 September 2010 21:08:56, Pedro Alves wrote:
> On Wednesday 01 September 2010 21:06:24, Daniel Jacobowitz wrote:
> > On Wed, Sep 01, 2010 at 08:59:36PM +0100, Pedro Alves wrote:
> > > But, here's another idea of how to get compiler warnings/errors,
> > > that I think is more transparent to code throughout:
> > > 
> > > /* An empty struct.  It's the instances we care about.  */
> > > struct gdb_signal_1
> > > {
> > > };
> > 
> > Please don't do this!  It makes things much harder to debug.
> 
> Not with a gdb_signal pretty printer.  ;-)

Okay, upon popular request, I spend a bit this evening (well, night)
actually going ahead with that idea, while trying to not make
it much harder to debug, even without a pretty printer...

The main change compared to what I suggested before, is to
not make the object empty as quoted above, but actually give it
some fields:

struct target_signal_o
{
  int number;
  const char *name;
  const char *string;
};

I think this removes the "much" from much harder to debug.  It
may even remove the "harder".  See further below for example debugging-gdb
snippets.

The rest of the idea remains.  A target_signal_o array to hold
all the possible gdb signals, and a target_signal becomes:

typedef const struct target_signal_o * target_signal;

The TARGET_SIGNAL_... we all know and love become things like:

extern const target_signal TARGET_SIGNAL_0;
...
extern const target_signal TARGET_SIGNAL_TRAP;
...

defined as:

const target_signal TARGET_SIGNAL_0 = &signals[0];
...
const target_signal TARGET_SIGNAL_TRAP = &signals[5];
...

This has the advantage that we get compile time warnings/errors
when we mess up host signals with gdb signals, and, there is
no need for all those comparision macros.  Even LT and GT comparisons and
through the signals are allowed:

 for (target_signal sig = TARGET_SIGNAL_FIRST; sig < TARGET_SIGNAL_LAST; sig++)

I ended up borrowing a couple of macros from Jan's patch, like
TARGET_SIGNAL_NUMBER.

At debug-your-favorite-program time, you'd now simply dereference the
target_signal pointer to see what it is, instead of the previous suggested
macro magic:

 Breakpoint 3, linux_nat_resume (ops=0xbdcbc0, ptid=..., step=1, signo=0x810ac0) at ../../src/gdb/linux-nat.c:1872
 1872      if (debug_linux_nat)
 (top-gdb) p *signo
 $1 = {number = 0, name = 0x80fb80 "0", string = 0x80fb82 "Signal 0"}

which is a big harder than the status quo, but not umbearable-kind-of-hard,
I think.  On the bright side, you get to see the signal name and description
right there on the spot:

 (top-gdb) p *inferior_thread ()->stop_signal
 $6 = {number = 5, name = 0x80fbd2 "SIGTRAP", string = 0x80fbda "Trace/breakpoint trap"}

I only went as far as making it possible to build gdb on x86_64-unknown.linux-gnu.

Anyway, here it is at least for the archives.

-- 
Pedro Alves
---
 gdb/amd64-linux-tdep.c   |    2 
 gdb/common/gdb_signals.h |   14 +--
 gdb/common/signals.c     |  208 +++++++++++++++++++++++++----------------------
 gdb/corelow.c            |   17 +--
 gdb/defs.h               |    2 
 gdb/fork-child.c         |    2 
 gdb/gdbarch.c            |    6 -
 gdb/gdbarch.h            |   12 +-
 gdb/gdbarch.sh           |    6 -
 gdb/gdbthread.h          |    2 
 gdb/i386-linux-nat.c     |    2 
 gdb/i386-linux-tdep.c    |    2 
 gdb/inf-ptrace.c         |    2 
 gdb/infcmd.c             |    2 
 gdb/inferior.h           |   18 ++--
 gdb/infrun.c             |  187 ++++++++++++++++++++++--------------------
 gdb/linux-nat.c          |   35 ++++---
 gdb/linux-thread-db.c    |    2 
 gdb/record.c             |   20 ++--
 gdb/remote.c             |   46 ++++++----
 gdb/target.c             |    2 
 gdb/target.h             |   16 +--
 include/gdb/signals.def  |  151 ++++++++++++++++------------------
 include/gdb/signals.h    |   32 +++++--
 24 files changed, 420 insertions(+), 368 deletions(-)

Index: src/gdb/amd64-linux-tdep.c
===================================================================
--- src.orig/gdb/amd64-linux-tdep.c	2010-08-04 16:25:27.000000000 +0100
+++ src/gdb/amd64-linux-tdep.c	2010-09-01 22:46:12.000000000 +0100
@@ -1230,7 +1230,7 @@ amd64_linux_syscall_record (struct regca
 int
 amd64_linux_record_signal (struct gdbarch *gdbarch,
                            struct regcache *regcache,
-                           enum target_signal signal)
+                           target_signal signal)
 {
   ULONGEST rsp;
 
Index: src/gdb/common/gdb_signals.h
===================================================================
--- src.orig/gdb/common/gdb_signals.h	2010-01-05 11:46:50.000000000 +0000
+++ src/gdb/common/gdb_signals.h	2010-09-02 00:03:37.000000000 +0100
@@ -31,7 +31,7 @@
    In this context ``target_signal'' refers to GDB's internal
    representation of the target's set of signals while ``host signal''
    refers to the target operating system's signal.  Confused?  */
-extern int target_signal_to_host_p (enum target_signal signo);
+extern int target_signal_to_host_p (target_signal signo);
 
 /* Convert between host signal numbers and enum target_signal's.
    target_signal_to_host() returns 0 and prints a warning() on GDB's
@@ -41,16 +41,18 @@ extern int target_signal_to_host_p (enum
    Similarly, ``enum target_signal'' is named incorrectly, ``enum
    gdb_signal'' would probably be better as it is refering to GDB's
    internal representation of a target operating system's signal.  */
-extern enum target_signal target_signal_from_host (int);
-extern int target_signal_to_host (enum target_signal);
+extern target_signal target_signal_from_host (int);
+extern int target_signal_to_host (target_signal);
 
 /* Return the string for a signal.  */
-extern const char *target_signal_to_string (enum target_signal);
+extern const char *target_signal_to_string (target_signal);
 
 /* Return the name (SIGHUP, etc.) for a signal.  */
-extern const char *target_signal_to_name (enum target_signal);
+extern const char *target_signal_to_name (target_signal);
 
 /* Given a name (SIGHUP, etc.), return its signal.  */
-enum target_signal target_signal_from_name (const char *);
+target_signal target_signal_from_name (const char *);
+
+extern target_signal target_signal_from_number (int signo);
 
 #endif /* COMMON_GDB_SIGNALS_H */
Index: src/gdb/common/signals.c
===================================================================
--- src.orig/gdb/common/signals.c	2010-07-31 08:37:35.000000000 +0100
+++ src/gdb/common/signals.c	2010-09-02 02:30:58.000000000 +0100
@@ -48,38 +48,39 @@ struct gdbarch;
 # endif
 #endif
 
-/* This table must match in order and size the signals in enum target_signal.  */
+/* This table must match in order and size the signals in target_signal.  */
 
-static const struct {
-  const char *name;
-  const char *string;
-  } signals [] =
-{
-#define SET(symbol, constant, name, string) ANY (symbol, name, string)
-#define ANY(symbol, name, string) { name, string },
+static const struct target_signal_o signals[] =
+  {
+#define SET(symbol, constant, name, string)	\
+    { constant, name, string },
 #include "gdb/signals.def"
-#undef ANY
 #undef SET
-};
+  };
 
+#define SET(symbol, constant, name, string)		\
+    const target_signal symbol = (&signals[constant]);
+#include "gdb/signals.def"
+#undef SET
 
 /* Return the string for a signal.  */
 const char *
-target_signal_to_string (enum target_signal sig)
+target_signal_to_string (target_signal sig)
 {
-  if ((int) sig >= TARGET_SIGNAL_FIRST && (int) sig <= TARGET_SIGNAL_LAST)
-    return signals[sig].string;
+  if (TARGET_SIGNAL_NUMBER (sig) >= TARGET_SIGNAL_NUMBER (TARGET_SIGNAL_FIRST)
+      && TARGET_SIGNAL_NUMBER (sig) <= TARGET_SIGNAL_NUMBER (TARGET_SIGNAL_LAST))
+    return TARGET_SIGNAL_STRING (sig);
   else
-    return signals[TARGET_SIGNAL_UNKNOWN].string;
+    return TARGET_SIGNAL_STRING (TARGET_SIGNAL_UNKNOWN);
 }
 
 /* Return the name for a signal.  */
 const char *
-target_signal_to_name (enum target_signal sig)
+target_signal_to_name (target_signal sig)
 {
-  if ((int) sig >= TARGET_SIGNAL_FIRST && (int) sig <= TARGET_SIGNAL_LAST
-      && signals[sig].name != NULL)
-    return signals[sig].name;
+  if (sig >= TARGET_SIGNAL_FIRST && sig <= TARGET_SIGNAL_LAST
+      && sig->name != NULL)
+    return sig->name;
   else
     /* I think the code which prints this will always print it along
        with the string, so no need to be verbose (very old comment).  */
@@ -87,32 +88,43 @@ target_signal_to_name (enum target_signa
 }
 
 /* Given a name, return its signal.  */
-enum target_signal
+target_signal
 target_signal_from_name (const char *name)
 {
-  enum target_signal sig;
+  size_t sig;
 
   /* It's possible we also should allow "SIGCLD" as well as "SIGCHLD"
      for TARGET_SIGNAL_SIGCHLD.  SIGIOT, on the other hand, is more
      questionable; seems like by now people should call it SIGABRT
      instead.  */
 
-  /* This ugly cast brought to you by the native VAX compiler.  */
-  for (sig = TARGET_SIGNAL_HUP;
-       sig < TARGET_SIGNAL_LAST;
-       sig = (enum target_signal) ((int) sig + 1))
+  for (sig = 0;
+       sig < sizeof (signals) / sizeof (signals[0]);
+       sig++)
     if (signals[sig].name != NULL
 	&& strcmp (name, signals[sig].name) == 0)
-      return sig;
+      return &signals[sig];
   return TARGET_SIGNAL_UNKNOWN;
 }
+
+/* Return the target_signal for a gdb signal.  */
+
+target_signal
+target_signal_from_number (int number)
+{
+  if (number < 0 || number >= TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_LAST))
+    return TARGET_SIGNAL_UNKNOWN;
+  else
+    return &signals[number];
+}
+
 
 /* The following functions are to help certain targets deal
    with the signal/waitstatus stuff.  They could just as well be in
    a file called native-utils.c or unixwaitstatus-utils.c or whatever.  */
 
 /* Convert host signal to our signals.  */
-enum target_signal
+target_signal
 target_signal_from_host (int hostsig)
 {
   /* A switch statement would make sense but would require special kludges
@@ -342,13 +354,11 @@ target_signal_from_host (int hostsig)
     {
       /* This block of TARGET_SIGNAL_REALTIME value is in order.  */
       if (33 <= hostsig && hostsig <= 63)
-	return (enum target_signal)
-	  (hostsig - 33 + (int) TARGET_SIGNAL_REALTIME_33);
+	return &signals[hostsig - 33 + TARGET_SIGNAL_REALTIME_33->number];
       else if (hostsig == 32)
 	return TARGET_SIGNAL_REALTIME_32;
       else if (64 <= hostsig && hostsig <= 127)
-	return (enum target_signal)
-	  (hostsig - 64 + (int) TARGET_SIGNAL_REALTIME_64);
+	return &signals[hostsig - 64 + (int) TARGET_SIGNAL_REALTIME_64->number];
       else
 	error ("GDB bug: target.c (target_signal_from_host): unrecognized real-time signal");
     }
@@ -357,96 +367,98 @@ target_signal_from_host (int hostsig)
   return TARGET_SIGNAL_UNKNOWN;
 }
 
-/* Convert a OURSIG (an enum target_signal) to the form used by the
-   target operating system (refered to as the ``host'') or zero if the
+/* Convert a OURSIG (a target_signal) to the form used by the target
+   operating system (refered to as the ``host'') or zero if the
    equivalent host signal is not available.  Set/clear OURSIG_OK
    accordingly. */
 
 static int
-do_target_signal_to_host (enum target_signal oursig,
-			  int *oursig_ok)
+do_target_signal_to_host (target_signal oursig, int *oursig_ok)
 {
   int retsig;
   /* Silence the 'not used' warning, for targets that
      do not support signals.  */
   (void) retsig;
 
+#define TSNC \
+  TARGET_SIGNAL_NUMBER_CONST
+
   *oursig_ok = 1;
-  switch (oursig)
+  switch (oursig->number)
     {
-    case TARGET_SIGNAL_0:
+    case TSNC (TARGET_SIGNAL_0):
       return 0;
 
 #if defined (SIGHUP)
-    case TARGET_SIGNAL_HUP:
+    case TSNC (TARGET_SIGNAL_HUP):
       return SIGHUP;
 #endif
 #if defined (SIGINT)
-    case TARGET_SIGNAL_INT:
+    case TSNC (TARGET_SIGNAL_INT):
       return SIGINT;
 #endif
 #if defined (SIGQUIT)
-    case TARGET_SIGNAL_QUIT:
+    case TSNC (TARGET_SIGNAL_QUIT):
       return SIGQUIT;
 #endif
 #if defined (SIGILL)
-    case TARGET_SIGNAL_ILL:
+    case TSNC (TARGET_SIGNAL_ILL):
       return SIGILL;
 #endif
 #if defined (SIGTRAP)
-    case TARGET_SIGNAL_TRAP:
+    case TSNC (TARGET_SIGNAL_TRAP):
       return SIGTRAP;
 #endif
 #if defined (SIGABRT)
-    case TARGET_SIGNAL_ABRT:
+    case TSNC (TARGET_SIGNAL_ABRT):
       return SIGABRT;
 #endif
 #if defined (SIGEMT)
-    case TARGET_SIGNAL_EMT:
+    case TSNC (TARGET_SIGNAL_EMT):
       return SIGEMT;
 #endif
 #if defined (SIGFPE)
-    case TARGET_SIGNAL_FPE:
+    case TSNC (TARGET_SIGNAL_FPE):
       return SIGFPE;
 #endif
 #if defined (SIGKILL)
-    case TARGET_SIGNAL_KILL:
+    case TSNC (TARGET_SIGNAL_KILL):
       return SIGKILL;
 #endif
 #if defined (SIGBUS)
-    case TARGET_SIGNAL_BUS:
+    case TSNC (TARGET_SIGNAL_BUS):
       return SIGBUS;
 #endif
 #if defined (SIGSEGV)
-    case TARGET_SIGNAL_SEGV:
+    case TSNC (TARGET_SIGNAL_SEGV):
       return SIGSEGV;
 #endif
 #if defined (SIGSYS)
-    case TARGET_SIGNAL_SYS:
+    case TSNC (TARGET_SIGNAL_SYS):
       return SIGSYS;
 #endif
 #if defined (SIGPIPE)
-    case TARGET_SIGNAL_PIPE:
+    case TSNC (TARGET_SIGNAL_PIPE):
       return SIGPIPE;
 #endif
 #if defined (SIGALRM)
-    case TARGET_SIGNAL_ALRM:
+    case TSNC (TARGET_SIGNAL_ALRM):
       return SIGALRM;
 #endif
 #if defined (SIGTERM)
-    case TARGET_SIGNAL_TERM:
+    case TSNC (TARGET_SIGNAL_TERM):
       return SIGTERM;
 #endif
 #if defined (SIGUSR1)
-    case TARGET_SIGNAL_USR1:
+    case TSNC (TARGET_SIGNAL_USR1):
       return SIGUSR1;
 #endif
 #if defined (SIGUSR2)
-    case TARGET_SIGNAL_USR2:
+    case TSNC (TARGET_SIGNAL_USR2):
       return SIGUSR2;
 #endif
 #if defined (SIGCHLD) || defined (SIGCLD)
-    case TARGET_SIGNAL_CHLD:
+    case TSNC (TARGET_SIGNAL_CHLD):
 #if defined (SIGCHLD)
       return SIGCHLD;
 #else
@@ -454,145 +466,147 @@ do_target_signal_to_host (enum target_si
 #endif
 #endif /* SIGCLD or SIGCHLD */
 #if defined (SIGPWR)
-    case TARGET_SIGNAL_PWR:
+    case TSNC (TARGET_SIGNAL_PWR):
       return SIGPWR;
 #endif
 #if defined (SIGWINCH)
-    case TARGET_SIGNAL_WINCH:
+    case TSNC (TARGET_SIGNAL_WINCH):
       return SIGWINCH;
 #endif
 #if defined (SIGURG)
-    case TARGET_SIGNAL_URG:
+    case TSNC (TARGET_SIGNAL_URG):
       return SIGURG;
 #endif
 #if defined (SIGIO)
-    case TARGET_SIGNAL_IO:
+    case TSNC (TARGET_SIGNAL_IO):
       return SIGIO;
 #endif
 #if defined (SIGPOLL)
-    case TARGET_SIGNAL_POLL:
+    case TSNC (TARGET_SIGNAL_POLL):
       return SIGPOLL;
 #endif
 #if defined (SIGSTOP)
-    case TARGET_SIGNAL_STOP:
+    case TSNC (TARGET_SIGNAL_STOP):
       return SIGSTOP;
 #endif
 #if defined (SIGTSTP)
-    case TARGET_SIGNAL_TSTP:
+    case TSNC (TARGET_SIGNAL_TSTP):
       return SIGTSTP;
 #endif
 #if defined (SIGCONT)
-    case TARGET_SIGNAL_CONT:
+    case TSNC (TARGET_SIGNAL_CONT):
       return SIGCONT;
 #endif
 #if defined (SIGTTIN)
-    case TARGET_SIGNAL_TTIN:
+    case TSNC (TARGET_SIGNAL_TTIN):
       return SIGTTIN;
 #endif
 #if defined (SIGTTOU)
-    case TARGET_SIGNAL_TTOU:
+    case TSNC (TARGET_SIGNAL_TTOU):
       return SIGTTOU;
 #endif
 #if defined (SIGVTALRM)
-    case TARGET_SIGNAL_VTALRM:
+    case TSNC (TARGET_SIGNAL_VTALRM):
       return SIGVTALRM;
 #endif
 #if defined (SIGPROF)
-    case TARGET_SIGNAL_PROF:
+    case TSNC (TARGET_SIGNAL_PROF):
       return SIGPROF;
 #endif
 #if defined (SIGXCPU)
-    case TARGET_SIGNAL_XCPU:
+    case TSNC (TARGET_SIGNAL_XCPU):
       return SIGXCPU;
 #endif
 #if defined (SIGXFSZ)
-    case TARGET_SIGNAL_XFSZ:
+    case TSNC (TARGET_SIGNAL_XFSZ):
       return SIGXFSZ;
 #endif
 #if defined (SIGWIND)
-    case TARGET_SIGNAL_WIND:
+    case TSNC (TARGET_SIGNAL_WIND):
       return SIGWIND;
 #endif
 #if defined (SIGPHONE)
-    case TARGET_SIGNAL_PHONE:
+    case TSNC (TARGET_SIGNAL_PHONE):
       return SIGPHONE;
 #endif
 #if defined (SIGLOST)
-    case TARGET_SIGNAL_LOST:
+    case TSNC (TARGET_SIGNAL_LOST):
       return SIGLOST;
 #endif
 #if defined (SIGWAITING)
-    case TARGET_SIGNAL_WAITING:
+    case TSNC (TARGET_SIGNAL_WAITING):
       return SIGWAITING;
 #endif
 #if defined (SIGCANCEL)
-    case TARGET_SIGNAL_CANCEL:
+    case TSNC (TARGET_SIGNAL_CANCEL):
       return SIGCANCEL;
 #endif
 #if defined (SIGLWP)
-    case TARGET_SIGNAL_LWP:
+    case TSNC (TARGET_SIGNAL_LWP):
       return SIGLWP;
 #endif
 #if defined (SIGDANGER)
-    case TARGET_SIGNAL_DANGER:
+    case TSNC (TARGET_SIGNAL_DANGER):
       return SIGDANGER;
 #endif
 #if defined (SIGGRANT)
-    case TARGET_SIGNAL_GRANT:
+    case TSNC (TARGET_SIGNAL_GRANT):
       return SIGGRANT;
 #endif
 #if defined (SIGRETRACT)
-    case TARGET_SIGNAL_RETRACT:
+    case TSNC (TARGET_SIGNAL_RETRACT):
       return SIGRETRACT;
 #endif
 #if defined (SIGMSG)
-    case TARGET_SIGNAL_MSG:
+    case TSNC (TARGET_SIGNAL_MSG):
       return SIGMSG;
 #endif
 #if defined (SIGSOUND)
-    case TARGET_SIGNAL_SOUND:
+    case TSNC (TARGET_SIGNAL_SOUND):
       return SIGSOUND;
 #endif
 #if defined (SIGSAK)
-    case TARGET_SIGNAL_SAK:
+    case TSNC (TARGET_SIGNAL_SAK):
       return SIGSAK;
 #endif
 #if defined (SIGPRIO)
-    case TARGET_SIGNAL_PRIO:
+    case TSNC (TARGET_SIGNAL_PRIO):
       return SIGPRIO;
 #endif
 
       /* Mach exceptions.  Assumes that the values for EXC_ are positive! */
 #if defined (EXC_BAD_ACCESS) && defined (_NSIG)
-    case TARGET_EXC_BAD_ACCESS:
+    case TSNC (TARGET_EXC_BAD_ACCESS):
       return _NSIG + EXC_BAD_ACCESS;
 #endif
 #if defined (EXC_BAD_INSTRUCTION) && defined (_NSIG)
-    case TARGET_EXC_BAD_INSTRUCTION:
+    case TSNC (TARGET_EXC_BAD_INSTRUCTION):
       return _NSIG + EXC_BAD_INSTRUCTION;
 #endif
 #if defined (EXC_ARITHMETIC) && defined (_NSIG)
-    case TARGET_EXC_ARITHMETIC:
+    case TSNC (TARGET_EXC_ARITHMETIC):
       return _NSIG + EXC_ARITHMETIC;
 #endif
 #if defined (EXC_EMULATION) && defined (_NSIG)
-    case TARGET_EXC_EMULATION:
+    case TSNC (TARGET_EXC_EMULATION):
       return _NSIG + EXC_EMULATION;
 #endif
 #if defined (EXC_SOFTWARE) && defined (_NSIG)
-    case TARGET_EXC_SOFTWARE:
+    case TSNC (TARGET_EXC_SOFTWARE):
       return _NSIG + EXC_SOFTWARE;
 #endif
 #if defined (EXC_BREAKPOINT) && defined (_NSIG)
-    case TARGET_EXC_BREAKPOINT:
+    case TSNC (TARGET_EXC_BREAKPOINT):
       return _NSIG + EXC_BREAKPOINT;
 #endif
 
 #if defined (SIGINFO)
-    case TARGET_SIGNAL_INFO:
+    case TSNC (TARGET_SIGNAL_INFO):
       return SIGINFO;
 #endif
 
+#undef TSNC
+
     default:
 #if defined (REALTIME_LO)
       retsig = 0;
@@ -602,7 +616,7 @@ do_target_signal_to_host (enum target_si
 	{
 	  /* This block of signals is continuous, and
              TARGET_SIGNAL_REALTIME_33 is 33 by definition.  */
-	  retsig = (int) oursig - (int) TARGET_SIGNAL_REALTIME_33 + 33;
+	  retsig = oursig->number - TARGET_SIGNAL_REALTIME_33->number + 33;
 	}
       else if (oursig == TARGET_SIGNAL_REALTIME_32)
 	{
@@ -615,7 +629,7 @@ do_target_signal_to_host (enum target_si
 	{
 	  /* This block of signals is continuous, and
              TARGET_SIGNAL_REALTIME_64 is 64 by definition.  */
-	  retsig = (int) oursig - (int) TARGET_SIGNAL_REALTIME_64 + 64;
+	  retsig = oursig->number - TARGET_SIGNAL_REALTIME_64->number + 64;
 	}
 
       if (retsig >= REALTIME_LO && retsig < REALTIME_HI)
@@ -628,7 +642,7 @@ do_target_signal_to_host (enum target_si
 }
 
 int
-target_signal_to_host_p (enum target_signal oursig)
+target_signal_to_host_p (target_signal oursig)
 {
   int oursig_ok;
   do_target_signal_to_host (oursig, &oursig_ok);
@@ -636,7 +650,7 @@ target_signal_to_host_p (enum target_sig
 }
 
 int
-target_signal_to_host (enum target_signal oursig)
+target_signal_to_host (target_signal oursig)
 {
   int oursig_ok;
   int targ_signo = do_target_signal_to_host (oursig, &oursig_ok);
@@ -662,11 +676,11 @@ target_signal_to_host (enum target_signa
    lenient and allow 1-15 which should match host signal numbers on
    most systems.  Use of symbolic signal names is strongly encouraged.  */
 
-enum target_signal
+target_signal
 target_signal_from_command (int num)
 {
   if (num >= 1 && num <= 15)
-    return (enum target_signal) num;
+    return &signals[num];
   error ("Only signals 1-15 are valid as numeric signals.\n\
 Use \"info signals\" for a list of symbolic signals.");
 }
@@ -676,17 +690,17 @@ extern initialize_file_ftype _initialize
 void
 _initialize_signals (void)
 {
-  if (strcmp (signals[TARGET_SIGNAL_LAST].string, "TARGET_SIGNAL_MAGIC") != 0)
+  if (strcmp (TARGET_SIGNAL_LAST->string, "TARGET_SIGNAL_MAGIC") != 0)
     internal_error (__FILE__, __LINE__, "failed internal consistency check");
 }
 
 int
-default_target_signal_to_host (struct gdbarch *gdbarch, enum target_signal ts)
+default_target_signal_to_host (struct gdbarch *gdbarch, target_signal ts)
 {
   return target_signal_to_host (ts);
 }
 
-enum target_signal
+target_signal
 default_target_signal_from_host (struct gdbarch *gdbarch, int signo)
 {
   return target_signal_from_host (signo);
Index: src/gdb/corelow.c
===================================================================
--- src.orig/gdb/corelow.c	2010-08-18 15:07:25.000000000 +0100
+++ src/gdb/corelow.c	2010-09-02 01:33:20.000000000 +0100
@@ -429,15 +429,14 @@ core_open (char *filename, int from_tty)
 
   siggy = bfd_core_file_failing_signal (core_bfd);
   if (siggy > 0)
-    /* NOTE: target_signal_from_host() converts a target signal value
-       into gdb's internal signal value.  Unfortunately gdb's internal
-       value is called ``target_signal'' and this function got the
-       name ..._from_host(). */
-    printf_filtered (_("Program terminated with signal %d, %s.\n"), siggy,
-		     target_signal_to_string (
-		       (core_gdbarch != NULL) ?
-			gdbarch_target_signal_from_host (core_gdbarch, siggy)
-			: siggy));
+    {
+      target_signal sig = ((core_gdbarch != NULL)
+			   ? gdbarch_target_signal_from_host (core_gdbarch, siggy)
+			   : target_signal_from_number (siggy));
+
+      printf_filtered (_("Program terminated with signal %d, %s.\n"), siggy,
+		       target_signal_to_string (sig));
+    }
 
   /* Fetch all registers from core file.  */
   target_fetch_registers (get_current_regcache (), -1);
Index: src/gdb/defs.h
===================================================================
--- src.orig/gdb/defs.h	2010-09-01 14:35:07.000000000 +0100
+++ src/gdb/defs.h	2010-09-01 22:43:07.000000000 +0100
@@ -64,7 +64,7 @@
 
 #include "gdb_wchar.h"
 
-/* For ``enum target_signal''.  */
+/* For ``target_signal''.  */
 #include "gdb/signals.h"
 
 /* Just in case they're not defined in stdio.h.  */
Index: src/gdb/fork-child.c
===================================================================
--- src.orig/gdb/fork-child.c	2010-06-16 10:58:23.000000000 +0100
+++ src/gdb/fork-child.c	2010-09-01 22:51:31.000000000 +0100
@@ -448,7 +448,7 @@ startup_inferior (int ntraps)
 
   while (1)
     {
-      int resume_signal = TARGET_SIGNAL_0;
+      target_signal resume_signal = TARGET_SIGNAL_0;
       ptid_t event_ptid;
 
       struct target_waitstatus ws;
Index: src/gdb/gdbarch.c
===================================================================
--- src.orig/gdb/gdbarch.c	2010-08-18 15:07:25.000000000 +0100
+++ src/gdb/gdbarch.c	2010-09-01 22:43:44.000000000 +0100
@@ -3507,7 +3507,7 @@ gdbarch_process_record_signal_p (struct 
 }
 
 int
-gdbarch_process_record_signal (struct gdbarch *gdbarch, struct regcache *regcache, enum target_signal signal)
+gdbarch_process_record_signal (struct gdbarch *gdbarch, struct regcache *regcache, target_signal signal)
 {
   gdb_assert (gdbarch != NULL);
   gdb_assert (gdbarch->process_record_signal != NULL);
@@ -3523,7 +3523,7 @@ set_gdbarch_process_record_signal (struc
   gdbarch->process_record_signal = process_record_signal;
 }
 
-enum target_signal
+target_signal
 gdbarch_target_signal_from_host (struct gdbarch *gdbarch, int signo)
 {
   gdb_assert (gdbarch != NULL);
@@ -3541,7 +3541,7 @@ set_gdbarch_target_signal_from_host (str
 }
 
 int
-gdbarch_target_signal_to_host (struct gdbarch *gdbarch, enum target_signal ts)
+gdbarch_target_signal_to_host (struct gdbarch *gdbarch, target_signal ts)
 {
   gdb_assert (gdbarch != NULL);
   gdb_assert (gdbarch->target_signal_to_host != NULL);
Index: src/gdb/gdbarch.h
===================================================================
--- src.orig/gdb/gdbarch.h	2010-08-18 15:07:25.000000000 +0100
+++ src/gdb/gdbarch.h	2010-09-01 22:43:38.000000000 +0100
@@ -880,22 +880,22 @@ extern void set_gdbarch_process_record (
 
 extern int gdbarch_process_record_signal_p (struct gdbarch *gdbarch);
 
-typedef int (gdbarch_process_record_signal_ftype) (struct gdbarch *gdbarch, struct regcache *regcache, enum target_signal signal);
-extern int gdbarch_process_record_signal (struct gdbarch *gdbarch, struct regcache *regcache, enum target_signal signal);
+typedef int (gdbarch_process_record_signal_ftype) (struct gdbarch *gdbarch, struct regcache *regcache, target_signal signal);
+extern int gdbarch_process_record_signal (struct gdbarch *gdbarch, struct regcache *regcache, target_signal signal);
 extern void set_gdbarch_process_record_signal (struct gdbarch *gdbarch, gdbarch_process_record_signal_ftype *process_record_signal);
 
 /* Signal translation: translate inferior's signal (host's) number into
    GDB's representation. */
 
-typedef enum target_signal (gdbarch_target_signal_from_host_ftype) (struct gdbarch *gdbarch, int signo);
-extern enum target_signal gdbarch_target_signal_from_host (struct gdbarch *gdbarch, int signo);
+typedef target_signal (gdbarch_target_signal_from_host_ftype) (struct gdbarch *gdbarch, int signo);
+extern target_signal gdbarch_target_signal_from_host (struct gdbarch *gdbarch, int signo);
 extern void set_gdbarch_target_signal_from_host (struct gdbarch *gdbarch, gdbarch_target_signal_from_host_ftype *target_signal_from_host);
 
 /* Signal translation: translate GDB's signal number into inferior's host
    signal number. */
 
-typedef int (gdbarch_target_signal_to_host_ftype) (struct gdbarch *gdbarch, enum target_signal ts);
-extern int gdbarch_target_signal_to_host (struct gdbarch *gdbarch, enum target_signal ts);
+typedef int (gdbarch_target_signal_to_host_ftype) (struct gdbarch *gdbarch, target_signal ts);
+extern int gdbarch_target_signal_to_host (struct gdbarch *gdbarch, target_signal ts);
 extern void set_gdbarch_target_signal_to_host (struct gdbarch *gdbarch, gdbarch_target_signal_to_host_ftype *target_signal_to_host);
 
 /* Extra signal info inspection.
Index: src/gdb/gdbarch.sh
===================================================================
--- src.orig/gdb/gdbarch.sh	2010-08-18 15:07:25.000000000 +0100
+++ src/gdb/gdbarch.sh	2010-09-01 22:43:29.000000000 +0100
@@ -748,14 +748,14 @@ M:int:process_record:struct regcache *re
 
 # Save process state after a signal.
 # Return -1 if something goes wrong, 0 otherwise.
-M:int:process_record_signal:struct regcache *regcache, enum target_signal signal:regcache, signal
+M:int:process_record_signal:struct regcache *regcache, target_signal signal:regcache, signal
 
 # Signal translation: translate inferior's signal (host's) number into
 # GDB's representation.
-m:enum target_signal:target_signal_from_host:int signo:signo::default_target_signal_from_host::0
+m:target_signal:target_signal_from_host:int signo:signo::default_target_signal_from_host::0
 # Signal translation: translate GDB's signal number into inferior's host
 # signal number.
-m:int:target_signal_to_host:enum target_signal ts:ts::default_target_signal_to_host::0
+m:int:target_signal_to_host:target_signal ts:ts::default_target_signal_to_host::0
 
 # Extra signal info inspection.
 #
Index: src/gdb/gdbthread.h
===================================================================
--- src.orig/gdb/gdbthread.h	2010-01-12 23:11:40.000000000 +0000
+++ src/gdb/gdbthread.h	2010-09-01 22:44:12.000000000 +0100
@@ -176,7 +176,7 @@ struct thread_info
   struct target_waitstatus pending_follow;
 
   /* Last signal that the inferior received (why it stopped).  */
-  enum target_signal stop_signal;
+  target_signal stop_signal;
 
   /* Chain containing status of breakpoint(s) the thread stopped
      at.  */
Index: src/gdb/i386-linux-nat.c
===================================================================
--- src.orig/gdb/i386-linux-nat.c	2010-08-30 20:35:21.000000000 +0100
+++ src/gdb/i386-linux-nat.c	2010-09-01 22:45:40.000000000 +0100
@@ -829,7 +829,7 @@ static const unsigned char linux_syscall
 
 static void
 i386_linux_resume (struct target_ops *ops,
-		   ptid_t ptid, int step, enum target_signal signal)
+		   ptid_t ptid, int step, target_signal signal)
 {
   int pid = PIDGET (ptid);
 
Index: src/gdb/i386-linux-tdep.c
===================================================================
--- src.orig/gdb/i386-linux-tdep.c	2010-08-04 16:25:27.000000000 +0100
+++ src/gdb/i386-linux-tdep.c	2010-09-01 22:45:17.000000000 +0100
@@ -463,7 +463,7 @@ i386_linux_intx80_sysenter_record (struc
 int
 i386_linux_record_signal (struct gdbarch *gdbarch,
                           struct regcache *regcache,
-                          enum target_signal signal)
+                          target_signal signal)
 {
   ULONGEST esp;
 
Index: src/gdb/inf-ptrace.c
===================================================================
--- src.orig/gdb/inf-ptrace.c	2010-08-30 20:35:21.000000000 +0100
+++ src/gdb/inf-ptrace.c	2010-09-01 22:46:49.000000000 +0100
@@ -350,7 +350,7 @@ inf_ptrace_stop (ptid_t ptid)
 
 static void
 inf_ptrace_resume (struct target_ops *ops,
-		   ptid_t ptid, int step, enum target_signal signal)
+		   ptid_t ptid, int step, target_signal signal)
 {
   pid_t pid = ptid_get_pid (ptid);
   int request;
Index: src/gdb/infcmd.c
===================================================================
--- src.orig/gdb/infcmd.c	2010-08-06 16:20:50.000000000 +0100
+++ src/gdb/infcmd.c	2010-09-01 22:46:34.000000000 +0100
@@ -1161,7 +1161,7 @@ go_command (char *line_no, int from_tty)
 static void
 signal_command (char *signum_exp, int from_tty)
 {
-  enum target_signal oursig;
+  target_signal oursig;
   int async_exec = 0;
 
   dont_repeat ();		/* Too dangerous.  */
Index: src/gdb/inferior.h
===================================================================
--- src.orig/gdb/inferior.h	2010-07-19 15:47:18.000000000 +0100
+++ src/gdb/inferior.h	2010-09-01 23:56:54.000000000 +0100
@@ -35,7 +35,7 @@ struct terminal_info;
 /* For bpstat.  */
 #include "breakpoint.h"
 
-/* For enum target_signal.  */
+/* For target_signal.  */
 #include "target.h"
 
 /* For struct frame_id.  */
@@ -143,7 +143,7 @@ extern int sync_execution;
 
 extern void clear_proceed_status (void);
 
-extern void proceed (CORE_ADDR, enum target_signal, int);
+extern void proceed (CORE_ADDR, target_signal, int);
 
 extern int sched_multi;
 
@@ -198,7 +198,7 @@ extern void reopen_exec_file (void);
 /* The `resume' routine should only be called in special circumstances.
    Normally, use `proceed', which handles a lot of bookkeeping.  */
 
-extern void resume (int, enum target_signal);
+extern void resume (int, target_signal);
 
 /* From misc files */
 
@@ -240,17 +240,17 @@ extern void start_remote (int from_tty);
 
 extern void normal_stop (void);
 
-extern int signal_stop_state (int);
+extern int signal_stop_state (target_signal);
 
-extern int signal_print_state (int);
+extern int signal_print_state (target_signal);
 
-extern int signal_pass_state (int);
+extern int signal_pass_state (target_signal);
 
-extern int signal_stop_update (int, int);
+extern int signal_stop_update (target_signal, int);
 
-extern int signal_print_update (int, int);
+extern int signal_print_update (target_signal, int);
 
-extern int signal_pass_update (int, int);
+extern int signal_pass_update (target_signal, int);
 
 extern void get_last_target_status(ptid_t *ptid,
                                    struct target_waitstatus *status);
Index: src/gdb/infrun.c
===================================================================
--- src.orig/gdb/infrun.c	2010-09-01 14:35:08.000000000 +0100
+++ src/gdb/infrun.c	2010-09-02 02:18:19.000000000 +0100
@@ -59,7 +59,7 @@ static void signals_info (char *, int);
 
 static void handle_command (char *, int);
 
-static void sig_print_info (enum target_signal);
+static void sig_print_info (target_signal);
 
 static void sig_print_header (void);
 
@@ -1297,7 +1297,7 @@ write_memory_ptid (ptid_t ptid, CORE_ADD
 }
 
 static void
-displaced_step_fixup (ptid_t event_ptid, enum target_signal signal)
+displaced_step_fixup (ptid_t event_ptid, target_signal signal)
 {
   struct cleanup *old_cleanups;
   struct displaced_step_inferior_state *displaced
@@ -1538,7 +1538,7 @@ maybe_software_singlestep (struct gdbarc
    STEP nonzero if we should step (zero to continue instead).
    SIG is the signal to give the inferior (zero for none).  */
 void
-resume (int step, enum target_signal sig)
+resume (int step, target_signal sig)
 {
   int should_resume = 1;
   struct cleanup *old_cleanups = make_cleanup (resume_cleanups, 0);
@@ -1554,7 +1554,7 @@ resume (int step, enum target_signal sig
     fprintf_unfiltered (gdb_stdlog,
                         "infrun: resume (step=%d, signal=%d), "
 			"trap_expected=%d\n",
- 			step, sig, tp->trap_expected);
+ 			step, TARGET_SIGNAL_NUMBER (sig), tp->trap_expected);
 
   /* Normally, by the time we reach `resume', the breakpoints are either
      removed or inserted, as appropriate.  The exception is if we're sitting
@@ -1871,7 +1871,7 @@ prepare_to_proceed (int step)
    You should call clear_proceed_status before calling proceed.  */
 
 void
-proceed (CORE_ADDR addr, enum target_signal siggnal, int step)
+proceed (CORE_ADDR addr, target_signal siggnal, int step)
 {
   struct regcache *regcache;
   struct gdbarch *gdbarch;
@@ -1929,7 +1929,8 @@ proceed (CORE_ADDR addr, enum target_sig
   if (debug_infrun)
     fprintf_unfiltered (gdb_stdlog,
 			"infrun: proceed (addr=%s, signal=%d, step=%d)\n",
-			paddress (gdbarch, addr), siggnal, step);
+			paddress (gdbarch, addr),
+			TARGET_SIGNAL_NUMBER (siggnal), step);
 
   /* We're handling a live event, so make sure we're doing live
      debugging.  If we're looking at traceframes while the target is
@@ -2013,7 +2014,7 @@ proceed (CORE_ADDR addr, enum target_sig
     tp->stop_signal = siggnal;
   /* If this signal should not be seen by program,
      give it zero.  Used for debugging signals.  */
-  else if (!signal_program[tp->stop_signal])
+  else if (!signal_pass_state (tp->stop_signal))
     tp->stop_signal = TARGET_SIGNAL_0;
 
   annotate_starting ();
@@ -3188,7 +3189,7 @@ handle_inferior_event (struct execution_
          may be needed. */
       target_mourn_inferior ();
 
-      print_stop_reason (SIGNAL_EXITED, ecs->ws.value.sig);
+      print_stop_reason (SIGNAL_EXITED, TARGET_SIGNAL_NUMBER (ecs->ws.value.sig));
       singlestep_breakpoints_inserted_p = 0;
       cancel_single_step_breakpoints ();
       stop_stepping (ecs);
@@ -3589,7 +3590,7 @@ targets should add new threads to the th
 
 	     if (new_singlestep_pc != singlestep_pc)
 	       {
-		 enum target_signal stop_signal;
+		 target_signal stop_signal;
 
 		 if (debug_infrun)
 		   fprintf_unfiltered (gdb_stdlog, "infrun: unexpected thread,"
@@ -3954,15 +3955,16 @@ process_event_stop_test:
 
       if (debug_infrun)
 	 fprintf_unfiltered (gdb_stdlog, "infrun: random signal %d\n",
-			     ecs->event_thread->stop_signal);
+			     TARGET_SIGNAL_NUMBER (ecs->event_thread->stop_signal));
 
       stopped_by_random_signal = 1;
 
-      if (signal_print[ecs->event_thread->stop_signal])
+      if (signal_print_state (ecs->event_thread->stop_signal))
 	{
 	  printed = 1;
 	  target_terminal_ours_for_output ();
-	  print_stop_reason (SIGNAL_RECEIVED, ecs->event_thread->stop_signal);
+	  print_stop_reason (SIGNAL_RECEIVED,
+			     TARGET_SIGNAL_NUMBER (ecs->event_thread->stop_signal));
 	}
       /* Always stop on signals if we're either just gaining control
 	 of the program, or the user explicitly requested this thread
@@ -3981,7 +3983,7 @@ process_event_stop_test:
 	target_terminal_inferior ();
 
       /* Clear the signal if it should not be passed.  */
-      if (signal_program[ecs->event_thread->stop_signal] == 0)
+      if (signal_pass_state (ecs->event_thread->stop_signal) == 0)
 	ecs->event_thread->stop_signal = TARGET_SIGNAL_0;
 
       if (ecs->event_thread->prev_pc == stop_pc
@@ -5168,7 +5170,7 @@ keep_going (struct execution_control_sta
          equivalent of a SIGNAL_TRAP to the program being debugged. */
 
       if (ecs->event_thread->stop_signal == TARGET_SIGNAL_TRAP
-	  && !signal_program[ecs->event_thread->stop_signal])
+	  && !signal_pass_state (ecs->event_thread->stop_signal))
 	ecs->event_thread->stop_signal = TARGET_SIGNAL_0;
 
       discard_cleanups (old_cleanups);
@@ -5226,13 +5228,15 @@ print_stop_reason (enum inferior_stop_re
 	   async_reason_lookup (EXEC_ASYNC_EXITED_SIGNALLED));
       ui_out_text (uiout, "\nProgram terminated with signal ");
       annotate_signal_name ();
+      /* These target_signal_from_number calls won't be needed with the
+	 print_stop_reason split.  */
       ui_out_field_string (uiout, "signal-name",
-			   target_signal_to_name (stop_info));
+			   target_signal_to_name (target_signal_from_number (stop_info)));
       annotate_signal_name_end ();
       ui_out_text (uiout, ", ");
       annotate_signal_string ();
       ui_out_field_string (uiout, "signal-meaning",
-			   target_signal_to_string (stop_info));
+			   target_signal_to_string (target_signal_from_number (stop_info)));
       annotate_signal_string_end ();
       ui_out_text (uiout, ".\n");
       ui_out_text (uiout, "The program no longer exists.\n");
@@ -5266,7 +5270,7 @@ print_stop_reason (enum inferior_stop_re
 	 it. */
       annotate_signal ();
 
-      if (stop_info == TARGET_SIGNAL_0 && !ui_out_is_mi_like_p (uiout))
+      if (target_signal_from_number (stop_info) == TARGET_SIGNAL_0 && !ui_out_is_mi_like_p (uiout))
 	{
 	  struct thread_info *t = inferior_thread ();
 
@@ -5284,12 +5288,12 @@ print_stop_reason (enum inferior_stop_re
 	    ui_out_field_string
 	      (uiout, "reason", async_reason_lookup (EXEC_ASYNC_SIGNAL_RECEIVED));
 	  ui_out_field_string (uiout, "signal-name",
-			       target_signal_to_name (stop_info));
+			       target_signal_to_name (target_signal_from_number (stop_info)));
 	  annotate_signal_name_end ();
 	  ui_out_text (uiout, ", ");
 	  annotate_signal_string ();
 	  ui_out_field_string (uiout, "signal-meaning",
-			       target_signal_to_string (stop_info));
+			       target_signal_to_string (target_signal_from_number (stop_info)));
 	  annotate_signal_string_end ();
 	}
       ui_out_text (uiout, ".\n");
@@ -5573,47 +5577,47 @@ hook_stop_stub (void *cmd)
 }
 
 int
-signal_stop_state (int signo)
+signal_stop_state (target_signal sig)
 {
-  return signal_stop[signo];
+  return signal_stop[TARGET_SIGNAL_NUMBER (sig)];
 }
 
 int
-signal_print_state (int signo)
+signal_print_state (target_signal sig)
 {
-  return signal_print[signo];
+  return signal_print[TARGET_SIGNAL_NUMBER (sig)];
 }
 
 int
-signal_pass_state (int signo)
+signal_pass_state (target_signal sig)
 {
-  return signal_program[signo];
+  return signal_program[TARGET_SIGNAL_NUMBER (sig)];
 }
 
 int
-signal_stop_update (int signo, int state)
+signal_stop_update (target_signal sig, int state)
 {
-  int ret = signal_stop[signo];
+  int ret = signal_stop[TARGET_SIGNAL_NUMBER (sig)];
 
-  signal_stop[signo] = state;
+  signal_stop[TARGET_SIGNAL_NUMBER (sig)] = state;
   return ret;
 }
 
 int
-signal_print_update (int signo, int state)
+signal_print_update (target_signal sig, int state)
 {
-  int ret = signal_print[signo];
+  int ret = signal_print[TARGET_SIGNAL_NUMBER (sig)];
 
-  signal_print[signo] = state;
+  signal_print[TARGET_SIGNAL_NUMBER (sig)] = state;
   return ret;
 }
 
 int
-signal_pass_update (int signo, int state)
+signal_pass_update (target_signal sig, int state)
 {
-  int ret = signal_program[signo];
+  int ret = signal_program[TARGET_SIGNAL_NUMBER (sig)];
 
-  signal_program[signo] = state;
+  signal_program[TARGET_SIGNAL_NUMBER (sig)] = state;
   return ret;
 }
 
@@ -5625,7 +5629,7 @@ Signal        Stop\tPrint\tPass to progr
 }
 
 static void
-sig_print_info (enum target_signal oursig)
+sig_print_info (target_signal oursig)
 {
   const char *name = target_signal_to_name (oursig);
   int name_padding = 13 - strlen (name);
@@ -5635,9 +5639,9 @@ sig_print_info (enum target_signal oursi
 
   printf_filtered ("%s", name);
   printf_filtered ("%*.*s ", name_padding, name_padding, "                 ");
-  printf_filtered ("%s\t", signal_stop[oursig] ? "Yes" : "No");
-  printf_filtered ("%s\t", signal_print[oursig] ? "Yes" : "No");
-  printf_filtered ("%s\t\t", signal_program[oursig] ? "Yes" : "No");
+  printf_filtered ("%s\t", signal_stop_state (oursig) ? "Yes" : "No");
+  printf_filtered ("%s\t", signal_print_state (oursig) ? "Yes" : "No");
+  printf_filtered ("%s\t\t", signal_pass_state (oursig) ? "Yes" : "No");
   printf_filtered ("%s\n", target_signal_to_string (oursig));
 }
 
@@ -5649,7 +5653,7 @@ handle_command (char *args, int from_tty
   char **argv;
   int digits, wordlen;
   int sigfirst, signum, siglast;
-  enum target_signal oursig;
+  target_signal oursig;
   int allsigs;
   int nsigs;
   unsigned char *sigs;
@@ -5662,7 +5666,7 @@ handle_command (char *args, int from_tty
 
   /* Allocate and zero an array of flags for which signals to handle. */
 
-  nsigs = (int) TARGET_SIGNAL_LAST;
+  nsigs = TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_LAST);
   sigs = (unsigned char *) alloca (nsigs);
   memset (sigs, 0, nsigs);
 
@@ -5735,12 +5739,13 @@ handle_command (char *args, int from_tty
 	     using symbolic names anyway, and the common ones like
 	     SIGHUP, SIGINT, SIGALRM, etc. will work right anyway.  */
 
-	  sigfirst = siglast = (int)
-	    target_signal_from_command (atoi (*argv));
+	  target_signal sig = target_signal_from_command (atoi (*argv));
+
+	  sigfirst = siglast = TARGET_SIGNAL_NUMBER (sig);
 	  if ((*argv)[digits] == '-')
 	    {
-	      siglast = (int)
-		target_signal_from_command (atoi ((*argv) + digits + 1));
+	      sig = target_signal_from_command (atoi ((*argv) + digits + 1));
+	      siglast = TARGET_SIGNAL_NUMBER (sig);
 	    }
 	  if (sigfirst > siglast)
 	    {
@@ -5755,7 +5760,7 @@ handle_command (char *args, int from_tty
 	  oursig = target_signal_from_name (*argv);
 	  if (oursig != TARGET_SIGNAL_UNKNOWN)
 	    {
-	      sigfirst = siglast = (int) oursig;
+	      sigfirst = siglast = TARGET_SIGNAL_NUMBER (oursig);
 	    }
 	  else
 	    {
@@ -5767,16 +5772,21 @@ handle_command (char *args, int from_tty
       /* If any signal numbers or symbol names were found, set flags for
          which signals to apply actions to. */
 
-      for (signum = sigfirst; signum >= 0 && signum <= siglast; signum++)
+      for (signum = sigfirst;
+	   (signum >= TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_0)
+	    && signum <= siglast);
+	   signum++)
 	{
-	  switch ((enum target_signal) signum)
+#define TSNC TARGET_SIGNAL_NUMBER_CONST
+	  switch (signum)
 	    {
-	    case TARGET_SIGNAL_TRAP:
-	    case TARGET_SIGNAL_INT:
+	    case TSNC (TARGET_SIGNAL_TRAP):
+	    case TSNC (TARGET_SIGNAL_INT):
 	      if (!allsigs && !sigs[signum])
 		{
 		  if (query (_("%s is used by the debugger.\n\
-Are you sure you want to change it? "), target_signal_to_name ((enum target_signal) signum)))
+Are you sure you want to change it? "),
+			     target_signal_to_name (target_signal_from_number (signum))))
 		    {
 		      sigs[signum] = 1;
 		    }
@@ -5787,15 +5797,16 @@ Are you sure you want to change it? "), 
 		    }
 		}
 	      break;
-	    case TARGET_SIGNAL_0:
-	    case TARGET_SIGNAL_DEFAULT:
-	    case TARGET_SIGNAL_UNKNOWN:
+	    case TSNC (TARGET_SIGNAL_0):
+	    case TSNC (TARGET_SIGNAL_DEFAULT):
+	    case TSNC (TARGET_SIGNAL_UNKNOWN):
 	      /* Make sure that "all" doesn't print these.  */
 	      break;
 	    default:
 	      sigs[signum] = 1;
 	      break;
 	    }
+#undef TSNC
 	}
 
       argv++;
@@ -5812,7 +5823,7 @@ Are you sure you want to change it? "), 
 	    sig_print_header ();
 	    for (; signum < nsigs; signum++)
 	      if (sigs[signum])
-		sig_print_info (signum);
+		sig_print_info (target_signal_from_number (signum));
 	  }
 
 	break;
@@ -5844,7 +5855,7 @@ xdb_handle_command (char *args, int from
       if (argBuf)
 	{
 	  int validFlag = 1;
-	  enum target_signal oursig;
+	  target_signal oursig;
 
 	  oursig = target_signal_from_name (argv[0]);
 	  memset (argBuf, 0, bufLen);
@@ -5854,21 +5865,21 @@ xdb_handle_command (char *args, int from
 	    {
 	      if (strcmp (argv[1], "s") == 0)
 		{
-		  if (!signal_stop[oursig])
+		  if (!signal_stop_state (oursig))
 		    sprintf (argBuf, "%s %s", argv[0], "stop");
 		  else
 		    sprintf (argBuf, "%s %s", argv[0], "nostop");
 		}
 	      else if (strcmp (argv[1], "i") == 0)
 		{
-		  if (!signal_program[oursig])
+		  if (!signal_pass_state (oursig))
 		    sprintf (argBuf, "%s %s", argv[0], "pass");
 		  else
 		    sprintf (argBuf, "%s %s", argv[0], "nopass");
 		}
 	      else if (strcmp (argv[1], "r") == 0)
 		{
-		  if (!signal_print[oursig])
+		  if (!signal_print_state (oursig))
 		    sprintf (argBuf, "%s %s", argv[0], "print");
 		  else
 		    sprintf (argBuf, "%s %s", argv[0], "noprint");
@@ -5895,7 +5906,7 @@ xdb_handle_command (char *args, int from
 static void
 signals_info (char *signum_exp, int from_tty)
 {
-  enum target_signal oursig;
+  target_signal oursig;
 
   sig_print_header ();
 
@@ -5914,10 +5925,8 @@ signals_info (char *signum_exp, int from
     }
 
   printf_filtered ("\n");
-  /* These ugly casts brought to you by the native VAX compiler.  */
-  for (oursig = TARGET_SIGNAL_FIRST;
-       (int) oursig < (int) TARGET_SIGNAL_LAST;
-       oursig = (enum target_signal) ((int) oursig + 1))
+
+  for (oursig = TARGET_SIGNAL_FIRST; oursig < TARGET_SIGNAL_LAST; oursig++)
     {
       QUIT;
 
@@ -6013,7 +6022,7 @@ siginfo_make_value (struct gdbarch *gdba
 
 struct inferior_thread_state
 {
-  enum target_signal stop_signal;
+  target_signal stop_signal;
   CORE_ADDR stop_pc;
   struct regcache *registers;
 };
@@ -6590,7 +6599,7 @@ leave it stopped or free to run as neede
 			   &setlist,
 			   &showlist);
 
-  numsigs = (int) TARGET_SIGNAL_LAST;
+  numsigs = TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_LAST);
   signal_stop = (unsigned char *) xmalloc (sizeof (signal_stop[0]) * numsigs);
   signal_print = (unsigned char *)
     xmalloc (sizeof (signal_print[0]) * numsigs);
@@ -6605,37 +6614,37 @@ leave it stopped or free to run as neede
 
   /* Signals caused by debugger's own actions
      should not be given to the program afterwards.  */
-  signal_program[TARGET_SIGNAL_TRAP] = 0;
-  signal_program[TARGET_SIGNAL_INT] = 0;
+  signal_pass_update (TARGET_SIGNAL_TRAP, 0);
+  signal_pass_update (TARGET_SIGNAL_INT, 0);
 
   /* Signals that are not errors should not normally enter the debugger.  */
-  signal_stop[TARGET_SIGNAL_ALRM] = 0;
-  signal_print[TARGET_SIGNAL_ALRM] = 0;
-  signal_stop[TARGET_SIGNAL_VTALRM] = 0;
-  signal_print[TARGET_SIGNAL_VTALRM] = 0;
-  signal_stop[TARGET_SIGNAL_PROF] = 0;
-  signal_print[TARGET_SIGNAL_PROF] = 0;
-  signal_stop[TARGET_SIGNAL_CHLD] = 0;
-  signal_print[TARGET_SIGNAL_CHLD] = 0;
-  signal_stop[TARGET_SIGNAL_IO] = 0;
-  signal_print[TARGET_SIGNAL_IO] = 0;
-  signal_stop[TARGET_SIGNAL_POLL] = 0;
-  signal_print[TARGET_SIGNAL_POLL] = 0;
-  signal_stop[TARGET_SIGNAL_URG] = 0;
-  signal_print[TARGET_SIGNAL_URG] = 0;
-  signal_stop[TARGET_SIGNAL_WINCH] = 0;
-  signal_print[TARGET_SIGNAL_WINCH] = 0;
+  signal_stop_update (TARGET_SIGNAL_ALRM, 0);
+  signal_print_update (TARGET_SIGNAL_ALRM, 0);
+  signal_stop_update (TARGET_SIGNAL_VTALRM, 0);
+  signal_print_update (TARGET_SIGNAL_VTALRM, 0);
+  signal_stop_update (TARGET_SIGNAL_PROF, 0);
+  signal_print_update (TARGET_SIGNAL_PROF, 0);
+  signal_stop_update (TARGET_SIGNAL_CHLD, 0);
+  signal_print_update (TARGET_SIGNAL_CHLD, 0);
+  signal_stop_update (TARGET_SIGNAL_IO, 0);
+  signal_print_update (TARGET_SIGNAL_IO, 0);
+  signal_stop_update (TARGET_SIGNAL_POLL, 0);
+  signal_print_update (TARGET_SIGNAL_POLL, 0);
+  signal_stop_update (TARGET_SIGNAL_URG, 0);
+  signal_print_update (TARGET_SIGNAL_URG, 0);
+  signal_stop_update (TARGET_SIGNAL_WINCH, 0);
+  signal_print_update (TARGET_SIGNAL_WINCH, 0);
 
   /* These signals are used internally by user-level thread
      implementations.  (See signal(5) on Solaris.)  Like the above
      signals, a healthy program receives and handles them as part of
      its normal operation.  */
-  signal_stop[TARGET_SIGNAL_LWP] = 0;
-  signal_print[TARGET_SIGNAL_LWP] = 0;
-  signal_stop[TARGET_SIGNAL_WAITING] = 0;
-  signal_print[TARGET_SIGNAL_WAITING] = 0;
-  signal_stop[TARGET_SIGNAL_CANCEL] = 0;
-  signal_print[TARGET_SIGNAL_CANCEL] = 0;
+  signal_stop_update (TARGET_SIGNAL_LWP, 0);
+  signal_print_update (TARGET_SIGNAL_LWP, 0);
+  signal_stop_update (TARGET_SIGNAL_WAITING, 0);
+  signal_print_update (TARGET_SIGNAL_WAITING, 0);
+  signal_stop_update (TARGET_SIGNAL_CANCEL, 0);
+  signal_print_update (TARGET_SIGNAL_CANCEL, 0);
 
   add_setshow_zinteger_cmd ("stop-on-solib-events", class_support,
 			    &stop_on_solib_events, _("\
Index: src/gdb/linux-nat.c
===================================================================
--- src.orig/gdb/linux-nat.c	2010-09-01 14:35:08.000000000 +0100
+++ src/gdb/linux-nat.c	2010-09-02 01:27:03.000000000 +0100
@@ -1581,7 +1581,7 @@ linux_nat_attach (struct target_ops *ops
 	}
       else if (WIFSIGNALED (status))
 	{
-	  enum target_signal signo;
+	  target_signal signo;
 
 	  target_terminal_ours ();
 	  target_mourn_inferior ();
@@ -1617,7 +1617,7 @@ linux_nat_attach (struct target_ops *ops
 static int
 get_pending_status (struct lwp_info *lp, int *status)
 {
-  enum target_signal signo = TARGET_SIGNAL_0;
+  target_signal signo = TARGET_SIGNAL_0;
 
   /* If we paused threads momentarily, we may have stored pending
      events in lp->status or lp->waitstatus (see stop_wait_callback),
@@ -1863,7 +1863,7 @@ resume_set_callback (struct lwp_info *lp
 
 static void
 linux_nat_resume (struct target_ops *ops,
-		  ptid_t ptid, int step, enum target_signal signo)
+		  ptid_t ptid, int step, target_signal signo)
 {
   sigset_t prev_mask;
   struct lwp_info *lp;
@@ -1874,7 +1874,8 @@ linux_nat_resume (struct target_ops *ops
 			"LLR: Preparing to %s %s, %s, inferior_ptid %s\n",
 			step ? "step" : "resume",
 			target_pid_to_str (ptid),
-			signo ? strsignal (signo) : "0",
+			(signo != TARGET_SIGNAL_0
+			 ? strsignal (target_signal_to_host (signo)) : "0"),
 			target_pid_to_str (inferior_ptid));
 
   block_child_signals (&prev_mask);
@@ -1907,7 +1908,7 @@ linux_nat_resume (struct target_ops *ops
 
   if (lp->status && WIFSTOPPED (lp->status))
     {
-      int saved_signo;
+      target_signal saved_signo;
       struct inferior *inf;
 
       inf = find_inferior_pid (ptid_get_pid (lp->ptid));
@@ -1974,7 +1975,8 @@ linux_nat_resume (struct target_ops *ops
 			"LLR: %s %s, %s (resume event thread)\n",
 			step ? "PTRACE_SINGLESTEP" : "PTRACE_CONT",
 			target_pid_to_str (ptid),
-			signo ? strsignal (signo) : "0");
+			(signo != TARGET_SIGNAL_0
+			 ? strsignal (target_signal_to_host (signo)) : "0"));
 
   restore_child_signals_mask (&prev_mask);
   if (target_can_async_p ())
@@ -2266,7 +2268,7 @@ linux_handle_extended_wait (struct lwp_i
 	     catchpoints.  */
 	  if (!stopping)
 	    {
-	      int signo;
+	      target_signal signo;
 
 	      new_lp->stopped = 0;
 	      new_lp->resumed = 1;
@@ -3567,7 +3569,8 @@ retry:
 
   if (WIFSTOPPED (status))
     {
-      int signo = target_signal_from_host (WSTOPSIG (status));
+      int signo = WSTOPSIG (status);
+      target_signal sig = target_signal_from_host (signo);
       struct inferior *inf;
 
       inf = find_inferior_pid (ptid_get_pid (lp->ptid));
@@ -3579,9 +3582,9 @@ retry:
 	 inferior.  */
       if (!lp->step
 	  && inf->stop_soon == NO_STOP_QUIETLY
-	  && signal_stop_state (signo) == 0
-	  && signal_print_state (signo) == 0
-	  && signal_pass_state (signo) == 1)
+	  && signal_stop_state (sig) == 0
+	  && signal_print_state (sig) == 0
+	  && signal_pass_state (sig) == 1)
 	{
 	  /* FIMXE: kettenis/2001-06-06: Should we resume all threads
 	     here?  It is not clear we should.  GDB may not expect
@@ -3590,7 +3593,7 @@ retry:
 	     getting them running.  */
 	  registers_changed ();
 	  linux_ops->to_resume (linux_ops, pid_to_ptid (GET_LWP (lp->ptid)),
-				lp->step, signo);
+				lp->step, sig);
 	  if (debug_linux_nat)
 	    fprintf_unfiltered (gdb_stdlog,
 				"LLW: %s %s, %s (preempt 'handle')\n",
@@ -3607,7 +3610,7 @@ retry:
 	  /* Only do the below in all-stop, as we currently use SIGINT
 	     to implement target_stop (see linux_nat_stop) in
 	     non-stop.  */
-	  if (signo == TARGET_SIGNAL_INT && signal_pass_state (signo) == 0)
+	  if (sig == TARGET_SIGNAL_INT && signal_pass_state (sig) == 0)
 	    {
 	      /* If ^C/BREAK is typed at the tty/console, SIGINT gets
 		 forwarded to the entire process group, that is, all LWPs
@@ -4165,7 +4168,7 @@ find_signalled_thread (struct thread_inf
   return 0;
 }
 
-static enum target_signal
+static target_signal
 find_stop_signal (void)
 {
   struct thread_info *info =
@@ -4183,7 +4186,7 @@ find_stop_signal (void)
 static char *
 linux_nat_do_thread_registers (bfd *obfd, ptid_t ptid,
 			       char *note_data, int *note_size,
-			       enum target_signal stop_signal)
+			       target_signal stop_signal)
 {
   unsigned long lwp = ptid_get_lwp (ptid);
   struct gdbarch *gdbarch = target_gdbarch;
@@ -4276,7 +4279,7 @@ struct linux_nat_corefile_thread_data
   char *note_data;
   int *note_size;
   int num_notes;
-  enum target_signal stop_signal;
+  target_signal stop_signal;
 };
 
 /* Called by gdbthread.c once per thread.  Records the thread's
Index: src/gdb/linux-thread-db.c
===================================================================
--- src.orig/gdb/linux-thread-db.c	2010-08-18 15:07:25.000000000 +0100
+++ src/gdb/linux-thread-db.c	2010-09-01 22:47:06.000000000 +0100
@@ -1650,7 +1650,7 @@ thread_db_get_ada_task_ptid (long lwp, l
 
 static void
 thread_db_resume (struct target_ops *ops,
-		  ptid_t ptid, int step, enum target_signal signo)
+		  ptid_t ptid, int step, target_signal signo)
 {
   struct target_ops *beneath = find_target_beneath (ops);
   struct thread_db_info *info;
Index: src/gdb/record.c
===================================================================
--- src.orig/gdb/record.c	2010-08-19 17:56:49.000000000 +0100
+++ src/gdb/record.c	2010-09-02 00:50:20.000000000 +0100
@@ -98,7 +98,7 @@ struct record_reg_entry
 
 struct record_end_entry
 {
-  enum target_signal sigval;
+  target_signal sigval;
   ULONGEST insn_num;
 };
 
@@ -207,7 +207,7 @@ static struct target_ops record_core_ops
 /* The beneath function pointers.  */
 static struct target_ops *record_beneath_to_resume_ops;
 static void (*record_beneath_to_resume) (struct target_ops *, ptid_t, int,
-                                         enum target_signal);
+                                         target_signal);
 static struct target_ops *record_beneath_to_wait_ops;
 static ptid_t (*record_beneath_to_wait) (struct target_ops *, ptid_t,
 					 struct target_waitstatus *,
@@ -578,7 +578,7 @@ record_arch_list_cleanups (void *ignore)
    record_arch_list, and add it to record_list.  */
 
 static int
-record_message (struct regcache *regcache, enum target_signal signal)
+record_message (struct regcache *regcache, target_signal signal)
 {
   int ret;
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
@@ -649,7 +649,7 @@ record_message (struct regcache *regcach
 
 struct record_message_args {
   struct regcache *regcache;
-  enum target_signal signal;
+  target_signal signal;
 };
 
 static int
@@ -662,7 +662,7 @@ record_message_wrapper (void *args)
 
 static int
 record_message_wrapper_safe (struct regcache *regcache,
-                             enum target_signal signal)
+                             target_signal signal)
 {
   struct record_message_args args;
 
@@ -783,7 +783,7 @@ record_exec_insn (struct regcache *regca
 
 static struct target_ops *tmp_to_resume_ops;
 static void (*tmp_to_resume) (struct target_ops *, ptid_t, int,
-			      enum target_signal);
+			      target_signal);
 static struct target_ops *tmp_to_wait_ops;
 static ptid_t (*tmp_to_wait) (struct target_ops *, ptid_t,
 			      struct target_waitstatus *,
@@ -1005,7 +1005,7 @@ static int record_resume_step = 0;
 
 static void
 record_resume (struct target_ops *ops, ptid_t ptid, int step,
-               enum target_signal signal)
+               target_signal signal)
 {
   record_resume_step = step;
 
@@ -1746,7 +1746,7 @@ init_record_ops (void)
 
 static void
 record_core_resume (struct target_ops *ops, ptid_t ptid, int step,
-                    enum target_signal signal)
+                    target_signal signal)
 {
   record_resume_step = step;
 }
@@ -2302,7 +2302,7 @@ record_restore (void)
 	  bfdcore_read (core_bfd, osec, &signal, 
 			sizeof (signal), &bfd_offset);
 	  signal = netorder32 (signal);
-	  rec->u.end.sigval = signal;
+	  rec->u.end.sigval = target_signal_from_number (signal);
 
 	  /* Get insn count.  */
 	  bfdcore_read (core_bfd, osec, &count, 
@@ -2560,7 +2560,7 @@ cmd_record_save (char *args, int from_tt
 				      (unsigned long) sizeof (signal),
 				      (unsigned long) sizeof (count));
 		/* Write signal value.  */
-		signal = netorder32 (record_list->u.end.sigval);
+		signal = netorder32 (TARGET_SIGNAL_NUMBER (record_list->u.end.sigval));
 		bfdcore_write (obfd, osec, &signal,
 			       sizeof (signal), &bfd_offset);
 
Index: src/gdb/remote.c
===================================================================
--- src.orig/gdb/remote.c	2010-07-29 00:17:52.000000000 +0100
+++ src/gdb/remote.c	2010-09-02 02:20:19.000000000 +0100
@@ -1557,15 +1557,17 @@ remote_pass_signals (void)
   if (remote_protocol_packets[PACKET_QPassSignals].support != PACKET_DISABLE)
     {
       char *pass_packet, *p;
-      int numsigs = (int) TARGET_SIGNAL_LAST;
+      int numsigs = TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_LAST);
       int count = 0, i;
 
       gdb_assert (numsigs < 256);
       for (i = 0; i < numsigs; i++)
 	{
-	  if (signal_stop_state (i) == 0
-	      && signal_print_state (i) == 0
-	      && signal_pass_state (i) == 1)
+	  target_signal sig = target_signal_from_number (i);
+
+	  if (signal_stop_state (sig) == 0
+	      && signal_print_state (sig) == 0
+	      && signal_pass_state (sig) == 1)
 	    count++;
 	}
       pass_packet = xmalloc (count * 3 + strlen ("QPassSignals:") + 1);
@@ -1573,9 +1575,11 @@ remote_pass_signals (void)
       p = pass_packet + strlen (pass_packet);
       for (i = 0; i < numsigs; i++)
 	{
-	  if (signal_stop_state (i) == 0
-	      && signal_print_state (i) == 0
-	      && signal_pass_state (i) == 1)
+	  target_signal sig = target_signal_from_number (i);
+
+	  if (signal_stop_state (sig) == 0
+	      && signal_print_state (sig) == 0
+	      && signal_pass_state (sig) == 1)
 	    {
 	      if (i >= 16)
 		*p++ = tohex (i >> 4);
@@ -4384,16 +4388,16 @@ remote_vcont_probe (struct remote_state 
 
 static char *
 append_resumption (char *p, char *endp,
-		   ptid_t ptid, int step, enum target_signal siggnal)
+		   ptid_t ptid, int step, target_signal siggnal)
 {
   struct remote_state *rs = get_remote_state ();
 
   if (step && siggnal != TARGET_SIGNAL_0)
-    p += xsnprintf (p, endp - p, ";S%02x", siggnal);
+    p += xsnprintf (p, endp - p, ";S%02x", TARGET_SIGNAL_NUMBER (siggnal));
   else if (step)
     p += xsnprintf (p, endp - p, ";s");
   else if (siggnal != TARGET_SIGNAL_0)
-    p += xsnprintf (p, endp - p, ";C%02x", siggnal);
+    p += xsnprintf (p, endp - p, ";C%02x", TARGET_SIGNAL_NUMBER (siggnal));
   else
     p += xsnprintf (p, endp - p, ";c");
 
@@ -4427,7 +4431,7 @@ append_resumption (char *p, char *endp,
    moment.  */
 
 static int
-remote_vcont_resume (ptid_t ptid, int step, enum target_signal siggnal)
+remote_vcont_resume (ptid_t ptid, int step, target_signal siggnal)
 {
   struct remote_state *rs = get_remote_state ();
   char *p;
@@ -4495,13 +4499,13 @@ remote_vcont_resume (ptid_t ptid, int st
 
 /* Tell the remote machine to resume.  */
 
-static enum target_signal last_sent_signal = TARGET_SIGNAL_0;
+static target_signal last_sent_signal;
 
 static int last_sent_step;
 
 static void
 remote_resume (struct target_ops *ops,
-	       ptid_t ptid, int step, enum target_signal siggnal)
+	       ptid_t ptid, int step, target_signal siggnal)
 {
   struct remote_state *rs = get_remote_state ();
   char *buf;
@@ -4531,7 +4535,7 @@ remote_resume (struct target_ops *ops,
       /* We don't pass signals to the target in reverse exec mode.  */
       if (info_verbose && siggnal != TARGET_SIGNAL_0)
 	warning (" - Can't pass signal %d to target in reverse: ignored.\n",
-		 siggnal);
+		 TARGET_SIGNAL_NUMBER (siggnal));
 
       if (step 
 	  && remote_protocol_packets[PACKET_bs].support == PACKET_DISABLE)
@@ -4544,9 +4548,10 @@ remote_resume (struct target_ops *ops,
     }
   else if (siggnal != TARGET_SIGNAL_0)
     {
+      int signo = TARGET_SIGNAL_NUMBER (siggnal);
       buf[0] = step ? 'S' : 'C';
-      buf[1] = tohex (((int) siggnal >> 4) & 0xf);
-      buf[2] = tohex (((int) siggnal) & 0xf);
+      buf[1] = tohex (((int) signo >> 4) & 0xf);
+      buf[2] = tohex (((int) signo) & 0xf);
       buf[3] = '\0';
     }
   else
@@ -5155,8 +5160,9 @@ Packet: '%s'\n"),
       else
 	{
 	  event->ws.kind = TARGET_WAITKIND_STOPPED;
-	  event->ws.value.sig = (enum target_signal)
-	    (((fromhex (buf[1])) << 4) + (fromhex (buf[2])));
+	  event->ws.value.sig
+	    = target_signal_from_number (((fromhex (buf[1])) << 4)
+					 + (fromhex (buf[2])));
 	}
       break;
     case 'W':		/* Target exited.  */
@@ -5181,7 +5187,7 @@ Packet: '%s'\n"),
 	  {
 	    /* The remote process exited with a signal.  */
 	    event->ws.kind = TARGET_WAITKIND_SIGNALLED;
-	    event->ws.value.sig = (enum target_signal) value;
+	    event->ws.value.sig = target_signal_from_number (value);
 	  }
 
 	/* If no process is specified, assume inferior_ptid.  */
@@ -10788,5 +10794,7 @@ Show the remote pathname for \"run\""), 
 
   target_buf_size = 2048;
   target_buf = xmalloc (target_buf_size);
+
+  last_sent_signal = TARGET_SIGNAL_0;
 }
 
Index: src/gdb/target.c
===================================================================
--- src.orig/gdb/target.c	2010-09-01 14:35:08.000000000 +0100
+++ src/gdb/target.c	2010-09-01 22:27:28.000000000 +0100
@@ -2407,7 +2407,7 @@ target_pid_to_str (ptid_t ptid)
 }
 
 void
-target_resume (ptid_t ptid, int step, enum target_signal signal)
+target_resume (ptid_t ptid, int step, target_signal signal)
 {
   struct target_ops *t;
 
Index: src/gdb/target.h
===================================================================
--- src.orig/gdb/target.h	2010-09-01 14:35:08.000000000 +0100
+++ src/gdb/target.h	2010-09-01 22:27:12.000000000 +0100
@@ -162,7 +162,7 @@ struct target_waitstatus
     union
       {
 	int integer;
-	enum target_signal sig;
+	target_signal sig;
 	ptid_t related_pid;
 	char *execd_pathname;
 	int syscall_number;
@@ -401,7 +401,7 @@ struct target_ops
     void (*to_post_attach) (int);
     void (*to_detach) (struct target_ops *ops, char *, int);
     void (*to_disconnect) (struct target_ops *, char *, int);
-    void (*to_resume) (struct target_ops *, ptid_t, int, enum target_signal);
+    void (*to_resume) (struct target_ops *, ptid_t, int, target_signal);
     ptid_t (*to_wait) (struct target_ops *,
 		       ptid_t, struct target_waitstatus *, int);
     void (*to_fetch_registers) (struct target_ops *, struct regcache *, int);
@@ -797,7 +797,7 @@ extern void target_disconnect (char *, i
    the target, or TARGET_SIGNAL_0 for no signal.  The caller may not
    pass TARGET_SIGNAL_DEFAULT.  */
 
-extern void target_resume (ptid_t ptid, int step, enum target_signal signal);
+extern void target_resume (ptid_t ptid, int step, target_signal signal);
 
 /* Wait for process pid to do something.  PTID = -1 to wait for any
    pid to do something.  Return pid of child, or -1 in case of error;
@@ -1585,13 +1585,13 @@ extern int remote_timeout;
 extern void store_waitstatus (struct target_waitstatus *, int);
 
 /* These are in common/signals.c, but they're only used by gdb.  */
-extern enum target_signal default_target_signal_from_host (struct gdbarch *,
-							   int);
+extern target_signal default_target_signal_from_host (struct gdbarch *,
+						      int);
 extern int default_target_signal_to_host (struct gdbarch *, 
-					  enum target_signal);
+					  target_signal);
 
-/* Convert from a number used in a GDB command to an enum target_signal.  */
-extern enum target_signal target_signal_from_command (int);
+/* Convert from a number used in a GDB command to an target_signal.  */
+extern target_signal target_signal_from_command (int);
 /* End of files in common/signals.c.  */
 
 /* Set the show memory breakpoints mode to show, and installs a cleanup
Index: src/include/gdb/signals.h
===================================================================
--- src.orig/include/gdb/signals.h	2010-08-30 20:35:21.000000000 +0100
+++ src/include/gdb/signals.h	2010-09-02 02:04:34.000000000 +0100
@@ -49,15 +49,33 @@
 /* For an explanation of what each signal means, see
    target_signal_to_string.  */
 
-enum target_signal
-  {
+#define TARGET_SIGNAL_NUMBER(target_signal) (target_signal)->number
+#define TARGET_SIGNAL_STRING(target_signal) (target_signal)->string
+#define TARGET_SIGNAL_NAME(target_signal) (target_signal)->name
+#define TARGET_SIGNAL_NUMBER_CONST(target_signal) target_signal ## _NUMBER
+
+enum target_signal_number
+   {
+#define SET(symbol, constant, name, string)		\
+     TARGET_SIGNAL_NUMBER_CONST (symbol) = constant,
+#include "gdb/signals.def"
+#undef SET
+};
+
+#define TARGET_SIGNAL_FIRST TARGET_SIGNAL_0
+
+struct target_signal_o
+{
+  int number;
+  const char *name;
+  const char *string;
+};
+
+typedef const struct target_signal_o * target_signal;
+
 #define SET(symbol, constant, name, string) \
-    symbol = constant,
-#define ANY(symbol, name, string) \
-    symbol,
+  extern const target_signal symbol;
 #include "gdb/signals.def"
-#undef ANY
 #undef SET
-  };
 
 #endif /* #ifndef GDB_SIGNALS_H */
Index: src/include/gdb/signals.def
===================================================================
--- src.orig/include/gdb/signals.def	2010-07-31 05:17:44.000000000 +0100
+++ src/include/gdb/signals.def	2010-09-02 01:59:43.000000000 +0100
@@ -19,7 +19,6 @@
 /* Used some places (e.g. stop_signal) to record the concept that
    there is no signal.  */
 SET (TARGET_SIGNAL_0, 0, "0", "Signal 0")
-#define TARGET_SIGNAL_FIRST TARGET_SIGNAL_0
 SET (TARGET_SIGNAL_HUP, 1, "SIGHUP", "Hangup")
 SET (TARGET_SIGNAL_INT, 2, "SIGINT", "Interrupt")
 SET (TARGET_SIGNAL_QUIT, 3, "SIGQUIT", "Quit")
@@ -105,96 +104,96 @@ SET (TARGET_SIGNAL_CANCEL, 76, "SIGCANCE
    GNU/Linux does, and we can't disturb the numbering, since it's
    part of the remote protocol.  Note that in some GDB's
    TARGET_SIGNAL_REALTIME_32 is number 76.  */
-ANY (TARGET_SIGNAL_REALTIME_32, "SIG32", "Real-time event 32")
+SET (TARGET_SIGNAL_REALTIME_32, 77, "SIG32", "Real-time event 32")
 /* Yet another pain, IRIX 6 has SIG64. */
-ANY (TARGET_SIGNAL_REALTIME_64, "SIG64", "Real-time event 64")
+SET (TARGET_SIGNAL_REALTIME_64, 78, "SIG64", "Real-time event 64")
 /* Yet another pain, GNU/Linux MIPS might go up to 128. */
-ANY (TARGET_SIGNAL_REALTIME_65, "SIG65", "Real-time event 65")
-ANY (TARGET_SIGNAL_REALTIME_66, "SIG66", "Real-time event 66")
-ANY (TARGET_SIGNAL_REALTIME_67, "SIG67", "Real-time event 67")
-ANY (TARGET_SIGNAL_REALTIME_68, "SIG68", "Real-time event 68")
-ANY (TARGET_SIGNAL_REALTIME_69, "SIG69", "Real-time event 69")
-ANY (TARGET_SIGNAL_REALTIME_70, "SIG70", "Real-time event 70")
-ANY (TARGET_SIGNAL_REALTIME_71, "SIG71", "Real-time event 71")
-ANY (TARGET_SIGNAL_REALTIME_72, "SIG72", "Real-time event 72")
-ANY (TARGET_SIGNAL_REALTIME_73, "SIG73", "Real-time event 73")
-ANY (TARGET_SIGNAL_REALTIME_74, "SIG74", "Real-time event 74")
-ANY (TARGET_SIGNAL_REALTIME_75, "SIG75", "Real-time event 75")
-ANY (TARGET_SIGNAL_REALTIME_76, "SIG76", "Real-time event 76")
-ANY (TARGET_SIGNAL_REALTIME_77, "SIG77", "Real-time event 77")
-ANY (TARGET_SIGNAL_REALTIME_78, "SIG78", "Real-time event 78")
-ANY (TARGET_SIGNAL_REALTIME_79, "SIG79", "Real-time event 79")
-ANY (TARGET_SIGNAL_REALTIME_80, "SIG80", "Real-time event 80")
-ANY (TARGET_SIGNAL_REALTIME_81, "SIG81", "Real-time event 81")
-ANY (TARGET_SIGNAL_REALTIME_82, "SIG82", "Real-time event 82")
-ANY (TARGET_SIGNAL_REALTIME_83, "SIG83", "Real-time event 83")
-ANY (TARGET_SIGNAL_REALTIME_84, "SIG84", "Real-time event 84")
-ANY (TARGET_SIGNAL_REALTIME_85, "SIG85", "Real-time event 85")
-ANY (TARGET_SIGNAL_REALTIME_86, "SIG86", "Real-time event 86")
-ANY (TARGET_SIGNAL_REALTIME_87, "SIG87", "Real-time event 87")
-ANY (TARGET_SIGNAL_REALTIME_88, "SIG88", "Real-time event 88")
-ANY (TARGET_SIGNAL_REALTIME_89, "SIG89", "Real-time event 89")
-ANY (TARGET_SIGNAL_REALTIME_90, "SIG90", "Real-time event 90")
-ANY (TARGET_SIGNAL_REALTIME_91, "SIG91", "Real-time event 91")
-ANY (TARGET_SIGNAL_REALTIME_92, "SIG92", "Real-time event 92")
-ANY (TARGET_SIGNAL_REALTIME_93, "SIG93", "Real-time event 93")
-ANY (TARGET_SIGNAL_REALTIME_94, "SIG94", "Real-time event 94")
-ANY (TARGET_SIGNAL_REALTIME_95, "SIG95", "Real-time event 95")
-ANY (TARGET_SIGNAL_REALTIME_96, "SIG96", "Real-time event 96")
-ANY (TARGET_SIGNAL_REALTIME_97, "SIG97", "Real-time event 97")
-ANY (TARGET_SIGNAL_REALTIME_98, "SIG98", "Real-time event 98")
-ANY (TARGET_SIGNAL_REALTIME_99, "SIG99", "Real-time event 99")
-ANY (TARGET_SIGNAL_REALTIME_100, "SIG100", "Real-time event 100")
-ANY (TARGET_SIGNAL_REALTIME_101, "SIG101", "Real-time event 101")
-ANY (TARGET_SIGNAL_REALTIME_102, "SIG102", "Real-time event 102")
-ANY (TARGET_SIGNAL_REALTIME_103, "SIG103", "Real-time event 103")
-ANY (TARGET_SIGNAL_REALTIME_104, "SIG104", "Real-time event 104")
-ANY (TARGET_SIGNAL_REALTIME_105, "SIG105", "Real-time event 105")
-ANY (TARGET_SIGNAL_REALTIME_106, "SIG106", "Real-time event 106")
-ANY (TARGET_SIGNAL_REALTIME_107, "SIG107", "Real-time event 107")
-ANY (TARGET_SIGNAL_REALTIME_108, "SIG108", "Real-time event 108")
-ANY (TARGET_SIGNAL_REALTIME_109, "SIG109", "Real-time event 109")
-ANY (TARGET_SIGNAL_REALTIME_110, "SIG110", "Real-time event 110")
-ANY (TARGET_SIGNAL_REALTIME_111, "SIG111", "Real-time event 111")
-ANY (TARGET_SIGNAL_REALTIME_112, "SIG112", "Real-time event 112")
-ANY (TARGET_SIGNAL_REALTIME_113, "SIG113", "Real-time event 113")
-ANY (TARGET_SIGNAL_REALTIME_114, "SIG114", "Real-time event 114")
-ANY (TARGET_SIGNAL_REALTIME_115, "SIG115", "Real-time event 115")
-ANY (TARGET_SIGNAL_REALTIME_116, "SIG116", "Real-time event 116")
-ANY (TARGET_SIGNAL_REALTIME_117, "SIG117", "Real-time event 117")
-ANY (TARGET_SIGNAL_REALTIME_118, "SIG118", "Real-time event 118")
-ANY (TARGET_SIGNAL_REALTIME_119, "SIG119", "Real-time event 119")
-ANY (TARGET_SIGNAL_REALTIME_120, "SIG120", "Real-time event 120")
-ANY (TARGET_SIGNAL_REALTIME_121, "SIG121", "Real-time event 121")
-ANY (TARGET_SIGNAL_REALTIME_122, "SIG122", "Real-time event 122")
-ANY (TARGET_SIGNAL_REALTIME_123, "SIG123", "Real-time event 123")
-ANY (TARGET_SIGNAL_REALTIME_124, "SIG124", "Real-time event 124")
-ANY (TARGET_SIGNAL_REALTIME_125, "SIG125", "Real-time event 125")
-ANY (TARGET_SIGNAL_REALTIME_126, "SIG126", "Real-time event 126")
-ANY (TARGET_SIGNAL_REALTIME_127, "SIG127", "Real-time event 127")
+SET (TARGET_SIGNAL_REALTIME_65, 79, "SIG65", "Real-time event 65")
+SET (TARGET_SIGNAL_REALTIME_66, 80, "SIG66", "Real-time event 66")
+SET (TARGET_SIGNAL_REALTIME_67, 81, "SIG67", "Real-time event 67")
+SET (TARGET_SIGNAL_REALTIME_68, 82, "SIG68", "Real-time event 68")
+SET (TARGET_SIGNAL_REALTIME_69, 83, "SIG69", "Real-time event 69")
+SET (TARGET_SIGNAL_REALTIME_70, 84, "SIG70", "Real-time event 70")
+SET (TARGET_SIGNAL_REALTIME_71, 85, "SIG71", "Real-time event 71")
+SET (TARGET_SIGNAL_REALTIME_72, 86, "SIG72", "Real-time event 72")
+SET (TARGET_SIGNAL_REALTIME_73, 87, "SIG73", "Real-time event 73")
+SET (TARGET_SIGNAL_REALTIME_74, 88, "SIG74", "Real-time event 74")
+SET (TARGET_SIGNAL_REALTIME_75, 89, "SIG75", "Real-time event 75")
+SET (TARGET_SIGNAL_REALTIME_76, 90, "SIG76", "Real-time event 76")
+SET (TARGET_SIGNAL_REALTIME_77, 91, "SIG77", "Real-time event 77")
+SET (TARGET_SIGNAL_REALTIME_78, 92, "SIG78", "Real-time event 78")
+SET (TARGET_SIGNAL_REALTIME_79, 93, "SIG79", "Real-time event 79")
+SET (TARGET_SIGNAL_REALTIME_80, 94, "SIG80", "Real-time event 80")
+SET (TARGET_SIGNAL_REALTIME_81, 95, "SIG81", "Real-time event 81")
+SET (TARGET_SIGNAL_REALTIME_82, 96, "SIG82", "Real-time event 82")
+SET (TARGET_SIGNAL_REALTIME_83, 97, "SIG83", "Real-time event 83")
+SET (TARGET_SIGNAL_REALTIME_84, 98, "SIG84", "Real-time event 84")
+SET (TARGET_SIGNAL_REALTIME_85, 99, "SIG85", "Real-time event 85")
+SET (TARGET_SIGNAL_REALTIME_86, 100, "SIG86", "Real-time event 86")
+SET (TARGET_SIGNAL_REALTIME_87, 101, "SIG87", "Real-time event 87")
+SET (TARGET_SIGNAL_REALTIME_88, 102, "SIG88", "Real-time event 88")
+SET (TARGET_SIGNAL_REALTIME_89, 103, "SIG89", "Real-time event 89")
+SET (TARGET_SIGNAL_REALTIME_90, 104, "SIG90", "Real-time event 90")
+SET (TARGET_SIGNAL_REALTIME_91, 105, "SIG91", "Real-time event 91")
+SET (TARGET_SIGNAL_REALTIME_92, 106, "SIG92", "Real-time event 92")
+SET (TARGET_SIGNAL_REALTIME_93, 107, "SIG93", "Real-time event 93")
+SET (TARGET_SIGNAL_REALTIME_94, 108, "SIG94", "Real-time event 94")
+SET (TARGET_SIGNAL_REALTIME_95, 109, "SIG95", "Real-time event 95")
+SET (TARGET_SIGNAL_REALTIME_96, 110, "SIG96", "Real-time event 96")
+SET (TARGET_SIGNAL_REALTIME_97, 111, "SIG97", "Real-time event 97")
+SET (TARGET_SIGNAL_REALTIME_98, 112, "SIG98", "Real-time event 98")
+SET (TARGET_SIGNAL_REALTIME_99, 113, "SIG99", "Real-time event 99")
+SET (TARGET_SIGNAL_REALTIME_100, 114, "SIG100", "Real-time event 100")
+SET (TARGET_SIGNAL_REALTIME_101, 115, "SIG101", "Real-time event 101")
+SET (TARGET_SIGNAL_REALTIME_102, 116, "SIG102", "Real-time event 102")
+SET (TARGET_SIGNAL_REALTIME_103, 117, "SIG103", "Real-time event 103")
+SET (TARGET_SIGNAL_REALTIME_104, 118, "SIG104", "Real-time event 104")
+SET (TARGET_SIGNAL_REALTIME_105, 119, "SIG105", "Real-time event 105")
+SET (TARGET_SIGNAL_REALTIME_106, 120, "SIG106", "Real-time event 106")
+SET (TARGET_SIGNAL_REALTIME_107, 121, "SIG107", "Real-time event 107")
+SET (TARGET_SIGNAL_REALTIME_108, 122, "SIG108", "Real-time event 108")
+SET (TARGET_SIGNAL_REALTIME_109, 123, "SIG109", "Real-time event 109")
+SET (TARGET_SIGNAL_REALTIME_110, 124, "SIG110", "Real-time event 110")
+SET (TARGET_SIGNAL_REALTIME_111, 125, "SIG111", "Real-time event 111")
+SET (TARGET_SIGNAL_REALTIME_112, 126, "SIG112", "Real-time event 112")
+SET (TARGET_SIGNAL_REALTIME_113, 127, "SIG113", "Real-time event 113")
+SET (TARGET_SIGNAL_REALTIME_114, 128, "SIG114", "Real-time event 114")
+SET (TARGET_SIGNAL_REALTIME_115, 129, "SIG115", "Real-time event 115")
+SET (TARGET_SIGNAL_REALTIME_116, 130, "SIG116", "Real-time event 116")
+SET (TARGET_SIGNAL_REALTIME_117, 131, "SIG117", "Real-time event 117")
+SET (TARGET_SIGNAL_REALTIME_118, 132, "SIG118", "Real-time event 118")
+SET (TARGET_SIGNAL_REALTIME_119, 133, "SIG119", "Real-time event 119")
+SET (TARGET_SIGNAL_REALTIME_120, 134, "SIG120", "Real-time event 120")
+SET (TARGET_SIGNAL_REALTIME_121, 135, "SIG121", "Real-time event 121")
+SET (TARGET_SIGNAL_REALTIME_122, 136, "SIG122", "Real-time event 122")
+SET (TARGET_SIGNAL_REALTIME_123, 137, "SIG123", "Real-time event 123")
+SET (TARGET_SIGNAL_REALTIME_124, 138, "SIG124", "Real-time event 124")
+SET (TARGET_SIGNAL_REALTIME_125, 139, "SIG125", "Real-time event 125")
+SET (TARGET_SIGNAL_REALTIME_126, 140, "SIG126", "Real-time event 126")
+SET (TARGET_SIGNAL_REALTIME_127, 141, "SIG127", "Real-time event 127")
 
-ANY (TARGET_SIGNAL_INFO, "SIGINFO", "Information request")
+SET (TARGET_SIGNAL_INFO, 142, "SIGINFO", "Information request")
 
 /* Some signal we don't know about.  */
-ANY (TARGET_SIGNAL_UNKNOWN, NULL, "Unknown signal")
+SET (TARGET_SIGNAL_UNKNOWN, 143, NULL, "Unknown signal")
 
 /* Use whatever signal we use when one is not specifically specified
    (for passing to proceed and so on).  */
-ANY (TARGET_SIGNAL_DEFAULT, NULL,
+SET (TARGET_SIGNAL_DEFAULT, 144, NULL,
      "Internal error: printing TARGET_SIGNAL_DEFAULT")
 
 /* Mach exceptions.  In versions of GDB before 5.2, these were just before
    TARGET_SIGNAL_INFO if you were compiling on a Mach host (and missing
    otherwise).  */
-ANY (TARGET_EXC_BAD_ACCESS, "EXC_BAD_ACCESS", "Could not access memory")
-ANY (TARGET_EXC_BAD_INSTRUCTION, "EXC_BAD_INSTRUCTION",
+SET (TARGET_EXC_BAD_ACCESS, 145, "EXC_BAD_ACCESS", "Could not access memory")
+SET (TARGET_EXC_BAD_INSTRUCTION, 146, "EXC_BAD_INSTRUCTION",
      "Illegal instruction/operand")
-ANY (TARGET_EXC_ARITHMETIC, "EXC_ARITHMETIC", "Arithmetic exception")
-ANY (TARGET_EXC_EMULATION, "EXC_EMULATION", "Emulation instruction")
-ANY (TARGET_EXC_SOFTWARE, "EXC_SOFTWARE", "Software generated exception")
-ANY (TARGET_EXC_BREAKPOINT, "EXC_BREAKPOINT", "Breakpoint")
+SET (TARGET_EXC_ARITHMETIC, 147, "EXC_ARITHMETIC", "Arithmetic exception")
+SET (TARGET_EXC_EMULATION, 148, "EXC_EMULATION", "Emulation instruction")
+SET (TARGET_EXC_SOFTWARE, 149, "EXC_SOFTWARE", "Software generated exception")
+SET (TARGET_EXC_BREAKPOINT, 150, "EXC_BREAKPOINT", "Breakpoint")
 
 /* If you are adding a new signal, add it just above this comment.  */
 
 /* Last and unused enum value, for sizing arrays, etc.  */
-ANY (TARGET_SIGNAL_LAST, NULL, "TARGET_SIGNAL_MAGIC")
+SET (TARGET_SIGNAL_LAST, 151, NULL, "TARGET_SIGNAL_MAGIC")


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]