From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 39365 invoked by alias); 1 Feb 2017 15:49:17 -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 39355 invoked by uid 89); 1 Feb 2017 15:49:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1327, sk:max_reg, sk:MAX_REG, Removal 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 ESMTP; Wed, 01 Feb 2017 15:49:16 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F144B7E9CA; Wed, 1 Feb 2017 15:49:15 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.phx2.redhat.com [10.5.9.4]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v11FnEkA011767; Wed, 1 Feb 2017 10:49:15 -0500 Subject: Re: [PATCH] Removal of uses of MAX_REGISTER_SIZE To: Alan Hayward References: <7CF07197-4FED-4970-BB4B-2FE828E29A63@arm.com> <45e3a5e1-a9aa-1bc0-5d08-526b89fc458e@redhat.com> Cc: "gdb-patches@sourceware.org" , nd From: Pedro Alves Message-ID: <9bf11853-462e-1950-aab4-19fa376faf4e@redhat.com> Date: Wed, 01 Feb 2017 15:49:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2017-02/txt/msg00031.txt.bz2 On 01/27/2017 04:46 PM, Alan Hayward wrote: > --- a/gdb/xtensa-tdep.c > +++ b/gdb/xtensa-tdep.c > @@ -370,7 +370,10 @@ static void > xtensa_register_write_masked (struct regcache *regcache, > xtensa_register_t *reg, const gdb_byte *buffer) > { > - unsigned int value[(MAX_REGISTER_SIZE + 3) / 4]; > + struct gdbarch *gdbarch = get_regcache_arch (regcache); > + unsigned int *value = (unsigned int *) alloca (max_register_size (gdbarch) > + + 1); I don't think I understand this +1. AFAICS, the previous code was creating an array of ints such that sizeof(value) is as big as MAX_REGISTER_SIZE, rounded up to sizeof int. Seems like a replacement would be: alloca (align_up (max_register_size (gdbarch), 4)); or better: alloca (align_up (max_register_size (gdbarch), sizeof (int))); ? > + > const xtensa_mask_t *mask = reg->mask; > > int shift = 0; /* Shift for next mask (mod 32). */ > @@ -454,7 +457,9 @@ static enum register_status > xtensa_register_read_masked (struct regcache *regcache, > xtensa_register_t *reg, gdb_byte *buffer) > { > - unsigned int value[(MAX_REGISTER_SIZE + 3) / 4]; > + struct gdbarch *gdbarch = get_regcache_arch (regcache); > + unsigned int *value = (unsigned int *) alloca (max_register_size (gdbarch) > + + 1); Ditto. Thanks, Pedro Alves