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

2c2fa1
From feea5f36a9dd65a0ff279c71744423c419b77ada Mon Sep 17 00:00:00 2001
2c2fa1
From: Andreas Arnez <arnez@linux.vnet.ibm.com>
2c2fa1
Date: Fri, 12 Dec 2014 14:14:21 +0100
2c2fa1
Subject: [PATCH 8/9] gdbserver: Support read-only regsets in linux-low.c
2c2fa1
2c2fa1
For GNU/Linux targets using the regsets interface, this change
2c2fa1
supports regsets that can be read but not written.  The S390 "last
2c2fa1
break" regset is an example.  So far it had been defined with
2c2fa1
regset->set_request == PTRACE_GETREGSET, such that the respective
2c2fa1
ptrace call does not cause any harm.  Now we just skip the whole
2c2fa1
read/modify/write sequence for regsets that do not define a
2c2fa1
fill_function.
2c2fa1
2c2fa1
gdb/gdbserver/ChangeLog:
2c2fa1
2c2fa1
	* linux-low.c (regsets_store_inferior_registers): Skip regsets
2c2fa1
	without a fill_function.
2c2fa1
	* linux-s390-low.c (s390_fill_last_break): Remove.
2c2fa1
	(s390_regsets): Set fill_function to NULL for NT_S390_LAST_BREAK.
2c2fa1
	(s390_arch_setup): Use regset's size instead of fill_function for
2c2fa1
	loop end condition.
2c2fa1
---
2c2fa1
 gdb/gdbserver/ChangeLog        |  9 +++++++++
2c2fa1
 gdb/gdbserver/linux-low.c      |  3 ++-
2c2fa1
 gdb/gdbserver/linux-s390-low.c | 14 ++++----------
2c2fa1
 3 files changed, 15 insertions(+), 11 deletions(-)
2c2fa1
2c2fa1
Index: gdb-7.6.1/gdb/gdbserver/linux-low.c
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.1.orig/gdb/gdbserver/linux-low.c
2c2fa1
+++ gdb-7.6.1/gdb/gdbserver/linux-low.c
2c2fa1
@@ -4120,7 +4120,8 @@ regsets_store_inferior_registers (struct
2c2fa1
       void *buf, *data;
2c2fa1
       int nt_type, res;
2c2fa1
 
2c2fa1
-      if (regset->size == 0 || disabled_regsets[regset - target_regsets])
2c2fa1
+      if (regset->size == 0 || disabled_regsets[regset - target_regsets]
2c2fa1
+	  || regset->fill_function == NULL)
2c2fa1
 	{
2c2fa1
 	  regset ++;
2c2fa1
 	  continue;
2c2fa1
Index: gdb-7.6.1/gdb/gdbserver/linux-s390-low.c
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.1.orig/gdb/gdbserver/linux-s390-low.c
2c2fa1
+++ gdb-7.6.1/gdb/gdbserver/linux-s390-low.c
2c2fa1
@@ -264,12 +264,6 @@ static void s390_fill_gregset (struct re
2c2fa1
 /* Fill and store functions for extended register sets.  */
2c2fa1
 
2c2fa1
 static void
2c2fa1
-s390_fill_last_break (struct regcache *regcache, void *buf)
2c2fa1
-{
2c2fa1
-  /* Last break address is read-only.  */
2c2fa1
-}
2c2fa1
-
2c2fa1
-static void
2c2fa1
 s390_store_last_break (struct regcache *regcache, const void *buf)
2c2fa1
 {
2c2fa1
   supply_register_by_name (regcache, "last_break",
2c2fa1
@@ -290,9 +284,9 @@ s390_store_system_call (struct regcache
2c2fa1
 
2c2fa1
 struct regset_info target_regsets[] = {
2c2fa1
   { 0, 0, 0, 0, GENERAL_REGS, s390_fill_gregset, NULL },
2c2fa1
-  /* Last break address is read-only; do not attempt PTRACE_SETREGSET.  */
2c2fa1
-  { PTRACE_GETREGSET, PTRACE_GETREGSET, NT_S390_LAST_BREAK, 0,
2c2fa1
-    EXTENDED_REGS, s390_fill_last_break, s390_store_last_break },
2c2fa1
+  /* Last break address is read-only; no fill function.  */
2c2fa1
+  { PTRACE_GETREGSET, -1, NT_S390_LAST_BREAK, 0, EXTENDED_REGS,
2c2fa1
+    NULL, s390_store_last_break },
2c2fa1
   { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_S390_SYSTEM_CALL, 0,
2c2fa1
     EXTENDED_REGS, s390_fill_system_call, s390_store_system_call },
2c2fa1
   { 0, 0, 0, -1, -1, NULL, NULL }
2c2fa1
@@ -454,7 +448,7 @@ s390_arch_setup (void)
2c2fa1
   }
2c2fa1
 #endif
2c2fa1
   /* Update target_regsets according to available register sets.  */
2c2fa1
-  for (regset = target_regsets; regset->fill_function != NULL; regset++)
2c2fa1
+  for (regset = target_regsets; regset->size >= 0; regset++)
2c2fa1
     if (regset->get_request == PTRACE_GETREGSET)
2c2fa1
       switch (regset->nt_type)
2c2fa1
 	{