From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15344 invoked by alias); 9 Aug 2012 20:04:21 -0000 Received: (qmail 15329 invoked by uid 22791); 9 Aug 2012 20:04:20 -0000 X-SWARE-Spam-Status: No, hits=-6.2 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,SPF_HELO_PASS,TW_VP,T_RP_MATCHES_RCVD 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; Thu, 09 Aug 2012 20:04:02 +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 (8.14.4/8.14.4) with ESMTP id q79K42aZ015818 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 9 Aug 2012 16:04:02 -0400 Received: from host2.jankratochvil.net (ovpn-116-46.ams2.redhat.com [10.36.116.46]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q79K3uNx016694 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Thu, 9 Aug 2012 16:04:00 -0400 Date: Thu, 09 Aug 2012 20:04:00 -0000 From: Jan Kratochvil To: Siddhesh Poyarekar Cc: gdb-patches@sourceware.org Subject: Re: bitpos expansion patches summary Message-ID: <20120809200356.GA11680@host2.jankratochvil.net> References: <20120805005350.150e5b74@spoyarek> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20120805005350.150e5b74@spoyarek> User-Agent: Mutt/1.5.21 (2010-09-15) 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: 2012-08/txt/msg00291.txt.bz2 Hi Siddhesh, just some incremental notes, still looking at it. Thanks, Jan @@ -1406,6 +1406,15 @@ lookup_struct_elt_type (struct type *type, char *name, int noerr) error (_("Type %s has no component named %s."), typename, name); } +/* Ensure that the input TYPE is not larger than the maximum capacity of the + host system, i.e. size_t. */ +void +ensure_type_fits_sizet (const struct type *type) + +Make it ensure_type_fits_size_t. And there should be 'error' in its name. +For example 'type_fits_size_t_or_error' or something like that. + + +{ + if (!TYPE_LENGTH_FITS_SIZET (type)) + error (_("Target object too large for host GDB memory.")); + +Please print the sizes. Also this message is present at multiple places so +maybe rather make a function for unconditionally printing the error? + + +} + /* Lookup the vptr basetype/fieldno values for TYPE. If found store vptr_basetype in *BASETYPEP if non-NULL, and return vptr_fieldno. Also, if found and basetype is from the same objfile, @@ -1059,6 +1059,10 @@ extern void allocate_gnat_aux_type (struct type *); so you only have to call check_typedef once. Since allocate_value calls check_typedef, TYPE_LENGTH (VALUE_TYPE (X)) is safe. */ #define TYPE_LENGTH(thistype) (thistype)->length + +Empty line. + +/* Make sure that TYPE_LENGTH fits into a size_t. */ +#define TYPE_LENGTH_FITS_SIZET(thistype) ((size_t) TYPE_LENGTH (thistype) \ + == TYPE_LENGTH (thistype)) + +Make it TYPE_LENGTH_FITS_SIZE_T, please. And I think this macro is not needed, +inline it. (It does not access internal fields of the type structures.) + +And (a) check it already for ssize_t. Because the code is not safe enough to +properly handle unsigned sizes everywhere without overflows. (b) Make there +some reserve, anything close to ssize_t will never get successfully xmalloc-ed +anyway. Some maximum size could be: ((size_t) -1) / 4. Depending on SSIZE_MAX +may not be compatible enough I guess. + + + /* Note that TYPE_CODE can be TYPE_CODE_TYPEDEF, so if you want the real type, you need to do TYPE_CODE (check_type (this_type)). */ #define TYPE_CODE(thistype) TYPE_MAIN_TYPE(thistype)->code