public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [patch 1/9]#2 Rename `enum target_signal' to target_signal_t
@ 2010-08-30  7:11 Jan Kratochvil
  2010-08-30  8:14 ` Mark Kettenis
  0 siblings, 1 reply; 40+ messages in thread
From: Jan Kratochvil @ 2010-08-30  7:11 UTC (permalink / raw)
  To: gdb-patches

series #2 of: http://sourceware.org/ml/gdb-patches/2010-07/msg00408.html

Hi,

there is no compiled code change in this patch.  This patch just renames `enum
target_signal' to target_signal_t (typedef) so the code is more flexible for
the later changes.  No other change is made.


Thanks,
Jan


include/gdb/
2010-08-29  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
	Rename enum target_signal to target_signal_t.
	* signals.h (enum target_signal): Rename to ...
	(target_signal_t): ... this one.

gdb/gdbserver/
2010-08-29  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
	Rename enum target_signal to target_signal_t.
	* target.h, win32-low.c: Rename all the uses of enum target_signal to
	target_signal_t.

sim/common/
2010-08-29  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
	Rename enum target_signal to target_signal_t.
	* sim-signal.c, sim-signal.h: Rename all the uses of enum
	target_signal to target_signal_t.

gdb/
2010-08-29  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
	Rename enum target_signal to target_signal_t.
	* aix-thread.c, amd64-linux-tdep.c, bsd-uthread.c,
	common/gdb_signals.h, common/signals.c, corelow.c, darwin-nat.c,
	defs.h, fbsd-nat.c, gdbarch.c, gdbarch.h, gdbarch.sh, gdbthread.h,
	gnu-nat.c, go32-nat.c, hpux-thread.c, i386-linux-nat.c,
	i386-linux-tdep.c, i386fbsd-nat.c, inf-ptrace.c, inf-ttrace.c,
	infcmd.c, inferior.h, infrun.c, linux-nat.c, linux-thread-db.c,
	monitor.c, nto-procfs.c, procfs.c, record.c, remote-m32r-sdi.c,
	remote-mips.c, remote-sim.c, remote.c, sol-thread.c, target.c,
	target.h, windows-nat.c: Rename all the uses of enum target_signal to
	target_signal_t.

--- a/gdb/aix-thread.c
+++ b/gdb/aix-thread.c
@@ -970,7 +970,7 @@ aix_thread_detach (struct target_ops *ops, char *args, int from_tty)
 
 static void
 aix_thread_resume (struct target_ops *ops,
-                   ptid_t ptid, int step, enum target_signal sig)
+                   ptid_t ptid, int step, target_signal_t sig)
 {
   struct thread_info *thread;
   pthdb_tid_t tid[2];
--- a/gdb/amd64-linux-tdep.c
+++ b/gdb/amd64-linux-tdep.c
@@ -1230,7 +1230,7 @@ amd64_linux_syscall_record (struct regcache *regcache)
 int
 amd64_linux_record_signal (struct gdbarch *gdbarch,
                            struct regcache *regcache,
-                           enum target_signal signal)
+                           target_signal_t signal)
 {
   ULONGEST rsp;
 
--- a/gdb/bsd-uthread.c
+++ b/gdb/bsd-uthread.c
@@ -397,7 +397,7 @@ bsd_uthread_wait (struct target_ops *ops,
 
 static void
 bsd_uthread_resume (struct target_ops *ops,
-		    ptid_t ptid, int step, enum target_signal sig)
+		    ptid_t ptid, int step, target_signal_t sig)
 {
   /* Pass the request to the layer beneath.  */
   struct target_ops *beneath = find_target_beneath (ops);
--- a/gdb/common/gdb_signals.h
+++ b/gdb/common/gdb_signals.h
@@ -28,29 +28,29 @@
    targ_signal SIGNO has an equivalent ``host'' representation.  */
 /* FIXME: cagney/1999-11-22: The name below was chosen in preference
    to the shorter target_signal_p() because it is far less ambigious.
-   In this context ``target_signal'' refers to GDB's internal
+   In this context ``target_signal_t'' 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_t signo);
 
-/* Convert between host signal numbers and enum target_signal's.
+/* Convert between host signal numbers and target_signal_t's.
    target_signal_to_host() returns 0 and prints a warning() on GDB's
    console if SIGNO has no equivalent host representation.  */
 /* FIXME: cagney/1999-11-22: Here ``host'' is used incorrectly, it is
    refering to the target operating system's signal numbering.
-   Similarly, ``enum target_signal'' is named incorrectly, ``enum
+   Similarly, ``target_signal_t'' 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_t target_signal_from_host (int);
+extern int target_signal_to_host (target_signal_t);
 
 /* 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_t);
 
 /* 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_t);
 
 /* Given a name (SIGHUP, etc.), return its signal.  */
-enum target_signal target_signal_from_name (const char *);
+target_signal_t target_signal_from_name (const char *);
 
 #endif /* COMMON_GDB_SIGNALS_H */
--- a/gdb/common/signals.c
+++ b/gdb/common/signals.c
@@ -48,7 +48,7 @@ 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_t.  */
 
 static const struct {
   const char *name;
@@ -65,7 +65,7 @@ static const struct {
 
 /* Return the string for a signal.  */
 const char *
-target_signal_to_string (enum target_signal sig)
+target_signal_to_string (target_signal_t sig)
 {
   if ((int) sig >= TARGET_SIGNAL_FIRST && (int) sig <= TARGET_SIGNAL_LAST)
     return signals[sig].string;
@@ -75,7 +75,7 @@ target_signal_to_string (enum target_signal sig)
 
 /* Return the name for a signal.  */
 const char *
-target_signal_to_name (enum target_signal sig)
+target_signal_to_name (target_signal_t sig)
 {
   if ((int) sig >= TARGET_SIGNAL_FIRST && (int) sig <= TARGET_SIGNAL_LAST
       && signals[sig].name != NULL)
@@ -87,10 +87,10 @@ target_signal_to_name (enum target_signal sig)
 }
 
 /* Given a name, return its signal.  */
-enum target_signal
+target_signal_t
 target_signal_from_name (const char *name)
 {
-  enum target_signal sig;
+  target_signal_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
@@ -100,7 +100,7 @@ target_signal_from_name (const char *name)
   /* 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))
+       sig = (target_signal_t) ((int) sig + 1))
     if (signals[sig].name != NULL
 	&& strcmp (name, signals[sig].name) == 0)
       return sig;
@@ -112,7 +112,7 @@ target_signal_from_name (const char *name)
    a file called native-utils.c or unixwaitstatus-utils.c or whatever.  */
 
 /* Convert host signal to our signals.  */
-enum target_signal
+target_signal_t
 target_signal_from_host (int hostsig)
 {
   /* A switch statement would make sense but would require special kludges
@@ -342,12 +342,12 @@ 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)
+	return (target_signal_t)
 	  (hostsig - 33 + (int) TARGET_SIGNAL_REALTIME_33);
       else if (hostsig == 32)
 	return TARGET_SIGNAL_REALTIME_32;
       else if (64 <= hostsig && hostsig <= 127)
-	return (enum target_signal)
+	return (target_signal_t)
 	  (hostsig - 64 + (int) TARGET_SIGNAL_REALTIME_64);
       else
 	error ("GDB bug: target.c (target_signal_from_host): unrecognized real-time signal");
@@ -357,13 +357,13 @@ target_signal_from_host (int hostsig)
   return TARGET_SIGNAL_UNKNOWN;
 }
 
-/* Convert a OURSIG (an enum target_signal) to the form used by the
+/* Convert a OURSIG (an target_signal_t) 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,
+do_target_signal_to_host (target_signal_t oursig,
 			  int *oursig_ok)
 {
   int retsig;
@@ -628,7 +628,7 @@ do_target_signal_to_host (enum target_signal oursig,
 }
 
 int
-target_signal_to_host_p (enum target_signal oursig)
+target_signal_to_host_p (target_signal_t oursig)
 {
   int oursig_ok;
   do_target_signal_to_host (oursig, &oursig_ok);
@@ -636,7 +636,7 @@ target_signal_to_host_p (enum target_signal oursig)
 }
 
 int
-target_signal_to_host (enum target_signal oursig)
+target_signal_to_host (target_signal_t oursig)
 {
   int oursig_ok;
   int targ_signo = do_target_signal_to_host (oursig, &oursig_ok);
@@ -662,11 +662,11 @@ target_signal_to_host (enum target_signal oursig)
    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_t
 target_signal_from_command (int num)
 {
   if (num >= 1 && num <= 15)
-    return (enum target_signal) num;
+    return (target_signal_t) num;
   error ("Only signals 1-15 are valid as numeric signals.\n\
 Use \"info signals\" for a list of symbolic signals.");
 }
@@ -681,12 +681,12 @@ _initialize_signals (void)
 }
 
 int
-default_target_signal_to_host (struct gdbarch *gdbarch, enum target_signal ts)
+default_target_signal_to_host (struct gdbarch *gdbarch, target_signal_t ts)
 {
   return target_signal_to_host (ts);
 }
 
-enum target_signal
+target_signal_t
 default_target_signal_from_host (struct gdbarch *gdbarch, int signo)
 {
   return target_signal_from_host (signo);
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -431,7 +431,7 @@ core_open (char *filename, int from_tty)
   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
+       value is called ``target_signal_t'' and this function got the
        name ..._from_host(). */
     printf_filtered (_("Program terminated with signal %d, %s.\n"), siggy,
 		     target_signal_to_string (
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -89,9 +89,9 @@ extern boolean_t exc_server (mach_msg_header_t *in, mach_msg_header_t *out);
 static void darwin_stop (ptid_t);
 
 static void darwin_resume_to (struct target_ops *ops, ptid_t ptid, int step,
-                              enum target_signal signal);
+                              target_signal_t signal);
 static void darwin_resume (ptid_t ptid, int step,
-			   enum target_signal signal);
+			   target_signal_t signal);
 
 static ptid_t darwin_wait_to (struct target_ops *ops, ptid_t ptid,
                               struct target_waitstatus *status, int options);
@@ -767,7 +767,7 @@ darwin_suspend_inferior_threads (struct inferior *inf)
 }
 
 static void
-darwin_resume (ptid_t ptid, int step, enum target_signal signal)
+darwin_resume (ptid_t ptid, int step, target_signal_t signal)
 {
   struct target_waitstatus status;
   int pid;
@@ -833,7 +833,7 @@ darwin_resume (ptid_t ptid, int step, enum target_signal signal)
 
 static void
 darwin_resume_to (struct target_ops *ops, ptid_t ptid, int step,
-                  enum target_signal signal)
+                  target_signal_t signal)
 {
   return darwin_resume (ptid, step, signal);
 }
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -64,7 +64,7 @@
 
 #include "gdb_wchar.h"
 
-/* For ``enum target_signal''.  */
+/* For ``target_signal_t''.  */
 #include "gdb/signals.h"
 
 /* Just in case they're not defined in stdio.h.  */
--- a/gdb/fbsd-nat.c
+++ b/gdb/fbsd-nat.c
@@ -152,7 +152,7 @@ find_signalled_thread (struct thread_info *info, void *data)
   return 0;
 }
 
-static enum target_signal
+static target_signal_t
 find_stop_signal (void)
 {
   struct thread_info *info =
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -3507,7 +3507,7 @@ gdbarch_process_record_signal_p (struct gdbarch *gdbarch)
 }
 
 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_t signal)
 {
   gdb_assert (gdbarch != NULL);
   gdb_assert (gdbarch->process_record_signal != NULL);
@@ -3523,7 +3523,7 @@ set_gdbarch_process_record_signal (struct gdbarch *gdbarch,
   gdbarch->process_record_signal = process_record_signal;
 }
 
-enum target_signal
+target_signal_t
 gdbarch_target_signal_from_host (struct gdbarch *gdbarch, int signo)
 {
   gdb_assert (gdbarch != NULL);
@@ -3541,7 +3541,7 @@ set_gdbarch_target_signal_from_host (struct gdbarch *gdbarch,
 }
 
 int
-gdbarch_target_signal_to_host (struct gdbarch *gdbarch, enum target_signal ts)
+gdbarch_target_signal_to_host (struct gdbarch *gdbarch, target_signal_t ts)
 {
   gdb_assert (gdbarch != NULL);
   gdb_assert (gdbarch->target_signal_to_host != NULL);
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -880,22 +880,22 @@ extern void set_gdbarch_process_record (struct gdbarch *gdbarch, gdbarch_process
 
 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_t signal);
+extern int gdbarch_process_record_signal (struct gdbarch *gdbarch, struct regcache *regcache, target_signal_t 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_t (gdbarch_target_signal_from_host_ftype) (struct gdbarch *gdbarch, int signo);
+extern target_signal_t 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_t ts);
+extern int gdbarch_target_signal_to_host (struct gdbarch *gdbarch, target_signal_t 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.
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -748,14 +748,14 @@ M:int:process_record:struct regcache *regcache, CORE_ADDR addr:regcache, addr
 
 # 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_t 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_t: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_t ts:ts::default_target_signal_to_host::0
 
 # Extra signal info inspection.
 #
--- a/gdb/gdbserver/target.h
+++ b/gdb/gdbserver/target.h
@@ -54,7 +54,7 @@ struct thread_resume
      thread.  If stopping a thread, and this is 0, the target should
      stop the thread however it best decides to (e.g., SIGSTOP on
      linux; SuspendThread on win32).  This is a host signal value (not
-     enum target_signal).  */
+     target_signal_t).  */
   int sig;
 };
 
@@ -98,7 +98,7 @@ struct target_waitstatus
     union
       {
 	int integer;
-	enum target_signal sig;
+	target_signal_t sig;
 	ptid_t related_pid;
 	char *execd_pathname;
       }
--- a/gdb/gdbserver/win32-low.c
+++ b/gdb/gdbserver/win32-low.c
@@ -73,7 +73,7 @@ static int attaching = 0;
 static HANDLE current_process_handle = NULL;
 static DWORD current_process_id = 0;
 static DWORD main_thread_id = 0;
-static enum target_signal last_sig = TARGET_SIGNAL_0;
+static target_signal_t last_sig = TARGET_SIGNAL_0;
 
 /* The current debug event from WaitForDebugEvent.  */
 static DEBUG_EVENT current_event;
@@ -803,7 +803,7 @@ static void
 win32_resume (struct thread_resume *resume_info, size_t n)
 {
   DWORD tid;
-  enum target_signal sig;
+  target_signal_t sig;
   int step;
   win32_thread_info *th;
   DWORD continue_status = DBG_CONTINUE;
--- a/gdb/gdbthread.h
+++ b/gdb/gdbthread.h
@@ -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_t stop_signal;
 
   /* Chain containing status of breakpoint(s) the thread stopped
      at.  */
--- a/gdb/gnu-nat.c
+++ b/gdb/gnu-nat.c
@@ -107,7 +107,7 @@ void inf_resume (struct inf *inf);
 void inf_set_step_thread (struct inf *inf, struct proc *proc);
 void inf_detach (struct inf *inf);
 void inf_attach (struct inf *inf, int pid);
-void inf_signal (struct inf *inf, enum target_signal sig);
+void inf_signal (struct inf *inf, target_signal_t sig);
 void inf_continue (struct inf *inf);
 
 #define inf_debug(_inf, msg, args...) \
@@ -1318,7 +1318,7 @@ inf_restore_exc_ports (struct inf *inf)
    signal 0, will continue it.  INF is assumed to be in a paused state, and
    the resume_sc's of INF's threads may be affected.  */
 void
-inf_signal (struct inf *inf, enum target_signal sig)
+inf_signal (struct inf *inf, target_signal_t sig)
 {
   error_t err = 0;
   int host_sig = target_signal_to_host (sig);
@@ -1965,7 +1965,7 @@ port_msgs_queued (mach_port_t port)
  */
 static void
 gnu_resume (struct target_ops *ops,
-	    ptid_t ptid, int step, enum target_signal sig)
+	    ptid_t ptid, int step, target_signal_t sig)
 {
   struct proc *step_thread = 0;
   int resume_all;
--- a/gdb/go32-nat.c
+++ b/gdb/go32-nat.c
@@ -238,7 +238,7 @@ static void go32_attach (struct target_ops *ops, char *args, int from_tty);
 static void go32_detach (struct target_ops *ops, char *args, int from_tty);
 static void go32_resume (struct target_ops *ops,
 			 ptid_t ptid, int step,
-			 enum target_signal siggnal);
+			 target_signal_t siggnal);
 static void go32_fetch_registers (struct target_ops *ops,
 				  struct regcache *, int regno);
 static void store_register (const struct regcache *, int regno);
@@ -309,7 +309,7 @@ regno_mapping[] =
 static struct
   {
     int go32_sig;
-    enum target_signal gdb_sig;
+    target_signal_t gdb_sig;
   }
 sig_map[] =
 {
@@ -343,7 +343,7 @@ sig_map[] =
 };
 
 static struct {
-  enum target_signal gdb_sig;
+  target_signal_t gdb_sig;
   int djgpp_excepno;
 } excepn_map[] = {
   {TARGET_SIGNAL_0, -1},
@@ -391,7 +391,7 @@ static int resume_signal = -1;
 
 static void
 go32_resume (struct target_ops *ops,
-	     ptid_t ptid, int step, enum target_signal siggnal)
+	     ptid_t ptid, int step, target_signal_t siggnal)
 {
   int i;
 
--- a/gdb/hpux-thread.c
+++ b/gdb/hpux-thread.c
@@ -169,7 +169,7 @@ hpux_thread_detach (struct target_ops *ops, char *args, int from_tty)
 
 static void
 hpux_thread_resume (struct target_ops *ops,
-		    ptid_t ptid, int step, enum target_signal signo)
+		    ptid_t ptid, int step, target_signal_t signo)
 {
   struct cleanup *old_chain;
 
--- a/gdb/i386-linux-nat.c
+++ b/gdb/i386-linux-nat.c
@@ -829,7 +829,7 @@ static const unsigned char linux_syscall[] = { 0xcd, 0x80 };
 
 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_t signal)
 {
   int pid = PIDGET (ptid);
 
--- a/gdb/i386-linux-tdep.c
+++ b/gdb/i386-linux-tdep.c
@@ -463,7 +463,7 @@ i386_linux_intx80_sysenter_record (struct regcache *regcache)
 int
 i386_linux_record_signal (struct gdbarch *gdbarch,
                           struct regcache *regcache,
-                          enum target_signal signal)
+                          target_signal_t signal)
 {
   ULONGEST esp;
 
--- a/gdb/i386fbsd-nat.c
+++ b/gdb/i386fbsd-nat.c
@@ -37,7 +37,7 @@
 
 static void
 i386fbsd_resume (struct target_ops *ops,
-		 ptid_t ptid, int step, enum target_signal signal)
+		 ptid_t ptid, int step, target_signal_t signal)
 {
   pid_t pid = ptid_get_pid (ptid);
   int request = PT_STEP;
--- a/gdb/inf-ptrace.c
+++ b/gdb/inf-ptrace.c
@@ -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_t signal)
 {
   pid_t pid = ptid_get_pid (ptid);
   int request;
--- a/gdb/inf-ttrace.c
+++ b/gdb/inf-ttrace.c
@@ -867,7 +867,7 @@ inf_ttrace_resume_callback (struct thread_info *info, void *arg)
 
 static void
 inf_ttrace_resume (struct target_ops *ops,
-		   ptid_t ptid, int step, enum target_signal signal)
+		   ptid_t ptid, int step, target_signal_t signal)
 {
   int resume_all;
   ttreq_t request = step ? TT_LWP_SINGLE : TT_LWP_CONTINUE;
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -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_t oursig;
   int async_exec = 0;
 
   dont_repeat ();		/* Too dangerous.  */
--- a/gdb/inferior.h
+++ b/gdb/inferior.h
@@ -35,7 +35,7 @@ struct terminal_info;
 /* For bpstat.  */
 #include "breakpoint.h"
 
-/* For enum target_signal.  */
+/* For target_signal_t.  */
 #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_t, 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_t);
 
 /* From misc files */
 
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -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_t);
 
 static void sig_print_header (void);
 
@@ -1297,7 +1297,7 @@ write_memory_ptid (ptid_t ptid, CORE_ADDR memaddr, const gdb_byte *myaddr, int l
 }
 
 static void
-displaced_step_fixup (ptid_t event_ptid, enum target_signal signal)
+displaced_step_fixup (ptid_t event_ptid, target_signal_t signal)
 {
   struct cleanup *old_cleanups;
   struct displaced_step_inferior_state *displaced
@@ -1538,7 +1538,7 @@ maybe_software_singlestep (struct gdbarch *gdbarch, CORE_ADDR pc)
    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_t sig)
 {
   int should_resume = 1;
   struct cleanup *old_cleanups = make_cleanup (resume_cleanups, 0);
@@ -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_t siggnal, int step)
 {
   struct regcache *regcache;
   struct gdbarch *gdbarch;
@@ -3589,7 +3589,7 @@ targets should add new threads to the thread list themselves in non-stop mode.")
 
 	     if (new_singlestep_pc != singlestep_pc)
 	       {
-		 enum target_signal stop_signal;
+		 target_signal_t stop_signal;
 
 		 if (debug_infrun)
 		   fprintf_unfiltered (gdb_stdlog, "infrun: unexpected thread,"
@@ -5625,7 +5625,7 @@ Signal        Stop\tPrint\tPass to program\tDescription\n"));
 }
 
 static void
-sig_print_info (enum target_signal oursig)
+sig_print_info (target_signal_t oursig)
 {
   const char *name = target_signal_to_name (oursig);
   int name_padding = 13 - strlen (name);
@@ -5649,7 +5649,7 @@ handle_command (char *args, int from_tty)
   char **argv;
   int digits, wordlen;
   int sigfirst, signum, siglast;
-  enum target_signal oursig;
+  target_signal_t oursig;
   int allsigs;
   int nsigs;
   unsigned char *sigs;
@@ -5769,14 +5769,14 @@ handle_command (char *args, int from_tty)
 
       for (signum = sigfirst; signum >= 0 && signum <= siglast; signum++)
 	{
-	  switch ((enum target_signal) signum)
+	  switch ((target_signal_t) signum)
 	    {
 	    case TARGET_SIGNAL_TRAP:
 	    case 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_t) signum)))
 		    {
 		      sigs[signum] = 1;
 		    }
@@ -5844,7 +5844,7 @@ xdb_handle_command (char *args, int from_tty)
       if (argBuf)
 	{
 	  int validFlag = 1;
-	  enum target_signal oursig;
+	  target_signal_t oursig;
 
 	  oursig = target_signal_from_name (argv[0]);
 	  memset (argBuf, 0, bufLen);
@@ -5895,7 +5895,7 @@ xdb_handle_command (char *args, int from_tty)
 static void
 signals_info (char *signum_exp, int from_tty)
 {
-  enum target_signal oursig;
+  target_signal_t oursig;
 
   sig_print_header ();
 
@@ -5917,7 +5917,7 @@ signals_info (char *signum_exp, int from_tty)
   /* 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))
+       oursig = (target_signal_t) ((int) oursig + 1))
     {
       QUIT;
 
@@ -6013,7 +6013,7 @@ siginfo_make_value (struct gdbarch *gdbarch, struct internalvar *var)
 
 struct inferior_thread_state
 {
-  enum target_signal stop_signal;
+  target_signal_t stop_signal;
   CORE_ADDR stop_pc;
   struct regcache *registers;
 };
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -1581,7 +1581,7 @@ linux_nat_attach (struct target_ops *ops, char *args, int from_tty)
 	}
       else if (WIFSIGNALED (status))
 	{
-	  enum target_signal signo;
+	  target_signal_t signo;
 
 	  target_terminal_ours ();
 	  target_mourn_inferior ();
@@ -1617,7 +1617,7 @@ linux_nat_attach (struct target_ops *ops, char *args, int from_tty)
 static int
 get_pending_status (struct lwp_info *lp, int *status)
 {
-  enum target_signal signo = TARGET_SIGNAL_0;
+  target_signal_t 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, void *data)
 
 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_t signo)
 {
   sigset_t prev_mask;
   struct lwp_info *lp;
@@ -4167,7 +4167,7 @@ find_signalled_thread (struct thread_info *info, void *data)
   return 0;
 }
 
-static enum target_signal
+static target_signal_t
 find_stop_signal (void)
 {
   struct thread_info *info =
@@ -4185,7 +4185,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_t stop_signal)
 {
   unsigned long lwp = ptid_get_lwp (ptid);
   struct gdbarch *gdbarch = target_gdbarch;
@@ -4278,7 +4278,7 @@ struct linux_nat_corefile_thread_data
   char *note_data;
   int *note_size;
   int num_notes;
-  enum target_signal stop_signal;
+  target_signal_t stop_signal;
 };
 
 /* Called by gdbthread.c once per thread.  Records the thread's
--- a/gdb/linux-thread-db.c
+++ b/gdb/linux-thread-db.c
@@ -1650,7 +1650,7 @@ thread_db_get_ada_task_ptid (long lwp, long thread)
 
 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_t signo)
 {
   struct target_ops *beneath = find_target_beneath (ops);
   struct thread_db_info *info;
--- a/gdb/monitor.c
+++ b/gdb/monitor.c
@@ -928,7 +928,7 @@ monitor_supply_register (struct regcache *regcache, int regno, char *valstr)
 
 static void
 monitor_resume (struct target_ops *ops,
-		ptid_t ptid, int step, enum target_signal sig)
+		ptid_t ptid, int step, target_signal_t sig)
 {
   /* Some monitors require a different command when starting a program */
   monitor_debug ("MON resume\n");
--- a/gdb/nto-procfs.c
+++ b/gdb/nto-procfs.c
@@ -952,7 +952,7 @@ procfs_remove_hw_breakpoint (struct gdbarch *gdbarch,
 
 static void
 procfs_resume (struct target_ops *ops,
-	       ptid_t ptid, int step, enum target_signal signo)
+	       ptid_t ptid, int step, target_signal_t signo)
 {
   int signal_to_pass;
   procfs_status status;
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -113,7 +113,7 @@
 static void procfs_attach (struct target_ops *, char *, int);
 static void procfs_detach (struct target_ops *, char *, int);
 static void procfs_resume (struct target_ops *,
-			   ptid_t, int, enum target_signal);
+			   ptid_t, int, target_signal_t);
 static void procfs_stop (ptid_t);
 static void procfs_files_info (struct target_ops *);
 static void procfs_fetch_registers (struct target_ops *,
@@ -4388,7 +4388,7 @@ make_signal_thread_runnable (procinfo *process, procinfo *pi, void *ptr)
 
 static void
 procfs_resume (struct target_ops *ops,
-	       ptid_t ptid, int step, enum target_signal signo)
+	       ptid_t ptid, int step, target_signal_t signo)
 {
   procinfo *pi, *thread;
   int native_signo;
@@ -5641,7 +5641,7 @@ procfs_first_available (void)
 static char *
 procfs_do_thread_registers (bfd *obfd, ptid_t ptid,
 			    char *note_data, int *note_size,
-			    enum target_signal stop_signal)
+			    target_signal_t stop_signal)
 {
   struct regcache *regcache = get_thread_regcache (ptid);
   gdb_gregset_t gregs;
@@ -5692,7 +5692,7 @@ struct procfs_corefile_thread_data {
   bfd *obfd;
   char *note_data;
   int *note_size;
-  enum target_signal stop_signal;
+  target_signal_t stop_signal;
 };
 
 static int
@@ -5722,7 +5722,7 @@ find_signalled_thread (struct thread_info *info, void *data)
   return 0;
 }
 
-static enum target_signal
+static target_signal_t
 find_stop_signal (void)
 {
   struct thread_info *info =
@@ -5748,7 +5748,7 @@ procfs_make_note_section (bfd *obfd, int *note_size)
   struct procfs_corefile_thread_data thread_args;
   gdb_byte *auxv;
   int auxv_len;
-  enum target_signal stop_signal;
+  target_signal_t stop_signal;
 
   if (get_exec_file (0))
     {
--- a/gdb/record.c
+++ b/gdb/record.c
@@ -98,7 +98,7 @@ struct record_reg_entry
 
 struct record_end_entry
 {
-  enum target_signal sigval;
+  target_signal_t 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_t);
 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_t signal)
 {
   int ret;
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
@@ -649,7 +649,7 @@ record_message (struct regcache *regcache, enum target_signal signal)
 
 struct record_message_args {
   struct regcache *regcache;
-  enum target_signal signal;
+  target_signal_t 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_t signal)
 {
   struct record_message_args args;
 
@@ -783,7 +783,7 @@ record_exec_insn (struct regcache *regcache, struct gdbarch *gdbarch,
 
 static struct target_ops *tmp_to_resume_ops;
 static void (*tmp_to_resume) (struct target_ops *, ptid_t, int,
-			      enum target_signal);
+			      target_signal_t);
 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_t 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_t signal)
 {
   record_resume_step = step;
 }
--- a/gdb/remote-m32r-sdi.c
+++ b/gdb/remote-m32r-sdi.c
@@ -453,7 +453,7 @@ m32r_close (int quitting)
 
 static void
 m32r_resume (struct target_ops *ops,
-	     ptid_t ptid, int step, enum target_signal sig)
+	     ptid_t ptid, int step, target_signal_t sig)
 {
   unsigned long pc_addr, bp_addr, ab_addr;
   int ib_breakpoints;
--- a/gdb/remote-mips.c
+++ b/gdb/remote-mips.c
@@ -1744,7 +1744,7 @@ mips_detach (struct target_ops *ops, char *args, int from_tty)
 
 static void
 mips_resume (struct target_ops *ops,
-	     ptid_t ptid, int step, enum target_signal siggnal)
+	     ptid_t ptid, int step, target_signal_t siggnal)
 {
   int err;
 
@@ -1758,7 +1758,7 @@ mips_resume (struct target_ops *ops,
 /* Return the signal corresponding to SIG, where SIG is the number which
    the MIPS protocol uses for the signal.  */
 
-static enum target_signal
+static target_signal_t
 mips_signal_from_protocol (int sig)
 {
   /* We allow a few more signals than the IDT board actually returns, on
@@ -1772,7 +1772,7 @@ mips_signal_from_protocol (int sig)
      from MIPS signal numbers, not host ones.  Our internal numbers
      match the MIPS numbers for the signals the board can return, which
      are: SIGINT, SIGSEGV, SIGBUS, SIGILL, SIGFPE, SIGTRAP.  */
-  return (enum target_signal) sig;
+  return (target_signal_t) sig;
 }
 
 /* Set the register designated by REGNO to the value designated by VALUE.  */
--- a/gdb/remote-sim.c
+++ b/gdb/remote-sim.c
@@ -119,7 +119,7 @@ struct sim_inferior_data {
   ptid_t remote_sim_ptid;
 
   /* Signal with which to resume.  */
-  enum target_signal resume_siggnal;
+  target_signal_t resume_siggnal;
 
   /* Flag which indicates whether resume should step or not.  */
   int resume_step;
@@ -825,7 +825,7 @@ gdbsim_detach (struct target_ops *ops, char *args, int from_tty)
 
 struct resume_data
 {
-  enum target_signal siggnal;
+  target_signal_t siggnal;
   int step;
 };
 
@@ -854,7 +854,7 @@ gdbsim_resume_inferior (struct inferior *inf, void *arg)
 
 static void
 gdbsim_resume (struct target_ops *ops,
-	       ptid_t ptid, int step, enum target_signal siggnal)
+	       ptid_t ptid, int step, target_signal_t siggnal)
 {
   struct resume_data rd;
   struct sim_inferior_data *sim_data
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -4384,7 +4384,7 @@ remote_vcont_probe (struct remote_state *rs)
 
 static char *
 append_resumption (char *p, char *endp,
-		   ptid_t ptid, int step, enum target_signal siggnal)
+		   ptid_t ptid, int step, target_signal_t siggnal)
 {
   struct remote_state *rs = get_remote_state ();
 
@@ -4427,7 +4427,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_t siggnal)
 {
   struct remote_state *rs = get_remote_state ();
   char *p;
@@ -4495,13 +4495,13 @@ remote_vcont_resume (ptid_t ptid, int step, enum target_signal siggnal)
 
 /* Tell the remote machine to resume.  */
 
-static enum target_signal last_sent_signal = TARGET_SIGNAL_0;
+static target_signal_t last_sent_signal = TARGET_SIGNAL_0;
 
 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_t siggnal)
 {
   struct remote_state *rs = get_remote_state ();
   char *buf;
@@ -5155,7 +5155,7 @@ Packet: '%s'\n"),
       else
 	{
 	  event->ws.kind = TARGET_WAITKIND_STOPPED;
-	  event->ws.value.sig = (enum target_signal)
+	  event->ws.value.sig = (target_signal_t)
 	    (((fromhex (buf[1])) << 4) + (fromhex (buf[2])));
 	}
       break;
@@ -5181,7 +5181,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_t) value;
 	  }
 
 	/* If no process is specified, assume inferior_ptid.  */
--- a/gdb/sol-thread.c
+++ b/gdb/sol-thread.c
@@ -348,7 +348,7 @@ sol_thread_detach (struct target_ops *ops, char *args, int from_tty)
 
 static void
 sol_thread_resume (struct target_ops *ops,
-		   ptid_t ptid, int step, enum target_signal signo)
+		   ptid_t ptid, int step, target_signal_t signo)
 {
   struct cleanup *old_chain;
   struct target_ops *beneath = find_target_beneath (ops);
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -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_t signal)
 {
   struct target_ops *t;
 
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -162,7 +162,7 @@ struct target_waitstatus
     union
       {
 	int integer;
-	enum target_signal sig;
+	target_signal_t 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_t);
     ptid_t (*to_wait) (struct target_ops *,
 		       ptid_t, struct target_waitstatus *, int);
     void (*to_fetch_registers) (struct target_ops *, struct regcache *, int);
@@ -801,7 +801,7 @@ extern void target_disconnect (char *, int);
    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_t 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;
@@ -1589,13 +1589,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 *,
+extern target_signal_t default_target_signal_from_host (struct gdbarch *,
 							   int);
 extern int default_target_signal_to_host (struct gdbarch *, 
-					  enum target_signal);
+					  target_signal_t);
 
-/* 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_t.  */
+extern target_signal_t target_signal_from_command (int);
 /* End of files in common/signals.c.  */
 
 /* Set the show memory breakpoints mode to show, and installs a cleanup
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -185,7 +185,7 @@ static void cygwin_set_dr (int i, CORE_ADDR addr);
 static void cygwin_set_dr7 (unsigned long val);
 static unsigned long cygwin_get_dr6 (void);
 
-static enum target_signal last_sig = TARGET_SIGNAL_0;
+static target_signal_t last_sig = TARGET_SIGNAL_0;
 /* Set if a signal was received from the debugged process */
 
 /* Thread information structure used to track information that is
@@ -258,7 +258,7 @@ static const int *mappings;
 struct xlate_exception
   {
     int them;
-    enum target_signal us;
+    target_signal_t us;
   };
 
 static const struct xlate_exception
@@ -1282,7 +1282,7 @@ fake_create_process (void)
 
 static void
 windows_resume (struct target_ops *ops,
-		ptid_t ptid, int step, enum target_signal sig)
+		ptid_t ptid, int step, target_signal_t sig)
 {
   thread_info *th;
   DWORD continue_status = DBG_CONTINUE;
--- a/include/gdb/signals.h
+++ b/include/gdb/signals.h
@@ -49,7 +49,7 @@
 /* For an explanation of what each signal means, see
    target_signal_to_string.  */
 
-enum target_signal
+typedef enum
   {
 #define SET(symbol, constant, name, string) \
     symbol = constant,
@@ -58,6 +58,7 @@ enum target_signal
 #include "gdb/signals.def"
 #undef ANY
 #undef SET
-  };
+  }
+target_signal_t;
 
 #endif /* #ifndef GDB_SIGNALS_H */
--- a/sim/common/sim-signal.c
+++ b/sim/common/sim-signal.c
@@ -94,7 +94,7 @@ sim_signal_to_host (SIM_DESC sd, SIM_SIGNAL sig)
 #endif
 }
 
-enum target_signal 
+target_signal_t 
 sim_signal_to_target (SIM_DESC sd, SIM_SIGNAL sig)
 {
   switch (sig)
--- a/sim/common/sim-signal.h
+++ b/sim/common/sim-signal.h
@@ -46,6 +46,6 @@ typedef enum {
 } SIM_SIGNAL;
 
 int sim_signal_to_host (SIM_DESC sd, SIM_SIGNAL);
-enum target_signal sim_signal_to_target (SIM_DESC sd, SIM_SIGNAL);
+target_signal_t sim_signal_to_target (SIM_DESC sd, SIM_SIGNAL);
 
 #endif /* SIM_SIGNAL_H */

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [patch 1/9]#2 Rename `enum target_signal' to target_signal_t
  2010-08-30  7:11 [patch 1/9]#2 Rename `enum target_signal' to target_signal_t Jan Kratochvil
@ 2010-08-30  8:14 ` Mark Kettenis
  2010-08-30  8:24   ` Jan Kratochvil
  0 siblings, 1 reply; 40+ messages in thread
From: Mark Kettenis @ 2010-08-30  8:14 UTC (permalink / raw)
  To: jan.kratochvil; +Cc: gdb-patches

> Date: Mon, 30 Aug 2010 09:10:40 +0200
> From: Jan Kratochvil <jan.kratochvil@redhat.com>
> 
> series #2 of: http://sourceware.org/ml/gdb-patches/2010-07/msg00408.html
> 
> Hi,
> 
> there is no compiled code change in this patch.  This patch just renames `enum
> target_signal' to target_signal_t (typedef) so the code is more flexible for
> the later changes.  No other change is made.

The _t suffix is actually reserved by POSIX, so using it is actually a
bad idea.  Perhaps change it to gdb_target_signal, or just
target_signal (making it a typedef for an anonymous enum)?

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [patch 1/9]#2 Rename `enum target_signal' to target_signal_t
  2010-08-30  8:14 ` Mark Kettenis
@ 2010-08-30  8:24   ` Jan Kratochvil
  2010-08-30 10:09     ` Eli Zaretskii
  2010-08-30 17:34     ` Michael Snyder
  0 siblings, 2 replies; 40+ messages in thread
From: Jan Kratochvil @ 2010-08-30  8:24 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: gdb-patches

On Mon, 30 Aug 2010 10:14:12 +0200, Mark Kettenis wrote:
> The _t suffix is actually reserved by POSIX, so using it is actually a
> bad idea.  Perhaps change it to gdb_target_signal, or just
> target_signal (making it a typedef for an anonymous enum)?

I see too many types in GDB and everywhere ending with _t (ptid_t for all).

I do not mind at all about the type name but before reposting the patchset
I would like agreement from one more global maintainer.


Thanks,
Jan

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [patch 1/9]#2 Rename `enum target_signal' to target_signal_t
  2010-08-30  8:24   ` Jan Kratochvil
@ 2010-08-30 10:09     ` Eli Zaretskii
  2010-08-30 11:11       ` Mark Kettenis
  2010-08-30 17:34     ` Michael Snyder
  1 sibling, 1 reply; 40+ messages in thread
From: Eli Zaretskii @ 2010-08-30 10:09 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: mark.kettenis, gdb-patches

> Date: Mon, 30 Aug 2010 10:24:07 +0200
> From: Jan Kratochvil <jan.kratochvil@redhat.com>
> Cc: gdb-patches@sourceware.org
> 
> On Mon, 30 Aug 2010 10:14:12 +0200, Mark Kettenis wrote:
> > The _t suffix is actually reserved by POSIX, so using it is actually a
> > bad idea.  Perhaps change it to gdb_target_signal, or just
> > target_signal (making it a typedef for an anonymous enum)?
> 
> I see too many types in GDB and everywhere ending with _t (ptid_t for all).

Right, and I didn't know it was reserved.  Mark, could you please
point to the Posix document (hopefully, freely accessible) which says
that?  TIA

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [patch 1/9]#2 Rename `enum target_signal' to target_signal_t
  2010-08-30 10:09     ` Eli Zaretskii
@ 2010-08-30 11:11       ` Mark Kettenis
  2010-08-30 14:08         ` Joel Brobecker
  2010-08-30 14:11         ` Eli Zaretskii
  0 siblings, 2 replies; 40+ messages in thread
From: Mark Kettenis @ 2010-08-30 11:11 UTC (permalink / raw)
  To: eliz; +Cc: jan.kratochvil, gdb-patches

> From: Eli Zaretskii <eliz@gnu.org>
> Date: Mon, 30 Aug 2010 06:08:50 -0400
> 
> > Date: Mon, 30 Aug 2010 10:24:07 +0200
> > From: Jan Kratochvil <jan.kratochvil@redhat.com>
> > Cc: gdb-patches@sourceware.org
> > 
> > On Mon, 30 Aug 2010 10:14:12 +0200, Mark Kettenis wrote:
> > > The _t suffix is actually reserved by POSIX, so using it is actually a
> > > bad idea.  Perhaps change it to gdb_target_signal, or just
> > > target_signal (making it a typedef for an anonymous enum)?
> > 
> > I see too many types in GDB and everywhere ending with _t (ptid_t for all).
> 
> Right, and I didn't know it was reserved.  Mark, could you please
> point to the Posix document (hopefully, freely accessible) which says
> that?  TIA

http://www.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_02.html

The _t suffix is listed on the last row of the first table on that page.

Cheers,

Mark

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [patch 1/9]#2 Rename `enum target_signal' to target_signal_t
  2010-08-30 11:11       ` Mark Kettenis
@ 2010-08-30 14:08         ` Joel Brobecker
  2010-08-31 18:28           ` Jan Kratochvil
  2010-08-30 14:11         ` Eli Zaretskii
  1 sibling, 1 reply; 40+ messages in thread
From: Joel Brobecker @ 2010-08-30 14:08 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: eliz, jan.kratochvil, gdb-patches

> http://www.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_02.html
> 
> The _t suffix is listed on the last row of the first table on that page.

It does not matter much to me if we decide to allow types named with
a _t suffix. But the gdb_ prefix also increases the chances of avoiding
name collisions with external declarations. Especially in this particular
case, I feel that target_signal is sufficiently generic that we might
want to be extra careful.

-- 
Joel

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [patch 1/9]#2 Rename `enum target_signal' to target_signal_t
  2010-08-30 11:11       ` Mark Kettenis
  2010-08-30 14:08         ` Joel Brobecker
@ 2010-08-30 14:11         ` Eli Zaretskii
  1 sibling, 0 replies; 40+ messages in thread
From: Eli Zaretskii @ 2010-08-30 14:11 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: jan.kratochvil, gdb-patches

> Date: Mon, 30 Aug 2010 13:11:00 +0200 (CEST)
> From: Mark Kettenis <mark.kettenis@xs4all.nl>
> CC: jan.kratochvil@redhat.com, gdb-patches@sourceware.org
> 
> http://www.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_02.html
> 
> The _t suffix is listed on the last row of the first table on that page.

Right.  A strange ruling, I think _t is used in lots of applications.
I also don't really understand the language of the ruling in its last
part:

  End in the string indicated as a reserved suffix in the table and do
  not use the reserved prefixes posix_, POSIX_, or _POSIX_, as long as
  the reserved suffix is in that part of the name considered significant
  by the implementation.

I guess we need to start removing those suffixes, but given the amount
of existing code that uses them, I'm not sure Jan's patches should be
blocked because of that.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [patch 1/9]#2 Rename `enum target_signal' to target_signal_t
  2010-08-30  8:24   ` Jan Kratochvil
  2010-08-30 10:09     ` Eli Zaretskii
@ 2010-08-30 17:34     ` Michael Snyder
  1 sibling, 0 replies; 40+ messages in thread
From: Michael Snyder @ 2010-08-30 17:34 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: Mark Kettenis, gdb-patches

Jan Kratochvil wrote:
> On Mon, 30 Aug 2010 10:14:12 +0200, Mark Kettenis wrote:
>> The _t suffix is actually reserved by POSIX, so using it is actually a
>> bad idea.  Perhaps change it to gdb_target_signal, or just
>> target_signal (making it a typedef for an anonymous enum)?
> 
> I see too many types in GDB and everywhere ending with _t (ptid_t for all).
> 
> I do not mind at all about the type name but before reposting the patchset
> I would like agreement from one more global maintainer.

ptid_t was an extension from pid_t, which is a posix typedef I think.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [patch 1/9]#2 Rename `enum target_signal' to target_signal_t
  2010-08-30 14:08         ` Joel Brobecker
@ 2010-08-31 18:28           ` Jan Kratochvil
  2010-08-31 18:45             ` Mark Kettenis
                               ` (2 more replies)
  0 siblings, 3 replies; 40+ messages in thread
From: Jan Kratochvil @ 2010-08-31 18:28 UTC (permalink / raw)
  To: Joel Brobecker, Eli Zaretskii; +Cc: Mark Kettenis, gdb-patches

On Mon, 30 Aug 2010 16:08:14 +0200, Joel Brobecker wrote:
> It does not matter much to me if we decide to allow types named with
> a _t suffix. But the gdb_ prefix also increases the chances of avoiding
> name collisions with external declarations.

On Mon, 30 Aug 2010 16:11:45 +0200, Eli Zaretskii wrote:
> A strange ruling, I think _t is used in lots of applications.

I would prefer gdb_target_signal_t or also gdb_target_signal.

Is one of those approved?


Now I probably won't extend target_signal by any new fields (as the logic can
be kept inside linux-nat.c) so this part remains only as a "code cleanup" to
better sanity check the types compatibility (by the struct wrapping).  There
have been caught several minor bugs already before and in this patchset.


Thanks,
Jan

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [patch 1/9]#2 Rename `enum target_signal' to target_signal_t
  2010-08-31 18:28           ` Jan Kratochvil
@ 2010-08-31 18:45             ` Mark Kettenis
  2010-09-01  2:03             ` Joel Brobecker
  2010-09-01 18:18             ` Joel Brobecker
  2 siblings, 0 replies; 40+ messages in thread
From: Mark Kettenis @ 2010-08-31 18:45 UTC (permalink / raw)
  To: jan.kratochvil; +Cc: brobecker, eliz, mark.kettenis, gdb-patches

> Date: Tue, 31 Aug 2010 20:28:29 +0200
> From: Jan Kratochvil <jan.kratochvil@redhat.com>
> 
> On Mon, 30 Aug 2010 16:08:14 +0200, Joel Brobecker wrote:
> > It does not matter much to me if we decide to allow types named with
> > a _t suffix. But the gdb_ prefix also increases the chances of avoiding
> > name collisions with external declarations.
> 
> On Mon, 30 Aug 2010 16:11:45 +0200, Eli Zaretskii wrote:
> > A strange ruling, I think _t is used in lots of applications.
> 
> I would prefer gdb_target_signal_t or also gdb_target_signal.
> 
> Is one of those approved?

If you're going to change it, I vote for gdb_target_signal.  

I won't block target_signal_t either, but I do hope people realize the
_t suffix should be avoided, or at least an app-specific prefix should
be used.

Cheers,

Mark

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [patch 1/9]#2 Rename `enum target_signal' to target_signal_t
  2010-08-31 18:28           ` Jan Kratochvil
  2010-08-31 18:45             ` Mark Kettenis
@ 2010-09-01  2:03             ` Joel Brobecker
  2010-09-01 18:18             ` Joel Brobecker
  2 siblings, 0 replies; 40+ messages in thread
From: Joel Brobecker @ 2010-09-01  2:03 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: Eli Zaretskii, Mark Kettenis, gdb-patches

> I would prefer gdb_target_signal_t or also gdb_target_signal.
> Is one of those approved?

FWIW: I also prefer gdb_target_signal - Let's avoid _t if POSIX doesn't
like it, and I don't think that the _t brings much anyways.

> Now I probably won't extend target_signal by any new fields (as the logic can
> be kept inside linux-nat.c) so this part remains only as a "code cleanup" to
> better sanity check the types compatibility (by the struct wrapping).  There
> have been caught several minor bugs already before and in this patchset.

I will try to have a look at the patch tomorrow, but I agree on
the principle.

-- 
Joel

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [patch 1/9]#2 Rename `enum target_signal' to target_signal_t
  2010-08-31 18:28           ` Jan Kratochvil
  2010-08-31 18:45             ` Mark Kettenis
  2010-09-01  2:03             ` Joel Brobecker
@ 2010-09-01 18:18             ` Joel Brobecker
  2010-09-01 18:30               ` Jan Kratochvil
  2 siblings, 1 reply; 40+ messages in thread
From: Joel Brobecker @ 2010-09-01 18:18 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: Eli Zaretskii, Mark Kettenis, gdb-patches

> I would prefer gdb_target_signal_t or also gdb_target_signal.
> 
> Is one of those approved?

I've just realize that this specific patch really only renames
the type, in addition to adding a typedef.

I'm just wondering why this is actually useful to you. I would have
thought that we could avoid this patch entirely, and then let the
next patch which introduces the gdb_target_signal as a struct just
update all uses of the enum type. Once the struct has been introduced,
we could do a rename if we feel that a better name of the enum can
be found - I think that doing the rename would produce a patch
that is smaller if done after introducing the struct wrapper first.

Just some thoughts...

-- 
Joel

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [patch 1/9]#2 Rename `enum target_signal' to target_signal_t
  2010-09-01 18:18             ` Joel Brobecker
@ 2010-09-01 18:30               ` Jan Kratochvil
  2010-09-01 18:38                 ` Pedro Alves
  2010-09-01 18:40                 ` Joel Brobecker
  0 siblings, 2 replies; 40+ messages in thread
From: Jan Kratochvil @ 2010-09-01 18:30 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: Eli Zaretskii, Mark Kettenis, gdb-patches

On Wed, 01 Sep 2010 20:18:30 +0200, Joel Brobecker wrote:
> > I would prefer gdb_target_signal_t or also gdb_target_signal.
> > 
> > Is one of those approved?
> 
> I've just realize that this specific patch really only renames
> the type, in addition to adding a typedef.
> 
> I'm just wondering why this is actually useful to you. I would have
> thought that we could avoid this patch entirely, and then let the
> next patch which introduces the gdb_target_signal as a struct just
> update all uses of the enum type. Once the struct has been introduced,
> we could do a rename if we feel that a better name of the enum can
> be found - I think that doing the rename would produce a patch
> that is smaller if done after introducing the struct wrapper first.

I found target_signal_t to be more convenient than `struct target_signal'.
Some coding styles never use the `struct' types and always use typedef for any
struct defined (more matching C++).  target_signal operations are mostly fully
encapsulated in the patch so it does not have to be clear to its user it is in
fact a dereferencable struct.

Another point I was tracking with these changes is to make the patching
easier=automatic.  I can do s/\benum target_signal\b/target_signal_t/g and be
done with it as strlen rhs is smaller than strlen of lhs.
`struct target_signal' is longer and thus causing line wrapping requiring many
adjustments of GNU coding style 78 columns compliance by hand.

(This reindentation affects also the typedef name `gdb_target_signal_t'
although it would not affect `gdb_target_signal'.  Still there would be less
reindentation cases than in the `struct gdb_target_signal' case.)

These were the reasons for the typedef but I do not mind and I can
monkey-patch whatever gets agreed upon and be done with this part which
accidentally became a code cleanup only patch.


Thanks,
Jan

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [patch 1/9]#2 Rename `enum target_signal' to target_signal_t
  2010-09-01 18:30               ` Jan Kratochvil
@ 2010-09-01 18:38                 ` Pedro Alves
  2010-09-01 18:45                   ` Jan Kratochvil
  2010-09-01 18:40                 ` Joel Brobecker
  1 sibling, 1 reply; 40+ messages in thread
From: Pedro Alves @ 2010-09-01 18:38 UTC (permalink / raw)
  To: gdb-patches; +Cc: Jan Kratochvil, Joel Brobecker, Eli Zaretskii, Mark Kettenis

On Wednesday 01 September 2010 19:29:43, Jan Kratochvil wrote:
> I found target_signal_t to be more convenient than `struct target_signal'.
> Some coding styles never use the `struct' types and always use typedef for any
> struct defined (more matching C++).  target_signal operations are mostly fully
> encapsulated in the patch so it does not have to be clear to its user it is in
> fact a dereferencable struct.
> 
> Another point I was tracking with these changes is to make the patching
> easier=automatic.  I can do s/\benum target_signal\b/target_signal_t/g and be
> done with it as strlen rhs is smaller than strlen of lhs.
> `struct target_signal' is longer and thus causing line wrapping requiring many
> adjustments of GNU coding style 78 columns compliance by hand.

Weren't you proposing to end up with something like
"typedef struct target_signal target_signal"?

Then you'd do "s/enum target_signal/target_signal/g" , which is
shorter.

> (This reindentation affects also the typedef name `gdb_target_signal_t'
> although it would not affect `gdb_target_signal'.  Still there would be less
> reindentation cases than in the `struct gdb_target_signal' case.)

Everything that's behind the debug API abstraction is currently
called target_... (mostly target_ops and its methods), which is
I think the reason `enum target_signal' is called what it is called.

But, if you guys want to rename the type, I won't stand in the way,
thought I'd suggest simply gdb_signal.  One of "gdb or "target" in
"gdb_target" appears redundant to me.

-- 
Pedro Alves

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [patch 1/9]#2 Rename `enum target_signal' to target_signal_t
  2010-09-01 18:30               ` Jan Kratochvil
  2010-09-01 18:38                 ` Pedro Alves
@ 2010-09-01 18:40                 ` Joel Brobecker
  2010-09-01 18:51                   ` Jan Kratochvil
  1 sibling, 1 reply; 40+ messages in thread
From: Joel Brobecker @ 2010-09-01 18:40 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: Eli Zaretskii, Mark Kettenis, gdb-patches

> These were the reasons for the typedef but I do not mind and I can
> monkey-patch whatever gets agreed upon and be done with this part which
> accidentally became a code cleanup only patch.

I'm not against the typedef at all :). I was just thinking that
perhaps we could leave the enum alone as one component of the struct
(be it typedef'ed).

-- 
Joel

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [patch 1/9]#2 Rename `enum target_signal' to target_signal_t
  2010-09-01 18:38                 ` Pedro Alves
@ 2010-09-01 18:45                   ` Jan Kratochvil
  0 siblings, 0 replies; 40+ messages in thread
From: Jan Kratochvil @ 2010-09-01 18:45 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches, Joel Brobecker, Eli Zaretskii, Mark Kettenis

On Wed, 01 Sep 2010 20:38:01 +0200, Pedro Alves wrote:
> Weren't you proposing to end up with something like
> "typedef struct target_signal target_signal"?
> 
> Then you'd do "s/enum target_signal/target_signal/g" , which is
> shorter.

I have never proposed "target_signal" to be a type as I find it a possible
parameter/variable name; although it is not in use now:
	grep -rP '(?<!enum )target_signal\b' .


> But, if you guys want to rename the type, I won't stand in the way,
> thought I'd suggest simply gdb_signal.  One of "gdb or "target" in
> "gdb_target" appears redundant to me.

Removing the misleading "target" word would be great, "gdb_target" even
suggests it is an in-GDB signal type, not a target-encoded signal type.


Thanks,
Jan

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [patch 1/9]#2 Rename `enum target_signal' to target_signal_t
  2010-09-01 18:40                 ` Joel Brobecker
@ 2010-09-01 18:51                   ` Jan Kratochvil
  2010-09-01 19:08                     ` Pedro Alves
                                       ` (2 more replies)
  0 siblings, 3 replies; 40+ messages in thread
From: Jan Kratochvil @ 2010-09-01 18:51 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: Eli Zaretskii, Mark Kettenis, gdb-patches

On Wed, 01 Sep 2010 20:39:52 +0200, Joel Brobecker wrote:
> > These were the reasons for the typedef but I do not mind and I can
> > monkey-patch whatever gets agreed upon and be done with this part which
> > accidentally became a code cleanup only patch.
> 
> I'm not against the typedef at all :). I was just thinking that
> perhaps we could leave the enum alone as one component of the struct
> (be it typedef'ed).

The patches of mine re-introduce (in [patch 3/9]#2) former
`enum target_signal' as `enum target_signal_number'.

Keeping the `enum target_signal' name would contradict (**) the sole remaining
meaning of the [patch 3/9]#2 patch (*) - making target_signal and
`int host_signal' type incompatible catching various bugs in the current code.

(*) After it stopped to be a pre-requisite for the [rfc 7/9]#2 patch.

(**) While it is easy to ensure no `enum target_signal' remains used/misplaced
     in the current code it would not get protected against all the 3rd party
     patches floating around out there reintroducing the same problem in the
     future.

`enum target_signal_number' is a new type and it is used only on very few
places where the user is fortunately careful enough not to misplace it with
`int host_signal'.  On other places `target_signal_t' is now a struct
naturally type-incompatible with `int host_signal'.


Thanks,
Jan

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [patch 1/9]#2 Rename `enum target_signal' to target_signal_t
  2010-09-01 18:51                   ` Jan Kratochvil
@ 2010-09-01 19:08                     ` Pedro Alves
  2010-09-01 19:28                       ` Jan Kratochvil
  2010-09-01 19:12                     ` Joel Brobecker
  2010-09-01 22:37                     ` Tom Tromey
  2 siblings, 1 reply; 40+ messages in thread
From: Pedro Alves @ 2010-09-01 19:08 UTC (permalink / raw)
  To: gdb-patches; +Cc: Jan Kratochvil, Joel Brobecker, Eli Zaretskii, Mark Kettenis

I think that if we do rename target_signal/gdb_signal, it becomes
easier for review to catch these bad conversions, and easier to 
not write then in the first place.

I wonder if switching on "-Wc++-compat" wouldn't catch these (at
least with recent enough gccs) and be more productive than
switching to a struct.  /me ducks.

-- 
Pedro Alves

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [patch 1/9]#2 Rename `enum target_signal' to target_signal_t
  2010-09-01 18:51                   ` Jan Kratochvil
  2010-09-01 19:08                     ` Pedro Alves
@ 2010-09-01 19:12                     ` Joel Brobecker
  2010-09-01 22:37                     ` Tom Tromey
  2 siblings, 0 replies; 40+ messages in thread
From: Joel Brobecker @ 2010-09-01 19:12 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: Eli Zaretskii, Mark Kettenis, gdb-patches

> Keeping the `enum target_signal' name would contradict (**) the sole
> remaining meaning of the [patch 3/9]#2 patch (*) - making
> target_signal and `int host_signal' type incompatible catching various
> bugs in the current code.

The approach you are suggesting looks fine to me. I thought it would
have been easier to makes changes in the other order, but whichever
you think is best works for me too.

-- 
Joel

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [patch 1/9]#2 Rename `enum target_signal' to target_signal_t
  2010-09-01 19:08                     ` Pedro Alves
@ 2010-09-01 19:28                       ` Jan Kratochvil
  2010-09-01 20:06                         ` Pedro Alves
  2010-09-01 21:32                         ` Joseph S. Myers
  0 siblings, 2 replies; 40+ messages in thread
From: Jan Kratochvil @ 2010-09-01 19:28 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches, Joel Brobecker, Eli Zaretskii, Mark Kettenis

On Wed, 01 Sep 2010 21:07:55 +0200, Pedro Alves wrote:
> I wonder if switching on "-Wc++-compat" wouldn't catch these (at
> least with recent enough gccs) and be more productive than
> switching to a struct.  /me ducks.

I wanted to argue with this great point myself but during my tests (gcc-4.5)
enum unfortunately IS compatible with int even in C++ (tried -Wall/-pedantic
etc.).  I haven't checked the C++ spec.

enum a is not compatible with enum b in C++; while it is compatible in C.
This does not help for the GDB case, though.


Thanks,
Jan

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [patch 1/9]#2 Rename `enum target_signal' to target_signal_t
  2010-09-01 20:06                         ` Pedro Alves
@ 2010-09-01 20:06                           ` Daniel Jacobowitz
  2010-09-01 20:10                             ` Pedro Alves
  2010-09-01 20:23                           ` Jan Kratochvil
  1 sibling, 1 reply; 40+ messages in thread
From: Daniel Jacobowitz @ 2010-09-01 20:06 UTC (permalink / raw)
  To: Pedro Alves
  Cc: Jan Kratochvil, gdb-patches, Joel Brobecker, Eli Zaretskii,
	Mark Kettenis

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.

-- 
Daniel Jacobowitz
CodeSourcery

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [patch 1/9]#2 Rename `enum target_signal' to target_signal_t
  2010-09-01 19:28                       ` Jan Kratochvil
@ 2010-09-01 20:06                         ` Pedro Alves
  2010-09-01 20:06                           ` Daniel Jacobowitz
  2010-09-01 20:23                           ` Jan Kratochvil
  2010-09-01 21:32                         ` Joseph S. Myers
  1 sibling, 2 replies; 40+ messages in thread
From: Pedro Alves @ 2010-09-01 20:06 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches, Joel Brobecker, Eli Zaretskii, Mark Kettenis

On Wednesday 01 September 2010 20:18:43, Jan Kratochvil wrote:
> On Wed, 01 Sep 2010 21:07:55 +0200, Pedro Alves wrote:
> > I wonder if switching on "-Wc++-compat" wouldn't catch these (at
> > least with recent enough gccs) and be more productive than
> > switching to a struct.  /me ducks.
> 
> I wanted to argue with this great point myself but during my tests (gcc-4.5)
> enum unfortunately IS compatible with int even in C++ (tried -Wall/-pedantic
> etc.).  I haven't checked the C++ spec.

I think "int signal = TARGET_SIGNAL_TRAP" would be valid C++, while
"enum gdb_signal signal = SIGTRAP" would not.  I thought the latter would
be the most common scenario to catch though.  Maybe not.

Anyway, personally, I'd just do a enum target_signal/enum gdb_signal
rename, and stay with that.

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
{
};

/* An array of all defined gdb signals.  */
const struct gdb_signal_1 gdb_signals[NUM_GDB_SIGNALS];

/* gdb code uses gdb_signal, not gdb_signal_1.  gdb_signal is a
   pointer.  */
typedef struct gdb_signal_1 * gdb_signal;

/* Define the constants.  */
#define TARGET_SIGNAL_0 (&gdb_signals[0])
#define TARGET_SIGNAL_TRAP (&gdb_signals[5])
#define TARGET_SIGNAL_FOO (&gdb_signals[FOO])
...


Then, you can do this:

 gdb_signal signal = TARGET_SIGNAL_TRAP;

and still do this:

 for (gdb_signal foo = TARGET_SIGNAL_0; sig < TARGET_SIGNAL_LAST; sig++)
    do_things(foo);

... all as before.  But these:

int sig = TARGET_SIGNAL_TRAP;
gdb_signal sig = SIGTRAP;

gdb_signal sig = TARGET_SIGNAL_TRAP;
if (sig < SIGTRAP)
 do_things ();

... give out a warnings, fatal with -Werror.

Getting at the signal integer is simply:

#define GDB_SIGNAL_NUMBER(gdb_sig) \
  (((gdb_sig) - TARGET_SIGNAL_0) / sizeof (gdb_sig))


All the other macros TARGET_SIGNAL_EQ|NE|GT|... disappear.

Here's a compilable example:

$ cat sig.c
#include <signal.h>

struct gdb_signal_1 {};

typedef struct gdb_signal_1 * gdb_signal;

struct gdb_signal_1 signals[10];

#define TARGET_SIGNAL_TRAP (&signals[5])

int main ()
{
	gdb_signal sig = TARGET_SIGNAL_TRAP;
	int sig2 = SIGTRAP;

	if (sig == sig2)
	  {
	  }

	sig = sig2;
	sig2 = sig;

	return 0;
}

$ gcc sig.c -o sig.o -c -Wall
sig.c: In function ‘main’:
sig.c:16: warning: comparison between pointer and integer
sig.c:20: warning: assignment makes pointer from integer without a cast
sig.c:21: warning: assignment makes integer from pointer without a cast

-- 
Pedro Alves

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [patch 1/9]#2 Rename `enum target_signal' to target_signal_t
  2010-09-01 20:06                           ` Daniel Jacobowitz
@ 2010-09-01 20:10                             ` Pedro Alves
  2010-09-02  9:46                               ` Pedro Alves
  0 siblings, 1 reply; 40+ messages in thread
From: Pedro Alves @ 2010-09-01 20:10 UTC (permalink / raw)
  To: gdb-patches
  Cc: Daniel Jacobowitz, Jan Kratochvil, Joel Brobecker, Eli Zaretskii,
	Mark Kettenis

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.  ;-)

-- 
Pedro Alves

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [patch 1/9]#2 Rename `enum target_signal' to target_signal_t
  2010-09-01 20:06                         ` Pedro Alves
  2010-09-01 20:06                           ` Daniel Jacobowitz
@ 2010-09-01 20:23                           ` Jan Kratochvil
  2010-09-01 20:30                             ` Mark Kettenis
  2010-09-01 20:47                             ` Pedro Alves
  1 sibling, 2 replies; 40+ messages in thread
From: Jan Kratochvil @ 2010-09-01 20:23 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches, Joel Brobecker, Eli Zaretskii, Mark Kettenis

On Wed, 01 Sep 2010 21:59:36 +0200, Pedro Alves wrote:
> Anyway, personally, I'd just do a enum target_signal/enum gdb_signal
> rename, and stay with that.

I do not mind about this point, someone can post it.


> 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
> {
> };

OK, just that's a new patch.  I coded this conversion to a struct just for the
purpose of the patch #7.  I would have never started to code that just for the
purpose of a code cleanup.

Now I thought it is reusable at least as a code cleanup when it is already in
IMO an acceptable state.

I also found as an advantage target_signal_t as a struct could get extended by
additional information later, as has been done now (although unnecessarily
- not completely wrongly) for siginfo, addressing the "gdb/signals.h" part:

                                             However, it is
   recognized that this set of signals has limitations (such as not
   distinguishing between various kinds of SIGSEGV, or not
   distinguishing hitting a breakpoint from finishing a single step).
   So in the future we may get around this either by adding additional
   signals for breakpoint, single-step, etc., or by adding signal
   codes; the latter seems more in the spirit of what BSD, System V,
   etc. are doing to address these issues.  */


Therefore going to drop this part.  I will repost those few fixes that have
been found by this patchset.  I will re-post the patch #7 as a linux-nat.c
only one (as GDB is not yet ready for a regression-free gdbserver-only
switch).


Thanks,
Jan

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [patch 1/9]#2 Rename `enum target_signal' to target_signal_t
  2010-09-01 20:23                           ` Jan Kratochvil
@ 2010-09-01 20:30                             ` Mark Kettenis
  2010-09-01 20:47                             ` Pedro Alves
  1 sibling, 0 replies; 40+ messages in thread
From: Mark Kettenis @ 2010-09-01 20:30 UTC (permalink / raw)
  To: jan.kratochvil; +Cc: pedro, gdb-patches, brobecker, eliz

> Date: Wed, 1 Sep 2010 22:10:25 +0200
> From: Jan Kratochvil <jan.kratochvil@redhat.com>

Ugh Jan, I'm sorry for derailing this diff.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [patch 1/9]#2 Rename `enum target_signal' to target_signal_t
  2010-09-01 20:23                           ` Jan Kratochvil
  2010-09-01 20:30                             ` Mark Kettenis
@ 2010-09-01 20:47                             ` Pedro Alves
  1 sibling, 0 replies; 40+ messages in thread
From: Pedro Alves @ 2010-09-01 20:47 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches, Joel Brobecker, Eli Zaretskii, Mark Kettenis

On Wednesday 01 September 2010 21:10:25, Jan Kratochvil wrote:
> On Wed, 01 Sep 2010 21:59:36 +0200, Pedro Alves wrote:
> > Anyway, personally, I'd just do a enum target_signal/enum gdb_signal
> > rename, and stay with that.
> 
> I do not mind about this point, someone can post it.

I thought you were already going to have to rename target_signal_t
anyway for your patch to be acceptible, as it has been raised that
target_signal_t  was not a good name, given that it ends in _t.
Sorry if I misunderstood that.

> Now I thought it is reusable at least as a code cleanup when it is already in
> IMO an acceptable state.

I personally didn't think things looked that cleaner afterwards, but I
do recognize the value in catching bugs at compile time, hence I'll
agree that that justifies code not looking as neat in some cases.  I
was just giving out a suggestion that I thought might be interesting.  I
am really sorry that you go through all this trouble of writing large
mechanical patches that may sometimes be dropped.  But I do believe that you
can save yourself effort sometimes by discussing these changes upfront,
or just post an experimental patch that doesn't fix everything all
uses at once.  That said, once again, I have not objected to your patch.

> I also found as an advantage target_signal_t as a struct could get extended by
> additional information later, as has been done now (although unnecessarily
> - not completely wrongly) for siginfo, addressing the "gdb/signals.h" part:
> 
>                                              However, it is
>    recognized that this set of signals has limitations (such as not
>    distinguishing between various kinds of SIGSEGV, or not
>    distinguishing hitting a breakpoint from finishing a single step).
>    So in the future we may get around this either by adding additional
>    signals for breakpoint, single-step, etc., or by adding signal
>    codes; the latter seems more in the spirit of what BSD, System V,
>    etc. are doing to address these issues.  */

I see no reason that we can't extend target_waitkind/target_waitstatus
instead if we need to.  There's no implying from the above that the
"signal codes" need to be the target_signal itself.  I think that may
be talking about siginfo->si_code even.

-- 
Pedro Alves

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [patch 1/9]#2 Rename `enum target_signal' to target_signal_t
  2010-09-01 19:28                       ` Jan Kratochvil
  2010-09-01 20:06                         ` Pedro Alves
@ 2010-09-01 21:32                         ` Joseph S. Myers
  1 sibling, 0 replies; 40+ messages in thread
From: Joseph S. Myers @ 2010-09-01 21:32 UTC (permalink / raw)
  To: Jan Kratochvil
  Cc: Pedro Alves, gdb-patches, Joel Brobecker, Eli Zaretskii, Mark Kettenis

On Wed, 1 Sep 2010, Jan Kratochvil wrote:

> enum a is not compatible with enum b in C++; while it is compatible in C.

No, enum a is not compatible with enum b in C.  They may both be 
compatible with int, or both be compatible with unsigned int, depending on 
which is chosen as the underlying type, but type compatibility is not 
transitive.  (enum constants, however, always have type int in C, and you 
can assign between integer and enum types without needing compatibility, 
so incompatibility doesn't help detect problem assignments.)

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [patch 1/9]#2 Rename `enum target_signal' to target_signal_t
  2010-09-01 18:51                   ` Jan Kratochvil
  2010-09-01 19:08                     ` Pedro Alves
  2010-09-01 19:12                     ` Joel Brobecker
@ 2010-09-01 22:37                     ` Tom Tromey
  2 siblings, 0 replies; 40+ messages in thread
From: Tom Tromey @ 2010-09-01 22:37 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: Joel Brobecker, Eli Zaretskii, Mark Kettenis, gdb-patches

>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:

I read through this thread today.

Jan> Keeping the `enum target_signal' name would contradict (**) the
Jan> sole remaining meaning of the [patch 3/9]#2 patch (*) - making
Jan> target_signal and `int host_signal' type incompatible catching
Jan> various bugs in the current code.

I think this is still worth doing.  This sort of compile-time check
catches real bugs cheaply.

I think your approach is the most reasonable overall of the ones that
have been proposed.  If I read the thread correctly, nobody actually
objected to the use of a struct that is passed by value.  So, I propose
moving forward with that.

I didn't follow the naming discussion as closely, and I don't really
have an opinion.  So here I suggest picking any name that was proposed,
that you like, and that was not objected to.

thanks,
Tom

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [patch 1/9]#2 Rename `enum target_signal' to target_signal_t
  2010-09-01 20:10                             ` Pedro Alves
@ 2010-09-02  9:46                               ` Pedro Alves
  2010-09-02 14:01                                 ` Jan Kratochvil
                                                   ` (3 more replies)
  0 siblings, 4 replies; 40+ messages in thread
From: Pedro Alves @ 2010-09-02  9:46 UTC (permalink / raw)
  To: gdb-patches
  Cc: Daniel Jacobowitz, Jan Kratochvil, Joel Brobecker, Eli Zaretskii,
	Mark Kettenis

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];
+}
+
 \f
 /* 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)
 }
 \f
 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")

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [patch 1/9]#2 Rename `enum target_signal' to target_signal_t
  2010-09-02  9:46                               ` Pedro Alves
@ 2010-09-02 14:01                                 ` Jan Kratochvil
  2010-09-02 15:36                                   ` Joel Brobecker
  2010-09-02 19:02                                   ` Pedro Alves
  2010-09-02 16:02                                 ` Joel Brobecker
                                                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 40+ messages in thread
From: Jan Kratochvil @ 2010-09-02 14:01 UTC (permalink / raw)
  To: Pedro Alves
  Cc: gdb-patches, Daniel Jacobowitz, Joel Brobecker, Eli Zaretskii,
	Mark Kettenis

On Thu, 02 Sep 2010 03:54:47 +0200, Pedro Alves wrote:
> 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;

This means there is abandoned the possibility to associate dynamic information
with a signal (such as to associate siginfo_t with it).  Target signal (SIG*)
without its siginfo_t is an incomplete information.  Therefore I was
automatically trying to fix this problem before.

Therefore if GDB middle-end (infrun.c) does not need the siginfo_t part ...
does it even need to know the signal number (int host_signal - SIG*) part?
	echo * mi/* tui/* gdbserver/*|tr ' ' '\n'|grep -v ChangeLog|xargs cat|perl -lne 'print $& while /\bTARGET_SIGNAL_\w+/g;'|sort|uniq -c|sort -nr|vi -
says GDB references only 30 TARGET_SIGNAL_* signals (out of the 150 existing
ones) so it does not need to really know the specific signal number.

Those 120 signals could be kept private only to remote.c and gdbserver(s) for
the purpose of compatibility of the gdbserver protocol.
(In fact all TARGET_SIGNAL_* should be kept private to the target as for
example the "Treating signal as SIGTRAP" hack in infrun.c should be target
specific and TARGET_SIGNAL_SIGTRAP should be called
TARGET_SIGNAL_BREAKPOINT_HIT etc.  But a full signals abstraction is a too
expensive/naive/unreal clean-up project for now.)

As a proof Linux `SIGSTKFLT' is now missing in the TARGET_SIGNAL_* list.
But no GDB middle-end code needs to know what is `SIGSTKFLT'.  This suggests
we can reduce the TARGET_SIGNAL_* set only to the 30 signals (for an easy
compatibility with current GDB code) and introduce a new target specific field
(similar to the abandoned siginfo field):

typedef struct
  {
    enum target_signal_number sig;  /* TARGET_SIGNAL_* 30 possibilities */
    int host_signal;  /* untranslated SIG* number for TARGET_SIGNAL_UNKNOWN.  */
  } target_signal;
 - Naming is kept compatible with current GDB naming.  The reality is:
   s/target_signal/gdb_signal/
   s/host_signal/target_signal/

Target could provide a number-name table for the `handle' command covering
just the specific 64 signals available at the Linux target (instead of the 150
ones from the TARGET_SIGNAL_* list).


I don't say I want to do it or that it should be done.  It has just explained
to me why target_signal_t does not need to contain the siginfo_t information.


> Anyway, here it is at least for the archives.

BTW I like this approach (when no dynamic information needs and as explained
above probably never will need to get associated).  I do not like the
`target_signal' name used for a type but that is a nitpick.


<bite>
Is ChangeLog required only for the final check-in?  Or are global maintainers
excluded from the ChangeLog submit requirement?  I have spent a whole day
writing it and the review did not get past the basic idea of my patchset.


Thanks,
Jan

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [patch 1/9]#2 Rename `enum target_signal' to target_signal_t
  2010-09-02 14:01                                 ` Jan Kratochvil
@ 2010-09-02 15:36                                   ` Joel Brobecker
  2010-09-02 19:02                                   ` Pedro Alves
  1 sibling, 0 replies; 40+ messages in thread
From: Joel Brobecker @ 2010-09-02 15:36 UTC (permalink / raw)
  To: Jan Kratochvil
  Cc: Pedro Alves, gdb-patches, Daniel Jacobowitz, Eli Zaretskii,
	Mark Kettenis

> Is ChangeLog required only for the final check-in?  Or are global maintainers
> excluded from the ChangeLog submit requirement?  I have spent a whole day
> writing it and the review did not get past the basic idea of my patchset.

This was a proof of concept, and I think it's acceptable in this case
to not send a ChangeLog.  I think we request the ChangeLog with official
submissions in order to have a chance to check it before it gets
committed.  But other than that, I rely more on the description of
the patch than on the ChangeLog itself to tell me what the patch is
about.

Sorry about the time you spent writing a ChangeLog :-(.

-- 
Joel

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [patch 1/9]#2 Rename `enum target_signal' to target_signal_t
  2010-09-02  9:46                               ` Pedro Alves
  2010-09-02 14:01                                 ` Jan Kratochvil
@ 2010-09-02 16:02                                 ` Joel Brobecker
  2010-09-02 17:04                                   ` Jan Kratochvil
  2010-09-06  0:29                                 ` Jan Kratochvil
  2010-09-08 23:42                                 ` Jan Kratochvil
  3 siblings, 1 reply; 40+ messages in thread
From: Joel Brobecker @ 2010-09-02 16:02 UTC (permalink / raw)
  To: Pedro Alves
  Cc: gdb-patches, Daniel Jacobowitz, Jan Kratochvil, Eli Zaretskii,
	Mark Kettenis

> 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 like this approach! It's really nice to have all the information
all in one place, for starters, and I wonder if we might want to do
the same for Eg the ABI enumeration. The number of times I got bitten
because I added one enumeration and forgot to update the associated
array (not that we do it often enough that it mike make sense, it
was just the example that came to mind).

And I don't think that this is incompatible with Jan's initial goal
of having a structure with signal and siginfo data. I admit I only
glanced at this part of the discussion, but if we ever change our
mind again, and determine that it is necessary to pass the siginfo_t
data together with the signal, couldn't we just create a new struct
that holds both, a la struct symtab_and_line?

-- 
Joel

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [patch 1/9]#2 Rename `enum target_signal' to target_signal_t
  2010-09-02 16:02                                 ` Joel Brobecker
@ 2010-09-02 17:04                                   ` Jan Kratochvil
  0 siblings, 0 replies; 40+ messages in thread
From: Jan Kratochvil @ 2010-09-02 17:04 UTC (permalink / raw)
  To: Joel Brobecker
  Cc: Pedro Alves, gdb-patches, Daniel Jacobowitz, Eli Zaretskii,
	Mark Kettenis

On Thu, 02 Sep 2010 17:39:23 +0200, Joel Brobecker wrote:
> > struct target_signal_o
> > {
> >   int number;
> >   const char *name;
> >   const char *string;
> > };
[...]
> And I don't think that this is incompatible with Jan's initial goal
> of having a structure with signal and siginfo data.

It is currently incompatible as to keep it <= / >= etc. comparable it must be
kept as a pointer-to-struct, not as a struct-as-value.  This approach expects
there is a finite set of predefined target_signal possibilities.

But then arbitrary set of dynamic content requires some allocate/free and/or
ref/unref.  Marking all reffing/unreffing in the code is according to my
experience unmanageable.


> but if we ever change our mind again,

one day in the future GDB may already have C++ and everything will be easy.


Thanks,
Jan

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [patch 1/9]#2 Rename `enum target_signal' to target_signal_t
  2010-09-02 14:01                                 ` Jan Kratochvil
  2010-09-02 15:36                                   ` Joel Brobecker
@ 2010-09-02 19:02                                   ` Pedro Alves
  2010-09-02 20:46                                     ` Jan Kratochvil
  1 sibling, 1 reply; 40+ messages in thread
From: Pedro Alves @ 2010-09-02 19:02 UTC (permalink / raw)
  To: Jan Kratochvil
  Cc: gdb-patches, Daniel Jacobowitz, Joel Brobecker, Eli Zaretskii,
	Mark Kettenis

On Thursday 02 September 2010 11:31:22, Jan Kratochvil wrote:
> On Thu, 02 Sep 2010 03:54:47 +0200, Pedro Alves wrote:
> > 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;
> 
> This means there is abandoned the possibility to associate dynamic information
> with a signal (such as to associate siginfo_t with it).  Target signal (SIG*)
> without its siginfo_t is an incomplete information.  Therefore I was
> automatically trying to fix this problem before.

I don't think it is a good idea to associate the siginfo with a signal
and think of it as a single entity.  For many cases, you don't need the
siginfo.  Carrying it around would be extra burden, especially for the remote
target.  For example, consider a signal set to "pass nostop".  GDB does not
need to read the whole siginfo to decide whether the signal should be passed
down straight to the inferior.  IMO, it is better to leave
a "target_signal" being a tag into which signal triggered, and keep the
siginfo a separate object, which may or not be available, even.

> and TARGET_SIGNAL_SIGTRAP should be called
> TARGET_SIGNAL_BREAKPOINT_HIT etc.  

I'm not sure that would be a good idea either.  That's not a
signal in the "unix sense".  A breakpoint hit is a higher
level event than a SIGTRAP.
If the target can determine itself that a breakpoint triggered, and
we want to carry that info to infrun, we can either add a new
waitkind for it (and associate any necessary info along) if it doesn't
make sense to associate the event with a signal, or have the core
ask the target if it can explain the TARGET_SIGNAL_TRAP (much like
watchpoints are handled).  In any case, for a new breakpoint
hit waitkind (TARGET_WAITKIND_BREAKPOINT_HIT or something.
Think of TARGET_WAITKIND_FORK|VFORK|EXEC), you
wouldn't need to give infrun the whole siginfo either.  At the
remote protocol level, you'd probably have the remote stub transfer
something like "T05 bkpt", rather than a stop reply with the
whole siginfo.  Consider the remote protocol and software
single-step targets.  You don't want to have to transfer
the whole siginfo blob back and forth for each single-step.
I don't think I mentioned it yet, but I'm presently working on a
stub for an OS where "signal info" size is _not_ a hard constant,
and can be 2048 bytes, if not more.

> But a full signals abstraction is a too
> expensive/naive/unreal clean-up project for now.)

We can consider TARGET_WAITKIND_STOPPED to be an event
associated with a boring old unix-like signal, and add
other high level waitkinds for other things.  Or reuse
the waitking and add more flags to it.  In any case,
even if we got rid of the gdb-signal <-> host-signals
mapping completely (which would be underirable as it would mean
we'd need to teach gdb about any random OS we want to use
remote debugging with), embedding more info _within_ a simple
signal id appears wrong to me.  And that's what the whole
series was about, and I think we're in agreement on that now.

> typedef struct
>   {
>     enum target_signal_number sig;  /* TARGET_SIGNAL_* 30 possibilities */
>     int host_signal;  /* untranslated SIG* number for TARGET_SIGNAL_UNKNOWN.  */
>   } target_signal;
>  - Naming is kept compatible with current GDB naming.  The reality is:
>    s/target_signal/gdb_signal/
>    s/host_signal/target_signal/
> 
> Target could provide a number-name table for the `handle' command covering
> just the specific 64 signals available at the Linux target (instead of the 150
> ones from the TARGET_SIGNAL_* list).

It could.  For remote targets, there would need to be a fallback for
a table of the current whole gdb signal numbers, and a way to select
the correct table for the remote os/target --- based on osabi, or fully
described in the target description.  If you get rid of the gdb generic
signals from infrun.c completely, some things might become
weird if you don't have such a mechanism, like "signal FOO" sending
one signal when native debugging, and another when remote debugging.

-- 
Pedro Alves

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [patch 1/9]#2 Rename `enum target_signal' to target_signal_t
  2010-09-02 19:02                                   ` Pedro Alves
@ 2010-09-02 20:46                                     ` Jan Kratochvil
  2010-09-07 18:59                                       ` Jan Kratochvil
  0 siblings, 1 reply; 40+ messages in thread
From: Jan Kratochvil @ 2010-09-02 20:46 UTC (permalink / raw)
  To: Pedro Alves
  Cc: gdb-patches, Daniel Jacobowitz, Joel Brobecker, Eli Zaretskii,
	Mark Kettenis

On Thu, 02 Sep 2010 19:27:52 +0200, Pedro Alves wrote:
> I don't think it is a good idea to associate the siginfo with a signal
> and think of it as a single entity.  For many cases, you don't need the
> siginfo.  Carrying it around would be extra burden, especially for the remote
> target.

For the remote part I was thinking about making it lazy, requesting it only
when retrieved for a different kind of processing than a target resume.

When we forget for a moment about GDB:  From the OS point of view int SIG* and
siginfo_t are associated.  Why should their GDB model differ?


> > and TARGET_SIGNAL_SIGTRAP should be called
> > TARGET_SIGNAL_BREAKPOINT_HIT etc.  
> 
> I'm not sure that would be a good idea either.  That's not a
> signal in the "unix sense".  A breakpoint hit is a higher
> level event than a SIGTRAP.

Yes, it is a higher level event.  Then why infrun.c has conditions like:

  /* Make sure we were stopped at a breakpoint.  */
  if (wait_status.kind != TARGET_WAITKIND_STOPPED
      || (wait_status.value.sig != TARGET_SIGNAL_TRAP
          && wait_status.value.sig != TARGET_SIGNAL_ILL
          && wait_status.value.sig != TARGET_SIGNAL_SEGV
          && wait_status.value.sig != TARGET_SIGNAL_EMT))

http://sourceware.org/ml/gdb-patches/2010-01/msg00619.html
+  if (ecs->ws.kind == TARGET_WAITKIND_STOPPED
+      && (ecs->ws.value.sig == TARGET_SIGNAL_ILL
+	  || ecs->ws.value.sig == TARGET_SIGNAL_SEGV
+	  || ecs->ws.value.sig == TARGET_SIGNAL_EMT)
+      && breakpoint_inserted_here_p (get_regcache_aspace (regcache),
+				     regcache_read_pc (regcache)))
+    {
+      if (debug_infrun)
+	fprintf_unfiltered (gdb_stdlog,
+			    "infrun: Treating signal as SIGTRAP\n");
+      ecs->ws.value.sig = TARGET_SIGNAL_TRAP;

here TARGET_SIGNAL_TRAP is considered to represent a breakpoint hit.

(I do not say it is a wrong patch, it IMO fits the current GDB architecture,
just the current GDB architecture is not right.  Also I do not say it is
a blocker for any bug, just that it is internally not right.)


> In any case, for a new breakpoint hit waitkind
> (TARGET_WAITKIND_BREAKPOINT_HIT or something.

OK, thanks, I wasn't so TARGET_WAITKIND_* aware.


> At the remote protocol level, you'd probably have the remote stub transfer
> something like "T05 bkpt", rather than a stop reply with the whole siginfo.
> Consider the remote protocol and software single-step targets.  You don't
> want to have to transfer the whole siginfo blob back and forth for each
> single-step.

I believe it is right to assume the signal should have the siginfo associated.
Then we can implement various accelerations for special cases when it does not
have to be transferred.

Currently if the GDB middle-end (infrun.c) would want to save a signal and
restore it later, it cannot.  So here is a testcase:
FAIL: FSF GDB linux-nat
FAIL: FSF GDB gdbserver
PASS: FSF GDB linux-nat with my siginfo_t patchset

I understand you can save and restore TARGET_OBJECT_SIGNAL_INFO along
tp->stop_signal in save_inferior_thread_state and
restore_inferior_thread_state.  But is it really the right way when we talk
about the proper design?  While it is IMO clearly wrong design it still may be
pragmatically the most practical way to go, though.


> In any case, even if we got rid of the gdb-signal <-> host-signals mapping
> completely (which would be underirable as it would mean we'd need to teach
> gdb about any random OS we want to use remote debugging with),

OK, good point...  Still the protocol should then transfer TARGET_WAITKIND_*
rather than TARGET_SIGNAL_*.


> embedding more info _within_ a simple
> signal id appears wrong to me.  And that's what the whole
> series was about, and I think we're in agreement on that now.

I may possibly agree it is enough for the current GDB as-is.
I would not agree for it on an academic discussion how it should be properly
designed.


> If you get rid of the gdb generic
> signals from infrun.c completely, some things might become
> weird if you don't have such a mechanism, like "signal FOO" sending
> one signal when native debugging, and another when remote debugging.

linux-nat should have its own signal list plus linux-nat should not exist.


Thanks,
Jan


gdb/testsuite/
2010-09-02  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.base/siginfo-infcall.exp: New file.
	* gdb.base/siginfo-infcall.c: New file.

--- /dev/null
+++ b/gdb/testsuite/gdb.base/siginfo-infcall.c
@@ -0,0 +1,68 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2010 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <signal.h>
+#include <assert.h>
+#include <string.h>
+
+#ifndef SA_SIGINFO
+# error "SA_SIGINFO is required for this test"
+#endif
+
+static int
+callme (void)
+{
+  return 42;
+}
+
+static volatile int pass, fail;
+
+static void
+handler (int sig, siginfo_t *siginfo, void *context)
+{
+  assert (sig == SIGUSR1);
+  assert (siginfo->si_signo == SIGUSR1);
+  if (siginfo->si_pid == getpid ())
+    pass = 1;
+  else
+    fail = 1;
+}
+
+int
+main (void)
+{
+  struct sigaction sa;
+  int i;
+
+  callme ();
+
+  memset (&sa, 0, sizeof (sa));
+  sa.sa_sigaction = handler;
+  sa.sa_flags = SA_SIGINFO;
+
+  i = sigemptyset (&sa.sa_mask);
+  assert (i == 0);
+
+  i = sigaction (SIGUSR1, &sa, NULL);
+  assert (i == 0);
+
+  i = raise (SIGUSR1);
+  assert (i == 0);
+
+  sleep (600);
+  return 0;
+}
--- /dev/null
+++ b/gdb/testsuite/gdb.base/siginfo-infcall.exp
@@ -0,0 +1,47 @@
+# Copyright 2010 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+if [target_info exists gdb,nosignals] {
+    verbose "Skipping siginfo-infcall.exp because of nosignals."
+    continue
+}
+
+set testfile siginfo-infcall
+set srcfile ${testfile}.c
+set executable ${testfile}
+if { [prepare_for_testing ${testfile}.exp $executable] } {
+    return -1
+}
+
+if ![runto_main] {
+    return -1
+}
+
+gdb_breakpoint [gdb_get_line_number "pass = 1;"]
+gdb_breakpoint [gdb_get_line_number "fail = 1;"]
+
+gdb_test "continue" "Program received signal SIGUSR1, .*" "continue to SIGUSR1"
+
+gdb_test "p callme ()" " = 42"
+
+set test "continue to the handler"
+gdb_test_multiple "continue" $test {
+    -re "pass = 1;\r\n$gdb_prompt $" {
+	pass $test
+    }
+    -re "fail = 1;\r\n$gdb_prompt $" {
+	fail $test
+    }
+}

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [patch 1/9]#2 Rename `enum target_signal' to target_signal_t
  2010-09-02  9:46                               ` Pedro Alves
  2010-09-02 14:01                                 ` Jan Kratochvil
  2010-09-02 16:02                                 ` Joel Brobecker
@ 2010-09-06  0:29                                 ` Jan Kratochvil
  2010-09-06 13:30                                   ` Pedro Alves
  2010-09-08 23:42                                 ` Jan Kratochvil
  3 siblings, 1 reply; 40+ messages in thread
From: Jan Kratochvil @ 2010-09-06  0:29 UTC (permalink / raw)
  To: Pedro Alves
  Cc: gdb-patches, Daniel Jacobowitz, Joel Brobecker, Eli Zaretskii,
	Mark Kettenis

On Thu, 02 Sep 2010 03:54:47 +0200, Pedro Alves wrote:
> typedef const struct target_signal_o * target_signal;

BTW if you omit this line of your patch it still compiles without a hiccup.

-         retsig = (int) oursig - (int) TARGET_SIGNAL_REALTIME_33 + 33;
+         retsig = oursig->number - TARGET_SIGNAL_REALTIME_33->number + 33;

(only on 32bit arches)


Anyway OK to check-in at least this noncontroversial part?
Checked in DWARF the enum definition stays the same.


Thanks,
Jan


gdb/
2010-09-04  Pedro Alves  <pedro@codesourcery.com>
	    Jan Kratochvil  <jan.kratochvil@redhat.com>

	* common/signals.c (ANY): Remove.
	(SET): No longer use ANY.

gdb/
2010-09-04  Pedro Alves  <pedro@codesourcery.com>

	* signals.def: Replace all ANY uses by SET with specific numbers.
	* signals.h (ANY): Remove.

--- a/gdb/common/signals.c
+++ b/gdb/common/signals.c
@@ -55,10 +55,8 @@ static const struct {
   const char *string;
   } signals [] =
 {
-#define SET(symbol, constant, name, string) ANY (symbol, name, string)
-#define ANY(symbol, name, string) { name, string },
+#define SET(symbol, constant, name, string) { name, string },
 #include "gdb/signals.def"
-#undef ANY
 #undef SET
 };
 
--- a/include/gdb/signals.def
+++ b/include/gdb/signals.def
@@ -105,96 +105,96 @@ SET (TARGET_SIGNAL_CANCEL, 76, "SIGCANCEL", "LWP internal signal")
    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")
--- a/include/gdb/signals.h
+++ b/include/gdb/signals.h
@@ -53,10 +53,7 @@ enum target_signal
   {
 #define SET(symbol, constant, name, string) \
     symbol = constant,
-#define ANY(symbol, name, string) \
-    symbol,
 #include "gdb/signals.def"
-#undef ANY
 #undef SET
   };
 

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [patch 1/9]#2 Rename `enum target_signal' to target_signal_t
  2010-09-06  0:29                                 ` Jan Kratochvil
@ 2010-09-06 13:30                                   ` Pedro Alves
  2010-09-06 14:52                                     ` Jan Kratochvil
  0 siblings, 1 reply; 40+ messages in thread
From: Pedro Alves @ 2010-09-06 13:30 UTC (permalink / raw)
  To: Jan Kratochvil
  Cc: gdb-patches, Daniel Jacobowitz, Joel Brobecker, Eli Zaretskii,
	Mark Kettenis

On Saturday 04 September 2010 21:48:12, Jan Kratochvil wrote:

> Anyway OK to check-in at least this noncontroversial part?
> Checked in DWARF the enum definition stays the same.

> gdb/
> 2010-09-04  Pedro Alves  <pedro@codesourcery.com>
> 	    Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> 	* common/signals.c (ANY): Remove.
> 	(SET): No longer use ANY.
> 
> gdb/
> 2010-09-04  Pedro Alves  <pedro@codesourcery.com>
> 
> 	* signals.def: Replace all ANY uses by SET with specific numbers.
> 	* signals.h (ANY): Remove.

Yes, please apply.  Thanks.

-- 
Pedro Alves

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [patch 1/9]#2 Rename `enum target_signal' to target_signal_t
  2010-09-06 13:30                                   ` Pedro Alves
@ 2010-09-06 14:52                                     ` Jan Kratochvil
  0 siblings, 0 replies; 40+ messages in thread
From: Jan Kratochvil @ 2010-09-06 14:52 UTC (permalink / raw)
  To: Pedro Alves
  Cc: gdb-patches, Daniel Jacobowitz, Joel Brobecker, Eli Zaretskii,
	Mark Kettenis

On Mon, 06 Sep 2010 12:59:18 +0200, Pedro Alves wrote:
> On Saturday 04 September 2010 21:48:12, Jan Kratochvil wrote:
> > gdb/
> > 2010-09-04  Pedro Alves  <pedro@codesourcery.com>
> > 	    Jan Kratochvil  <jan.kratochvil@redhat.com>
> > 
> > 	* common/signals.c (ANY): Remove.
> > 	(SET): No longer use ANY.
> > 
> > gdb/
> > 2010-09-04  Pedro Alves  <pedro@codesourcery.com>
> > 
> > 	* signals.def: Replace all ANY uses by SET with specific numbers.
> > 	* signals.h (ANY): Remove.
> 
> Yes, please apply.  Thanks.

Checked-in:
	http://sourceware.org/ml/gdb-cvs/2010-09/msg00043.html


Thanks,
Jan

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [patch 1/9]#2 Rename `enum target_signal' to target_signal_t
  2010-09-02 20:46                                     ` Jan Kratochvil
@ 2010-09-07 18:59                                       ` Jan Kratochvil
  0 siblings, 0 replies; 40+ messages in thread
From: Jan Kratochvil @ 2010-09-07 18:59 UTC (permalink / raw)
  To: Pedro Alves
  Cc: gdb-patches, Daniel Jacobowitz, Joel Brobecker, Eli Zaretskii,
	Mark Kettenis

On Thu, 02 Sep 2010 21:33:11 +0200, Jan Kratochvil wrote:
> On Thu, 02 Sep 2010 19:27:52 +0200, Pedro Alves wrote:
> > I don't think it is a good idea to associate the siginfo with a signal
> > and think of it as a single entity.  For many cases, you don't need the
> > siginfo.  Carrying it around would be extra burden, especially for the remote
> > target.
> 
> For the remote part I was thinking about making it lazy, requesting it only
> when retrieved for a different kind of processing than a target resume.

While trying to implement it I found it cannot be done (without C++).

If target_signal_t as returned by remote_wait (=to_wait implementation) is
lazy it can either be passed to remote_resume (=to_resume implementation) or
saved by infrun.c save_inferior_thread_state.  But remote.c can no longer
track where that target_signal_t has been copied without C++.

On Mon, 30 Aug 2010 09:09:55 +0200, Jan Kratochvil wrote:
# I tried to make target_signal a pointer with reference counter.  I have the
# unfinished patch here but I really do not find it viable.  All the assignments
# and passing by value to functions make it difficult to catch all the cases.
# With C++ GDB this patchset could be greatly simplified with fixed performance.
+
Even if the implementation would get finished I find target_signal_t a too
basic type to require explicit reference counting while having no compiler
checks of it.  It could become a large problem similar to all the effort to
manage the GObject reference counting in Gnome/C.

remote.c PASSes with FSF gdbserver even for gdb.base/siginfo-infcall.exp but
without C++ it has to have the back-and-forth siginfo_t transfer overhead.
[attached as a preview]

Therefore going to implement explicit carrying of associated siginfo_t
together with siginfo-less target_signal_t in the middle-end (infrun.c&co.).


Regards,
Jan


--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -176,6 +176,18 @@ static void print_packet (char *);
 
 static void compare_sections_command (char *, int);
 
+struct packet_config;
+
+static LONGEST remote_read_qxfer (struct target_ops *ops,
+				  const char *object_name, const char *annex,
+				  gdb_byte *readbuf, ULONGEST offset,
+				  LONGEST len, struct packet_config *packet);
+
+static LONGEST remote_write_qxfer (struct target_ops *ops,
+				   const char *object_name, const char *annex,
+				   const gdb_byte *writebuf, ULONGEST offset,
+				   LONGEST len, struct packet_config *packet);
+
 static void packet_command (char *, int);
 
 static int stub_unpack_int (char *buff, int fieldlength);
@@ -196,8 +208,6 @@ static int putpkt_binary (char *buf, int cnt);
 
 static void check_binary_download (CORE_ADDR addr);
 
-struct packet_config;
-
 static void show_packet_config_cmd (struct packet_config *config);
 
 static void update_packet_config (struct packet_config *config);
@@ -4446,6 +4456,32 @@ remote_vcont_resume (ptid_t ptid, int step, target_signal_t siggnal)
   if (remote_protocol_packets[PACKET_vCont].support == PACKET_DISABLE)
     return 0;
 
+  if (target_signal_siginfo_p (&siggnal))
+    {
+      ptid_t siggnal_ptid;
+      struct gdbarch *siggnal_ptid_gdbarch;
+      size_t len;
+      gdb_byte *siginfop;
+      LONGEST got;
+
+      if (ptid_equal (ptid, magic_null_ptid)
+          || ptid_equal (ptid, minus_one_ptid) || ptid_is_pid (ptid))
+	siggnal_ptid = inferior_ptid;
+      else
+	siggnal_ptid = ptid;
+
+      set_general_thread (siggnal_ptid);
+
+      siggnal_ptid_gdbarch = target_thread_architecture (siggnal_ptid);
+      len = target_signal_siginfo_len (siggnal_ptid_gdbarch);
+      siginfop = target_signal_siginfo_get (&siggnal, siggnal_ptid_gdbarch);
+
+      got = remote_write_qxfer (NULL /* unused */, "siginfo", NULL, siginfop,
+				0, len, &remote_protocol_packets
+					 [PACKET_qXfer_siginfo_read]);
+      /* FIXME: Real len.  */
+    }
+
   p = rs->buf;
   endp = rs->buf + get_remote_packet_size ();
 
@@ -4554,6 +4590,34 @@ remote_resume (struct target_ops *ops,
     {
       int siggnal_number = TARGET_SIGNAL_NUMBER (siggnal);
 
+      if (target_signal_siginfo_p (&siggnal))
+	{
+	  ptid_t siggnal_ptid;
+	  struct gdbarch *siggnal_ptid_gdbarch;
+	  size_t len;
+	  gdb_byte *siginfop;
+	  LONGEST got;
+
+	  if (ptid_equal (ptid, magic_null_ptid)
+	      || ptid_equal (ptid, minus_one_ptid) || ptid_is_pid (ptid))
+	    siggnal_ptid = inferior_ptid;
+	  else
+	    siggnal_ptid = ptid;
+
+	  set_general_thread (siggnal_ptid);
+
+	  siggnal_ptid_gdbarch = target_thread_architecture (siggnal_ptid);
+	  len = target_signal_siginfo_len (siggnal_ptid_gdbarch);
+	  siginfop = target_signal_siginfo_get (&siggnal,
+						siggnal_ptid_gdbarch);
+
+	  got = remote_write_qxfer (NULL /* unused */, "siginfo", NULL,
+				    siginfop, 0, len,
+				    &remote_protocol_packets
+				     [PACKET_qXfer_siginfo_read]);
+	  /* FIXME: Real len.  */
+	}
+
       buf[0] = step ? 'S' : 'C';
       buf[1] = tohex ((siggnal_number >> 4) & 0xf);
       buf[2] = tohex (siggnal_number & 0xf);
@@ -5575,6 +5639,37 @@ remote_wait (struct target_ops *ops,
   else
     event_ptid = remote_wait_as (ptid, status, options);
 
+  if (TARGET_WAITKIND_USES_SIG (status->kind))
+    {
+      ptid_t siggnal_ptid;
+      struct gdbarch *siggnal_ptid_gdbarch;
+      size_t len;
+      gdb_byte siginfo[MAX_SIGINFO_SIZE];
+      LONGEST got;
+
+      if (ptid_equal (event_ptid, magic_null_ptid)
+	  || ptid_equal (event_ptid, minus_one_ptid)
+	  || ptid_is_pid (event_ptid))
+	siggnal_ptid = inferior_ptid;
+      else
+	siggnal_ptid = event_ptid;
+
+      siggnal_ptid_gdbarch = target_thread_architecture (siggnal_ptid);
+      len = target_signal_siginfo_len (siggnal_ptid_gdbarch);
+
+      got = remote_read_qxfer (ops, "siginfo", NULL, siginfo, 0, len,
+			       &remote_protocol_packets
+				[PACKET_qXfer_siginfo_read]);
+      if (got >= 0)
+	{
+	  set_general_thread (siggnal_ptid);
+
+	  memset (&siginfo[got], 0, len - got);
+	  target_signal_siginfo_set (&status->value.sig, siggnal_ptid_gdbarch,
+				     siginfo);
+	}
+    }
+
   if (target_can_async_p ())
     {
       /* If there are are events left in the queue tell the event loop

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [patch 1/9]#2 Rename `enum target_signal' to target_signal_t
  2010-09-02  9:46                               ` Pedro Alves
                                                   ` (2 preceding siblings ...)
  2010-09-06  0:29                                 ` Jan Kratochvil
@ 2010-09-08 23:42                                 ` Jan Kratochvil
  3 siblings, 0 replies; 40+ messages in thread
From: Jan Kratochvil @ 2010-09-08 23:42 UTC (permalink / raw)
  To: Pedro Alves
  Cc: gdb-patches, Daniel Jacobowitz, Joel Brobecker, Eli Zaretskii,
	Mark Kettenis

[-- Attachment #1: Type: text/plain, Size: 1845 bytes --]

On Thu, 02 Sep 2010 03:54:47 +0200, Pedro Alves wrote:
> 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;

While trying to clean it up for a check-in I found it as a no-go.

The current GDB code assumes zeroed target_signal field is TARGET_SIGNAL_0.
Additionally literal `0' is also compatible with such target_signal type.

While sure one can try to find such places of implicit zeroed initializations
it may more destabilize the GDB codebase than what the code-neutral compile
time sanity checking goal should have reached.

5192	      resume (currently_stepping (ecs->event_thread),
5193		      ecs->event_thread->stop_signal);
->
#6  0x000000000069cc5e in resume (step=0, sig=0x0) at infrun.c:1743
(gdb) p sig
$9 = (gdb_target_signal_t) 0x0

The struct { } solution
	[patch 3/9]#2 Change target_signal_t to a struct
	http://sourceware.org/ml/gdb-patches/2010-08/msg00483.html
had (unintentionally?) TARGET_SIGNAL_0 equivalent to a zeroed memory block.

Another possibility would be to make it a `(type *) 0L', `(type *) 1L' etc.

But in general if TARGET_SIGNAL_EQ() etc. operators are not acceptable I find
mostly the compile-time sanity checks as not feasible for plain C.  Trying
further so hard to avoid all the C obstacles is becoming contraproductive.

This part has become a sanity-checking one only.  It is no longer
a pre-requisite for the (planned) siginfo fix.


Attaching the two patches (bare rename + the conversion) FYI.  They have
a regression at least on fork-child-threads.exp.  They are based on:
	Re: [patch 1/9]#2 Rename `enum target_signal' to target_signal_t
	http://sourceware.org/ml/gdb-patches/2010-09/msg00078.html
	From: Pedro Alves <pedro at codesourcery dot com>


Thanks,
Jan

[-- Attachment #2: sigrename.patch --]
[-- Type: text/plain, Size: 43932 bytes --]

--- a/gdb/aix-thread.c
+++ b/gdb/aix-thread.c
@@ -970,7 +970,7 @@ aix_thread_detach (struct target_ops *ops, char *args, int from_tty)
 
 static void
 aix_thread_resume (struct target_ops *ops,
-                   ptid_t ptid, int step, enum target_signal sig)
+                   ptid_t ptid, int step, gdb_target_signal_t sig)
 {
   struct thread_info *thread;
   pthdb_tid_t tid[2];
--- a/gdb/amd64-linux-tdep.c
+++ b/gdb/amd64-linux-tdep.c
@@ -1230,7 +1230,7 @@ amd64_linux_syscall_record (struct regcache *regcache)
 int
 amd64_linux_record_signal (struct gdbarch *gdbarch,
                            struct regcache *regcache,
-                           enum target_signal signal)
+                           gdb_target_signal_t signal)
 {
   ULONGEST rsp;
 
--- a/gdb/bsd-uthread.c
+++ b/gdb/bsd-uthread.c
@@ -397,7 +397,7 @@ bsd_uthread_wait (struct target_ops *ops,
 
 static void
 bsd_uthread_resume (struct target_ops *ops,
-		    ptid_t ptid, int step, enum target_signal sig)
+		    ptid_t ptid, int step, gdb_target_signal_t sig)
 {
   /* Pass the request to the layer beneath.  */
   struct target_ops *beneath = find_target_beneath (ops);
--- a/gdb/common/gdb_signals.h
+++ b/gdb/common/gdb_signals.h
@@ -28,29 +28,29 @@
    targ_signal SIGNO has an equivalent ``host'' representation.  */
 /* FIXME: cagney/1999-11-22: The name below was chosen in preference
    to the shorter target_signal_p() because it is far less ambigious.
-   In this context ``target_signal'' refers to GDB's internal
+   In this context ``gdb_target_signal_t'' 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 (gdb_target_signal_t signo);
 
-/* Convert between host signal numbers and enum target_signal's.
+/* Convert between host signal numbers and gdb_target_signal_t's.
    target_signal_to_host() returns 0 and prints a warning() on GDB's
    console if SIGNO has no equivalent host representation.  */
 /* FIXME: cagney/1999-11-22: Here ``host'' is used incorrectly, it is
    refering to the target operating system's signal numbering.
-   Similarly, ``enum target_signal'' is named incorrectly, ``enum
+   Similarly, ``gdb_target_signal_t'' 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 gdb_target_signal_t target_signal_from_host (int);
+extern int target_signal_to_host (gdb_target_signal_t);
 
 /* Return the string for a signal.  */
-extern const char *target_signal_to_string (enum target_signal);
+extern const char *target_signal_to_string (gdb_target_signal_t);
 
 /* 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 (gdb_target_signal_t);
 
 /* Given a name (SIGHUP, etc.), return its signal.  */
-enum target_signal target_signal_from_name (const char *);
+gdb_target_signal_t target_signal_from_name (const char *);
 
 #endif /* COMMON_GDB_SIGNALS_H */
--- a/gdb/common/signals.c
+++ b/gdb/common/signals.c
@@ -48,7 +48,8 @@ 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 gdb_target_signal_t.
+   */
 
 static const struct {
   const char *name;
@@ -63,7 +64,7 @@ static const struct {
 
 /* Return the string for a signal.  */
 const char *
-target_signal_to_string (enum target_signal sig)
+target_signal_to_string (gdb_target_signal_t sig)
 {
   if ((int) sig >= TARGET_SIGNAL_FIRST && (int) sig <= TARGET_SIGNAL_LAST)
     return signals[sig].string;
@@ -73,7 +74,7 @@ target_signal_to_string (enum target_signal sig)
 
 /* Return the name for a signal.  */
 const char *
-target_signal_to_name (enum target_signal sig)
+target_signal_to_name (gdb_target_signal_t sig)
 {
   if ((int) sig >= TARGET_SIGNAL_FIRST && (int) sig <= TARGET_SIGNAL_LAST
       && signals[sig].name != NULL)
@@ -85,10 +86,10 @@ target_signal_to_name (enum target_signal sig)
 }
 
 /* Given a name, return its signal.  */
-enum target_signal
+gdb_target_signal_t
 target_signal_from_name (const char *name)
 {
-  enum target_signal sig;
+  gdb_target_signal_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
@@ -98,7 +99,7 @@ target_signal_from_name (const char *name)
   /* 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))
+       sig = (gdb_target_signal_t) ((int) sig + 1))
     if (signals[sig].name != NULL
 	&& strcmp (name, signals[sig].name) == 0)
       return sig;
@@ -110,7 +111,7 @@ target_signal_from_name (const char *name)
    a file called native-utils.c or unixwaitstatus-utils.c or whatever.  */
 
 /* Convert host signal to our signals.  */
-enum target_signal
+gdb_target_signal_t
 target_signal_from_host (int hostsig)
 {
   /* A switch statement would make sense but would require special kludges
@@ -340,12 +341,12 @@ 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)
+	return (gdb_target_signal_t)
 	  (hostsig - 33 + (int) TARGET_SIGNAL_REALTIME_33);
       else if (hostsig == 32)
 	return TARGET_SIGNAL_REALTIME_32;
       else if (64 <= hostsig && hostsig <= 127)
-	return (enum target_signal)
+	return (gdb_target_signal_t)
 	  (hostsig - 64 + (int) TARGET_SIGNAL_REALTIME_64);
       else
 	error ("GDB bug: target.c (target_signal_from_host): unrecognized real-time signal");
@@ -355,13 +356,13 @@ target_signal_from_host (int hostsig)
   return TARGET_SIGNAL_UNKNOWN;
 }
 
-/* Convert a OURSIG (an enum target_signal) to the form used by the
+/* Convert a OURSIG (an gdb_target_signal_t) 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,
+do_target_signal_to_host (gdb_target_signal_t oursig,
 			  int *oursig_ok)
 {
   int retsig;
@@ -626,7 +627,7 @@ do_target_signal_to_host (enum target_signal oursig,
 }
 
 int
-target_signal_to_host_p (enum target_signal oursig)
+target_signal_to_host_p (gdb_target_signal_t oursig)
 {
   int oursig_ok;
   do_target_signal_to_host (oursig, &oursig_ok);
@@ -634,7 +635,7 @@ target_signal_to_host_p (enum target_signal oursig)
 }
 
 int
-target_signal_to_host (enum target_signal oursig)
+target_signal_to_host (gdb_target_signal_t oursig)
 {
   int oursig_ok;
   int targ_signo = do_target_signal_to_host (oursig, &oursig_ok);
@@ -660,11 +661,11 @@ target_signal_to_host (enum target_signal oursig)
    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
+gdb_target_signal_t
 target_signal_from_command (int num)
 {
   if (num >= 1 && num <= 15)
-    return (enum target_signal) num;
+    return (gdb_target_signal_t) num;
   error ("Only signals 1-15 are valid as numeric signals.\n\
 Use \"info signals\" for a list of symbolic signals.");
 }
@@ -679,12 +680,13 @@ _initialize_signals (void)
 }
 
 int
-default_target_signal_to_host (struct gdbarch *gdbarch, enum target_signal ts)
+default_target_signal_to_host (struct gdbarch *gdbarch,
+			       gdb_target_signal_t ts)
 {
   return target_signal_to_host (ts);
 }
 
-enum target_signal
+gdb_target_signal_t
 default_target_signal_from_host (struct gdbarch *gdbarch, int signo)
 {
   return target_signal_from_host (signo);
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -432,9 +432,9 @@ core_open (char *filename, int from_tty)
     {
       /* 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
+	 value is called ``gdb_target_signal_t'' and this function got the
 	 name ..._from_host(). */
-      enum target_signal sig = (core_gdbarch != NULL
+      gdb_target_signal_t sig = (core_gdbarch != NULL
 		       ? gdbarch_target_signal_from_host (core_gdbarch, siggy)
 		       : target_signal_from_host (siggy));
 
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -89,9 +89,9 @@ extern boolean_t exc_server (mach_msg_header_t *in, mach_msg_header_t *out);
 static void darwin_stop (ptid_t);
 
 static void darwin_resume_to (struct target_ops *ops, ptid_t ptid, int step,
-                              enum target_signal signal);
+                              gdb_target_signal_t signal);
 static void darwin_resume (ptid_t ptid, int step,
-			   enum target_signal signal);
+			   gdb_target_signal_t signal);
 
 static ptid_t darwin_wait_to (struct target_ops *ops, ptid_t ptid,
                               struct target_waitstatus *status, int options);
@@ -767,7 +767,7 @@ darwin_suspend_inferior_threads (struct inferior *inf)
 }
 
 static void
-darwin_resume (ptid_t ptid, int step, enum target_signal signal)
+darwin_resume (ptid_t ptid, int step, gdb_target_signal_t signal)
 {
   struct target_waitstatus status;
   int pid;
@@ -833,7 +833,7 @@ darwin_resume (ptid_t ptid, int step, enum target_signal signal)
 
 static void
 darwin_resume_to (struct target_ops *ops, ptid_t ptid, int step,
-                  enum target_signal signal)
+                  gdb_target_signal_t signal)
 {
   return darwin_resume (ptid, step, signal);
 }
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -64,7 +64,7 @@
 
 #include "gdb_wchar.h"
 
-/* For ``enum target_signal''.  */
+/* For ``gdb_target_signal_t''.  */
 #include "gdb/signals.h"
 
 /* Just in case they're not defined in stdio.h.  */
--- a/gdb/fbsd-nat.c
+++ b/gdb/fbsd-nat.c
@@ -150,7 +150,7 @@ find_signalled_thread (struct thread_info *info, void *data)
   return 0;
 }
 
-static enum target_signal
+static gdb_target_signal_t
 find_stop_signal (void)
 {
   struct thread_info *info =
--- a/gdb/fork-child.c
+++ b/gdb/fork-child.c
@@ -448,7 +448,7 @@ startup_inferior (int ntraps)
 
   while (1)
     {
-      enum target_signal resume_signal = TARGET_SIGNAL_0;
+      gdb_target_signal_t resume_signal = TARGET_SIGNAL_0;
       ptid_t event_ptid;
 
       struct target_waitstatus ws;
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -3507,7 +3507,7 @@ gdbarch_process_record_signal_p (struct gdbarch *gdbarch)
 }
 
 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, gdb_target_signal_t signal)
 {
   gdb_assert (gdbarch != NULL);
   gdb_assert (gdbarch->process_record_signal != NULL);
@@ -3523,7 +3523,7 @@ set_gdbarch_process_record_signal (struct gdbarch *gdbarch,
   gdbarch->process_record_signal = process_record_signal;
 }
 
-enum target_signal
+gdb_target_signal_t
 gdbarch_target_signal_from_host (struct gdbarch *gdbarch, int signo)
 {
   gdb_assert (gdbarch != NULL);
@@ -3541,7 +3541,7 @@ set_gdbarch_target_signal_from_host (struct gdbarch *gdbarch,
 }
 
 int
-gdbarch_target_signal_to_host (struct gdbarch *gdbarch, enum target_signal ts)
+gdbarch_target_signal_to_host (struct gdbarch *gdbarch, gdb_target_signal_t ts)
 {
   gdb_assert (gdbarch != NULL);
   gdb_assert (gdbarch->target_signal_to_host != NULL);
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -880,22 +880,22 @@ extern void set_gdbarch_process_record (struct gdbarch *gdbarch, gdbarch_process
 
 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, gdb_target_signal_t signal);
+extern int gdbarch_process_record_signal (struct gdbarch *gdbarch, struct regcache *regcache, gdb_target_signal_t 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 gdb_target_signal_t (gdbarch_target_signal_from_host_ftype) (struct gdbarch *gdbarch, int signo);
+extern gdb_target_signal_t 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, gdb_target_signal_t ts);
+extern int gdbarch_target_signal_to_host (struct gdbarch *gdbarch, gdb_target_signal_t 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.
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -748,14 +748,14 @@ M:int:process_record:struct regcache *regcache, CORE_ADDR addr:regcache, addr
 
 # 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, gdb_target_signal_t 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:gdb_target_signal_t: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:gdb_target_signal_t ts:ts::default_target_signal_to_host::0
 
 # Extra signal info inspection.
 #
--- a/gdb/gdbserver/target.h
+++ b/gdb/gdbserver/target.h
@@ -54,7 +54,7 @@ struct thread_resume
      thread.  If stopping a thread, and this is 0, the target should
      stop the thread however it best decides to (e.g., SIGSTOP on
      linux; SuspendThread on win32).  This is a host signal value (not
-     enum target_signal).  */
+     gdb_target_signal_t).  */
   int sig;
 };
 
@@ -98,7 +98,7 @@ struct target_waitstatus
     union
       {
 	int integer;
-	enum target_signal sig;
+	gdb_target_signal_t sig;
 	ptid_t related_pid;
 	char *execd_pathname;
       }
--- a/gdb/gdbserver/win32-low.c
+++ b/gdb/gdbserver/win32-low.c
@@ -72,7 +72,7 @@ static int attaching = 0;
 static HANDLE current_process_handle = NULL;
 static DWORD current_process_id = 0;
 static DWORD main_thread_id = 0;
-static enum target_signal last_sig = TARGET_SIGNAL_0;
+static gdb_target_signal_t last_sig = TARGET_SIGNAL_0;
 
 /* The current debug event from WaitForDebugEvent.  */
 static DEBUG_EVENT current_event;
@@ -802,7 +802,7 @@ static void
 win32_resume (struct thread_resume *resume_info, size_t n)
 {
   DWORD tid;
-  enum target_signal sig;
+  gdb_target_signal_t sig;
   int step;
   win32_thread_info *th;
   DWORD continue_status = DBG_CONTINUE;
--- a/gdb/gdbthread.h
+++ b/gdb/gdbthread.h
@@ -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;
+  gdb_target_signal_t stop_signal;
 
   /* Chain containing status of breakpoint(s) the thread stopped
      at.  */
--- a/gdb/gnu-nat.c
+++ b/gdb/gnu-nat.c
@@ -107,7 +107,7 @@ void inf_resume (struct inf *inf);
 void inf_set_step_thread (struct inf *inf, struct proc *proc);
 void inf_detach (struct inf *inf);
 void inf_attach (struct inf *inf, int pid);
-void inf_signal (struct inf *inf, enum target_signal sig);
+void inf_signal (struct inf *inf, gdb_target_signal_t sig);
 void inf_continue (struct inf *inf);
 
 #define inf_debug(_inf, msg, args...) \
@@ -1318,7 +1318,7 @@ inf_restore_exc_ports (struct inf *inf)
    signal 0, will continue it.  INF is assumed to be in a paused state, and
    the resume_sc's of INF's threads may be affected.  */
 void
-inf_signal (struct inf *inf, enum target_signal sig)
+inf_signal (struct inf *inf, gdb_target_signal_t sig)
 {
   error_t err = 0;
   int host_sig = target_signal_to_host (sig);
@@ -1965,7 +1965,7 @@ port_msgs_queued (mach_port_t port)
  */
 static void
 gnu_resume (struct target_ops *ops,
-	    ptid_t ptid, int step, enum target_signal sig)
+	    ptid_t ptid, int step, gdb_target_signal_t sig)
 {
   struct proc *step_thread = 0;
   int resume_all;
--- a/gdb/go32-nat.c
+++ b/gdb/go32-nat.c
@@ -238,7 +238,7 @@ static void go32_attach (struct target_ops *ops, char *args, int from_tty);
 static void go32_detach (struct target_ops *ops, char *args, int from_tty);
 static void go32_resume (struct target_ops *ops,
 			 ptid_t ptid, int step,
-			 enum target_signal siggnal);
+			 gdb_target_signal_t siggnal);
 static void go32_fetch_registers (struct target_ops *ops,
 				  struct regcache *, int regno);
 static void store_register (const struct regcache *, int regno);
@@ -309,7 +309,7 @@ regno_mapping[] =
 static struct
   {
     int go32_sig;
-    enum target_signal gdb_sig;
+    gdb_target_signal_t gdb_sig;
   }
 sig_map[] =
 {
@@ -343,7 +343,7 @@ sig_map[] =
 };
 
 static struct {
-  enum target_signal gdb_sig;
+  gdb_target_signal_t gdb_sig;
   int djgpp_excepno;
 } excepn_map[] = {
   {TARGET_SIGNAL_0, -1},
@@ -391,7 +391,7 @@ static int resume_signal = -1;
 
 static void
 go32_resume (struct target_ops *ops,
-	     ptid_t ptid, int step, enum target_signal siggnal)
+	     ptid_t ptid, int step, gdb_target_signal_t siggnal)
 {
   int i;
 
--- a/gdb/hpux-thread.c
+++ b/gdb/hpux-thread.c
@@ -169,7 +169,7 @@ hpux_thread_detach (struct target_ops *ops, char *args, int from_tty)
 
 static void
 hpux_thread_resume (struct target_ops *ops,
-		    ptid_t ptid, int step, enum target_signal signo)
+		    ptid_t ptid, int step, gdb_target_signal_t signo)
 {
   struct cleanup *old_chain;
 
--- a/gdb/i386-linux-nat.c
+++ b/gdb/i386-linux-nat.c
@@ -829,7 +829,7 @@ static const unsigned char linux_syscall[] = { 0xcd, 0x80 };
 
 static void
 i386_linux_resume (struct target_ops *ops,
-		   ptid_t ptid, int step, enum target_signal signal)
+		   ptid_t ptid, int step, gdb_target_signal_t signal)
 {
   int pid = PIDGET (ptid);
 
--- a/gdb/i386-linux-tdep.c
+++ b/gdb/i386-linux-tdep.c
@@ -463,7 +463,7 @@ i386_linux_intx80_sysenter_record (struct regcache *regcache)
 int
 i386_linux_record_signal (struct gdbarch *gdbarch,
                           struct regcache *regcache,
-                          enum target_signal signal)
+                          gdb_target_signal_t signal)
 {
   ULONGEST esp;
 
--- a/gdb/i386fbsd-nat.c
+++ b/gdb/i386fbsd-nat.c
@@ -37,7 +37,7 @@
 
 static void
 i386fbsd_resume (struct target_ops *ops,
-		 ptid_t ptid, int step, enum target_signal signal)
+		 ptid_t ptid, int step, gdb_target_signal_t signal)
 {
   pid_t pid = ptid_get_pid (ptid);
   int request = PT_STEP;
--- a/gdb/inf-ptrace.c
+++ b/gdb/inf-ptrace.c
@@ -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, gdb_target_signal_t signal)
 {
   pid_t pid = ptid_get_pid (ptid);
   int request;
--- a/gdb/inf-ttrace.c
+++ b/gdb/inf-ttrace.c
@@ -867,7 +867,7 @@ inf_ttrace_resume_callback (struct thread_info *info, void *arg)
 
 static void
 inf_ttrace_resume (struct target_ops *ops,
-		   ptid_t ptid, int step, enum target_signal signal)
+		   ptid_t ptid, int step, gdb_target_signal_t signal)
 {
   int resume_all;
   ttreq_t request = step ? TT_LWP_SINGLE : TT_LWP_CONTINUE;
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -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;
+  gdb_target_signal_t oursig;
   int async_exec = 0;
 
   dont_repeat ();		/* Too dangerous.  */
--- a/gdb/inferior.h
+++ b/gdb/inferior.h
@@ -35,7 +35,7 @@ struct terminal_info;
 /* For bpstat.  */
 #include "breakpoint.h"
 
-/* For enum target_signal.  */
+/* For gdb_target_signal_t.  */
 #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, gdb_target_signal_t, 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, gdb_target_signal_t);
 
 /* From misc files */
 
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -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 (gdb_target_signal_t);
 
 static void sig_print_header (void);
 
@@ -85,11 +85,11 @@ static int prepare_to_proceed (int);
 
 static void print_exited_reason (int exitstatus);
 
-static void print_signal_exited_reason (enum target_signal siggnal);
+static void print_signal_exited_reason (gdb_target_signal_t siggnal);
 
 static void print_no_history_reason (void);
 
-static void print_signal_received_reason (enum target_signal siggnal);
+static void print_signal_received_reason (gdb_target_signal_t siggnal);
 
 static void print_end_stepping_range_reason (void);
 
@@ -1307,7 +1307,7 @@ write_memory_ptid (ptid_t ptid, CORE_ADDR memaddr, const gdb_byte *myaddr, int l
 }
 
 static void
-displaced_step_fixup (ptid_t event_ptid, enum target_signal signal)
+displaced_step_fixup (ptid_t event_ptid, gdb_target_signal_t signal)
 {
   struct cleanup *old_cleanups;
   struct displaced_step_inferior_state *displaced
@@ -1548,7 +1548,7 @@ maybe_software_singlestep (struct gdbarch *gdbarch, CORE_ADDR pc)
    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, gdb_target_signal_t sig)
 {
   int should_resume = 1;
   struct cleanup *old_cleanups = make_cleanup (resume_cleanups, 0);
@@ -1905,7 +1905,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, gdb_target_signal_t siggnal, int step)
 {
   struct regcache *regcache;
   struct gdbarch *gdbarch;
@@ -3605,7 +3605,7 @@ targets should add new threads to the thread list themselves in non-stop mode.")
 
 	     if (new_singlestep_pc != singlestep_pc)
 	       {
-		 enum target_signal stop_signal;
+		 gdb_target_signal_t stop_signal;
 
 		 if (debug_infrun)
 		   fprintf_unfiltered (gdb_stdlog, "infrun: unexpected thread,"
@@ -5235,7 +5235,7 @@ print_end_stepping_range_reason (void)
 /* The inferior was terminated by a signal, print why it stopped.  */
 
 static void
-print_signal_exited_reason (enum target_signal siggnal)
+print_signal_exited_reason (gdb_target_signal_t siggnal)
 {
   annotate_signalled ();
   if (ui_out_is_mi_like_p (uiout))
@@ -5285,7 +5285,7 @@ print_exited_reason (int exitstatus)
    tells us to print about it. */
 
 static void
-print_signal_received_reason (enum target_signal siggnal)
+print_signal_received_reason (gdb_target_signal_t siggnal)
 {
   annotate_signal ();
 
@@ -5646,7 +5646,7 @@ Signal        Stop\tPrint\tPass to program\tDescription\n"));
 }
 
 static void
-sig_print_info (enum target_signal oursig)
+sig_print_info (gdb_target_signal_t oursig)
 {
   const char *name = target_signal_to_name (oursig);
   int name_padding = 13 - strlen (name);
@@ -5670,7 +5670,7 @@ handle_command (char *args, int from_tty)
   char **argv;
   int digits, wordlen;
   int sigfirst, signum, siglast;
-  enum target_signal oursig;
+  gdb_target_signal_t oursig;
   int allsigs;
   int nsigs;
   unsigned char *sigs;
@@ -5790,14 +5790,15 @@ handle_command (char *args, int from_tty)
 
       for (signum = sigfirst; signum >= 0 && signum <= siglast; signum++)
 	{
-	  switch ((enum target_signal) signum)
+	  switch ((gdb_target_signal_t) signum)
 	    {
 	    case TARGET_SIGNAL_TRAP:
 	    case 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 ((gdb_target_signal_t) signum)))
 		    {
 		      sigs[signum] = 1;
 		    }
@@ -5865,7 +5866,7 @@ xdb_handle_command (char *args, int from_tty)
       if (argBuf)
 	{
 	  int validFlag = 1;
-	  enum target_signal oursig;
+	  gdb_target_signal_t oursig;
 
 	  oursig = target_signal_from_name (argv[0]);
 	  memset (argBuf, 0, bufLen);
@@ -5916,7 +5917,7 @@ xdb_handle_command (char *args, int from_tty)
 static void
 signals_info (char *signum_exp, int from_tty)
 {
-  enum target_signal oursig;
+  gdb_target_signal_t oursig;
 
   sig_print_header ();
 
@@ -5938,7 +5939,7 @@ signals_info (char *signum_exp, int from_tty)
   /* 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))
+       oursig = (gdb_target_signal_t) ((int) oursig + 1))
     {
       QUIT;
 
@@ -6034,7 +6035,7 @@ siginfo_make_value (struct gdbarch *gdbarch, struct internalvar *var)
 
 struct inferior_thread_state
 {
-  enum target_signal stop_signal;
+  gdb_target_signal_t stop_signal;
   CORE_ADDR stop_pc;
   struct regcache *registers;
 };
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -1581,7 +1581,7 @@ linux_nat_attach (struct target_ops *ops, char *args, int from_tty)
 	}
       else if (WIFSIGNALED (status))
 	{
-	  enum target_signal signo;
+	  gdb_target_signal_t signo;
 
 	  target_terminal_ours ();
 	  target_mourn_inferior ();
@@ -1617,7 +1617,7 @@ linux_nat_attach (struct target_ops *ops, char *args, int from_tty)
 static int
 get_pending_status (struct lwp_info *lp, int *status)
 {
-  enum target_signal signo = TARGET_SIGNAL_0;
+  gdb_target_signal_t 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, void *data)
 
 static void
 linux_nat_resume (struct target_ops *ops,
-		  ptid_t ptid, int step, enum target_signal signo)
+		  ptid_t ptid, int step, gdb_target_signal_t signo)
 {
   sigset_t prev_mask;
   struct lwp_info *lp;
@@ -1908,7 +1908,7 @@ linux_nat_resume (struct target_ops *ops,
 
   if (lp->status && WIFSTOPPED (lp->status))
     {
-      enum target_signal saved_signo;
+      gdb_target_signal_t saved_signo;
       struct inferior *inf;
 
       inf = find_inferior_pid (ptid_get_pid (lp->ptid));
@@ -2268,7 +2268,7 @@ linux_handle_extended_wait (struct lwp_info *lp, int status,
 	     catchpoints.  */
 	  if (!stopping)
 	    {
-	      enum target_signal signo;
+	      gdb_target_signal_t signo;
 
 	      new_lp->stopped = 0;
 	      new_lp->resumed = 1;
@@ -3569,7 +3569,7 @@ retry:
 
   if (WIFSTOPPED (status))
     {
-      enum target_signal signo = target_signal_from_host (WSTOPSIG (status));
+      gdb_target_signal_t signo = target_signal_from_host (WSTOPSIG (status));
       struct inferior *inf;
 
       inf = find_inferior_pid (ptid_get_pid (lp->ptid));
@@ -4169,7 +4169,7 @@ find_signalled_thread (struct thread_info *info, void *data)
   return 0;
 }
 
-static enum target_signal
+static gdb_target_signal_t
 find_stop_signal (void)
 {
   struct thread_info *info =
@@ -4187,7 +4187,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)
+			       gdb_target_signal_t stop_signal)
 {
   unsigned long lwp = ptid_get_lwp (ptid);
   struct gdbarch *gdbarch = target_gdbarch;
@@ -4280,7 +4280,7 @@ struct linux_nat_corefile_thread_data
   char *note_data;
   int *note_size;
   int num_notes;
-  enum target_signal stop_signal;
+  gdb_target_signal_t stop_signal;
 };
 
 /* Called by gdbthread.c once per thread.  Records the thread's
--- a/gdb/linux-thread-db.c
+++ b/gdb/linux-thread-db.c
@@ -1650,7 +1650,7 @@ thread_db_get_ada_task_ptid (long lwp, long thread)
 
 static void
 thread_db_resume (struct target_ops *ops,
-		  ptid_t ptid, int step, enum target_signal signo)
+		  ptid_t ptid, int step, gdb_target_signal_t signo)
 {
   struct target_ops *beneath = find_target_beneath (ops);
   struct thread_db_info *info;
--- a/gdb/monitor.c
+++ b/gdb/monitor.c
@@ -928,7 +928,7 @@ monitor_supply_register (struct regcache *regcache, int regno, char *valstr)
 
 static void
 monitor_resume (struct target_ops *ops,
-		ptid_t ptid, int step, enum target_signal sig)
+		ptid_t ptid, int step, gdb_target_signal_t sig)
 {
   /* Some monitors require a different command when starting a program */
   monitor_debug ("MON resume\n");
--- a/gdb/nto-procfs.c
+++ b/gdb/nto-procfs.c
@@ -952,7 +952,7 @@ procfs_remove_hw_breakpoint (struct gdbarch *gdbarch,
 
 static void
 procfs_resume (struct target_ops *ops,
-	       ptid_t ptid, int step, enum target_signal signo)
+	       ptid_t ptid, int step, gdb_target_signal_t signo)
 {
   int signal_to_pass;
   procfs_status status;
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -113,7 +113,7 @@
 static void procfs_attach (struct target_ops *, char *, int);
 static void procfs_detach (struct target_ops *, char *, int);
 static void procfs_resume (struct target_ops *,
-			   ptid_t, int, enum target_signal);
+			   ptid_t, int, gdb_target_signal_t);
 static void procfs_stop (ptid_t);
 static void procfs_files_info (struct target_ops *);
 static void procfs_fetch_registers (struct target_ops *,
@@ -4380,7 +4380,7 @@ make_signal_thread_runnable (procinfo *process, procinfo *pi, void *ptr)
 
 static void
 procfs_resume (struct target_ops *ops,
-	       ptid_t ptid, int step, enum target_signal signo)
+	       ptid_t ptid, int step, gdb_target_signal_t signo)
 {
   procinfo *pi, *thread;
   int native_signo;
@@ -5616,7 +5616,7 @@ procfs_first_available (void)
 static char *
 procfs_do_thread_registers (bfd *obfd, ptid_t ptid,
 			    char *note_data, int *note_size,
-			    enum target_signal stop_signal)
+			    gdb_target_signal_t stop_signal)
 {
   struct regcache *regcache = get_thread_regcache (ptid);
   gdb_gregset_t gregs;
@@ -5667,7 +5667,7 @@ struct procfs_corefile_thread_data {
   bfd *obfd;
   char *note_data;
   int *note_size;
-  enum target_signal stop_signal;
+  gdb_target_signal_t stop_signal;
 };
 
 static int
@@ -5697,7 +5697,7 @@ find_signalled_thread (struct thread_info *info, void *data)
   return 0;
 }
 
-static enum target_signal
+static gdb_target_signal_t
 find_stop_signal (void)
 {
   struct thread_info *info =
@@ -5723,7 +5723,7 @@ procfs_make_note_section (bfd *obfd, int *note_size)
   struct procfs_corefile_thread_data thread_args;
   gdb_byte *auxv;
   int auxv_len;
-  enum target_signal stop_signal;
+  gdb_target_signal_t stop_signal;
 
   if (get_exec_file (0))
     {
--- a/gdb/record.c
+++ b/gdb/record.c
@@ -98,7 +98,7 @@ struct record_reg_entry
 
 struct record_end_entry
 {
-  enum target_signal sigval;
+  gdb_target_signal_t 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);
+                                         gdb_target_signal_t);
 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, gdb_target_signal_t signal)
 {
   int ret;
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
@@ -649,7 +649,7 @@ record_message (struct regcache *regcache, enum target_signal signal)
 
 struct record_message_args {
   struct regcache *regcache;
-  enum target_signal signal;
+  gdb_target_signal_t 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)
+                             gdb_target_signal_t signal)
 {
   struct record_message_args args;
 
@@ -783,7 +783,7 @@ record_exec_insn (struct regcache *regcache, struct gdbarch *gdbarch,
 
 static struct target_ops *tmp_to_resume_ops;
 static void (*tmp_to_resume) (struct target_ops *, ptid_t, int,
-			      enum target_signal);
+			      gdb_target_signal_t);
 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)
+               gdb_target_signal_t 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)
+                    gdb_target_signal_t signal)
 {
   record_resume_step = step;
 }
--- a/gdb/remote-m32r-sdi.c
+++ b/gdb/remote-m32r-sdi.c
@@ -453,7 +453,7 @@ m32r_close (int quitting)
 
 static void
 m32r_resume (struct target_ops *ops,
-	     ptid_t ptid, int step, enum target_signal sig)
+	     ptid_t ptid, int step, gdb_target_signal_t sig)
 {
   unsigned long pc_addr, bp_addr, ab_addr;
   int ib_breakpoints;
--- a/gdb/remote-mips.c
+++ b/gdb/remote-mips.c
@@ -1744,7 +1744,7 @@ mips_detach (struct target_ops *ops, char *args, int from_tty)
 
 static void
 mips_resume (struct target_ops *ops,
-	     ptid_t ptid, int step, enum target_signal siggnal)
+	     ptid_t ptid, int step, gdb_target_signal_t siggnal)
 {
   int err;
 
@@ -1758,7 +1758,7 @@ mips_resume (struct target_ops *ops,
 /* Return the signal corresponding to SIG, where SIG is the number which
    the MIPS protocol uses for the signal.  */
 
-static enum target_signal
+static gdb_target_signal_t
 mips_signal_from_protocol (int sig)
 {
   /* We allow a few more signals than the IDT board actually returns, on
@@ -1772,7 +1772,7 @@ mips_signal_from_protocol (int sig)
      from MIPS signal numbers, not host ones.  Our internal numbers
      match the MIPS numbers for the signals the board can return, which
      are: SIGINT, SIGSEGV, SIGBUS, SIGILL, SIGFPE, SIGTRAP.  */
-  return (enum target_signal) sig;
+  return (gdb_target_signal_t) sig;
 }
 
 /* Set the register designated by REGNO to the value designated by VALUE.  */
--- a/gdb/remote-sim.c
+++ b/gdb/remote-sim.c
@@ -119,7 +119,7 @@ struct sim_inferior_data {
   ptid_t remote_sim_ptid;
 
   /* Signal with which to resume.  */
-  enum target_signal resume_siggnal;
+  gdb_target_signal_t resume_siggnal;
 
   /* Flag which indicates whether resume should step or not.  */
   int resume_step;
@@ -825,7 +825,7 @@ gdbsim_detach (struct target_ops *ops, char *args, int from_tty)
 
 struct resume_data
 {
-  enum target_signal siggnal;
+  gdb_target_signal_t siggnal;
   int step;
 };
 
@@ -854,7 +854,7 @@ gdbsim_resume_inferior (struct inferior *inf, void *arg)
 
 static void
 gdbsim_resume (struct target_ops *ops,
-	       ptid_t ptid, int step, enum target_signal siggnal)
+	       ptid_t ptid, int step, gdb_target_signal_t siggnal)
 {
   struct resume_data rd;
   struct sim_inferior_data *sim_data
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -4384,7 +4384,7 @@ remote_vcont_probe (struct remote_state *rs)
 
 static char *
 append_resumption (char *p, char *endp,
-		   ptid_t ptid, int step, enum target_signal siggnal)
+		   ptid_t ptid, int step, gdb_target_signal_t siggnal)
 {
   struct remote_state *rs = get_remote_state ();
 
@@ -4427,7 +4427,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, gdb_target_signal_t siggnal)
 {
   struct remote_state *rs = get_remote_state ();
   char *p;
@@ -4495,13 +4495,13 @@ remote_vcont_resume (ptid_t ptid, int step, enum target_signal siggnal)
 
 /* Tell the remote machine to resume.  */
 
-static enum target_signal last_sent_signal = TARGET_SIGNAL_0;
+static gdb_target_signal_t last_sent_signal = TARGET_SIGNAL_0;
 
 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, gdb_target_signal_t siggnal)
 {
   struct remote_state *rs = get_remote_state ();
   char *buf;
@@ -5155,7 +5155,7 @@ Packet: '%s'\n"),
       else
 	{
 	  event->ws.kind = TARGET_WAITKIND_STOPPED;
-	  event->ws.value.sig = (enum target_signal)
+	  event->ws.value.sig = (gdb_target_signal_t)
 	    (((fromhex (buf[1])) << 4) + (fromhex (buf[2])));
 	}
       break;
@@ -5181,7 +5181,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 = (gdb_target_signal_t) value;
 	  }
 
 	/* If no process is specified, assume inferior_ptid.  */
--- a/gdb/sol-thread.c
+++ b/gdb/sol-thread.c
@@ -348,7 +348,7 @@ sol_thread_detach (struct target_ops *ops, char *args, int from_tty)
 
 static void
 sol_thread_resume (struct target_ops *ops,
-		   ptid_t ptid, int step, enum target_signal signo)
+		   ptid_t ptid, int step, gdb_target_signal_t signo)
 {
   struct cleanup *old_chain;
   struct target_ops *beneath = find_target_beneath (ops);
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -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, gdb_target_signal_t signal)
 {
   struct target_ops *t;
 
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -162,7 +162,7 @@ struct target_waitstatus
     union
       {
 	int integer;
-	enum target_signal sig;
+	gdb_target_signal_t 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, gdb_target_signal_t);
     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 *, int);
    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, gdb_target_signal_t 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 *,
+extern gdb_target_signal_t default_target_signal_from_host (struct gdbarch *,
 							   int);
 extern int default_target_signal_to_host (struct gdbarch *, 
-					  enum target_signal);
+					  gdb_target_signal_t);
 
-/* 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 gdb_target_signal_t.  */
+extern gdb_target_signal_t target_signal_from_command (int);
 /* End of files in common/signals.c.  */
 
 /* Set the show memory breakpoints mode to show, and installs a cleanup
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -185,7 +185,7 @@ static void cygwin_set_dr (int i, CORE_ADDR addr);
 static void cygwin_set_dr7 (unsigned long val);
 static unsigned long cygwin_get_dr6 (void);
 
-static enum target_signal last_sig = TARGET_SIGNAL_0;
+static gdb_target_signal_t last_sig = TARGET_SIGNAL_0;
 /* Set if a signal was received from the debugged process */
 
 /* Thread information structure used to track information that is
@@ -258,7 +258,7 @@ static const int *mappings;
 struct xlate_exception
   {
     int them;
-    enum target_signal us;
+    gdb_target_signal_t us;
   };
 
 static const struct xlate_exception
@@ -1282,7 +1282,7 @@ fake_create_process (void)
 
 static void
 windows_resume (struct target_ops *ops,
-		ptid_t ptid, int step, enum target_signal sig)
+		ptid_t ptid, int step, gdb_target_signal_t sig)
 {
   thread_info *th;
   DWORD continue_status = DBG_CONTINUE;
--- a/include/gdb/signals.h
+++ b/include/gdb/signals.h
@@ -49,12 +49,13 @@
 /* For an explanation of what each signal means, see
    target_signal_to_string.  */
 
-enum target_signal
+typedef enum
   {
 #define SET(symbol, constant, name, string) \
     symbol = constant,
 #include "gdb/signals.def"
 #undef SET
-  };
+  }
+gdb_target_signal_t;
 
 #endif /* #ifndef GDB_SIGNALS_H */
--- a/sim/common/sim-signal.c
+++ b/sim/common/sim-signal.c
@@ -94,7 +94,7 @@ sim_signal_to_host (SIM_DESC sd, SIM_SIGNAL sig)
 #endif
 }
 
-enum target_signal 
+gdb_target_signal_t 
 sim_signal_to_target (SIM_DESC sd, SIM_SIGNAL sig)
 {
   switch (sig)
--- a/sim/common/sim-signal.h
+++ b/sim/common/sim-signal.h
@@ -46,6 +46,6 @@ typedef enum {
 } SIM_SIGNAL;
 
 int sim_signal_to_host (SIM_DESC sd, SIM_SIGNAL);
-enum target_signal sim_signal_to_target (SIM_DESC sd, SIM_SIGNAL);
+gdb_target_signal_t sim_signal_to_target (SIM_DESC sd, SIM_SIGNAL);
 
 #endif /* SIM_SIGNAL_H */

[-- Attachment #3: sigrename-sigasptr.patch --]
[-- Type: text/plain, Size: 34789 bytes --]

--- a/gdb/common/gdb_signals.h
+++ b/gdb/common/gdb_signals.h
@@ -53,4 +53,6 @@ extern const char *target_signal_to_name (gdb_target_signal_t);
 /* Given a name (SIGHUP, etc.), return its signal.  */
 gdb_target_signal_t target_signal_from_name (const char *);
 
+extern gdb_target_signal_t target_signal_from_number (int signo);
+
 #endif /* COMMON_GDB_SIGNALS_H */
--- a/gdb/common/signals.c
+++ b/gdb/common/signals.c
@@ -51,34 +51,36 @@ struct gdbarch;
 /* This table must match in order and size the signals in gdb_target_signal_t.
    */
 
-static const struct {
-  const char *name;
-  const char *string;
-  } signals [] =
+static const struct target_signal_o signals[] =
 {
-#define SET(symbol, constant, name, string) { name, string },
+#define SET(symbol, constant, name, string) \
+    { constant, name, string },
 #include "gdb/signals.def"
 #undef SET
 };
 
+#define SET(symbol, constant, name, string) \
+    const gdb_target_signal_t symbol = &signals[constant];
+#include "gdb/signals.def"
+#undef SET
 
 /* Return the string for a signal.  */
 const char *
 target_signal_to_string (gdb_target_signal_t sig)
 {
-  if ((int) sig >= TARGET_SIGNAL_FIRST && (int) sig <= TARGET_SIGNAL_LAST)
-    return signals[sig].string;
+  if (sig >= TARGET_SIGNAL_FIRST && sig <= 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 (gdb_target_signal_t 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
+      && TARGET_SIGNAL_NAME (sig) != NULL)
+    return TARGET_SIGNAL_NAME (sig);
   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).  */
@@ -97,15 +99,24 @@ target_signal_from_name (const char *name)
      instead.  */
 
   /* This ugly cast brought to you by the native VAX compiler.  */
-  for (sig = TARGET_SIGNAL_HUP;
-       sig < TARGET_SIGNAL_LAST;
-       sig = (gdb_target_signal_t) ((int) sig + 1))
-    if (signals[sig].name != NULL
-	&& strcmp (name, signals[sig].name) == 0)
+  for (sig = TARGET_SIGNAL_HUP; sig < TARGET_SIGNAL_LAST; sig++)
+    if (TARGET_SIGNAL_NAME (sig) != NULL
+	&& strcmp (name, TARGET_SIGNAL_NAME (sig)) == 0)
       return sig;
   return TARGET_SIGNAL_UNKNOWN;
 }
-\f
+
+/* Return the gdb_target_signal_t for a gdb signal.  */
+
+gdb_target_signal_t
+target_signal_from_number (int number)
+{
+  if (number < 0 || number > TARGET_SIGNAL_NUMBER (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.  */
@@ -341,13 +352,13 @@ target_signal_from_host (int hostsig)
     {
       /* This block of TARGET_SIGNAL_REALTIME value is in order.  */
       if (33 <= hostsig && hostsig <= 63)
-	return (gdb_target_signal_t)
-	  (hostsig - 33 + (int) TARGET_SIGNAL_REALTIME_33);
+	return target_signal_from_number
+	  (hostsig - 33 + TARGET_SIGNAL_NUMBER (TARGET_SIGNAL_REALTIME_33));
       else if (hostsig == 32)
 	return TARGET_SIGNAL_REALTIME_32;
       else if (64 <= hostsig && hostsig <= 127)
-	return (gdb_target_signal_t)
-	  (hostsig - 64 + (int) TARGET_SIGNAL_REALTIME_64);
+	return target_signal_from_number
+	  (hostsig - 64 + TARGET_SIGNAL_NUMBER (TARGET_SIGNAL_REALTIME_64));
       else
 	error ("GDB bug: target.c (target_signal_from_host): unrecognized real-time signal");
     }
@@ -371,81 +382,81 @@ do_target_signal_to_host (gdb_target_signal_t oursig,
   (void) retsig;
 
   *oursig_ok = 1;
-  switch (oursig)
+  switch (TARGET_SIGNAL_NUMBER (oursig))
     {
-    case TARGET_SIGNAL_0:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_0):
       return 0;
 
 #if defined (SIGHUP)
-    case TARGET_SIGNAL_HUP:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_HUP):
       return SIGHUP;
 #endif
 #if defined (SIGINT)
-    case TARGET_SIGNAL_INT:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_INT):
       return SIGINT;
 #endif
 #if defined (SIGQUIT)
-    case TARGET_SIGNAL_QUIT:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_QUIT):
       return SIGQUIT;
 #endif
 #if defined (SIGILL)
-    case TARGET_SIGNAL_ILL:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_ILL):
       return SIGILL;
 #endif
 #if defined (SIGTRAP)
-    case TARGET_SIGNAL_TRAP:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_TRAP):
       return SIGTRAP;
 #endif
 #if defined (SIGABRT)
-    case TARGET_SIGNAL_ABRT:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_ABRT):
       return SIGABRT;
 #endif
 #if defined (SIGEMT)
-    case TARGET_SIGNAL_EMT:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_EMT):
       return SIGEMT;
 #endif
 #if defined (SIGFPE)
-    case TARGET_SIGNAL_FPE:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_FPE):
       return SIGFPE;
 #endif
 #if defined (SIGKILL)
-    case TARGET_SIGNAL_KILL:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_KILL):
       return SIGKILL;
 #endif
 #if defined (SIGBUS)
-    case TARGET_SIGNAL_BUS:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_BUS):
       return SIGBUS;
 #endif
 #if defined (SIGSEGV)
-    case TARGET_SIGNAL_SEGV:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_SEGV):
       return SIGSEGV;
 #endif
 #if defined (SIGSYS)
-    case TARGET_SIGNAL_SYS:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_SYS):
       return SIGSYS;
 #endif
 #if defined (SIGPIPE)
-    case TARGET_SIGNAL_PIPE:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_PIPE):
       return SIGPIPE;
 #endif
 #if defined (SIGALRM)
-    case TARGET_SIGNAL_ALRM:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_ALRM):
       return SIGALRM;
 #endif
 #if defined (SIGTERM)
-    case TARGET_SIGNAL_TERM:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_TERM):
       return SIGTERM;
 #endif
 #if defined (SIGUSR1)
-    case TARGET_SIGNAL_USR1:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_USR1):
       return SIGUSR1;
 #endif
 #if defined (SIGUSR2)
-    case TARGET_SIGNAL_USR2:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_USR2):
       return SIGUSR2;
 #endif
 #if defined (SIGCHLD) || defined (SIGCLD)
-    case TARGET_SIGNAL_CHLD:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_CHLD):
 #if defined (SIGCHLD)
       return SIGCHLD;
 #else
@@ -453,111 +464,111 @@ do_target_signal_to_host (gdb_target_signal_t oursig,
 #endif
 #endif /* SIGCLD or SIGCHLD */
 #if defined (SIGPWR)
-    case TARGET_SIGNAL_PWR:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_PWR):
       return SIGPWR;
 #endif
 #if defined (SIGWINCH)
-    case TARGET_SIGNAL_WINCH:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_WINCH):
       return SIGWINCH;
 #endif
 #if defined (SIGURG)
-    case TARGET_SIGNAL_URG:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_URG):
       return SIGURG;
 #endif
 #if defined (SIGIO)
-    case TARGET_SIGNAL_IO:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_IO):
       return SIGIO;
 #endif
 #if defined (SIGPOLL)
-    case TARGET_SIGNAL_POLL:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_POLL):
       return SIGPOLL;
 #endif
 #if defined (SIGSTOP)
-    case TARGET_SIGNAL_STOP:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_STOP):
       return SIGSTOP;
 #endif
 #if defined (SIGTSTP)
-    case TARGET_SIGNAL_TSTP:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_TSTP):
       return SIGTSTP;
 #endif
 #if defined (SIGCONT)
-    case TARGET_SIGNAL_CONT:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_CONT):
       return SIGCONT;
 #endif
 #if defined (SIGTTIN)
-    case TARGET_SIGNAL_TTIN:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_TTIN):
       return SIGTTIN;
 #endif
 #if defined (SIGTTOU)
-    case TARGET_SIGNAL_TTOU:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_TTOU):
       return SIGTTOU;
 #endif
 #if defined (SIGVTALRM)
-    case TARGET_SIGNAL_VTALRM:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_VTALRM):
       return SIGVTALRM;
 #endif
 #if defined (SIGPROF)
-    case TARGET_SIGNAL_PROF:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_PROF):
       return SIGPROF;
 #endif
 #if defined (SIGXCPU)
-    case TARGET_SIGNAL_XCPU:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_XCPU):
       return SIGXCPU;
 #endif
 #if defined (SIGXFSZ)
-    case TARGET_SIGNAL_XFSZ:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_XFSZ):
       return SIGXFSZ;
 #endif
 #if defined (SIGWIND)
-    case TARGET_SIGNAL_WIND:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_WIND):
       return SIGWIND;
 #endif
 #if defined (SIGPHONE)
-    case TARGET_SIGNAL_PHONE:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_PHONE):
       return SIGPHONE;
 #endif
 #if defined (SIGLOST)
-    case TARGET_SIGNAL_LOST:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_LOST):
       return SIGLOST;
 #endif
 #if defined (SIGWAITING)
-    case TARGET_SIGNAL_WAITING:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_WAITING):
       return SIGWAITING;
 #endif
 #if defined (SIGCANCEL)
-    case TARGET_SIGNAL_CANCEL:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_CANCEL):
       return SIGCANCEL;
 #endif
 #if defined (SIGLWP)
-    case TARGET_SIGNAL_LWP:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_LWP):
       return SIGLWP;
 #endif
 #if defined (SIGDANGER)
-    case TARGET_SIGNAL_DANGER:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_DANGER):
       return SIGDANGER;
 #endif
 #if defined (SIGGRANT)
-    case TARGET_SIGNAL_GRANT:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_GRANT):
       return SIGGRANT;
 #endif
 #if defined (SIGRETRACT)
-    case TARGET_SIGNAL_RETRACT:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_RETRACT):
       return SIGRETRACT;
 #endif
 #if defined (SIGMSG)
-    case TARGET_SIGNAL_MSG:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_MSG):
       return SIGMSG;
 #endif
 #if defined (SIGSOUND)
-    case TARGET_SIGNAL_SOUND:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_SOUND):
       return SIGSOUND;
 #endif
 #if defined (SIGSAK)
-    case TARGET_SIGNAL_SAK:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_SAK):
       return SIGSAK;
 #endif
 #if defined (SIGPRIO)
-    case TARGET_SIGNAL_PRIO:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_PRIO):
       return SIGPRIO;
 #endif
 
@@ -588,7 +599,7 @@ do_target_signal_to_host (gdb_target_signal_t oursig,
 #endif
 
 #if defined (SIGINFO)
-    case TARGET_SIGNAL_INFO:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_INFO):
       return SIGINFO;
 #endif
 
@@ -601,7 +612,8 @@ do_target_signal_to_host (gdb_target_signal_t oursig,
 	{
 	  /* 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 = (TARGET_SIGNAL_NUMBER (oursig)
+		    - TARGET_SIGNAL_NUMBER (TARGET_SIGNAL_REALTIME_33) + 33);
 	}
       else if (oursig == TARGET_SIGNAL_REALTIME_32)
 	{
@@ -614,7 +626,8 @@ do_target_signal_to_host (gdb_target_signal_t oursig,
 	{
 	  /* 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 = (TARGET_SIGNAL_NUMBER (oursig)
+		    - TARGET_SIGNAL_NUMBER (TARGET_SIGNAL_REALTIME_64) + 64);
 	}
 
       if (retsig >= REALTIME_LO && retsig < REALTIME_HI)
@@ -665,7 +678,7 @@ gdb_target_signal_t
 target_signal_from_command (int num)
 {
   if (num >= 1 && num <= 15)
-    return (gdb_target_signal_t) num;
+    return target_signal_from_number (num);
   error ("Only signals 1-15 are valid as numeric signals.\n\
 Use \"info signals\" for a list of symbolic signals.");
 }
@@ -675,8 +688,17 @@ extern initialize_file_ftype _initialize_signals; /* -Wmissing-prototype */
 void
 _initialize_signals (void)
 {
-  if (strcmp (signals[TARGET_SIGNAL_LAST].string, "TARGET_SIGNAL_MAGIC") != 0)
-    internal_error (__FILE__, __LINE__, "failed internal consistency check");
+  gdb_target_signal_t sig;
+
+  for (sig = TARGET_SIGNAL_0; sig <= TARGET_SIGNAL_LAST; sig++)
+    if (sig - TARGET_SIGNAL_0 != TARGET_SIGNAL_NUMBER (sig))
+      internal_error (__FILE__, __LINE__, "failed internal consistency check "
+                                          "(signals continuity)");
+
+  if (strcmp (TARGET_SIGNAL_STRING (TARGET_SIGNAL_LAST),
+	      "TARGET_SIGNAL_MAGIC") != 0)
+    internal_error (__FILE__, __LINE__, "failed internal consistency check"
+					"(last signal magic)");
 }
 
 int
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -2266,7 +2266,7 @@ Check if we're already there.\n",
 	       || WSTOPSIG (w) == __SIGRTMIN + 1))
 	  ||
 #endif
-	  (pass_signals[target_signal_from_host (WSTOPSIG (w))]
+  (pass_signals[TARGET_SIGNAL_NUMBER (target_signal_from_host (WSTOPSIG (w)))]
 	   && !(WSTOPSIG (w) == SIGSTOP
 		&& current_inferior->last_resume_kind == resume_stop))))
     {
@@ -2421,7 +2421,7 @@ Check if we're already there.\n",
     fprintf (stderr, "linux_wait ret = %s, %d, %d\n",
 	     target_pid_to_str (ptid_of (event_child)),
 	     ourstatus->kind,
-	     ourstatus->value.sig);
+	     TARGET_SIGNAL_NUMBER (ourstatus->value.sig));
 
   return ptid_of (event_child);
 }
--- a/gdb/gdbserver/remote-utils.c
+++ b/gdb/gdbserver/remote-utils.c
@@ -1240,7 +1240,7 @@ prepare_resume_reply (char *buf, ptid_t ptid,
 	const char **regp;
 	struct regcache *regcache;
 
-	sprintf (buf, "T%02x", status->value.sig);
+	sprintf (buf, "T%02x", TARGET_SIGNAL_NUMBER (status->value.sig));
 	buf += strlen (buf);
 
 	regp = gdbserver_expedite_regs;
@@ -1339,9 +1339,10 @@ prepare_resume_reply (char *buf, ptid_t ptid,
     case TARGET_WAITKIND_SIGNALLED:
       if (multi_process)
 	sprintf (buf, "X%x;process:%x",
-		 status->value.sig, ptid_get_pid (ptid));
+		 TARGET_SIGNAL_NUMBER (status->value.sig),
+		 ptid_get_pid (ptid));
       else
-	sprintf (buf, "X%02x", status->value.sig);
+	sprintf (buf, "X%02x", TARGET_SIGNAL_NUMBER (status->value.sig));
       break;
     default:
       error ("unhandled waitkind");
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -51,7 +51,7 @@ int debug_threads;
 /* Enable debugging of h/w breakpoint/watchpoint support.  */
 int debug_hw_points;
 
-int pass_signals[TARGET_SIGNAL_LAST];
+int pass_signals[TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_LAST)];
 
 jmp_buf toplevel;
 
@@ -398,7 +398,7 @@ handle_general_set (char *own_buf)
 {
   if (strncmp ("QPassSignals:", own_buf, strlen ("QPassSignals:")) == 0)
     {
-      int numsigs = (int) TARGET_SIGNAL_LAST, i;
+      int numsigs = TARGET_SIGNAL_NUMBER (TARGET_SIGNAL_LAST), i;
       const char *p = own_buf + strlen ("QPassSignals:");
       CORE_ADDR cursig;
 
@@ -1747,12 +1747,15 @@ handle_v_cont (char *own_buf)
 
       if (p[0] == 'S' || p[0] == 'C')
 	{
-	  int sig;
-	  sig = strtol (p + 1, &q, 16);
+	  int signo;
+	  gdb_target_signal_t sig;
+
+	  signo = strtol (p + 1, &q, 16);
 	  if (p == q)
 	    goto err;
 	  p = q;
 
+	  sig = target_signal_from_number (signo);
 	  if (!target_signal_to_host_p (sig))
 	    goto err;
 	  resume_info[i].sig = target_signal_to_host (sig);
@@ -2959,8 +2962,8 @@ process_serial_event (void)
     case 'C':
       require_running (own_buf);
       convert_ascii_to_int (own_buf + 1, &sig, 1);
-      if (target_signal_to_host_p (sig))
-	signal = target_signal_to_host (sig);
+      if (target_signal_to_host_p (target_signal_from_number (sig)))
+	signal = target_signal_to_host (target_signal_from_number (sig));
       else
 	signal = 0;
       myresume (own_buf, 0, signal);
@@ -2968,8 +2971,8 @@ process_serial_event (void)
     case 'S':
       require_running (own_buf);
       convert_ascii_to_int (own_buf + 1, &sig, 1);
-      if (target_signal_to_host_p (sig))
-	signal = target_signal_to_host (sig);
+      if (target_signal_to_host_p (target_signal_from_number (sig)))
+	signal = target_signal_to_host (target_signal_from_number (sig));
       else
 	signal = 0;
       myresume (own_buf, 1, signal);
--- a/gdb/inferior.h
+++ b/gdb/inferior.h
@@ -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 (gdb_target_signal_t sig);
 
-extern int signal_print_state (int);
+extern int signal_print_state (gdb_target_signal_t sig);
 
-extern int signal_pass_state (int);
+extern int signal_pass_state (gdb_target_signal_t sig);
 
-extern int signal_stop_update (int, int);
+extern int signal_stop_update (gdb_target_signal_t sig, int state);
 
-extern int signal_print_update (int, int);
+extern int signal_print_update (gdb_target_signal_t sig, int state);
 
-extern int signal_pass_update (int, int);
+extern int signal_pass_update (gdb_target_signal_t sig, int state);
 
 extern void get_last_target_status(ptid_t *ptid,
                                    struct target_waitstatus *status);
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -1583,7 +1583,7 @@ resume (int step, gdb_target_signal_t 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
@@ -1963,7 +1963,8 @@ proceed (CORE_ADDR addr, gdb_target_signal_t siggnal, int step)
   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
@@ -2047,7 +2048,7 @@ proceed (CORE_ADDR addr, gdb_target_signal_t siggnal, int step)
     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 ();
@@ -3970,11 +3971,11 @@ 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 ();
@@ -3997,7 +3998,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
@@ -5184,7 +5185,7 @@ keep_going (struct execution_control_state *ecs)
          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);
@@ -5594,47 +5595,47 @@ hook_stop_stub (void *cmd)
 }
 \f
 int
-signal_stop_state (int signo)
+signal_stop_state (gdb_target_signal_t sig)
 {
-  return signal_stop[signo];
+  return signal_stop[TARGET_SIGNAL_NUMBER (sig)];
 }
 
 int
-signal_print_state (int signo)
+signal_print_state (gdb_target_signal_t sig)
 {
-  return signal_print[signo];
+  return signal_print[TARGET_SIGNAL_NUMBER (sig)];
 }
 
 int
-signal_pass_state (int signo)
+signal_pass_state (gdb_target_signal_t sig)
 {
-  return signal_program[signo];
+  return signal_program[TARGET_SIGNAL_NUMBER (sig)];
 }
 
 int
-signal_stop_update (int signo, int state)
+signal_stop_update (gdb_target_signal_t 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 (gdb_target_signal_t 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 (gdb_target_signal_t 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;
 }
 
@@ -5656,9 +5657,9 @@ sig_print_info (gdb_target_signal_t oursig)
 
   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));
 }
 
@@ -5683,7 +5684,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 (TARGET_SIGNAL_LAST);
   sigs = (unsigned char *) alloca (nsigs);
   memset (sigs, 0, nsigs);
 
@@ -5756,12 +5757,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));
+	  gdb_target_signal_t 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)
 	    {
@@ -5776,7 +5778,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
 	    {
@@ -5790,15 +5792,15 @@ handle_command (char *args, int from_tty)
 
       for (signum = sigfirst; signum >= 0 && signum <= siglast; signum++)
 	{
-	  switch ((gdb_target_signal_t) signum)
+	  switch (signum)
 	    {
-	    case TARGET_SIGNAL_TRAP:
-	    case TARGET_SIGNAL_INT:
+	    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_TRAP):
+	    case TARGET_SIGNAL_NUMBER_CONST (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 ((gdb_target_signal_t) signum)))
+		  target_signal_to_name (target_signal_from_number (signum))))
 		    {
 		      sigs[signum] = 1;
 		    }
@@ -5809,9 +5811,9 @@ Are you sure you want to change it? "),
 		    }
 		}
 	      break;
-	    case TARGET_SIGNAL_0:
-	    case TARGET_SIGNAL_DEFAULT:
-	    case TARGET_SIGNAL_UNKNOWN:
+	    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_0):
+	    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_DEFAULT):
+	    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_UNKNOWN):
 	      /* Make sure that "all" doesn't print these.  */
 	      break;
 	    default:
@@ -5834,7 +5836,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;
@@ -5876,21 +5878,21 @@ xdb_handle_command (char *args, int from_tty)
 	    {
 	      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");
@@ -5937,9 +5939,7 @@ signals_info (char *signum_exp, int from_tty)
 
   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 = (gdb_target_signal_t) ((int) oursig + 1))
+  for (oursig = TARGET_SIGNAL_FIRST; oursig < TARGET_SIGNAL_LAST; oursig++)
     {
       QUIT;
 
@@ -6612,7 +6612,7 @@ leave it stopped or free to run as needed."),
 			   &setlist,
 			   &showlist);
 
-  numsigs = (int) TARGET_SIGNAL_LAST;
+  numsigs = TARGET_SIGNAL_NUMBER (TARGET_SIGNAL_LAST);
   signal_stop = (unsigned char *) xmalloc (sizeof (signal_stop[0]) * numsigs);
   signal_print = (unsigned char *)
     xmalloc (sizeof (signal_print[0]) * numsigs);
@@ -6627,37 +6627,37 @@ leave it stopped or free to run as needed."),
 
   /* 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, _("\
--- a/gdb/record.c
+++ b/gdb/record.c
@@ -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,8 @@ cmd_record_save (char *args, int from_tty)
 				      (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);
 
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -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 (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)
+	  gdb_target_signal_t 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)
+	  gdb_target_signal_t 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);
@@ -4389,11 +4393,11 @@ append_resumption (char *p, char *endp,
   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");
 
@@ -4495,7 +4499,7 @@ remote_vcont_resume (ptid_t ptid, int step, gdb_target_signal_t siggnal)
 
 /* Tell the remote machine to resume.  */
 
-static gdb_target_signal_t last_sent_signal = TARGET_SIGNAL_0;
+static gdb_target_signal_t last_sent_signal;
 
 static int last_sent_step;
 
@@ -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,11 @@ 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 ((signo >> 4) & 0xf);
+      buf[2] = tohex (signo & 0xf);
       buf[3] = '\0';
     }
   else
@@ -5155,8 +5161,9 @@ Packet: '%s'\n"),
       else
 	{
 	  event->ws.kind = TARGET_WAITKIND_STOPPED;
-	  event->ws.value.sig = (gdb_target_signal_t)
-	    (((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 +5188,7 @@ Packet: '%s'\n"),
 	  {
 	    /* The remote process exited with a signal.  */
 	    event->ws.kind = TARGET_WAITKIND_SIGNALLED;
-	    event->ws.value.sig = (gdb_target_signal_t) value;
+	    event->ws.value.sig = target_signal_from_number (value);
 	  }
 
 	/* If no process is specified, assume inferior_ptid.  */
@@ -10788,5 +10795,6 @@ Show the remote pathname for \"run\""), NULL, NULL, NULL,
 
   target_buf_size = 2048;
   target_buf = xmalloc (target_buf_size);
-}
 
+  last_sent_signal = TARGET_SIGNAL_0;
+}
--- a/include/gdb/signals.h
+++ b/include/gdb/signals.h
@@ -49,13 +49,31 @@
 /* For an explanation of what each signal means, see
    target_signal_to_string.  */
 
-typedef enum
+#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
+  };
+
+struct target_signal_o
   {
+    enum target_signal_number number;
+    const char *name;
+    const char *string;
+  };
+
+typedef const struct target_signal_o *gdb_target_signal_t;
+
 #define SET(symbol, constant, name, string) \
-    symbol = constant,
+    extern const gdb_target_signal_t symbol;
 #include "gdb/signals.def"
 #undef SET
-  }
-gdb_target_signal_t;
 
 #endif /* #ifndef GDB_SIGNALS_H */

^ permalink raw reply	[flat|nested] 40+ messages in thread

end of thread, other threads:[~2010-09-08 20:39 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-30  7:11 [patch 1/9]#2 Rename `enum target_signal' to target_signal_t Jan Kratochvil
2010-08-30  8:14 ` Mark Kettenis
2010-08-30  8:24   ` Jan Kratochvil
2010-08-30 10:09     ` Eli Zaretskii
2010-08-30 11:11       ` Mark Kettenis
2010-08-30 14:08         ` Joel Brobecker
2010-08-31 18:28           ` Jan Kratochvil
2010-08-31 18:45             ` Mark Kettenis
2010-09-01  2:03             ` Joel Brobecker
2010-09-01 18:18             ` Joel Brobecker
2010-09-01 18:30               ` Jan Kratochvil
2010-09-01 18:38                 ` Pedro Alves
2010-09-01 18:45                   ` Jan Kratochvil
2010-09-01 18:40                 ` Joel Brobecker
2010-09-01 18:51                   ` Jan Kratochvil
2010-09-01 19:08                     ` Pedro Alves
2010-09-01 19:28                       ` Jan Kratochvil
2010-09-01 20:06                         ` Pedro Alves
2010-09-01 20:06                           ` Daniel Jacobowitz
2010-09-01 20:10                             ` Pedro Alves
2010-09-02  9:46                               ` Pedro Alves
2010-09-02 14:01                                 ` Jan Kratochvil
2010-09-02 15:36                                   ` Joel Brobecker
2010-09-02 19:02                                   ` Pedro Alves
2010-09-02 20:46                                     ` Jan Kratochvil
2010-09-07 18:59                                       ` Jan Kratochvil
2010-09-02 16:02                                 ` Joel Brobecker
2010-09-02 17:04                                   ` Jan Kratochvil
2010-09-06  0:29                                 ` Jan Kratochvil
2010-09-06 13:30                                   ` Pedro Alves
2010-09-06 14:52                                     ` Jan Kratochvil
2010-09-08 23:42                                 ` Jan Kratochvil
2010-09-01 20:23                           ` Jan Kratochvil
2010-09-01 20:30                             ` Mark Kettenis
2010-09-01 20:47                             ` Pedro Alves
2010-09-01 21:32                         ` Joseph S. Myers
2010-09-01 19:12                     ` Joel Brobecker
2010-09-01 22:37                     ` Tom Tromey
2010-08-30 14:11         ` Eli Zaretskii
2010-08-30 17:34     ` Michael Snyder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).