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>
Subject: [PATCH 02/17] Linux kernel generic support
Date: Mon, 01 Jul 2013 07:43:00 -0000	[thread overview]
Message-ID: <1372664545-3947-3-git-send-email-sergiodj@redhat.com> (raw)
In-Reply-To: <1372664545-3947-1-git-send-email-sergiodj@redhat.com>

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.

It defines the full enum containing all x86 signals (as defined in
arch/x86/include/uapi/asm/signal.h, on the Linux kernel), and the
"generic" linux_gdb_signal_to_target, which is then exported to all
-tdep files.  This function will be used when (a) the target shares all
the signal numbers with x86 (thus, it is totally x86-compatible), or (b)
when the target shares some signal numbers with x86.  In the latter
case, the target is responsible for converting the different signals.

I have chosen x86 as the main source because it seems the de facto
implementation, and because it was easier for me.

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.
---
 gdb/linux-tdep.c | 182 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gdb/linux-tdep.h |   3 +
 2 files changed, 185 insertions(+)

diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index bfb6404..ecdba85 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -36,6 +36,60 @@
 
 #include <ctype.h>
 
+/* This enum represents the signals' numbers on a generic architecture
+   running the Linux kernel.  By "generic" we actually mean
+   "x86-compatible", since most architectures supported by this kernel
+   borrow the signals' numbers from x86.
+
+   For those architectures which are not compatible with x86 signals (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.
+
+   This enum is derived from the file
+   <arch/x86/include/uapi/asm/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 +1501,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 */
-- 
1.7.11.7


  parent reply	other threads:[~2013-07-01  7:43 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 16/17] Xtensa support Sergio Durigan Junior
2013-07-01  7:43 ` [PATCH 07/17] Cris 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 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 09/17] i386 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 10/17] IA-64 support Sergio Durigan Junior
2013-07-01  7:43 ` Sergio Durigan Junior [this message]
2013-07-01 10:57   ` [PATCH 02/17] Linux kernel generic 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=1372664545-3947-3-git-send-email-sergiodj@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