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

2c2fa1
From 6682d9595ed8d9b9bba5470bfd7fd1ccd378f19a Mon Sep 17 00:00:00 2001
2c2fa1
From: Andreas Arnez <arnez at linux dot vnet dot ibm dot com>
2c2fa1
Date: Tue, 5 Nov 2013 18:43:50 +0100
2c2fa1
Subject: [PATCH] S390: Fix TDB regset recognition
2c2fa1
2c2fa1
When checking for the presence of the TDB regset, the current code
2c2fa1
interprets ENODATA from PTRACE_GETREGSET as an indication that the TDB
2c2fa1
regset *could* occur on this system, but the inferior stopped outside
2c2fa1
a transaction.  However, the Linux kernel actually reports ENODATA
2c2fa1
even on systems without the transactional execution facility.  Thus
2c2fa1
the logic is now changed to check the TE field in the HWCAP as well.
2c2fa1
2c2fa1
This version also checks the existence of the TDB regset -- just to be
2c2fa1
on the safe side when running on TE-enabled hardware with a kernel
2c2fa1
that does not offer the TDB regset for some reason.
2c2fa1
2c2fa1
gdb/
2c2fa1
	* s390-linux-nat.c (s390_read_description): Consider the TE field
2c2fa1
	in the HWCAP for determining 'have_regset_tdb'.
2c2fa1
2c2fa1
gdbserver/
2c2fa1
	* linux-s390-low.c (HWCAP_S390_TE): New define.
2c2fa1
	(s390_arch_setup): Consider the TE field in the HWCAP for
2c2fa1
	determining 'have_regset_tdb'.
2c2fa1
---
2c2fa1
 gdb/ChangeLog                  |  5 +++++
2c2fa1
 gdb/gdbserver/ChangeLog        |  6 ++++++
2c2fa1
 gdb/gdbserver/linux-s390-low.c | 48 ++++++++++++++++++++++++++----------------
2c2fa1
 gdb/s390-linux-nat.c           |  5 +++--
2c2fa1
 4 files changed, 44 insertions(+), 20 deletions(-)
2c2fa1
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
@@ -32,6 +32,10 @@
2c2fa1
 #define HWCAP_S390_HIGH_GPRS 512
2c2fa1
 #endif
2c2fa1
 
2c2fa1
+#ifndef HWCAP_S390_TE
2c2fa1
+#define HWCAP_S390_TE 1024
2c2fa1
+#endif
2c2fa1
+
2c2fa1
 #ifndef PTRACE_GETREGSET
2c2fa1
 #define PTRACE_GETREGSET 0x4204
2c2fa1
 #endif
2c2fa1
@@ -390,23 +394,6 @@ s390_arch_setup (void)
2c2fa1
     = s390_check_regset (pid, NT_S390_SYSTEM_CALL, 4);
2c2fa1
   int have_regset_tdb = s390_check_regset (pid, NT_S390_TDB, 256);
2c2fa1
 
2c2fa1
-  /* Update target_regsets according to available register sets.  */
2c2fa1
-  for (regset = target_regsets; regset->fill_function != NULL; regset++)
2c2fa1
-    if (regset->get_request == PTRACE_GETREGSET)
2c2fa1
-      switch (regset->nt_type)
2c2fa1
-	{
2c2fa1
-	case NT_S390_LAST_BREAK:
2c2fa1
-	  regset->size = have_regset_last_break? 8 : 0;
2c2fa1
-	  break;
2c2fa1
-	case NT_S390_SYSTEM_CALL:
2c2fa1
-	  regset->size = have_regset_system_call? 4 : 0;
2c2fa1
-	  break;
2c2fa1
-	case NT_S390_TDB:
2c2fa1
-	  regset->size = have_regset_tdb ? 256 : 0;
2c2fa1
-	default:
2c2fa1
-	  break;
2c2fa1
-	}
2c2fa1
-
2c2fa1
   /* Assume 31-bit inferior process.  */
2c2fa1
   if (have_regset_system_call)
2c2fa1
     init_registers_s390_linux32v2 ();
2c2fa1
@@ -424,6 +411,7 @@ s390_arch_setup (void)
2c2fa1
   {
2c2fa1
     unsigned int pswm;
2c2fa1
     struct regcache *regcache = new_register_cache ();
2c2fa1
+
2c2fa1
     fetch_inferior_registers (regcache, find_regno ("pswm"));
2c2fa1
     collect_register_by_name (regcache, "pswm", &pswm);
2c2fa1
     free_register_cache (regcache);
2c2fa1
@@ -431,8 +419,12 @@ s390_arch_setup (void)
2c2fa1
     if (pswm & 1)
2c2fa1
       {
2c2fa1
 	if (have_regset_tdb)
2c2fa1
+	  have_regset_tdb =
2c2fa1
+	    (s390_get_hwcap () & HWCAP_S390_TE) != 0;
2c2fa1
+
2c2fa1
+	if (have_regset_tdb)
2c2fa1
 	  init_registers_s390x_te_linux64 ();
2c2fa1
-	if (have_regset_system_call)
2c2fa1
+	else if (have_regset_system_call)
2c2fa1
 	  init_registers_s390x_linux64v2 ();
2c2fa1
 	else if (have_regset_last_break)
2c2fa1
 	  init_registers_s390x_linux64v1 ();
2c2fa1
@@ -445,6 +437,9 @@ s390_arch_setup (void)
2c2fa1
     else if (s390_get_hwcap () & HWCAP_S390_HIGH_GPRS)
2c2fa1
       {
2c2fa1
 	if (have_regset_tdb)
2c2fa1
+	  have_regset_tdb = (s390_get_hwcap () & HWCAP_S390_TE) != 0;
2c2fa1
+
2c2fa1
+	if (have_regset_tdb)
2c2fa1
 	  init_registers_s390_te_linux64 ();
2c2fa1
 	if (have_regset_system_call)
2c2fa1
 	  init_registers_s390_linux64v2 ();
2c2fa1
@@ -458,6 +453,22 @@ s390_arch_setup (void)
2c2fa1
       }
2c2fa1
   }
2c2fa1
 #endif
2c2fa1
+  /* Update target_regsets according to available register sets.  */
2c2fa1
+  for (regset = target_regsets; regset->fill_function != NULL; regset++)
2c2fa1
+    if (regset->get_request == PTRACE_GETREGSET)
2c2fa1
+      switch (regset->nt_type)
2c2fa1
+	{
2c2fa1
+	case NT_S390_LAST_BREAK:
2c2fa1
+	  regset->size = have_regset_last_break? 8 : 0;
2c2fa1
+	  break;
2c2fa1
+	case NT_S390_SYSTEM_CALL:
2c2fa1
+	  regset->size = have_regset_system_call? 4 : 0;
2c2fa1
+	  break;
2c2fa1
+	case NT_S390_TDB:
2c2fa1
+	  regset->size = have_regset_tdb ? 256 : 0;
2c2fa1
+	default:
2c2fa1
+	  break;
2c2fa1
+	}
2c2fa1
 }
2c2fa1
 
2c2fa1
 
2c2fa1
Index: gdb-7.6.1/gdb/s390-nat.c
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.1.orig/gdb/s390-nat.c
2c2fa1
+++ gdb-7.6.1/gdb/s390-nat.c
2c2fa1
@@ -632,8 +632,6 @@ s390_read_description (struct target_ops
2c2fa1
     = check_regset (tid, NT_S390_LAST_BREAK, 8);
2c2fa1
   have_regset_system_call
2c2fa1
     = check_regset (tid, NT_S390_SYSTEM_CALL, 4);
2c2fa1
-  have_regset_tdb
2c2fa1
-    = check_regset (tid, NT_S390_TDB, s390_sizeof_tdbregset);
2c2fa1
 
2c2fa1
 #ifdef __s390x__
2c2fa1
   /* If GDB itself is compiled as 64-bit, we are running on a machine in
2c2fa1
@@ -642,6 +640,9 @@ s390_read_description (struct target_ops
2c2fa1
      addressing mode, but the kernel supports using 64-bit registers in
2c2fa1
      that mode, report s390 architecture with 64-bit GPRs.  */
2c2fa1
 
2c2fa1
+  have_regset_tdb = (s390_get_hwcap () & HWCAP_S390_TE) ?
2c2fa1
+    check_regset (tid, NT_S390_TDB, s390_sizeof_tdbregset) : 0;
2c2fa1
+
2c2fa1
   if (s390_target_wordsize () == 8)
2c2fa1
     return (have_regset_tdb ? tdesc_s390x_te_linux64 :
2c2fa1
 	    have_regset_system_call? tdesc_s390x_linux64v2 :