From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19149 invoked by alias); 8 Feb 2013 20:47:25 -0000 Received: (qmail 19126 invoked by uid 22791); 8 Feb 2013 20:47:23 -0000 X-SWARE-Spam-Status: No, hits=-6.2 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_SPAMHAUS_DROP,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 08 Feb 2013 20:47:07 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r18Kl7YP028733 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 8 Feb 2013 15:47:07 -0500 Received: from host2.jankratochvil.net (ovpn-116-18.ams2.redhat.com [10.36.116.18]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r18Kl2R4020183 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Fri, 8 Feb 2013 15:47:05 -0500 Date: Fri, 08 Feb 2013 20:47:00 -0000 From: Jan Kratochvil To: Sergio Durigan Junior Cc: GDB Patches Subject: Re: [PATCH] Handle bitfields inside inner structs for internalvars Message-ID: <20130208204702.GA22467@host2.jankratochvil.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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: 2013-02/txt/msg00228.txt.bz2 On Wed, 06 Feb 2013 21:39:10 +0100, Sergio Durigan Junior wrote: > gdb/ > 2013-02-06 Sergio Durigan Junior > > * valops.c (value_assign): Handling bitfield offset in > `lval_internalvar_component' case. > > gdb/testsuite/ > 2013-02-06 Sergio Durigan Junior > > * gdb.base/bitfields.c (struct internalvartest): New declaration. > * gdb.base/bitfields.exp (bitfield_internalvar): New function. OK for check-in with the bits below. > --- a/gdb/testsuite/gdb.base/bitfields.exp > +++ b/gdb/testsuite/gdb.base/bitfields.exp > @@ -245,6 +245,31 @@ proc bitfield_at_offset {} { > gdb_test "print container.two.u3" ".* = 3" > } > > +proc bitfield_internalvar {} { > + global gdb_prompt > + > + # First, we create an internal var holding an instance of > + # the struct (zeroed out). > + gdb_test "set \$myvar = \(struct internalvartest\) \{0\}" "" \ Backslashes are excessive here, parentheses are not special characters for the TCL interpretation and this string is not regexp: gdb_test "set \$myvar = (struct internalvartest) \{0\}" "" \ > + "set internal var" > + > + # Now, we set the proper bits. [...] > --- a/gdb/valops.c > +++ b/gdb/valops.c > @@ -1233,11 +1233,18 @@ value_assign (struct value *toval, struct value *fromval) > VALUE_INTERNALVAR (toval)); > > case lval_internalvar_component: > - set_internalvar_component (VALUE_INTERNALVAR (toval), > - value_offset (toval), > - value_bitpos (toval), > - value_bitsize (toval), > - fromval); > + { > + int offset = value_offset (toval); > + > + if (value_bitsize (toval)) > + offset += value_offset (value_parent (toval)); value_address rather tests for value_parent existence; although value_bitsize is right as value_parent is currently not used elsewhere. if (value_parent (toval)) { /* VALUE_INTERNALVAR below corresponds to the parent value while offset is relative to the parent value. */ gdb_assert (value_parent (value_parent (toval)) == NULL); offset += value_offset (value_parent (toval)); } And it was not so clear to me on the first look so I have added this comment if you are OK with it. > + > + set_internalvar_component (VALUE_INTERNALVAR (toval), > + offset, > + value_bitpos (toval), > + value_bitsize (toval), > + fromval); > + } > break; > Thanks, Jan