From patchwork Sat May 16 13:39:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kratochvil X-Patchwork-Id: 6766 Received: (qmail 114581 invoked by alias); 16 May 2015 13:39:31 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 114470 invoked by uid 89); 16 May 2015 13:39:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Sat, 16 May 2015 13:39:30 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id DB9AC8F30C for ; Sat, 16 May 2015 13:39:28 +0000 (UTC) Received: from host1.jankratochvil.net (ovpn-116-27.ams2.redhat.com [10.36.116.27]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t4GDdO2N005206 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sat, 16 May 2015 09:39:27 -0400 Date: Sat, 16 May 2015 15:39:24 +0200 From: Jan Kratochvil To: Pedro Alves Cc: gdb-patches@sourceware.org, Phil Muldoon Subject: [commit#2] [PATCH v5 6/7] compile: New 'compile print' Message-ID: <20150516133924.GA3421@host1.jankratochvil.net> References: <20150513201615.4051.5261.stgit@host1.jankratochvil.net> <20150513201704.4051.40784.stgit@host1.jankratochvil.net> <55562703.4060104@redhat.com> <20150516125814.GE9862@host1.jankratochvil.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20150516125814.GE9862@host1.jankratochvil.net> User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes On Sat, 16 May 2015 14:58:14 +0200, Jan Kratochvil wrote: > On Fri, 15 May 2015 19:04:03 +0200, Pedro Alves wrote: > > On 05/13/2015 09:17 PM, Jan Kratochvil wrote: > > > + if (TYPE_CODE (gdb_type) != TYPE_CODE_PTR) > > > + error (_("Invalid type code %d of symbol \"%s\" " > > > + "in compiled module \"%s\"."), > > > + TYPE_CODE (gdb_type_from_ptr), COMPILE_I_EXPR_VAL, > > > + objfile_name (objfile)); > > > + > > > + switch (TYPE_CODE (gdb_type_from_ptr)) > > > + { > > > + case TYPE_CODE_ARRAY: > > > + retval = gdb_type_from_ptr; > > > + gdb_type_from_ptr = TYPE_TARGET_TYPE (gdb_type_from_ptr); > > > + break; > > > + case TYPE_CODE_FUNC: > > > + retval = gdb_type_from_ptr; > > > > AFAIC, retval is always gdb_type_from_ptr, and could be > > moved out of the switch. > > It was written this way as it has semantical logic - how the type is > determined depends on TYPE_CODE_* of that object. Just accidentally in this > case it is the same. I do not do performance micro-optimizations which > compiler will do anyway. But I have changed it. I see I made a thinko in that optimization, therefore checked-in this fix-up: 4d18dfad9edf822df205edc2c1fe3fe9f1e467b8 Jan gdb/ChangeLog 2015-05-16 Jan Kratochvil * compile/compile-object-load.c (get_out_value_type): Fix returned type. --- gdb/ChangeLog | 4 ++++ gdb/compile/compile-object-load.c | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 3868599..e5de834 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,4 +1,8 @@ 2015-05-16 Jan Kratochvil + + * compile/compile-object-load.c (get_out_value_type): Fix returned type. + +2015-05-16 Jan Kratochvil Phil Muldoon * NEWS (Changes since GDB 7.9): Add compile print. diff --git a/gdb/compile/compile-object-load.c b/gdb/compile/compile-object-load.c index ed5ef88..e2d8f2f 100644 --- a/gdb/compile/compile-object-load.c +++ b/gdb/compile/compile-object-load.c @@ -372,7 +372,7 @@ get_out_value_type (struct symbol *func_sym, struct objfile *objfile, enum compile_i_scope_types scope) { struct symbol *gdb_ptr_type_sym, *gdb_val_sym; - struct type *gdb_ptr_type, *gdb_type_from_ptr, *gdb_type; + struct type *gdb_ptr_type, *gdb_type_from_ptr, *gdb_type, *retval; const struct block *block; const struct blockvector *bv; int nblocks = 0; @@ -440,6 +440,7 @@ get_out_value_type (struct symbol *func_sym, struct objfile *objfile, TYPE_CODE (gdb_type_from_ptr), COMPILE_I_EXPR_VAL, objfile_name (objfile)); + retval = gdb_type_from_ptr; switch (TYPE_CODE (gdb_type_from_ptr)) { case TYPE_CODE_ARRAY: @@ -461,7 +462,7 @@ get_out_value_type (struct symbol *func_sym, struct objfile *objfile, objfile_name (objfile)); if (scope == COMPILE_I_PRINT_ADDRESS_SCOPE) return NULL; - return gdb_type_from_ptr; + return retval; } /* Fetch the type of first parameter of FUNC_SYM.