Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Michael Eager <eager@eagerm.com>
To: "Maciej W. Rozycki" <macro@codesourcery.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
	 Pedro Alves <palves@redhat.com>
Subject: Re: [PATCH] MIPS Linux signals
Date: Fri, 01 Jun 2012 22:52:00 -0000	[thread overview]
Message-ID: <4FC947AE.2000008@eagerm.com> (raw)
In-Reply-To: <alpine.DEB.1.10.1206012135180.11227@tp.orcam.me.uk>

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

On 06/01/2012 01:53 PM, Maciej W. Rozycki wrote:
> Hi Michael,
>
>> This patch adds a target function to translate MIPS Linux signals
>> to GDB internal signal numbers.
>>
>> 2012-06-01  Michael Eager<eager@eagercon.com>
>>
>>   	* mips-linux-tdep.c (mips_gdb_signal_from_target): New
>>   	* mips-linux-tdep.h (mips_signals): New
>
>   Thanks, please make a unified diff (`diff -up') next time.  Further notes
> below.

Revised patch attached.

Some of the awkward code in translating REALTIME signals is due to
the fact that the GDB_SIGNAL_REALTIME block is not contiguous.

I recast the section of code copied from signals.c in terms of
MIPS_SIGRTMIN & MIPS_SIGRTMAX, but it isn't clear to me that this
is an improvement, since it is now different from the similar code
in signals.c.

-- 
Michael Eager	 eager@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077

[-- Attachment #2: mips.patch --]
[-- Type: text/x-patch, Size: 6800 bytes --]

Index: gdb/ChangeLog
===================================================================
RCS file: /cvs/src/src/gdb/ChangeLog,v
retrieving revision 1.14309
diff -u -p -r1.14309 ChangeLog
--- gdb/ChangeLog	1 Jun 2012 16:37:56 -0000	1.14309
+++ gdb/ChangeLog	1 Jun 2012 22:43:51 -0000
@@ -1,3 +1,8 @@
+2012-06-01  Michael Eager  <eager@eagercon.com>
+
+	* mips-linux-tdep.c (mips_gdb_signal_from_target): New
+	* mips-linux-tdep.h (mips_signals): New
+
 2012-06-01  Siddhesh Poyarekar  <siddhesh@redhat.com>
 
 	* target.c (target_read_memory): Make LEN argument as size_t.
Index: gdb/mips-linux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mips-linux-tdep.c,v
retrieving revision 1.94
diff -u -p -r1.94 mips-linux-tdep.c
--- gdb/mips-linux-tdep.c	22 May 2012 17:12:07 -0000	1.94
+++ gdb/mips-linux-tdep.c	1 Jun 2012 22:43:51 -0000
@@ -40,6 +40,7 @@
 #include "glibc-tdep.h"
 #include "linux-tdep.h"
 #include "xml-syscall.h"
+#include "gdb_signals.h"
 
 static struct target_so_ops mips_svr4_so_ops;
 
@@ -1330,6 +1331,98 @@ mips_linux_get_syscall_number (struct gd
   return ret;
 }
 
+/* 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)
+{
+  switch (signo) 
+    {
+    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:
+      return GDB_SIGNAL_EMT;
+    case MIPS_SIGFPE:
+      return GDB_SIGNAL_FPE;
+    case MIPS_SIGKILL:
+      return GDB_SIGNAL_KILL;
+    case MIPS_SIGBUS:
+      return GDB_SIGNAL_BUS;
+    case MIPS_SIGSEGV:
+      return GDB_SIGNAL_SEGV;
+    case MIPS_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:
+      return GDB_SIGNAL_USR1;
+    case MIPS_SIGUSR2:
+      return GDB_SIGNAL_USR2;
+    case MIPS_SIGCHLD:
+      return GDB_SIGNAL_CHLD;
+    case MIPS_SIGPWR:
+      return GDB_SIGNAL_PWR;
+    case MIPS_SIGWINCH:
+      return GDB_SIGNAL_WINCH;
+    case MIPS_SIGURG:
+      return GDB_SIGNAL_URG;
+    case MIPS_SIGPOLL:
+      return GDB_SIGNAL_POLL;
+    case MIPS_SIGSTOP:
+      return GDB_SIGNAL_STOP;
+    case MIPS_SIGTSTP:
+      return GDB_SIGNAL_TSTP;
+    case MIPS_SIGCONT:
+      return GDB_SIGNAL_CONT;
+    case MIPS_SIGTTIN:
+      return GDB_SIGNAL_TTIN;
+    case MIPS_SIGTTOU:
+      return GDB_SIGNAL_TTOU;
+    case MIPS_SIGVTALRM:
+      return GDB_SIGNAL_VTALRM;
+    case MIPS_SIGPROF:
+      return GDB_SIGNAL_PROF;
+    case MIPS_SIGXCPU:
+      return GDB_SIGNAL_XCPU;
+    case MIPS_SIGXFSZ:
+      return GDB_SIGNAL_XFSZ;
+  }
+
+  if (signo >= MIPS_SIGRTMIN && signo <= MIPS_SIGRTMAX)
+    {
+      /* This block of GDB_SIGNAL_REALTIME value is in order.  */
+      if (MIPS_SIGRTMIN <= signo && signo <= (MIPS_SIGRTMIN + 32))
+	return ((enum gdb_signal)
+		(signo - MIPS_SIGRTMIN + 1 + (int) GDB_SIGNAL_REALTIME_33));
+      else if (signo == MIPS_SIGRTMIN)
+	return GDB_SIGNAL_REALTIME_32;
+      else if ((MIPS_SIGRTMIN + 32) <= signo && signo <= MIPS_SIGRTMAX)
+	return ((enum gdb_signal)
+		(signo - (MIPS_SIGRTMIN + 32) + (int) GDB_SIGNAL_REALTIME_64));
+      else
+	error ("GDB bug: unrecognized real-time signal");
+    }
+
+  return GDB_SIGNAL_UNKNOWN;
+}
+
 /* Initialize one of the GNU/Linux OS ABIs.  */
 
 static void
@@ -1414,6 +1507,9 @@ mips_linux_init_abi (struct gdbarch_info
   set_gdbarch_regset_from_core_section (gdbarch,
 					mips_linux_regset_from_core_section);
 
+  set_gdbarch_gdb_signal_from_target (gdbarch,
+				      mips_gdb_signal_from_target);
+
   tdep->syscall_next_pc = mips_linux_syscall_next_pc;
 
   if (tdesc_data)
Index: gdb/mips-linux-tdep.h
===================================================================
RCS file: /cvs/src/src/gdb/mips-linux-tdep.h,v
retrieving revision 1.13
diff -u -p -r1.13 mips-linux-tdep.h
--- gdb/mips-linux-tdep.h	1 Mar 2012 22:19:45 -0000	1.13
+++ gdb/mips-linux-tdep.h	1 Jun 2012 22:43:51 -0000
@@ -105,3 +105,45 @@ 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.  */
+  };

  parent reply	other threads:[~2012-06-01 22:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-01 20:21 Michael Eager
2012-06-01 20:53 ` Maciej W. Rozycki
2012-06-01 21:07   ` Michael Eager
2012-06-04 15:49     ` Pedro Alves
2012-06-04 16:26       ` [PATCH 2/2] Make gdbarch_gdb_signal_from_target a method with predicate Pedro Alves
2012-06-04 16:26       ` [PATCH 1/2] gdbarch_gdb_signal_from_target: Mention host independence Pedro Alves
2012-06-01 22:52   ` Michael Eager [this message]
2012-06-06 22:52     ` [PATCH] MIPS Linux signals Maciej W. Rozycki
2012-06-06 23:12       ` Michael Eager
2012-06-11 16:09       ` Michael Eager

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=4FC947AE.2000008@eagerm.com \
    --to=eager@eagerm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=macro@codesourcery.com \
    --cc=palves@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