f524ac5
From: Fedora GDB patches <invalid@email.com>
f524ac5
Date: Fri, 27 Oct 2017 21:07:50 +0200
f524ac5
Subject: gdb-rhbz1420304-s390x-24of35.patch
f524ac5
f524ac5
FileName: gdb-rhbz1420304-s390x-24of35.patch
f524ac5
Jan Kratochvil 4f1de05
commit f236533e3c6a2693bea879b2a4d24d1229864ac9
Jan Kratochvil 4f1de05
Author: Andreas Arnez <arnez@linux.vnet.ibm.com>
Jan Kratochvil 4f1de05
Date:   Tue Jun 13 15:20:31 2017 +0200
Jan Kratochvil 4f1de05
Jan Kratochvil 4f1de05
    read/write_pieced_value: Remove unnecessary variable copies
Jan Kratochvil 4f1de05
    
Jan Kratochvil 4f1de05
    In read_pieced_value's main loop, the variables `dest_offset_bits' and
Jan Kratochvil 4f1de05
    `source_offset_bits' are basically just copies of `offset' and
Jan Kratochvil 4f1de05
    `bits_to_skip', respectively.  In write_pieced_value the copies are
Jan Kratochvil 4f1de05
    reversed.  This is not very helpful when trying to keep the logic between
Jan Kratochvil 4f1de05
    these functions in sync.  Since the copies are unnecessary, this patch
Jan Kratochvil 4f1de05
    just removes them.
Jan Kratochvil 4f1de05
    
Jan Kratochvil 4f1de05
    gdb/ChangeLog:
Jan Kratochvil 4f1de05
    
Jan Kratochvil 4f1de05
            * dwarf2loc.c (read_pieced_value): Remove unnecessary variables
Jan Kratochvil 4f1de05
            dest_offset_bits and source_offset_bits.
Jan Kratochvil 4f1de05
            (write_pieced_value): Likewise.
Jan Kratochvil 4f1de05
Jan Kratochvil 4f1de05
### a/gdb/ChangeLog
Jan Kratochvil 4f1de05
### b/gdb/ChangeLog
Jan Kratochvil 4f1de05
## -1,5 +1,11 @@
Jan Kratochvil 4f1de05
 2017-06-13  Andreas Arnez  <arnez@linux.vnet.ibm.com>
Jan Kratochvil 4f1de05
 
Jan Kratochvil 4f1de05
+	* dwarf2loc.c (read_pieced_value): Remove unnecessary variables
Jan Kratochvil 4f1de05
+	dest_offset_bits and source_offset_bits.
Jan Kratochvil 4f1de05
+	(write_pieced_value): Likewise.
Jan Kratochvil 4f1de05
+
Jan Kratochvil 4f1de05
+2017-06-13  Andreas Arnez  <arnez@linux.vnet.ibm.com>
Jan Kratochvil 4f1de05
+
Jan Kratochvil 4f1de05
 	* dwarf2loc.c (read_pieced_value): Respect the piece offset, as
Jan Kratochvil 4f1de05
 	given by DW_OP_bit_piece.
Jan Kratochvil 4f1de05
 	(write_pieced_value): Likewise.
Jan Kratochvil 4f1de05
--- a/gdb/dwarf2loc.c
Jan Kratochvil 4f1de05
+++ b/gdb/dwarf2loc.c
Jan Kratochvil 4f1de05
@@ -1790,25 +1790,16 @@ read_pieced_value (struct value *v)
Jan Kratochvil 4f1de05
   else
Jan Kratochvil 4f1de05
     max_offset = 8 * TYPE_LENGTH (value_type (v));
Jan Kratochvil 4f1de05
 
Jan Kratochvil 4f1de05
-  for (i = 0; i < c->n_pieces && offset < max_offset; i++)
Jan Kratochvil 4f1de05
+  /* Advance to the first non-skipped piece.  */
Jan Kratochvil 4f1de05
+  for (i = 0; i < c->n_pieces && bits_to_skip >= c->pieces[i].size; i++)
Jan Kratochvil 4f1de05
+    bits_to_skip -= c->pieces[i].size;
Jan Kratochvil 4f1de05
+
Jan Kratochvil 4f1de05
+  for (; i < c->n_pieces && offset < max_offset; i++)
Jan Kratochvil 4f1de05
     {
Jan Kratochvil 4f1de05
       struct dwarf_expr_piece *p = &c->pieces[i];
Jan Kratochvil 4f1de05
       size_t this_size, this_size_bits;
Jan Kratochvil 4f1de05
-      long dest_offset_bits, source_offset_bits;
Jan Kratochvil 4f1de05
-
Jan Kratochvil 4f1de05
-      /* Compute size, source, and destination offsets for copying, in
Jan Kratochvil 4f1de05
-	 bits.  */
Jan Kratochvil 4f1de05
-      this_size_bits = p->size;
Jan Kratochvil 4f1de05
-      if (bits_to_skip > 0 && bits_to_skip >= this_size_bits)
Jan Kratochvil 4f1de05
-	{
Jan Kratochvil 4f1de05
-	  bits_to_skip -= this_size_bits;
Jan Kratochvil 4f1de05
-	  continue;
Jan Kratochvil 4f1de05
-	}
Jan Kratochvil 4f1de05
-      source_offset_bits = bits_to_skip;
Jan Kratochvil 4f1de05
-      this_size_bits -= bits_to_skip;
Jan Kratochvil 4f1de05
-      bits_to_skip = 0;
Jan Kratochvil 4f1de05
-      dest_offset_bits = offset;
Jan Kratochvil 4f1de05
 
Jan Kratochvil 4f1de05
+      this_size_bits = p->size - bits_to_skip;
Jan Kratochvil 4f1de05
       if (this_size_bits > max_offset - offset)
Jan Kratochvil 4f1de05
 	this_size_bits = max_offset - offset;
Jan Kratochvil 4f1de05
 
Jan Kratochvil 4f1de05
@@ -1827,16 +1818,16 @@ read_pieced_value (struct value *v)
Jan Kratochvil 4f1de05
 		&& p->offset + p->size < reg_bits)
Jan Kratochvil 4f1de05
 	      {
Jan Kratochvil 4f1de05
 		/* Big-endian, and we want less than full size.  */
Jan Kratochvil 4f1de05
-		source_offset_bits += reg_bits - (p->offset + p->size);
Jan Kratochvil 4f1de05
+		bits_to_skip += reg_bits - (p->offset + p->size);
Jan Kratochvil 4f1de05
 	      }
Jan Kratochvil 4f1de05
 	    else
Jan Kratochvil 4f1de05
-	      source_offset_bits += p->offset;
Jan Kratochvil 4f1de05
+	      bits_to_skip += p->offset;
Jan Kratochvil 4f1de05
 
Jan Kratochvil 4f1de05
-	    this_size = bits_to_bytes (source_offset_bits, this_size_bits);
Jan Kratochvil 4f1de05
+	    this_size = bits_to_bytes (bits_to_skip, this_size_bits);
Jan Kratochvil 4f1de05
 	    buffer.reserve (this_size);
Jan Kratochvil 4f1de05
 
Jan Kratochvil 4f1de05
 	    if (!get_frame_register_bytes (frame, gdb_regnum,
Jan Kratochvil 4f1de05
-					   source_offset_bits / 8,
Jan Kratochvil 4f1de05
+					   bits_to_skip / 8,
Jan Kratochvil 4f1de05
 					   this_size, buffer.data (),
Jan Kratochvil 4f1de05
 					   &optim, &unavail))
Jan Kratochvil 4f1de05
 	      {
Jan Kratochvil 4f1de05
@@ -1846,24 +1837,23 @@ read_pieced_value (struct value *v)
Jan Kratochvil 4f1de05
 		  mark_value_bits_unavailable (v, offset, this_size_bits);
Jan Kratochvil 4f1de05
 		break;
Jan Kratochvil 4f1de05
 	      }
Jan Kratochvil 4f1de05
-
Jan Kratochvil 4f1de05
-	    copy_bitwise (contents, dest_offset_bits,
Jan Kratochvil 4f1de05
-			  buffer.data (), source_offset_bits % 8,
Jan Kratochvil 4f1de05
+	    copy_bitwise (contents, offset,
Jan Kratochvil 4f1de05
+			  buffer.data (), bits_to_skip % 8,
Jan Kratochvil 4f1de05
 			  this_size_bits, bits_big_endian);
Jan Kratochvil 4f1de05
 	  }
Jan Kratochvil 4f1de05
 	  break;
Jan Kratochvil 4f1de05
 
Jan Kratochvil 4f1de05
 	case DWARF_VALUE_MEMORY:
Jan Kratochvil 4f1de05
-	  source_offset_bits += p->offset;
Jan Kratochvil 4f1de05
-	  this_size = bits_to_bytes (source_offset_bits, this_size_bits);
Jan Kratochvil 4f1de05
+	  bits_to_skip += p->offset;
Jan Kratochvil 4f1de05
+	  this_size = bits_to_bytes (bits_to_skip, this_size_bits);
Jan Kratochvil 4f1de05
 	  buffer.reserve (this_size);
Jan Kratochvil 4f1de05
 
Jan Kratochvil 4f1de05
 	  read_value_memory (v, offset,
Jan Kratochvil 4f1de05
 			     p->v.mem.in_stack_memory,
Jan Kratochvil 4f1de05
-			     p->v.mem.addr + source_offset_bits / 8,
Jan Kratochvil 4f1de05
+			     p->v.mem.addr + bits_to_skip / 8,
Jan Kratochvil 4f1de05
 			     buffer.data (), this_size);
Jan Kratochvil 4f1de05
-	  copy_bitwise (contents, dest_offset_bits,
Jan Kratochvil 4f1de05
-			buffer.data (), source_offset_bits % 8,
Jan Kratochvil 4f1de05
+	  copy_bitwise (contents, offset,
Jan Kratochvil 4f1de05
+			buffer.data (), bits_to_skip % 8,
Jan Kratochvil 4f1de05
 			this_size_bits, bits_big_endian);
Jan Kratochvil 4f1de05
 	  break;
Jan Kratochvil 4f1de05
 
Jan Kratochvil 4f1de05
@@ -1880,14 +1870,13 @@ read_pieced_value (struct value *v)
Jan Kratochvil 4f1de05
 
Jan Kratochvil 4f1de05
 	    /* Piece is anchored at least significant bit end.  */
Jan Kratochvil 4f1de05
 	    if (gdbarch_byte_order (objfile_gdbarch) == BFD_ENDIAN_BIG)
Jan Kratochvil 4f1de05
-	      source_offset_bits += (stack_value_size_bits
Jan Kratochvil 4f1de05
-				     - p->offset - p->size);
Jan Kratochvil 4f1de05
+	      bits_to_skip += stack_value_size_bits - p->offset - p->size;
Jan Kratochvil 4f1de05
 	    else
Jan Kratochvil 4f1de05
-	      source_offset_bits += p->offset;
Jan Kratochvil 4f1de05
+	      bits_to_skip += p->offset;
Jan Kratochvil 4f1de05
 
Jan Kratochvil 4f1de05
-	    copy_bitwise (contents, dest_offset_bits,
Jan Kratochvil 4f1de05
+	    copy_bitwise (contents, offset,
Jan Kratochvil 4f1de05
 			  value_contents_all (p->v.value),
Jan Kratochvil 4f1de05
-			  source_offset_bits,
Jan Kratochvil 4f1de05
+			  bits_to_skip,
Jan Kratochvil 4f1de05
 			  this_size_bits, bits_big_endian);
Jan Kratochvil 4f1de05
 	  }
Jan Kratochvil 4f1de05
 	  break;
Jan Kratochvil 4f1de05
@@ -1898,14 +1887,14 @@ read_pieced_value (struct value *v)
Jan Kratochvil 4f1de05
 	    size_t n = this_size_bits;
Jan Kratochvil 4f1de05
 
Jan Kratochvil 4f1de05
 	    /* Cut off at the end of the implicit value.  */
Jan Kratochvil 4f1de05
-	    source_offset_bits += p->offset;
Jan Kratochvil 4f1de05
-	    if (source_offset_bits >= literal_size_bits)
Jan Kratochvil 4f1de05
+	    bits_to_skip += p->offset;
Jan Kratochvil 4f1de05
+	    if (bits_to_skip >= literal_size_bits)
Jan Kratochvil 4f1de05
 	      break;
Jan Kratochvil 4f1de05
-	    if (n > literal_size_bits - source_offset_bits)
Jan Kratochvil 4f1de05
-	      n = literal_size_bits - source_offset_bits;
Jan Kratochvil 4f1de05
+	    if (n > literal_size_bits - bits_to_skip)
Jan Kratochvil 4f1de05
+	      n = literal_size_bits - bits_to_skip;
Jan Kratochvil 4f1de05
 
Jan Kratochvil 4f1de05
-	    copy_bitwise (contents, dest_offset_bits,
Jan Kratochvil 4f1de05
-			  p->v.literal.data, source_offset_bits,
Jan Kratochvil 4f1de05
+	    copy_bitwise (contents, offset,
Jan Kratochvil 4f1de05
+			  p->v.literal.data, bits_to_skip,
Jan Kratochvil 4f1de05
 			  n, bits_big_endian);
Jan Kratochvil 4f1de05
 	  }
Jan Kratochvil 4f1de05
 	  break;
Jan Kratochvil 4f1de05
@@ -1924,6 +1913,7 @@ read_pieced_value (struct value *v)
Jan Kratochvil 4f1de05
 	}
Jan Kratochvil 4f1de05
 
Jan Kratochvil 4f1de05
       offset += this_size_bits;
Jan Kratochvil 4f1de05
+      bits_to_skip = 0;
Jan Kratochvil 4f1de05
     }
Jan Kratochvil 4f1de05
 }
Jan Kratochvil 4f1de05
 
Jan Kratochvil 4f1de05
@@ -1959,23 +1949,16 @@ write_pieced_value (struct value *to, struct value *from)
Jan Kratochvil 4f1de05
   else
Jan Kratochvil 4f1de05
     max_offset = 8 * TYPE_LENGTH (value_type (to));
Jan Kratochvil 4f1de05
 
Jan Kratochvil 4f1de05
-  for (i = 0; i < c->n_pieces && offset < max_offset; i++)
Jan Kratochvil 4f1de05
+  /* Advance to the first non-skipped piece.  */
Jan Kratochvil 4f1de05
+  for (i = 0; i < c->n_pieces && bits_to_skip >= c->pieces[i].size; i++)
Jan Kratochvil 4f1de05
+    bits_to_skip -= c->pieces[i].size;
Jan Kratochvil 4f1de05
+
Jan Kratochvil 4f1de05
+  for (; i < c->n_pieces && offset < max_offset; i++)
Jan Kratochvil 4f1de05
     {
Jan Kratochvil 4f1de05
       struct dwarf_expr_piece *p = &c->pieces[i];
Jan Kratochvil 4f1de05
       size_t this_size_bits, this_size;
Jan Kratochvil 4f1de05
-      long dest_offset_bits, source_offset_bits;
Jan Kratochvil 4f1de05
-
Jan Kratochvil 4f1de05
-      this_size_bits = p->size;
Jan Kratochvil 4f1de05
-      if (bits_to_skip > 0 && bits_to_skip >= this_size_bits)
Jan Kratochvil 4f1de05
-	{
Jan Kratochvil 4f1de05
-	  bits_to_skip -= this_size_bits;
Jan Kratochvil 4f1de05
-	  continue;
Jan Kratochvil 4f1de05
-	}
Jan Kratochvil 4f1de05
-      dest_offset_bits = bits_to_skip;
Jan Kratochvil 4f1de05
-      this_size_bits -= bits_to_skip;
Jan Kratochvil 4f1de05
-      bits_to_skip = 0;
Jan Kratochvil 4f1de05
-      source_offset_bits = offset;
Jan Kratochvil 4f1de05
 
Jan Kratochvil 4f1de05
+      this_size_bits = p->size - bits_to_skip;
Jan Kratochvil 4f1de05
       if (this_size_bits > max_offset - offset)
Jan Kratochvil 4f1de05
 	this_size_bits = max_offset - offset;
Jan Kratochvil 4f1de05
 
Jan Kratochvil 4f1de05
@@ -1992,22 +1975,22 @@ write_pieced_value (struct value *to, struct value *from)
Jan Kratochvil 4f1de05
 		&& p->offset + p->size < reg_bits)
Jan Kratochvil 4f1de05
 	      {
Jan Kratochvil 4f1de05
 		/* Big-endian, and we want less than full size.  */
Jan Kratochvil 4f1de05
-		dest_offset_bits += reg_bits - (p->offset + p->size);
Jan Kratochvil 4f1de05
+		bits_to_skip += reg_bits - (p->offset + p->size);
Jan Kratochvil 4f1de05
 	      }
Jan Kratochvil 4f1de05
 	    else
Jan Kratochvil 4f1de05
-	      dest_offset_bits += p->offset;
Jan Kratochvil 4f1de05
+	      bits_to_skip += p->offset;
Jan Kratochvil 4f1de05
 
Jan Kratochvil 4f1de05
-	    this_size = bits_to_bytes (dest_offset_bits, this_size_bits);
Jan Kratochvil 4f1de05
+	    this_size = bits_to_bytes (bits_to_skip, this_size_bits);
Jan Kratochvil 4f1de05
 	    buffer.reserve (this_size);
Jan Kratochvil 4f1de05
 
Jan Kratochvil 4f1de05
-	    if (dest_offset_bits % 8 != 0 || this_size_bits % 8 != 0)
Jan Kratochvil 4f1de05
+	    if (bits_to_skip % 8 != 0 || this_size_bits % 8 != 0)
Jan Kratochvil 4f1de05
 	      {
Jan Kratochvil 4f1de05
 		/* Data is copied non-byte-aligned into the register.
Jan Kratochvil 4f1de05
 		   Need some bits from original register value.  */
Jan Kratochvil 4f1de05
 		int optim, unavail;
Jan Kratochvil 4f1de05
 
Jan Kratochvil 4f1de05
 		if (!get_frame_register_bytes (frame, gdb_regnum,
Jan Kratochvil 4f1de05
-					       dest_offset_bits / 8,
Jan Kratochvil 4f1de05
+					       bits_to_skip / 8,
Jan Kratochvil 4f1de05
 					       this_size, buffer.data (),
Jan Kratochvil 4f1de05
 					       &optim, &unavail))
Jan Kratochvil 4f1de05
 		  {
Jan Kratochvil 4f1de05
@@ -2024,34 +2007,34 @@ write_pieced_value (struct value *to, struct value *from)
Jan Kratochvil 4f1de05
 		  }
Jan Kratochvil 4f1de05
 	      }
Jan Kratochvil 4f1de05
 
Jan Kratochvil 4f1de05
-	    copy_bitwise (buffer.data (), dest_offset_bits % 8,
Jan Kratochvil 4f1de05
-			  contents, source_offset_bits,
Jan Kratochvil 4f1de05
+	    copy_bitwise (buffer.data (), bits_to_skip % 8,
Jan Kratochvil 4f1de05
+			  contents, offset,
Jan Kratochvil 4f1de05
 			  this_size_bits, bits_big_endian);
Jan Kratochvil 4f1de05
 	    put_frame_register_bytes (frame, gdb_regnum,
Jan Kratochvil 4f1de05
-				      dest_offset_bits / 8,
Jan Kratochvil 4f1de05
+				      bits_to_skip / 8,
Jan Kratochvil 4f1de05
 				      this_size, buffer.data ());
Jan Kratochvil 4f1de05
 	  }
Jan Kratochvil 4f1de05
 	  break;
Jan Kratochvil 4f1de05
 	case DWARF_VALUE_MEMORY:
Jan Kratochvil 4f1de05
 	  {
Jan Kratochvil 4f1de05
-	    dest_offset_bits += p->offset;
Jan Kratochvil 4f1de05
+	    bits_to_skip += p->offset;
Jan Kratochvil 4f1de05
 
Jan Kratochvil 4f1de05
-	    CORE_ADDR start_addr = p->v.mem.addr + dest_offset_bits / 8;
Jan Kratochvil 4f1de05
+	    CORE_ADDR start_addr = p->v.mem.addr + bits_to_skip / 8;
Jan Kratochvil 4f1de05
 
Jan Kratochvil 4f1de05
-	    if (dest_offset_bits % 8 == 0 && this_size_bits % 8 == 0
Jan Kratochvil 4f1de05
-		&& source_offset_bits % 8 == 0)
Jan Kratochvil 4f1de05
+	    if (bits_to_skip % 8 == 0 && this_size_bits % 8 == 0
Jan Kratochvil 4f1de05
+		&& offset % 8 == 0)
Jan Kratochvil 4f1de05
 	      {
Jan Kratochvil 4f1de05
 		/* Everything is byte-aligned; no buffer needed.  */
Jan Kratochvil 4f1de05
 		write_memory (start_addr,
Jan Kratochvil 4f1de05
-			      contents + source_offset_bits / 8,
Jan Kratochvil 4f1de05
+			      contents + offset / 8,
Jan Kratochvil 4f1de05
 			      this_size_bits / 8);
Jan Kratochvil 4f1de05
 		break;
Jan Kratochvil 4f1de05
 	      }
Jan Kratochvil 4f1de05
 
Jan Kratochvil 4f1de05
-	    this_size = bits_to_bytes (dest_offset_bits, this_size_bits);
Jan Kratochvil 4f1de05
+	    this_size = bits_to_bytes (bits_to_skip, this_size_bits);
Jan Kratochvil 4f1de05
 	    buffer.reserve (this_size);
Jan Kratochvil 4f1de05
 
Jan Kratochvil 4f1de05
-	    if (dest_offset_bits % 8 != 0 || this_size_bits % 8 != 0)
Jan Kratochvil 4f1de05
+	    if (bits_to_skip % 8 != 0 || this_size_bits % 8 != 0)
Jan Kratochvil 4f1de05
 	      {
Jan Kratochvil 4f1de05
 		if (this_size <= 8)
Jan Kratochvil 4f1de05
 		  {
Jan Kratochvil 4f1de05
@@ -2068,8 +2051,8 @@ write_pieced_value (struct value *to, struct value *from)
Jan Kratochvil 4f1de05
 		  }
Jan Kratochvil 4f1de05
 	      }
Jan Kratochvil 4f1de05
 
Jan Kratochvil 4f1de05
-	    copy_bitwise (buffer.data (), dest_offset_bits % 8,
Jan Kratochvil 4f1de05
-			  contents, source_offset_bits,
Jan Kratochvil 4f1de05
+	    copy_bitwise (buffer.data (), bits_to_skip % 8,
Jan Kratochvil 4f1de05
+			  contents, offset,
Jan Kratochvil 4f1de05
 			  this_size_bits, bits_big_endian);
Jan Kratochvil 4f1de05
 	    write_memory (start_addr, buffer.data (), this_size);
Jan Kratochvil 4f1de05
 	  }
Jan Kratochvil 4f1de05
@@ -2079,6 +2062,7 @@ write_pieced_value (struct value *to, struct value *from)
Jan Kratochvil 4f1de05
 	  break;
Jan Kratochvil 4f1de05
 	}
Jan Kratochvil 4f1de05
       offset += this_size_bits;
Jan Kratochvil 4f1de05
+      bits_to_skip = 0;
Jan Kratochvil 4f1de05
     }
Jan Kratochvil 4f1de05
 }
Jan Kratochvil 4f1de05