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

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