Blame SOURCES/gdb-rhbz1105165-ibm-tdb-support-system-z-7of9.patch

01917d
From e5a9158d093d53f2bb1057359ac381dcdf6d4305 Mon Sep 17 00:00:00 2001
01917d
From: Andreas Arnez <arnez@linux.vnet.ibm.com>
01917d
Date: Fri, 12 Dec 2014 14:14:21 +0100
01917d
Subject: [PATCH 9/9] S390: Fix gdbserver support for TDB
01917d
01917d
This makes gdbserver actually provide values for the TDB registers
01917d
when the inferior was stopped in a transaction.  The change in
01917d
linux-low.c is needed to suppress the warning for an unavailable TDB.
01917d
01917d
The test case 's390-tdbregs.exp' passes with this patch and fails
01917d
without.
01917d
01917d
gdb/gdbserver/ChangeLog:
01917d
01917d
	* linux-low.c (regsets_fetch_inferior_registers): Suppress the
01917d
	warning upon ENODATA from ptrace.
01917d
	* linux-s390-low.c (s390_store_tdb): New.
01917d
	(s390_regsets): Add regset for NT_S390_TDB.
01917d
---
01917d
 gdb/gdbserver/ChangeLog        |  7 +++++++
01917d
 gdb/gdbserver/linux-low.c      |  6 ++++++
01917d
 gdb/gdbserver/linux-s390-low.c | 17 +++++++++++++++++
01917d
 3 files changed, 30 insertions(+)
01917d
01917d
Index: gdb-7.6.1/gdb/gdbserver/linux-low.c
01917d
===================================================================
01917d
--- gdb-7.6.1.orig/gdb/gdbserver/linux-low.c
01917d
+++ gdb-7.6.1/gdb/gdbserver/linux-low.c
01917d
@@ -4183,6 +4183,12 @@ regsets_store_inferior_registers (struct
01917d
 	      free (buf);
01917d
 	      return 0;
01917d
 	    }
01917d
+	  else if (errno == ENODATA)
01917d
+	    {
01917d
+	      /* ENODATA may be returned if the regset is currently
01917d
+		 not "active".  This can happen in normal operation,
01917d
+		 so suppress the warning in this case.  */
01917d
+	    }
01917d
 	  else
01917d
 	    {
01917d
 	      perror ("Warning: ptrace(regsets_store_inferior_registers)");
01917d
Index: gdb-7.6.1/gdb/gdbserver/linux-s390-low.c
01917d
===================================================================
01917d
--- gdb-7.6.1.orig/gdb/gdbserver/linux-s390-low.c
01917d
+++ gdb-7.6.1/gdb/gdbserver/linux-s390-low.c
01917d
@@ -282,6 +282,20 @@ s390_store_system_call (struct regcache
01917d
   supply_register_by_name (regcache, "system_call", buf);
01917d
 }
01917d
 
01917d
+static void
01917d
+s390_store_tdb (struct regcache *regcache, const void *buf)
01917d
+{
01917d
+  int tdb0 = find_regno ("tdb0");
01917d
+  int tr0 = find_regno ("tr0");
01917d
+  int i;
01917d
+
01917d
+  for (i = 0; i < 4; i++)
01917d
+    supply_register (regcache, tdb0 + i, (const char *) buf + 8 * i);
01917d
+
01917d
+  for (i = 0; i < 16; i++)
01917d
+    supply_register (regcache, tr0 + i, (const char *) buf + 8 * (16 + i));
01917d
+}
01917d
+
01917d
 struct regset_info target_regsets[] = {
01917d
   { 0, 0, 0, 0, GENERAL_REGS, s390_fill_gregset, NULL },
01917d
   /* Last break address is read-only; no fill function.  */
01917d
@@ -289,6 +303,9 @@ struct regset_info target_regsets[] = {
01917d
     NULL, s390_store_last_break },
01917d
   { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_S390_SYSTEM_CALL, 0,
01917d
     EXTENDED_REGS, s390_fill_system_call, s390_store_system_call },
01917d
+  /* TDB is read-only.  */
01917d
+  { PTRACE_GETREGSET, -1, NT_S390_TDB, 0, EXTENDED_REGS,
01917d
+    NULL, s390_store_tdb },
01917d
   { 0, 0, 0, -1, -1, NULL, NULL }
01917d
 };
01917d