From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32467 invoked by alias); 3 Jan 2010 05:48:07 -0000 Received: (qmail 32447 invoked by uid 22791); 3 Jan 2010 05:48:06 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_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; Sun, 03 Jan 2010 05:48:01 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o035lWfT021878 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 3 Jan 2010 00:47:32 -0500 Received: from host0.dyn.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o035lTaF013713 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 3 Jan 2010 00:47:32 -0500 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.14.3/8.14.3) with ESMTP id o035lT1R031226; Sun, 3 Jan 2010 06:47:29 +0100 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.3/8.14.3/Submit) id o035lSSl031222; Sun, 3 Jan 2010 06:47:28 +0100 Date: Sun, 03 Jan 2010 05:48:00 -0000 From: Jan Kratochvil To: Joel Brobecker Cc: gdb-patches@sourceware.org, gdb@sourceware.org, Vladimir Prus Subject: Re: [patch] Re: Regression: field type preservation: 7.0 -> 7.0.1+HEAD Message-ID: <20100103054727.GA31207@host0.dyn.jankratochvil.net> References: <20100101184505.GA18391@host0.dyn.jankratochvil.net> <201001021308.19130.vladimir@codesourcery.com> <20100102203022.GA8372@host0.dyn.jankratochvil.net> <20100103045717.GZ2788@adacore.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100103045717.GZ2788@adacore.com> User-Agent: Mutt/1.5.20 (2009-08-17) 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: 2010-01/txt/msg00037.txt.bz2 On Sun, 03 Jan 2010 05:57:17 +0100, Joel Brobecker wrote: > So, my proposal, if the other maintainers agree, is to document > the side-effect of check_typedef (sets the typedef TYPE_LENGTH) > as this appears to be a fully-intended behavior, and then do: OK, attached. As I find the type system [censored] I am never sure how it can be used in a sane way. OK to check-in with this wording? No regressions on {x86_64,x86_64-m32,i686}-fedora12-linux-gnu. Thanks, Jan gdb/ 2010-01-03 Jan Kratochvil Joel Brobecker * gdbtypes.c (check_typedef): New comment on type length. * value.c (allocate_value_lazy): Remove the unused atype variable. New comment on type length. (value_primitive_field): Keep the original TYPE value, new comment. gdb/testsuite/ 2010-01-03 Jan Kratochvil * gdb.mi/var-cmd.c (do_bitfield_tests): Change "V.sharable" type to "uint_for_mi_testing". --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -1342,12 +1342,17 @@ stub_noname_complaint (void) symbols which contain a full definition for the type. This used to be coded as a macro, but I don't think it is called - often enough to merit such treatment. */ + often enough to merit such treatment. -/* Find the real type of TYPE. This function returns the real type, + Find the real type of TYPE. This function returns the real type, after removing all layers of typedefs and completing opaque or stub types. Completion changes the TYPE argument, but stripping of - typedefs does not. */ + typedefs does not. + + If TYPE is a TYPE_CODE_TYPEDEF, its length is (also) set to the length of + the target type instead of zero. However, in the case of TYPE_CODE_TYPEDEF + check_typedef can still return different type than the original TYPE + pointer. */ struct type * check_typedef (struct type *type) --- a/gdb/testsuite/gdb.mi/var-cmd.c +++ b/gdb/testsuite/gdb.mi/var-cmd.c @@ -494,7 +494,7 @@ void do_bitfield_tests () mi_create_varobj V d "create varobj for Data" mi_list_varobj_children "V" { {"V.alloc" "alloc" "0" "int"} - {"V.sharable" "sharable" "0" "unsigned int"} + {"V.sharable" "sharable" "0" "uint_for_mi_testing"} } "list children of Data" mi_check_varobj_value V.sharable 3 "access bitfield" :*/ --- a/gdb/value.c +++ b/gdb/value.c @@ -254,7 +254,14 @@ struct value * allocate_value_lazy (struct type *type) { struct value *val; - struct type *atype = check_typedef (type); + + /* Call check_typedef on our type to make sure that, if TYPE + is a TYPE_CODE_TYPEDEF, its length is set to the length + of the target type instead of zero. However, we do not + replace the typedef type by the target type, because we want + to keep the typedef in order to be able to set the VAL's type + description correctly. */ + check_typedef (type); val = (struct value *) xzalloc (sizeof (struct value)); val->contents = NULL; @@ -1873,7 +1880,14 @@ value_primitive_field (struct value *arg1, int offset, CHECK_TYPEDEF (arg_type); type = TYPE_FIELD_TYPE (arg_type, fieldno); - type = check_typedef (type); + + /* Call check_typedef on our type to make sure that, if TYPE + is a TYPE_CODE_TYPEDEF, its length is set to the length + of the target type instead of zero. However, we do not + replace the typedef type by the target type, because we want + to keep the typedef in order to be able to print the type + description correctly. */ + check_typedef (type); /* Handle packed fields */