From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 55438 invoked by alias); 20 Sep 2017 14:40:26 -0000 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 Received: (qmail 55421 invoked by uid 89); 20 Sep 2017 14:40:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.4 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GIT_PATCH_3,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: smtp.polymtl.ca Received: from smtp.polymtl.ca (HELO smtp.polymtl.ca) (132.207.4.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 20 Sep 2017 14:40:24 +0000 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id v8KEeHxV023088 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 20 Sep 2017 10:40:22 -0400 Received: by simark.ca (Postfix, from userid 112) id 4A3571ED03; Wed, 20 Sep 2017 10:40:17 -0400 (EDT) Received: from simark.ca (localhost [127.0.0.1]) by simark.ca (Postfix) with ESMTP id AA7551EA17; Wed, 20 Sep 2017 10:40:15 -0400 (EDT) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 20 Sep 2017 14:40:00 -0000 From: Simon Marchi To: Ulrich Weigand Cc: gdb-patches@sourceware.org Subject: Re: [RFC] Make init_type/arch_type take a size in bits In-Reply-To: <20170920135111.469B4D835E2@oc3748833570.ibm.com> References: <20170920135111.469B4D835E2@oc3748833570.ibm.com> Message-ID: <05d19c3351b9c0fa8ed80e4dc2204024@polymtl.ca> X-Sender: simon.marchi@polymtl.ca User-Agent: Roundcube Webmail/1.3.0 X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Wed, 20 Sep 2017 14:40:17 +0000 X-IsSubscribed: yes X-SW-Source: 2017-09/txt/msg00491.txt.bz2 On 2017-09-20 15:51, Ulrich Weigand wrote: > Simon Marchi wrote: > >> Since this is where we do the division by >> TARGET_CHAR_BIT, and therefore assume (implicitly) that bit is a >> multiple of TARGET_CHAR_BIT, I think this is where the assert should >> be >> added. To avoid adding them everywhere, we could make >> arch_type/init_type take a size in bits, and do the division and >> assert >> there. > > As discussed, this changes the interfaces to init_type and arch_type > to take the type length in bits as input (instead of as bytes). The > routine asserts that the length is a multiple of TARGET_CHAR_BIT. > > For consistency, arch_flags_type is changed likewise, so that now > all type creation interfaces always use length in bits. > > All callers are updated in the straightforward manner. > > The assert actually found a bug in stabsread.c:read_range_type, where > the init_integer_type routine was called with a wrong argument > (probably > a bug introduced with the conversion to use init_integer_type). I took a quick look, it looks good to me. Just one comment below. > Index: binutils-gdb/gdb/gnu-v3-abi.c > =================================================================== > --- binutils-gdb.orig/gdb/gnu-v3-abi.c > +++ binutils-gdb/gdb/gnu-v3-abi.c > @@ -1024,7 +1024,7 @@ build_std_type_info_type (struct gdbarch > > gdb_assert (field == (field_list + 2)); > > - t = arch_type (arch, TYPE_CODE_STRUCT, offset, NULL); > + t = arch_type (arch, TYPE_CODE_STRUCT, offset * TARGET_CHAR_BIT, > NULL); > TYPE_NFIELDS (t) = field - field_list; > TYPE_FIELDS (t) = field_list; > TYPE_TAG_NAME (t) = "gdb_gnu_v3_type_info"; In gnu-v3-abi.c, there seems to be another call to arch_type that needs adjusting in build_gdb_vtable_type: t = arch_type (arch, TYPE_CODE_STRUCT, offset, NULL); Simon