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

01917d
commit 2492f0d005f0390eabb3deb58aa7db7fcd716763
01917d
Author: Andreas Arnez <arnez@linux.vnet.ibm.com>
01917d
Date:   Fri May 8 12:50:47 2015 +0200
01917d
01917d
    S390: Fix for inadvertently setting 24-bit mode in fill_gregset
01917d
    
01917d
    On 64-bit S390 platforms, for programs compiled with -m31, it could
01917d
    happen that GDB inadvertently cleared the inferior's 31-bit addressing
01917d
    mode bit and left the inferior running in 24-bit addressing mode.  In
01917d
    particular this occurred with checkpoint.exp, when the "restore"
01917d
    command needed to create a new regcache copy: At the time when the
01917d
    PSWM register was copied over, the addressing mode bit was taken from
01917d
    the PSWA register, which was still zero since it had not been copied
01917d
    yet.  And when the PSWA register was copied, the addressing mode was
01917d
    not updated again.
01917d
    
01917d
    The fix affects fill_gregset, where the bits "belonging" to each of
01917d
    the PSWA and PSWM registers are now carefully separated.  The
01917d
    addressing mode bit is no longer touched when writing PSWM, and --
01917d
    more importantly -- it *is* written when writing PSWA.
01917d
    
01917d
    gdb/ChangeLog:
01917d
    
01917d
    	* s390-linux-nat.c (fill_gregset): Avoid relying on the PSWA
01917d
    	register in the regcache when treating the PSWM register, and vice
01917d
    	versa.
01917d
01917d
Index: gdb-7.6.1/gdb/s390-nat.c
01917d
===================================================================
01917d
--- gdb-7.6.1.orig/gdb/s390-nat.c
01917d
+++ gdb-7.6.1/gdb/s390-nat.c
01917d
@@ -174,19 +174,28 @@ fill_gregset (const struct regcache *reg
01917d
 	  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
01917d
 	  ULONGEST pswa, pswm;
01917d
 	  gdb_byte buf[4];
01917d
+	  gdb_byte *pswm_p = (gdb_byte *) regp + 0;
01917d
+	  gdb_byte *pswa_p = (gdb_byte *) regp + 8;
01917d
 
01917d
-	  regcache_raw_collect (regcache, S390_PSWM_REGNUM, buf);
01917d
-	  pswm = extract_unsigned_integer (buf, 4, byte_order);
01917d
-	  regcache_raw_collect (regcache, S390_PSWA_REGNUM, buf);
01917d
-	  pswa = extract_unsigned_integer (buf, 4, byte_order);
01917d
+	  pswm = extract_unsigned_integer (pswm_p, 8, byte_order);
01917d
 
01917d
 	  if (regno == -1 || regno == S390_PSWM_REGNUM)
01917d
-	    store_unsigned_integer (psw_p[0], 8, byte_order,
01917d
-				    ((pswm & 0xfff7ffff) << 32) |
01917d
-				    (pswa & 0x80000000));
01917d
+	    {
01917d
+	      pswm &= 0x80000000;
01917d
+	      regcache_raw_collect (regcache, S390_PSWM_REGNUM, buf);
01917d
+	      pswm |= (extract_unsigned_integer (buf, 4, byte_order)
01917d
+		       & 0xfff7ffff) << 32;
01917d
+	    }
01917d
 	  if (regno == -1 || regno == S390_PSWA_REGNUM)
01917d
-	    store_unsigned_integer (psw_p[1], 8, byte_order,
01917d
-				    pswa & 0x7fffffff);
01917d
+	    {
01917d
+	      regcache_raw_collect (regcache, S390_PSWA_REGNUM, buf);
01917d
+	      pswa = extract_unsigned_integer (buf, 4, byte_order);
01917d
+	      pswm ^= (pswm ^ pswa) & 0x80000000;
01917d
+	      pswa &= 0x7fffffff;
01917d
+	      store_unsigned_integer (pswa_p, 8, byte_order, pswa);
01917d
+	    }
01917d
+
01917d
+	  store_unsigned_integer (pswm_p, 8, byte_order, pswm);
01917d
 	}
01917d
       return;
01917d
     }