From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 119792 invoked by alias); 22 May 2017 17:15:38 -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 119110 invoked by uid 89); 22 May 2017 17:15:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00,GIT_PATCH_2,GIT_PATCH_3,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1868 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; Mon, 22 May 2017 17:15:19 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B4B0FC0CC63A; Mon, 22 May 2017 17:15:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B4B0FC0CC63A Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=palves@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B4B0FC0CC63A Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id CD562783C4; Mon, 22 May 2017 17:15:02 +0000 (UTC) Subject: Re: [PATCH 3/11] Add MIPS_MAX_REGISTER_SIZE (2/4) To: Alan Hayward , Yao Qi References: <3C00280E-37C9-4C0A-9DA6-F3B9DB1A6E8F@arm.com> <86y3v7uf9j.fsf@gmail.com> <806B436F-EFA1-4200-AC54-9036D166C9B9@arm.com> <867f1m8nhm.fsf@gmail.com> <8637bx9jsw.fsf@gmail.com> <78A7E8EA-7203-44DF-B7FD-63E75A5ECEF5@arm.com> Cc: "gdb-patches@sourceware.org" , nd From: Pedro Alves Message-ID: <540372d8-efc3-f842-5cac-cd813bacc3f5@redhat.com> Date: Mon, 22 May 2017 17:15: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: <78A7E8EA-7203-44DF-B7FD-63E75A5ECEF5@arm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2017-05/txt/msg00494.txt.bz2 On 05/22/2017 05:05 PM, Alan Hayward wrote: > { > enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); > - gdb_byte buf[MAX_REGISTER_SIZE]; > LONGEST val; > > - val = extract_signed_integer ((const gdb_byte *) addr, len, byte_order); > - store_signed_integer (buf, register_size (gdbarch, regnum), byte_order, > - val); > - regcache_raw_supply (regcache, regnum, buf); > + val = extract_integer ((const gdb_byte *) addr, len, byte_order); > + regcache->raw_supply (regnum, val); > } > } > > else > { > enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); > - gdb_byte buf[MAX_REGISTER_SIZE]; > - LONGEST val; > - > - regcache_raw_collect (regcache, regnum, buf); > - val = extract_signed_integer (buf, register_size (gdbarch, regnum), > - byte_order); > - store_signed_integer ((gdb_byte *) addr, len, byte_order, val); > + LONGEST val = regcache->raw_collect (regnum); > + store_integer ((gdb_byte *) addr, len, byte_order, val); I wonder whether we can get rid of the LONGEST / host integer middleman and simplify things while at it. For instance, what if we had a version of raw_collect that took the destination buffer length as parameter: regcache->raw_collect_integer (regnum, (gdb_byte *) addr, len); that would copy bytes over into addr, and if the register is narrower than LEN, then it'd insert the necessary leading zeros (or 0xFFs if signed extension necessary), and if the registers is wider than LEN, then it'd skip copying enough significant bytes so that LEN fits. Likewise for regcache->raw_supply. > --- a/gdb/regcache.h > +++ b/gdb/regcache.h > @@ -21,6 +21,7 @@ > #define REGCACHE_H > > #include "common-regcache.h" > +#include "defs.h" Headers should not include defs.h. Is there some .c file that misses including defs.h first thing? Thanks, Pedro Alves