From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22804 invoked by alias); 1 Dec 2010 16:51:24 -0000 Received: (qmail 22796 invoked by uid 22791); 1 Dec 2010 16:51:22 -0000 X-SWARE-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL,BAYES_00,MSGID_FROM_MTA_HEADER,SPF_SOFTFAIL,TW_CP,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mtagate2.uk.ibm.com (HELO mtagate2.uk.ibm.com) (194.196.100.162) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 01 Dec 2010 16:51:17 +0000 Received: from d06nrmr1307.portsmouth.uk.ibm.com (d06nrmr1307.portsmouth.uk.ibm.com [9.149.38.129]) by mtagate2.uk.ibm.com (8.13.1/8.13.1) with ESMTP id oB1GpFQV020040 for ; Wed, 1 Dec 2010 16:51:15 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 oB1GpESE3530896 for ; Wed, 1 Dec 2010 16:51:14 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 oB1GpEQ1012134 for ; Wed, 1 Dec 2010 09:51:15 -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 oB1GpDQ8011783; Wed, 1 Dec 2010 09:51:13 -0700 Message-Id: <201012011651.oB1GpDQ8011783@d06av02.portsmouth.uk.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Wed, 01 Dec 2010 17:51:13 +0100 Subject: Re: [rfc] Fix value_assign return value (Re: [patch] fix pre-/post- in-/decrement) To: dan@codesourcery.com (Daniel Jacobowitz) Date: Wed, 01 Dec 2010 16:51:00 -0000 From: "Ulrich Weigand" Cc: ken@linux.vnet.ibm.com (Ken Werner), gdb-patches@sourceware.org, brobecker@adacore.com (Joel Brobecker), vladimir@codesourcery.com (Vladimir Prus) In-Reply-To: <20101026134146.GN8337@caradoc.them.org> from "Daniel Jacobowitz" at Oct 26, 2010 09:41:47 AM 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: 2010-12/txt/msg00006.txt.bz2 Dan Jacobowitz wrote: > On Wed, Oct 06, 2010 at 08:59:18PM +0200, Ulrich Weigand wrote: > > * valops.c (value_assign): Returned value is never lazy. If a > > C++ class type is returned, fix incorrect enclosing type / embedded > > offset. If internal variable is returned, allocate new internalvar > > value using value_of_internalvar. > > > > * NEWS: Document changes in behavior of "print x = 0" and similar > > expressions. > > Looks good to me. OK, thanks for the review! I've now updated the patch for recent changes (see below), retested on i386-linux, and checked it in. Bye, Ulrich ChangeLog: * valops.c (value_assign): Returned value is never lazy. If a C++ class type is returned, fix incorrect enclosing type / embedded offset. If internal variable is returned, allocate new internalvar value using value_of_internalvar. * NEWS: Document changes in behavior of "print x = 0" and similar expressions. Index: gdb/NEWS =================================================================== RCS file: /cvs/src/src/gdb/NEWS,v retrieving revision 1.411 diff -u -p -r1.411 NEWS --- gdb/NEWS 5 Nov 2010 16:55:37 -0000 1.411 +++ gdb/NEWS 25 Nov 2010 16:11:03 -0000 @@ -46,6 +46,12 @@ feature requires proper debuginfo support from the compiler; it was added to GCC 4.5. +* GDB now follows GCC's rules on accessing volatile objects when + reading or writing target state during expression evaluation. + One notable difference to prior behavior is that "print x = 0" + no longer generates a read of x; the value of the assignment is + now always taken directly from the value being assigned. + * GDB now has some support for using labels in the program's source in linespecs. For instance, you can use "advance label" to continue execution to a label. Index: gdb/valops.c =================================================================== RCS file: /cvs/src/src/gdb/valops.c,v retrieving revision 1.257 diff -u -p -r1.257 valops.c --- gdb/valops.c 10 Nov 2010 17:47:23 -0000 1.257 +++ gdb/valops.c 25 Nov 2010 16:11:04 -0000 @@ -1138,11 +1138,8 @@ value_assign (struct value *toval, struc { case lval_internalvar: set_internalvar (VALUE_INTERNALVAR (toval), fromval); - val = value_copy (fromval); - set_value_enclosing_type (val, value_enclosing_type (fromval)); - set_value_embedded_offset (val, value_embedded_offset (fromval)); - set_value_pointed_to_offset (val, value_pointed_to_offset (fromval)); - return val; + return value_of_internalvar (get_type_arch (type), + VALUE_INTERNALVAR (toval)); case lval_internalvar_component: set_internalvar_component (VALUE_INTERNALVAR (toval), @@ -1328,13 +1325,23 @@ value_assign (struct value *toval, struc fromval = value_from_longest (type, fieldval); } + /* The return value is a copy of TOVAL so it shares its location + information, but its contents are updated from FROMVAL. This + implies the returned value is not lazy, even if TOVAL was. */ val = value_copy (toval); + set_value_lazy (val, 0); memcpy (value_contents_raw (val), value_contents (fromval), TYPE_LENGTH (type)); - deprecated_set_value_type (val, type); - set_value_enclosing_type (val, value_enclosing_type (fromval)); - set_value_embedded_offset (val, value_embedded_offset (fromval)); - set_value_pointed_to_offset (val, value_pointed_to_offset (fromval)); + + /* We copy over the enclosing type and pointed-to offset from FROMVAL + in the case of pointer types. For object types, the enclosing type + and embedded offset must *not* be copied: the target object refered + to by TOVAL retains its original dynamic type after assignment. */ + if (TYPE_CODE (type) == TYPE_CODE_PTR) + { + set_value_enclosing_type (val, value_enclosing_type (fromval)); + set_value_pointed_to_offset (val, value_pointed_to_offset (fromval)); + } return val; } -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com