From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23586 invoked by alias); 18 Nov 2011 20:06:02 -0000 Received: (qmail 23571 invoked by uid 22791); 18 Nov 2011 20:05:59 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,MSGID_FROM_MTA_HEADER,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mtagate3.uk.ibm.com (HELO mtagate3.uk.ibm.com) (194.196.100.163) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 18 Nov 2011 20:05:40 +0000 Received: from d06nrmr1307.portsmouth.uk.ibm.com (d06nrmr1307.portsmouth.uk.ibm.com [9.149.38.129]) by mtagate3.uk.ibm.com (8.13.1/8.13.1) with ESMTP id pAIK5cD2014941 for ; Fri, 18 Nov 2011 20:05:38 GMT Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by d06nrmr1307.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id pAIK5csx2523140 for ; Fri, 18 Nov 2011 20:05:38 GMT Received: from d06av02.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id pAIK5bxr008379 for ; Fri, 18 Nov 2011 13:05:38 -0700 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with SMTP id pAIK5axF008363; Fri, 18 Nov 2011 13:05:36 -0700 Message-Id: <201111182005.pAIK5axF008363@d06av02.portsmouth.uk.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Fri, 18 Nov 2011 21:05:36 +0100 Subject: [commit] Re: Checked in: [RFA] read_frame_register_value and big endian arches To: brobecker@adacore.com (Joel Brobecker) Date: Fri, 18 Nov 2011 20:06:00 -0000 From: "Ulrich Weigand" Cc: gdb-patches@sourceware.org, tromey@redhat.com In-Reply-To: <20111118194039.GE2703@adacore.com> from "Joel Brobecker" at Nov 18, 2011 02:40:39 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: 2011-11/txt/msg00510.txt.bz2 Joel Brobecker wrote: > > This fixes the regressions on SPU for me. Does this work for the > > platforms where you were seeing issues as well? > > Thanks for doing this, Ulrich. I tested the patch on x86_64-linux > for kicks, but also on sparc-elf and avr, where the problems where > detected, and no regression. Thanks for the verification! > Just one tiny detail: > > > + struct gdbarch *gdbarch = get_frame_arch (frame); > > int offset = 0; > > + int reg_offset = value_offset (value); > > int regnum = VALUE_REGNUM (value); > > const int len = TYPE_LENGTH (check_typedef (value_type (value))); > ^^^^^ > > I had to remove the const, since we are decrementing len each time > we read contents from a register... Oops. I noticed this when building, and fixed it in my source tree, but then forgot to regenerate the patch ... Sorry. I've now checked in the version below. Bye, Ulrich ChangeLog: * findvar.c (read_frame_register_value): Respect value_offset of the register value. Remove big-endian special case. Index: gdb/findvar.c =================================================================== RCS file: /cvs/src/src/gdb/findvar.c,v retrieving revision 1.139 diff -u -p -r1.139 findvar.c --- gdb/findvar.c 10 Nov 2011 17:14:40 -0000 1.139 +++ gdb/findvar.c 18 Nov 2011 20:01:55 -0000 @@ -631,31 +631,37 @@ default_value_from_register (struct type void read_frame_register_value (struct value *value, struct frame_info *frame) { + struct gdbarch *gdbarch = get_frame_arch (frame); int offset = 0; + int reg_offset = value_offset (value); int regnum = VALUE_REGNUM (value); - const int len = TYPE_LENGTH (check_typedef (value_type (value))); + int len = TYPE_LENGTH (check_typedef (value_type (value))); gdb_assert (VALUE_LVAL (value) == lval_register); - while (offset < len) + /* Skip registers wholly inside of REG_OFFSET. */ + while (reg_offset >= register_size (gdbarch, regnum)) + { + reg_offset -= register_size (gdbarch, regnum); + regnum++; + } + + /* Copy the data. */ + while (len > 0) { struct value *regval = get_frame_register_value (frame, regnum); - int reg_len = TYPE_LENGTH (value_type (regval)); - int reg_offset = 0; + int reg_len = TYPE_LENGTH (value_type (regval)) - reg_offset; /* If the register length is larger than the number of bytes remaining to copy, then only copy the appropriate bytes. */ - if (offset + reg_len > len) - { - reg_len = len - offset; - if (gdbarch_byte_order (get_frame_arch (frame)) == BFD_ENDIAN_BIG) - reg_offset = TYPE_LENGTH (value_type (regval)) - reg_len; - } + if (reg_len > len) + reg_len = len; - value_contents_copy (value, offset, regval, - value_offset (regval) + reg_offset, reg_len); + value_contents_copy (value, offset, regval, reg_offset, reg_len); offset += reg_len; + len -= reg_len; + reg_offset = 0; regnum++; } } -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com