Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Sergio Durigan Junior <sergiodj@redhat.com>
To: GDB Patches <gdb-patches@sourceware.org>
Cc: Sergio Durigan Junior <sergiodj@redhat.com>,
	       Tom Tromey <tromey@redhat.com>
Subject: [PATCH 7/7] MIPS support
Date: Fri, 26 Jul 2013 20:13:00 -0000	[thread overview]
Message-ID: <1374869594-16965-8-git-send-email-sergiodj@redhat.com> (raw)
In-Reply-To: <1374869594-16965-1-git-send-email-sergiodj@redhat.com>

Support for the MIPS target.  MIPS already had a definition of
gdbarch_gdb_signal_from_target, and also an enum containing all signal
numbers from this target.  So, in order to make things standard, I
removed the previous enum in favor of the new, difference-only enum
declared by this patch series.  And I also redefined the implementation
of gdbarch_gdb_signal_from_target for MIPS in order to take this new
enum into account, and only handle the signals which are different from
the Linux kernel generic ones.

2013-07-26  Sergio Durigan Junior  <sergiodj@redhat.com>

	* mips-linux-tdep.c: Define enum with differences between
	signals in MIPS and Linux kernel generic ones.
	(mips_gdb_signal_to_target): New function.
	(mips_gdb_signal_from_target): Redefine to use new enum, handle
	only different signals from the Linux kernel generic.
	(mips_linux_init_abi): Set gdbarch_gdb_signal_{to,from}_target
	the functions defined above.
	* mips_gdb_signal_to_target (enum mips_signals): Remove.

mips
---
 gdb/mips-linux-tdep.c | 241 ++++++++++++++++++++++++++++++++++++++------------
 gdb/mips-linux-tdep.h |  42 ---------
 2 files changed, 185 insertions(+), 98 deletions(-)

diff --git a/gdb/mips-linux-tdep.c b/gdb/mips-linux-tdep.c
index 484b39f..816f120 100644
--- a/gdb/mips-linux-tdep.c
+++ b/gdb/mips-linux-tdep.c
@@ -45,6 +45,42 @@
 
 static struct target_so_ops mips_svr4_so_ops;
 
+/* This enum represents the signals' numbers on the MIPS
+   architecture.  It just contains the signal definitions which are
+   different from x86.
+
+   It is derived from the file <arch/mips/include/uapi/asm/signal.h>,
+   from the Linux kernel tree.  */
+
+enum
+  {
+    MIPS_LINUX_SIGEMT = 7,
+    MIPS_LINUX_SIGBUS = 10,
+    MIPS_LINUX_SIGSYS = 12,
+    MIPS_LINUX_SIGUSR1 = 16,
+    MIPS_LINUX_SIGUSR2 = 17,
+    MIPS_LINUX_SIGCHLD = 18,
+    MIPS_LINUX_SIGCLD = MIPS_LINUX_SIGCHLD,
+    MIPS_LINUX_SIGPWR = 19,
+    MIPS_LINUX_SIGWINCH = 20,
+    MIPS_LINUX_SIGURG = 21,
+    MIPS_LINUX_SIGIO = 22,
+    MIPS_LINUX_SIGPOLL = MIPS_LINUX_SIGIO,
+    MIPS_LINUX_SIGSTOP = 23,
+    MIPS_LINUX_SIGTSTP = 24,
+    MIPS_LINUX_SIGCONT = 25,
+    MIPS_LINUX_SIGTTIN = 26,
+    MIPS_LINUX_SIGTTOU = 27,
+    MIPS_LINUX_SIGVTALRM = 28,
+    MIPS_LINUX_SIGPROF = 29,
+    MIPS_LINUX_SIGXCPU = 30,
+    MIPS_LINUX_SIGXFSZ = 31,
+
+    MIPS_LINUX_SIGRTMIN = 32,
+    MIPS_LINUX_SIGRT64 = 64,
+    MIPS_LINUX_SIGRTMAX = 127,
+  };
+
 /* Figure out where the longjmp will land.
    We expect the first arg to be a pointer to the jmp_buf structure
    from which we extract the pc (MIPS_LINUX_JB_PC) that we will land
@@ -1339,94 +1375,184 @@ mips_linux_get_syscall_number (struct gdbarch *gdbarch,
   return ret;
 }
 
+/* Implementation of `gdbarch_gdb_signal_to_target', as defined in
+   gdbarch.h.  */
+
+static int
+mips_gdb_signal_to_target (struct gdbarch *gdbarch,
+			   enum gdb_signal signal)
+{
+  switch (signal)
+    {
+    case GDB_SIGNAL_EMT:
+      return MIPS_LINUX_SIGEMT;
+
+    case GDB_SIGNAL_BUS:
+      return MIPS_LINUX_SIGBUS;
+
+    case GDB_SIGNAL_SYS:
+      return MIPS_LINUX_SIGSYS;
+
+    case GDB_SIGNAL_USR1:
+      return MIPS_LINUX_SIGUSR1;
+
+    case GDB_SIGNAL_USR2:
+      return MIPS_LINUX_SIGUSR2;
+
+    case GDB_SIGNAL_CHLD:
+      return MIPS_LINUX_SIGCHLD;
+
+    case GDB_SIGNAL_PWR:
+      return MIPS_LINUX_SIGPWR;
+
+    case GDB_SIGNAL_WINCH:
+      return MIPS_LINUX_SIGWINCH;
+
+    case GDB_SIGNAL_URG:
+      return MIPS_LINUX_SIGURG;
+
+    case GDB_SIGNAL_IO:
+      return MIPS_LINUX_SIGIO;
+
+    case GDB_SIGNAL_POLL:
+      return MIPS_LINUX_SIGPOLL;
+
+    case GDB_SIGNAL_STOP:
+      return MIPS_LINUX_SIGSTOP;
+
+    case GDB_SIGNAL_TSTP:
+      return MIPS_LINUX_SIGTSTP;
+
+    case GDB_SIGNAL_CONT:
+      return MIPS_LINUX_SIGCONT;
+
+    case GDB_SIGNAL_TTIN:
+      return MIPS_LINUX_SIGTTIN;
+
+    case GDB_SIGNAL_TTOU:
+      return MIPS_LINUX_SIGTTOU;
+
+    case GDB_SIGNAL_VTALRM:
+      return MIPS_LINUX_SIGVTALRM;
+
+    case GDB_SIGNAL_PROF:
+      return MIPS_LINUX_SIGPROF;
+
+    case GDB_SIGNAL_XCPU:
+      return MIPS_LINUX_SIGXCPU;
+
+    case GDB_SIGNAL_XFSZ:
+      return MIPS_LINUX_SIGXFSZ;
+
+    /* GDB_SIGNAL_REALTIME_32 is not continuous in <gdb/signals.def>,
+       therefore we have to handle it here.  */
+    case GDB_SIGNAL_REALTIME_32:
+      return MIPS_LINUX_SIGRTMIN;
+    }
+
+  if (signal >= GDB_SIGNAL_REALTIME_33
+      && signal <= GDB_SIGNAL_REALTIME_63)
+    {
+      int offset = signal - GDB_SIGNAL_REALTIME_33;
+
+      return MIPS_LINUX_SIGRTMIN + 1 + offset;
+    }
+  else if (signal >= GDB_SIGNAL_REALTIME_64
+	   && signal <= GDB_SIGNAL_REALTIME_127)
+    {
+      int offset = signal - GDB_SIGNAL_REALTIME_64;
+
+      return MIPS_LINUX_SIGRT64 + offset;
+    }
+
+  return linux_gdb_signal_to_target (gdbarch, signal);
+}
+
 /* Translate signals based on MIPS signal values.
    Adapted from gdb/common/signals.c.  */
 
 static enum gdb_signal
-mips_gdb_signal_from_target (struct gdbarch *gdbarch, int signo)
+mips_gdb_signal_from_target (struct gdbarch *gdbarch, int signal)
 {
-  switch (signo)
+  switch (signal)
     {
-    case 0:
-      return GDB_SIGNAL_0;
-    case MIPS_SIGHUP:
-      return GDB_SIGNAL_HUP;
-    case MIPS_SIGINT:
-      return GDB_SIGNAL_INT;
-    case MIPS_SIGQUIT:
-      return GDB_SIGNAL_QUIT;
-    case MIPS_SIGILL:
-      return GDB_SIGNAL_ILL;
-    case MIPS_SIGTRAP:
-      return GDB_SIGNAL_TRAP;
-    case MIPS_SIGABRT:
-      return GDB_SIGNAL_ABRT;
-    case MIPS_SIGEMT:
+    case MIPS_LINUX_SIGEMT:
       return GDB_SIGNAL_EMT;
-    case MIPS_SIGFPE:
-      return GDB_SIGNAL_FPE;
-    case MIPS_SIGKILL:
-      return GDB_SIGNAL_KILL;
-    case MIPS_SIGBUS:
+
+    case MIPS_LINUX_SIGBUS:
       return GDB_SIGNAL_BUS;
-    case MIPS_SIGSEGV:
-      return GDB_SIGNAL_SEGV;
-    case MIPS_SIGSYS:
+
+    case MIPS_LINUX_SIGSYS:
       return GDB_SIGNAL_SYS;
-    case MIPS_SIGPIPE:
-      return GDB_SIGNAL_PIPE;
-    case MIPS_SIGALRM:
-      return GDB_SIGNAL_ALRM;
-    case MIPS_SIGTERM:
-      return GDB_SIGNAL_TERM;
-    case MIPS_SIGUSR1:
+
+    case MIPS_LINUX_SIGUSR1:
       return GDB_SIGNAL_USR1;
-    case MIPS_SIGUSR2:
+
+    case MIPS_LINUX_SIGUSR2:
       return GDB_SIGNAL_USR2;
-    case MIPS_SIGCHLD:
+
+    case MIPS_LINUX_SIGCHLD:
       return GDB_SIGNAL_CHLD;
-    case MIPS_SIGPWR:
+
+    case MIPS_LINUX_SIGPWR:
       return GDB_SIGNAL_PWR;
-    case MIPS_SIGWINCH:
+
+    case MIPS_LINUX_SIGWINCH:
       return GDB_SIGNAL_WINCH;
-    case MIPS_SIGURG:
+
+    case MIPS_LINUX_SIGURG:
       return GDB_SIGNAL_URG;
-    case MIPS_SIGPOLL:
-      return GDB_SIGNAL_POLL;
-    case MIPS_SIGSTOP:
+
+    /* No way to differentiate between SIGIO and SIGPOLL.
+       Therefore, we just handle the first one.  */
+    case MIPS_LINUX_SIGIO:
+      return GDB_SIGNAL_IO;
+
+    case MIPS_LINUX_SIGSTOP:
       return GDB_SIGNAL_STOP;
-    case MIPS_SIGTSTP:
+
+    case MIPS_LINUX_SIGTSTP:
       return GDB_SIGNAL_TSTP;
-    case MIPS_SIGCONT:
+
+    case MIPS_LINUX_SIGCONT:
       return GDB_SIGNAL_CONT;
-    case MIPS_SIGTTIN:
+
+    case MIPS_LINUX_SIGTTIN:
       return GDB_SIGNAL_TTIN;
-    case MIPS_SIGTTOU:
+
+    case MIPS_LINUX_SIGTTOU:
       return GDB_SIGNAL_TTOU;
-    case MIPS_SIGVTALRM:
+
+    case MIPS_LINUX_SIGVTALRM:
       return GDB_SIGNAL_VTALRM;
-    case MIPS_SIGPROF:
+
+    case MIPS_LINUX_SIGPROF:
       return GDB_SIGNAL_PROF;
-    case MIPS_SIGXCPU:
+
+    case MIPS_LINUX_SIGXCPU:
       return GDB_SIGNAL_XCPU;
-    case MIPS_SIGXFSZ:
+
+    case MIPS_LINUX_SIGXFSZ:
       return GDB_SIGNAL_XFSZ;
-  }
+    }
 
-  if (signo >= MIPS_SIGRTMIN && signo <= MIPS_SIGRTMAX)
+  if (signal >= MIPS_LINUX_SIGRTMIN && signal <= MIPS_LINUX_SIGRTMAX)
     {
       /* GDB_SIGNAL_REALTIME values are not contiguous, map parts of
          the MIPS block to the respective GDB_SIGNAL_REALTIME blocks.  */
-      signo -= MIPS_SIGRTMIN;
-      if (signo == 0)
+      int offset = signal - MIPS_LINUX_SIGRTMIN;
+
+      if (offset == 0)
 	return GDB_SIGNAL_REALTIME_32;
-      else if (signo < 32)
-	return ((enum gdb_signal) (signo - 1 + (int) GDB_SIGNAL_REALTIME_33));
+      else if (offset < 32)
+	return (enum gdb_signal) (offset - 1
+				  + (int) GDB_SIGNAL_REALTIME_33);
       else
-	return ((enum gdb_signal) (signo - 32 + (int) GDB_SIGNAL_REALTIME_64));
+	return (enum gdb_signal) (offset - 32
+				  + (int) GDB_SIGNAL_REALTIME_64);
     }
 
-  return GDB_SIGNAL_UNKNOWN;
+  return linux_gdb_signal_from_target (gdbarch, signal);
 }
 
 /* Initialize one of the GNU/Linux OS ABIs.  */
@@ -1516,6 +1642,9 @@ mips_linux_init_abi (struct gdbarch_info info,
   set_gdbarch_gdb_signal_from_target (gdbarch,
 				      mips_gdb_signal_from_target);
 
+  set_gdbarch_gdb_signal_to_target (gdbarch,
+				    mips_gdb_signal_to_target);
+
   tdep->syscall_next_pc = mips_linux_syscall_next_pc;
 
   if (tdesc_data)
diff --git a/gdb/mips-linux-tdep.h b/gdb/mips-linux-tdep.h
index 09cbc13..482d3c5 100644
--- a/gdb/mips-linux-tdep.h
+++ b/gdb/mips-linux-tdep.h
@@ -105,45 +105,3 @@ enum {
 /* Return 1 if MIPS_RESTART_REGNUM is usable.  */
 
 int mips_linux_restart_reg_p (struct gdbarch *gdbarch);
-
-/* MIPS Signals -- adapted from linux/arch/mips/include/asm/signal.h.  */
-
-enum mips_signals 
-  {
-    MIPS_SIGHUP    =  1,	/* Hangup (POSIX).  */
-    MIPS_SIGINT    =  2,	/* Interrupt (ANSI).  */
-    MIPS_SIGQUIT   =  3,	/* Quit (POSIX).  */
-    MIPS_SIGILL    =  4,	/* Illegal instruction (ANSI).  */
-    MIPS_SIGTRAP   =  5,	/* Trace trap (POSIX).  */
-    MIPS_SIGIOT    =  6,	/* IOT trap (4.2 BSD).  */
-    MIPS_SIGABRT   =  MIPS_SIGIOT, /* Abort (ANSI).  */
-    MIPS_SIGEMT    =  7,
-    MIPS_SIGFPE    =  8,	/* Floating-point exception (ANSI).  */
-    MIPS_SIGKILL   =  9,	/* Kill, unblockable (POSIX).  */
-    MIPS_SIGBUS    = 10,	/* BUS error (4.2 BSD).  */
-    MIPS_SIGSEGV   = 11,	/* Segmentation violation (ANSI).  */
-    MIPS_SIGSYS    = 12,
-    MIPS_SIGPIPE   = 13,	/* Broken pipe (POSIX).  */
-    MIPS_SIGALRM   = 14,	/* Alarm clock (POSIX).  */
-    MIPS_SIGTERM   = 15,	/* Termination (ANSI).  */
-    MIPS_SIGUSR1   = 16,	/* User-defined signal 1 (POSIX).  */
-    MIPS_SIGUSR2   = 17,	/* User-defined signal 2 (POSIX).  */
-    MIPS_SIGCHLD   = 18,	/* Child status has changed (POSIX).  */
-    MIPS_SIGCLD    = MIPS_SIGCHLD, /* Same as SIGCHLD (System V).  */
-    MIPS_SIGPWR    = 19,	/* Power failure restart (System V).  */
-    MIPS_SIGWINCH  = 20,	/* Window size change (4.3 BSD, Sun).  */
-    MIPS_SIGURG    = 21,	/* Urgent condition on socket (4.2 BSD).  */
-    MIPS_SIGIO     = 22,	/* I/O now possible (4.2 BSD).  */
-    MIPS_SIGPOLL   = MIPS_SIGIO, /* Pollable event occurred (System V).  */
-    MIPS_SIGSTOP   = 23,	/* Stop, unblockable (POSIX).  */
-    MIPS_SIGTSTP   = 24,	/* Keyboard stop (POSIX).  */
-    MIPS_SIGCONT   = 25,	/* Continue (POSIX).  */
-    MIPS_SIGTTIN   = 26,	/* Background read from tty (POSIX).  */
-    MIPS_SIGTTOU   = 27,	/* Background write to tty (POSIX).  */
-    MIPS_SIGVTALRM = 28,	/* Virtual alarm clock (4.2 BSD).  */
-    MIPS_SIGPROF   = 29,	/* Profiling alarm clock (4.2 BSD).  */
-    MIPS_SIGXCPU   = 30,	/* CPU limit exceeded (4.2 BSD).  */
-    MIPS_SIGXFSZ   = 31,	/* File size limit exceeded (4.2 BSD).  */
-    MIPS_SIGRTMIN  = 32,	/* Minimum RT signal.  */
-    MIPS_SIGRTMAX  = 128 - 1	/* Maximum RT signal.  */
-  };
-- 
1.7.11.7


  parent reply	other threads:[~2013-07-26 20:13 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-26 20:13 [PATCH 0/7] Implement gdbarch_gdb_signal_{to,from}_target Sergio Durigan Junior
2013-07-26 20:13 ` [PATCH 1/7] Implement the gdbarch.{sh,c,h} bits Sergio Durigan Junior
2013-07-26 20:13 ` [PATCH 2/7] Linux kernel generic support Sergio Durigan Junior
2013-07-26 20:13 ` [PATCH 6/7] Xtensa support Sergio Durigan Junior
2013-07-26 20:13 ` [PATCH 3/7] Alpha support Sergio Durigan Junior
2013-07-29 16:44   ` Pedro Alves
2013-08-07 21:09     ` Sergio Durigan Junior
2013-08-08 15:44       ` Pedro Alves
2013-07-26 20:13 ` Sergio Durigan Junior [this message]
2013-07-27 17:22   ` [PATCH 7/7] MIPS support Doug Evans
2013-08-07 21:02     ` Sergio Durigan Junior
2013-07-26 20:13 ` [PATCH 5/7] SPARC support Sergio Durigan Junior
2013-07-27 17:13   ` Doug Evans
2013-08-07 21:03     ` Sergio Durigan Junior
2013-07-26 20:13 ` [PATCH 4/7] AVR support Sergio Durigan Junior
2013-07-27 17:10   ` Doug Evans
2013-08-07 21:03     ` Sergio Durigan Junior
2013-07-27 17:57 ` [PATCH 0/7] Implement gdbarch_gdb_signal_{to,from}_target Doug Evans
2013-08-07 20:54   ` Sergio Durigan Junior
2013-07-29 16:43 ` Pedro Alves
2013-08-09 16:56 ` Sergio Durigan Junior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1374869594-16965-8-git-send-email-sergiodj@redhat.com \
    --to=sergiodj@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox