From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21182 invoked by alias); 27 Sep 2009 21:48:47 -0000 Received: (qmail 21163 invoked by uid 22791); 27 Sep 2009 21:48:44 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,MSGID_FROM_MTA_HEADER,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mtagate5.de.ibm.com (HELO mtagate5.de.ibm.com) (195.212.17.165) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 27 Sep 2009 21:48:39 +0000 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate5.de.ibm.com (8.13.1/8.13.1) with ESMTP id n8RLmasR002451 for ; Sun, 27 Sep 2009 21:48:36 GMT Received: from d12av02.megacenter.de.ibm.com (d12av02.megacenter.de.ibm.com [9.149.165.228]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id n8RLmaKX3362890 for ; Sun, 27 Sep 2009 23:48:36 +0200 Received: from d12av02.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n8RLmZuI032096 for ; Sun, 27 Sep 2009 23:48:36 +0200 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.12.11) with SMTP id n8RLmY2f032091; Sun, 27 Sep 2009 23:48:34 +0200 Message-Id: <200909272148.n8RLmY2f032091@d12av02.megacenter.de.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Sun, 27 Sep 2009 23:48:34 +0200 Subject: [rfc] Fix bitfield regressions on 64-bit big-endian targets To: drow@false.org (Daniel Jacobowitz) Date: Sun, 27 Sep 2009 21:48:00 -0000 From: "Ulrich Weigand" Cc: gdb-patches@sourceware.org In-Reply-To: <20090828184942.GA5711@caradoc.them.org> from "Daniel Jacobowitz" at Aug 28, 2009 02:49:42 PM MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2009-09/txt/msg00856.txt.bz2 Daniel Jacobowitz wrote: > value_offset for a bitfield is an offset to be added into the parent's > contents. So including the parent's offset is incorrect; the attached > test shows that we were reading the wrong location. With large enough > offsets, we could wander off to another page of memory and fault. This changes the value_offset for a bitfield, but does not adapt all places where the offset is used; in particular value_assign still does not take the parent's offset into account. This causes a significant number of store.exp testsuite failures on s390x-linux and ppc64-linux (and presumably other 64-bit big-endian platforms). The following patch updates value_assign to respect the parent offset, which fixes all those failures. Tested on s390(x)-linux and ppc(64)-linux with no regressions. Does this look OK to you? Bye, Ulrich ChangeLog: * valops.c (value_assign): Respect parent offset when assigning to a bitfield. Index: gdb/valops.c =================================================================== RCS file: /cvs/src/src/gdb/valops.c,v retrieving revision 1.225 diff -c -p -r1.225 valops.c *** gdb/valops.c 31 Aug 2009 20:18:45 -0000 1.225 --- gdb/valops.c 25 Sep 2009 18:37:40 -0000 *************** value_assign (struct value *toval, struc *** 827,832 **** --- 827,835 ---- if (value_bitsize (toval)) { + struct value *parent = value_parent (toval); + changed_addr = value_address (parent) + value_offset (toval); + changed_len = (value_bitpos (toval) + value_bitsize (toval) + HOST_CHAR_BIT - 1) *************** value_assign (struct value *toval, struc *** 838,854 **** registers. */ if (changed_len < TYPE_LENGTH (type) && TYPE_LENGTH (type) <= (int) sizeof (LONGEST) ! && ((LONGEST) value_address (toval) % TYPE_LENGTH (type)) == 0) changed_len = TYPE_LENGTH (type); if (changed_len > (int) sizeof (LONGEST)) error (_("Can't handle bitfields which don't fit in a %d bit word."), (int) sizeof (LONGEST) * HOST_CHAR_BIT); ! read_memory (value_address (toval), buffer, changed_len); modify_field (type, buffer, value_as_long (fromval), value_bitpos (toval), value_bitsize (toval)); - changed_addr = value_address (toval); dest_buffer = buffer; } else --- 841,856 ---- registers. */ if (changed_len < TYPE_LENGTH (type) && TYPE_LENGTH (type) <= (int) sizeof (LONGEST) ! && ((LONGEST) changed_addr % TYPE_LENGTH (type)) == 0) changed_len = TYPE_LENGTH (type); if (changed_len > (int) sizeof (LONGEST)) error (_("Can't handle bitfields which don't fit in a %d bit word."), (int) sizeof (LONGEST) * HOST_CHAR_BIT); ! read_memory (changed_addr, buffer, changed_len); modify_field (type, buffer, value_as_long (fromval), value_bitpos (toval), value_bitsize (toval)); dest_buffer = buffer; } else *************** value_assign (struct value *toval, struc *** 891,896 **** --- 893,900 ---- { if (value_bitsize (toval)) { + struct value *parent = value_parent (toval); + int offset = value_offset (parent) + value_offset (toval); int changed_len; gdb_byte buffer[sizeof (LONGEST)]; *************** value_assign (struct value *toval, struc *** 903,917 **** error (_("Can't handle bitfields which don't fit in a %d bit word."), (int) sizeof (LONGEST) * HOST_CHAR_BIT); ! get_frame_register_bytes (frame, value_reg, ! value_offset (toval), changed_len, buffer); modify_field (type, buffer, value_as_long (fromval), value_bitpos (toval), value_bitsize (toval)); ! put_frame_register_bytes (frame, value_reg, ! value_offset (toval), changed_len, buffer); } else --- 907,919 ---- error (_("Can't handle bitfields which don't fit in a %d bit word."), (int) sizeof (LONGEST) * HOST_CHAR_BIT); ! get_frame_register_bytes (frame, value_reg, offset, changed_len, buffer); modify_field (type, buffer, value_as_long (fromval), value_bitpos (toval), value_bitsize (toval)); ! put_frame_register_bytes (frame, value_reg, offset, changed_len, buffer); } else -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com