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>
Subject: Re: [PATCH 02/17] Linux kernel generic support
Date: Mon, 01 Jul 2013 10:57:00 -0000	[thread overview]
Message-ID: <m3li5qpmyk.fsf@redhat.com> (raw)
In-Reply-To: <1372664545-3947-3-git-send-email-sergiodj@redhat.com> (Sergio	Durigan Junior's message of "Mon, 1 Jul 2013 04:42:10 -0300")

On Monday, July 01 2013, I wrote:

> This is, along with the gdbarch changes, the main patch of this series.
> It implements the generic converter between GDB's internal signals and
> x86 ones.

According to Andreas' and Pedro's comments, here is a new patch which
updates the comment on linux-tdep.c's enum definition.  The ChangeLog is
the same.

> 2013-07-01  Sergio Durigan Junior  <sergiodj@redhat.com>
>
> 	* linux-tdep.c: Define enum with x86 signal numbers.
> 	(linux_gdb_signal_to_target): New function.
> 	* linux-tdep.h (linux_gdb_signal_to_target): New prototype.

diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index bfb6404..ec39060 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -36,6 +36,63 @@
 
 #include <ctype.h>
 
+/* This enum represents the signals' numbers on a generic architecture
+   running the Linux kernel.  The definition of "generic" comes from
+   the file <include/uapi/asm-generic/signal.h>, from the Linux kernel
+   tree, which is the "de facto" implementation of signal numbers to
+   be used by new architecture ports.
+
+   For those architectures which have differences from the generic
+   standard (e.g., Alpha), we define the different signals (and *only*
+   those) in the specific target-dependent file (e.g.,
+   alpha-linux-tdep.c, for Alpha).  Please refer to the architecture's
+   tdep file for more information.
+
+   As stated above, this enum is derived from
+   <include/uapi/asm-generic/signal.h>, from the Linux kernel
+   tree.  */
+
+enum
+  {
+    LINUX_SIGHUP = 1,
+    LINUX_SIGINT = 2,
+    LINUX_SIGQUIT = 3,
+    LINUX_SIGILL = 4,
+    LINUX_SIGTRAP = 5,
+    LINUX_SIGABRT = 6,
+    LINUX_SIGIOT = 6,
+    LINUX_SIGBUS = 7,
+    LINUX_SIGFPE = 8,
+    LINUX_SIGKILL = 9,
+    LINUX_SIGUSR1 = 10,
+    LINUX_SIGSEGV = 11,
+    LINUX_SIGUSR2 = 12,
+    LINUX_SIGPIPE = 13,
+    LINUX_SIGALRM = 14,
+    LINUX_SIGTERM = 15,
+    LINUX_SIGSTKFLT = 16,
+    LINUX_SIGCHLD = 17,
+    LINUX_SIGCONT = 18,
+    LINUX_SIGSTOP = 19,
+    LINUX_SIGTSTP = 20,
+    LINUX_SIGTTIN = 21,
+    LINUX_SIGTTOU = 22,
+    LINUX_SIGURG = 23,
+    LINUX_SIGXCPU = 24,
+    LINUX_SIGXFSZ = 25,
+    LINUX_SIGVTALRM = 26,
+    LINUX_SIGPROF = 27,
+    LINUX_SIGWINCH = 28,
+    LINUX_SIGIO = 29,
+    LINUX_SIGPOLL = LINUX_SIGIO,
+    LINUX_SIGPWR = 30,
+    LINUX_SIGSYS = 31,
+    LINUX_SIGUNUSED = 31,
+
+    LINUX_SIGRTMIN = 32,
+    LINUX_SIGRTMAX = 64,
+  };
+
 static struct gdbarch_data *linux_gdbarch_data_handle;
 
 struct linux_gdbarch_data
@@ -1447,6 +1504,134 @@ linux_make_corefile_notes_1 (struct gdbarch *gdbarch, bfd *obfd, int *note_size)
 				      linux_collect_thread_registers);
 }
 
+/* Implementation of `gdbarch_gdb_signal_to_target', as defined in
+   gdbarch.h.  This function is not static because it is exported to
+   other -tdep files.  */
+
+int
+linux_gdb_signal_to_target (struct gdbarch *gdbarch,
+			    enum gdb_signal signal)
+{
+  switch (signal)
+    {
+    case GDB_SIGNAL_0:
+      return 0;
+
+    case GDB_SIGNAL_HUP:
+      return LINUX_SIGHUP;
+
+    case GDB_SIGNAL_INT:
+      return LINUX_SIGINT;
+
+    case GDB_SIGNAL_QUIT:
+      return LINUX_SIGQUIT;
+
+    case GDB_SIGNAL_ILL:
+      return LINUX_SIGILL;
+
+    case GDB_SIGNAL_TRAP:
+      return LINUX_SIGTRAP;
+
+    case GDB_SIGNAL_ABRT:
+      return LINUX_SIGABRT;
+
+    case GDB_SIGNAL_FPE:
+      return LINUX_SIGFPE;
+
+    case GDB_SIGNAL_KILL:
+      return LINUX_SIGKILL;
+
+    case GDB_SIGNAL_BUS:
+      return LINUX_SIGBUS;
+
+    case GDB_SIGNAL_SEGV:
+      return LINUX_SIGSEGV;
+
+    case GDB_SIGNAL_SYS:
+      return LINUX_SIGSYS;
+
+    case GDB_SIGNAL_PIPE:
+      return LINUX_SIGPIPE;
+
+    case GDB_SIGNAL_ALRM:
+      return LINUX_SIGALRM;
+
+    case GDB_SIGNAL_TERM:
+      return LINUX_SIGTERM;
+
+    case GDB_SIGNAL_URG:
+      return LINUX_SIGURG;
+
+    case GDB_SIGNAL_STOP:
+      return LINUX_SIGSTOP;
+
+    case GDB_SIGNAL_TSTP:
+      return LINUX_SIGTSTP;
+
+    case GDB_SIGNAL_CONT:
+      return LINUX_SIGCONT;
+
+    case GDB_SIGNAL_CHLD:
+      return LINUX_SIGCHLD;
+
+    case GDB_SIGNAL_TTIN:
+      return LINUX_SIGTTIN;
+
+    case GDB_SIGNAL_TTOU:
+      return LINUX_SIGTTOU;
+
+    case GDB_SIGNAL_IO:
+      return LINUX_SIGIO;
+
+    case GDB_SIGNAL_XCPU:
+      return LINUX_SIGXCPU;
+
+    case GDB_SIGNAL_XFSZ:
+      return LINUX_SIGXFSZ;
+
+    case GDB_SIGNAL_VTALRM:
+      return LINUX_SIGVTALRM;
+
+    case GDB_SIGNAL_PROF:
+      return LINUX_SIGPROF;
+
+    case GDB_SIGNAL_WINCH:
+      return LINUX_SIGWINCH;
+
+    case GDB_SIGNAL_USR1:
+      return LINUX_SIGUSR1;
+
+    case GDB_SIGNAL_USR2:
+      return LINUX_SIGUSR2;
+
+    case GDB_SIGNAL_PWR:
+      return LINUX_SIGPWR;
+
+    case GDB_SIGNAL_POLL:
+      return LINUX_SIGPOLL;
+
+    /* GDB_SIGNAL_REALTIME_32 is not continuous in <gdb/signals.def>,
+       therefore we have to handle it here.  */
+    case GDB_SIGNAL_REALTIME_32:
+      return LINUX_SIGRTMIN;
+
+    /* Same comment applies to _64.  */
+    case GDB_SIGNAL_REALTIME_64:
+      return LINUX_SIGRTMAX;
+    }
+
+  /* GDB_SIGNAL_REALTIME_33 to _64 are continuous.  */
+  if (signal >= GDB_SIGNAL_REALTIME_33
+      && signal <= GDB_SIGNAL_REALTIME_63)
+    {
+      int offset = signal - GDB_SIGNAL_REALTIME_33;
+
+      return LINUX_SIGRTMIN + 1 + offset;
+    }
+
+  return -1;
+}
+
 /* To be called from the various GDB_OSABI_LINUX handlers for the
    various GNU/Linux architectures and machine types.  */
 
diff --git a/gdb/linux-tdep.h b/gdb/linux-tdep.h
index 380507e..c1d80de 100644
--- a/gdb/linux-tdep.h
+++ b/gdb/linux-tdep.h
@@ -34,6 +34,9 @@ char *linux_make_corefile_notes (struct gdbarch *, bfd *, int *,
 
 struct type *linux_get_siginfo_type (struct gdbarch *);
 
+extern int linux_gdb_signal_to_target (struct gdbarch *gdbarch,
+				       enum gdb_signal signal);
+
 extern void linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch);
 
 #endif /* linux-tdep.h */


  reply	other threads:[~2013-07-01 10:57 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-01  7:43 [PATCH 00/17] Implement gdbarch_gdb_signal_to_target Sergio Durigan Junior
2013-07-01  7:43 ` [PATCH 07/17] Cris support Sergio Durigan Junior
2013-07-01  7:43 ` [PATCH 16/17] Xtensa support Sergio Durigan Junior
2013-07-01  7:43 ` [PATCH 04/17] x86_64 support Sergio Durigan Junior
2013-07-17 17:16   ` Tom Tromey
2013-07-17 19:00     ` Mark Kettenis
2013-07-17 19:11     ` Sergio Durigan Junior
2013-07-01  7:43 ` [PATCH 06/17] AVR support Sergio Durigan Junior
2013-07-01  7:43 ` [PATCH 03/17] Alpha support Sergio Durigan Junior
2013-07-01  7:43 ` [PATCH 17/17] MIPS support Sergio Durigan Junior
2013-07-17 17:59   ` Tom Tromey
2013-07-25  6:20     ` Sergio Durigan Junior
2013-07-29 20:15       ` Pedro Alves
2013-07-01  7:43 ` [PATCH 12/17] m68klinux support Sergio Durigan Junior
2013-07-01  7:43 ` [PATCH 01/17] Implement the gdbarch.{sh,c,h} bits Sergio Durigan Junior
2013-07-01  7:43 ` [PATCH 09/17] i386 support Sergio Durigan Junior
2013-07-01  7:43 ` [PATCH 15/17] SPARC support Sergio Durigan Junior
2013-07-01  7:43 ` [PATCH 08/17] h8300 support Sergio Durigan Junior
2013-07-01  7:43 ` [PATCH 13/17] mn10300 support Sergio Durigan Junior
2013-07-01  7:43 ` [PATCH 14/17] s390 support Sergio Durigan Junior
2013-07-01  7:43 ` [PATCH 11/17] m32r support Sergio Durigan Junior
2013-07-01  7:43 ` [PATCH 02/17] Linux kernel generic support Sergio Durigan Junior
2013-07-01 10:57   ` Sergio Durigan Junior [this message]
2013-07-01  7:43 ` [PATCH 10/17] IA-64 support Sergio Durigan Junior
2013-07-01  7:43 ` [PATCH 05/17] ARM support Sergio Durigan Junior
2013-07-17 17:20   ` Tom Tromey
2013-07-25  6:25     ` Sergio Durigan Junior
2013-07-01  8:43 ` [PATCH 00/17] Implement gdbarch_gdb_signal_to_target Andreas Schwab
2013-07-01 10:40   ` Sergio Durigan Junior
2013-07-01 10:44     ` Pedro Alves
2013-07-01 10:59       ` Sergio Durigan Junior
2013-07-01 10:46 ` [PATCH 18/18] AArch64 support Sergio Durigan Junior
2013-07-08 23:08 ` [ping][PATCH 00/17] Implement gdbarch_gdb_signal_to_target Sergio Durigan Junior
2013-07-17 18:02 ` [PATCH " Tom Tromey

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=m3li5qpmyk.fsf@redhat.com \
    --to=sergiodj@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /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