Blob Blame History Raw
From e5a9158d093d53f2bb1057359ac381dcdf6d4305 Mon Sep 17 00:00:00 2001
From: Andreas Arnez <arnez@linux.vnet.ibm.com>
Date: Fri, 12 Dec 2014 14:14:21 +0100
Subject: [PATCH 9/9] S390: Fix gdbserver support for TDB

This makes gdbserver actually provide values for the TDB registers
when the inferior was stopped in a transaction.  The change in
linux-low.c is needed to suppress the warning for an unavailable TDB.

The test case 's390-tdbregs.exp' passes with this patch and fails
without.

gdb/gdbserver/ChangeLog:

	* linux-low.c (regsets_fetch_inferior_registers): Suppress the
	warning upon ENODATA from ptrace.
	* linux-s390-low.c (s390_store_tdb): New.
	(s390_regsets): Add regset for NT_S390_TDB.
---
 gdb/gdbserver/ChangeLog        |  7 +++++++
 gdb/gdbserver/linux-low.c      |  6 ++++++
 gdb/gdbserver/linux-s390-low.c | 17 +++++++++++++++++
 3 files changed, 30 insertions(+)

Index: gdb-7.6.1/gdb/gdbserver/linux-low.c
===================================================================
--- gdb-7.6.1.orig/gdb/gdbserver/linux-low.c
+++ gdb-7.6.1/gdb/gdbserver/linux-low.c
@@ -4183,6 +4183,12 @@ regsets_store_inferior_registers (struct
 	      free (buf);
 	      return 0;
 	    }
+	  else if (errno == ENODATA)
+	    {
+	      /* ENODATA may be returned if the regset is currently
+		 not "active".  This can happen in normal operation,
+		 so suppress the warning in this case.  */
+	    }
 	  else
 	    {
 	      perror ("Warning: ptrace(regsets_store_inferior_registers)");
Index: gdb-7.6.1/gdb/gdbserver/linux-s390-low.c
===================================================================
--- gdb-7.6.1.orig/gdb/gdbserver/linux-s390-low.c
+++ gdb-7.6.1/gdb/gdbserver/linux-s390-low.c
@@ -282,6 +282,20 @@ s390_store_system_call (struct regcache
   supply_register_by_name (regcache, "system_call", buf);
 }
 
+static void
+s390_store_tdb (struct regcache *regcache, const void *buf)
+{
+  int tdb0 = find_regno ("tdb0");
+  int tr0 = find_regno ("tr0");
+  int i;
+
+  for (i = 0; i < 4; i++)
+    supply_register (regcache, tdb0 + i, (const char *) buf + 8 * i);
+
+  for (i = 0; i < 16; i++)
+    supply_register (regcache, tr0 + i, (const char *) buf + 8 * (16 + i));
+}
+
 struct regset_info target_regsets[] = {
   { 0, 0, 0, 0, GENERAL_REGS, s390_fill_gregset, NULL },
   /* Last break address is read-only; no fill function.  */
@@ -289,6 +303,9 @@ struct regset_info target_regsets[] = {
     NULL, s390_store_last_break },
   { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_S390_SYSTEM_CALL, 0,
     EXTENDED_REGS, s390_fill_system_call, s390_store_system_call },
+  /* TDB is read-only.  */
+  { PTRACE_GETREGSET, -1, NT_S390_TDB, 0, EXTENDED_REGS,
+    NULL, s390_store_tdb },
   { 0, 0, 0, -1, -1, NULL, NULL }
 };