Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Ulrich Weigand" <uweigand@de.ibm.com>
To: dan@codesourcery.com (Daniel Jacobowitz)
Cc: ken@linux.vnet.ibm.com (Ken Werner),
	gdb-patches@sourceware.org,
	       brobecker@adacore.com (Joel Brobecker),
	       vladimir@codesourcery.com (Vladimir Prus)
Subject: Re: [rfc] Fix value_assign return value (Re: [patch] fix pre-/post- in-/decrement)
Date: Wed, 01 Dec 2010 16:51:00 -0000	[thread overview]
Message-ID: <201012011651.oB1GpDQ8011783@d06av02.portsmouth.uk.ibm.com> (raw)
In-Reply-To: <20101026134146.GN8337@caradoc.them.org> from "Daniel Jacobowitz" at Oct 26, 2010 09:41:47 AM

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


  reply	other threads:[~2010-12-01 16:51 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-17 12:58 [patch] GNU vector unop support Ken Werner
2010-09-28 16:04 ` Ken Werner
     [not found] ` <20100930185634.GC6213@adacore.com>
2010-10-01 17:45   ` [patch] fix pre-/post- in-/decrement Ken Werner
2010-10-04 13:01     ` Ulrich Weigand
2010-10-04 19:47       ` Ken Werner
2010-10-04 20:45         ` Daniel Jacobowitz
2010-10-04 21:58           ` Ulrich Weigand
2010-10-04 22:59             ` Daniel Jacobowitz
2010-10-04 23:25               ` Ulrich Weigand
2010-10-05  1:17                 ` Daniel Jacobowitz
2010-10-05 13:28                   ` Ulrich Weigand
2010-10-05 13:42                     ` Daniel Jacobowitz
2010-10-06 18:59                       ` [rfc] Fix value_assign return value (Re: [patch] fix pre-/post- in-/decrement) Ulrich Weigand
2010-10-26 13:42                         ` Daniel Jacobowitz
2010-12-01 16:51                           ` Ulrich Weigand [this message]
2010-10-06 20:55                       ` [patch] fix pre-/post- in-/decrement Vladimir Prus
2010-10-07 12:38         ` Ken Werner
2010-10-12 23:00           ` Tom Tromey
2010-10-13  8:45             ` Andreas Schwab
2010-10-13  9:23             ` Ken Werner
2010-10-13 16:07               ` Daniel Jacobowitz
2010-10-13 19:01               ` Tom Tromey
2010-10-19  7:38                 ` Ken Werner
2010-11-02  8:23                   ` Ken Werner
2010-11-02 20:31                   ` Tom Tromey
2010-11-03 13:52                     ` Ken Werner
2010-10-04 20:52   ` [patch] GNU vector unop support Ken Werner
2010-10-06 23:27     ` Joel Brobecker
2010-10-07 16:23       ` Ken Werner
2010-11-03 14:07       ` Ken Werner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201012011651.oB1GpDQ8011783@d06av02.portsmouth.uk.ibm.com \
    --to=uweigand@de.ibm.com \
    --cc=brobecker@adacore.com \
    --cc=dan@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    --cc=ken@linux.vnet.ibm.com \
    --cc=vladimir@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox