From patchwork Mon Dec 5 12:28:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Hayward X-Patchwork-Id: 18192 Received: (qmail 15784 invoked by alias); 5 Dec 2016 12:28:18 -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 15770 invoked by uid 89); 5 Dec 2016 12:28:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.5 required=5.0 tests=BAYES_00, KAM_LOTSOFHASH, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=belonging, OFFSET, worker, H*u:sk:Microso X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 05 Dec 2016 12:28:16 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 55AF415AB; Mon, 5 Dec 2016 04:28:15 -0800 (PST) Received: from [10.45.32.207] (e105284-mac.manchester.arm.com [10.45.32.207]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 415C93F445 for ; Mon, 5 Dec 2016 04:28:11 -0800 (PST) User-Agent: Microsoft-MacOutlook/14.7.0.161029 Date: Mon, 05 Dec 2016 12:28:08 +0000 Subject: [PATCH 4/8] AARCH64 SVE: Regcache compare methods From: Alan Hayward To: Message-ID: Mime-version: 1.0 Content-type: text/plain; charset="UTF-8" Content-transfer-encoding: 7bit This is part of a series adding AARCH64 SVE support to gdb and gdbserver. This patch simply adds two methods for comparing a register value to a buffer. The function will ignore the first OFFSET bytes of the register value - this is used in a later patch where we check if the value of a Z register is able to fit into a V register. Tested on x86 and aarch64. Ok to commit? Alan. set to or from a buffer. This is the main worker function for regcache_supply_regset and regcache_collect_regset. */ diff --git a/gdb/gdbserver/regcache.h b/gdb/gdbserver/regcache.h index 2209915ffea2737eaf166d697c9e122182792092..4535d23622090a460de81f8dbbf144844 48d3c83 100644 --- a/gdb/gdbserver/regcache.h +++ b/gdb/gdbserver/regcache.h @@ -120,4 +120,9 @@ void collect_register_as_string (struct regcache *regcache, int n, char *buf); void collect_register_by_name (struct regcache *regcache, const char *name, void *buf); +/* Compare the value of a register (ignoring the first OFFSET bytes) to a + value in a BUF. Returns 0 if identical. */ + +int compare_register (struct regcache *regcache, int n, void *buf, int offset); + #endif /* REGCACHE_H */ diff --git a/gdb/gdbserver/regcache.c b/gdb/gdbserver/regcache.c index 2af8e241d98db5a8795682aa203f1585a4820ddb..752148042f26e1a23c9d0b1b7fb5d14ca b2bf538 100644 --- a/gdb/gdbserver/regcache.c +++ b/gdb/gdbserver/regcache.c @@ -489,3 +489,14 @@ regcache_write_pc (struct regcache *regcache, CORE_ADDR pc) } #endif + +/* Compare the value of a register (ignoring the first OFFSET bytes) to a + value in a BUF. Returns 0 if identical. */ + +int +compare_register (struct regcache *regcache, int n, void *buf, int offset) +{ + gdb_assert (register_size (regcache->tdesc, n) > offset); + return memcmp (buf, register_data (regcache, n, 1) + offset, + register_size (regcache->tdesc, n) - offset); +} diff --git a/gdb/regcache.h b/gdb/regcache.h index 11a8bb98d69d0c32def1d3f5d2d68dd82900357f..20696415eb579774f6c0adb251b5e8be1 36cbcf1 100644 --- a/gdb/regcache.h +++ b/gdb/regcache.h @@ -144,6 +144,12 @@ extern void regcache_raw_supply (struct regcache *regcache, extern void regcache_raw_collect (const struct regcache *regcache, int regnum, void *buf); +/* Compare the value of a register (ignoring the first OFFSET bytes) to a + value in a BUF. Returns 0 if identical. */ + +extern int regcache_raw_compare (const struct regcache *regcache, int regnum, + void *buf, int offset); + /* Mapping between register numbers and offsets in a buffer, for use in the '*regset' functions below. In an array of 'regcache_map_entry' each element is interpreted like follows: diff --git a/gdb/regcache.c b/gdb/regcache.c index 1fcf93386f7d3d4180ab6dad4f228566563855b2..368463129f2e1ba7d0b90b7baf590f731 e5fe36e 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -1112,6 +1112,26 @@ regcache_raw_collect (const struct regcache *regcache, int regnum, void *buf) memcpy (buf, regbuf, size); } +/* Compare the value of a register (ignoring the first OFFSET bytes) to a + value in a BUF. Returns 0 if identical. */ + +int +regcache_raw_compare (const struct regcache *regcache, int regnum, void *buf, + int offset) +{ + const char *regbuf; + size_t size; + + gdb_assert (regcache != NULL && buf != NULL); + gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers); + + regbuf = (const char *) register_buffer (regcache, regnum); + size = regcache->descr->sizeof_register[regnum]; + gdb_assert (size > offset); + + return memcmp (buf, regbuf + offset, size - offset); +} + /* Transfer a single or all registers belonging to a certain register