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

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