From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.baldwin.cx (bigwig.baldwin.cx [66.216.25.90]) by sourceware.org (Postfix) with ESMTPS id 5DF8F3838010 for ; Mon, 12 Jul 2021 15:56:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5DF8F3838010 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=FreeBSD.org Received: from gimli.com (d-24-233-223-154.va.cpe.atlanticbb.net [24.233.223.154]) by mail.baldwin.cx (Postfix) with ESMTPSA id E48621A84BA9 for ; Mon, 12 Jul 2021 11:55:55 -0400 (EDT) From: John Baldwin To: gdb-patches@sourceware.org Subject: [PATCH v2 1/5] Add regcache_map_supplies helper routine. Date: Mon, 12 Jul 2021 08:53:49 -0700 Message-Id: <20210712155353.75907-2-jhb@FreeBSD.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210712155353.75907-1-jhb@FreeBSD.org> References: <20210712155353.75907-1-jhb@FreeBSD.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.4 (mail.baldwin.cx [0.0.0.0]); Mon, 12 Jul 2021 11:55:56 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.103.1 at mail.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_STATUS, KHOP_HELO_FCRDNS, SPF_HELO_PASS, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Jul 2021 15:56:02 -0000 This helper can be used in the fetch_registers and store_registers target methods to determine if a register set includes a specific register. --- gdb/regcache.c | 27 +++++++++++++++++++++++++++ gdb/regcache.h | 9 +++++++++ 2 files changed, 36 insertions(+) diff --git a/gdb/regcache.c b/gdb/regcache.c index fde0c61297..fe61512e50 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -1264,6 +1264,33 @@ regcache::collect_regset (const struct regset *regset, transfer_regset (regset, nullptr, regnum, nullptr, (gdb_byte *) buf, size); } +/* See regcache.h */ + +bool +regcache_map_supplies (const struct regcache_map_entry *map, int regnum, + struct gdbarch *gdbarch, size_t size) +{ + int offs = 0, count; + + for (; (count = map->count) != 0; map++) + { + int regno = map->regno; + int slot_size = map->size; + + if (slot_size == 0 && regno != REGCACHE_MAP_SKIP) + slot_size = register_size (gdbarch, regno); + + if (regno != REGCACHE_MAP_SKIP && regnum >= regno + && regnum < regno + count) + return offs + (regnum - regno + 1) * slot_size <= size; + + offs += count * slot_size; + if (offs >= size) + return false; + } + return false; +} + /* See gdbsupport/common-regcache.h. */ bool diff --git a/gdb/regcache.h b/gdb/regcache.h index ee254f381f..cd2e441fed 100644 --- a/gdb/regcache.h +++ b/gdb/regcache.h @@ -150,6 +150,15 @@ extern void regcache_collect_regset (const struct regset *regset, int regnum, void *buf, size_t size); +/* Return true if a set of registers contains the value of the + register numbered REGNUM. The size of the set of registers is + given in SIZE, and the layout of the set of registers is described + by MAP. */ + +extern bool regcache_map_supplies (const struct regcache_map_entry *map, + int regnum, struct gdbarch *gdbarch, + size_t size); + /* The type of a register. This function is slightly more efficient then its gdbarch vector counterpart since it returns a precomputed value stored in a table. */ -- 2.31.1