From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20695 invoked by alias); 30 Jan 2008 11:39:02 -0000 Received: (qmail 20603 invoked by uid 22791); 30 Jan 2008 11:38:57 -0000 X-Spam-Check-By: sourceware.org Received: from wa-out-1112.google.com (HELO wa-out-1112.google.com) (209.85.146.177) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 30 Jan 2008 11:38:34 +0000 Received: by wa-out-1112.google.com with SMTP id l35so312960waf.12 for ; Wed, 30 Jan 2008 03:38:32 -0800 (PST) Received: by 10.114.201.1 with SMTP id y1mr725490waf.121.1201693112680; Wed, 30 Jan 2008 03:38:32 -0800 (PST) Received: by 10.114.102.11 with HTTP; Wed, 30 Jan 2008 03:38:32 -0800 (PST) Message-ID: Date: Wed, 30 Jan 2008 12:06:00 -0000 From: "Rob Quill" To: "Rob Quill" , gdb-patches@sourceware.org Subject: Re: Remove deprecated_set_value_type (part 1) In-Reply-To: <20080129195506.GE9019@caradoc.them.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20080129195506.GE9019@caradoc.them.org> 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: 2008-01/txt/msg00784.txt.bz2 On 29/01/2008, Daniel Jacobowitz wrote: > I can't tell if this one is right. I don't understand what it's for > either. Mind leaving it out for now? > No problem, I've taken it out now. Thanks for you help with this and sorry about the formatting mistakes. I've attached the new patch, which shows no regressions, below. Rob 2008-01-30 Rob Quill Removes some uses of deprecated_set_value_type * ada-lang.c (ada_coerce_to_simple_array_type): Create a new zero value of the correct type instead of changing type. (ada_value_assign): Call copy_value_and_change_type instead. * c-valprint.c (c_value_print): Call copy_value_and_change_type. * printcmd.c (printf_command): Create a zero value of the correct type and copy the contents of the old value into it. * valops.c (value_cast_pointers, value_cast, value_assign, value_addr): Call value_value_copy_and_change_type instead of copying the value and then changing the type. * value.c (value_copy_and_change_type): Define. * value.h (value_copy_and_change_type): Declare. Index: gdb/ada-lang.c =================================================================== RCS file: /cvs/src/src/gdb/ada-lang.c,v retrieving revision 1.131 diff -u -p -r1.131 ada-lang.c --- gdb/ada-lang.c 8 Jan 2008 19:28:08 -0000 1.131 +++ gdb/ada-lang.c 30 Jan 2008 11:20:33 -0000 @@ -1737,9 +1737,8 @@ struct type * ada_coerce_to_simple_array_type (struct type *type) { struct value *mark = value_mark (); - struct value *dummy = value_from_longest (builtin_type_long, 0); + struct value *dummy = value_zero (type, not_lval); struct type *result; - deprecated_set_value_type (dummy, type); result = ada_type_of_array (dummy, 0); value_free_to_mark (mark); return result; Index: gdb/c-valprint.c =================================================================== RCS file: /cvs/src/src/gdb/c-valprint.c,v retrieving revision 1.48 diff -u -p -r1.48 c-valprint.c --- gdb/c-valprint.c 11 Jan 2008 13:34:14 -0000 1.48 +++ gdb/c-valprint.c 30 Jan 2008 11:20:33 -0000 @@ -562,8 +562,7 @@ c_value_print (struct value *val, struct * error about a non-pointer type in value_rtti_target_type */ struct value *temparg; - temparg=value_copy(val); - deprecated_set_value_type (temparg, lookup_pointer_type (TYPE_TARGET_TYPE(type))); + temparg=value_addr (val); val=temparg; } /* Pointer to class, check real type of object */ Index: gdb/printcmd.c =================================================================== RCS file: /cvs/src/src/gdb/printcmd.c,v retrieving revision 1.116 diff -u -p -r1.116 printcmd.c --- gdb/printcmd.c 11 Jan 2008 13:34:14 -0000 1.116 +++ gdb/printcmd.c 30 Jan 2008 11:20:38 -0000 @@ -2035,9 +2035,21 @@ printf_command (char *arg, int from_tty) { struct type *type = value_type (val_args[nargs]); if (TYPE_LENGTH (type) == sizeof (float)) - deprecated_set_value_type (val_args[nargs], builtin_type_float); + { + struct value *temp = value_zero (builtin_type_float, not_lval); + memcpy (value_contents_writeable (temp), + value_contents (val_args[nargs]), + TYPE_LENGTH (builtin_type_float)); + val_args[nargs] = temp; + } if (TYPE_LENGTH (type) == sizeof (double)) - deprecated_set_value_type (val_args[nargs], builtin_type_double); + { + struct value *temp = value_zero (builtin_type_double, not_lval); + memcpy (value_contents_all_raw (temp), + value_contents_all_raw (val_args[nargs]), + TYPE_LENGTH (builtin_type_double)); + val_args[nargs] = temp; + } } nargs++; s = s1; Index: gdb/valops.c =================================================================== RCS file: /cvs/src/src/gdb/valops.c,v retrieving revision 1.181 diff -u -p -r1.181 valops.c --- gdb/valops.c 7 Jan 2008 22:33:57 -0000 1.181 +++ gdb/valops.c 30 Jan 2008 11:20:41 -0000 @@ -250,8 +250,7 @@ value_cast_pointers (struct type *type, } /* No superclass found, just change the pointer type. */ - arg2 = value_copy (arg2); - deprecated_set_value_type (arg2, type); + arg2 = value_copy_and_change_type (arg2, type); arg2 = value_change_enclosing_type (arg2, type); set_value_pointed_to_offset (arg2, 0); /* pai: chk_val */ return arg2; @@ -440,8 +439,7 @@ value_cast (struct type *type, struct va if (code1 == TYPE_CODE_PTR && code2 == TYPE_CODE_PTR) return value_cast_pointers (type, arg2); - arg2 = value_copy (arg2); - deprecated_set_value_type (arg2, type); + arg2 = value_copy_and_change_type (arg2, type); arg2 = value_change_enclosing_type (arg2, type); set_value_pointed_to_offset (arg2, 0); /* pai: chk_val */ return arg2; @@ -754,10 +752,9 @@ value_assign (struct value *toval, struc fromval = value_from_longest (type, fieldval); } - val = value_copy (toval); + val = value_copy_and_change_type(toval, type); memcpy (value_contents_raw (val), value_contents (fromval), TYPE_LENGTH (type)); - deprecated_set_value_type (val, type); val = value_change_enclosing_type (val, value_enclosing_type (fromval)); set_value_embedded_offset (val, value_embedded_offset (fromval)); @@ -884,9 +881,8 @@ value_addr (struct value *arg1) /* Copy the value, but change the type from (T&) to (T*). We keep the same location information, which is efficient, and allows &(&X) to get the location containing the reference. */ - arg2 = value_copy (arg1); - deprecated_set_value_type (arg2, - lookup_pointer_type (TYPE_TARGET_TYPE (type))); + arg2 = value_copy_and_change_type (arg1, + lookup_pointer_type (TYPE_TARGET_TYPE (type))); return arg2; } if (TYPE_CODE (type) == TYPE_CODE_FUNC) Index: gdb/value.c =================================================================== RCS file: /cvs/src/src/gdb/value.c,v retrieving revision 1.56 diff -u -p -r1.56 value.c --- gdb/value.c 16 Jan 2008 16:16:44 -0000 1.56 +++ gdb/value.c 30 Jan 2008 11:20:42 -0000 @@ -275,6 +275,15 @@ deprecated_set_value_type (struct value value->type = type; } +struct value * +value_copy_and_change_type (struct value *arg, struct type *type) +{ + struct value *val = value_copy (arg); + val->type = type; + + return val; +} + int value_offset (struct value *value) { Index: gdb/value.h =================================================================== RCS file: /cvs/src/src/gdb/value.h,v retrieving revision 1.107 diff -u -p -r1.107 value.h --- gdb/value.h 18 Jan 2008 17:07:40 -0000 1.107 +++ gdb/value.h 30 Jan 2008 11:20:43 -0000 @@ -56,6 +56,12 @@ extern struct type *value_type (struct v extern void deprecated_set_value_type (struct value *value, struct type *type); +/* Copy ARG to new value. The new value is exactly the same, except + for its type, which is set to TYPE. */ + +extern struct value *value_copy_and_change_type(struct value *arg, + struct type *type); + /* Only used for bitfields; number of bits contained in them. */ extern int value_bitsize (struct value *);