From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1726) id A0774385840A; Wed, 31 Aug 2022 15:33:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A0774385840A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1661959985; bh=bxwfkOrekr04RD8+UWI7chpFT/wkZjkS7Mequmw3pMM=; h=From:To:Subject:Date:From; b=vb+aw1kCYh812Mb9VkUIQTHHGul3Uu+Q9TPEVUMVbh1XfxBjErx+0wT7y9ESqSR5h LOtz/sO1fgHrvB2iBBhQK1TxpWcpAaqLjMdsfLTIWREY0xxe8lQDo3fk+d6Cozx5g9 B8gjLhOqH2QKMdjD7VOATzP4RN4RlR1Gatn8H8TM= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Andrew Burgess To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb: Add tdesc_found_register function to tdesc API X-Act-Checkin: binutils-gdb X-Git-Author: Andrew Burgess X-Git-Refname: refs/heads/master X-Git-Oldrev: 3095d92634a938d447eed1ef2c5d59f40f44078e X-Git-Newrev: b49d7aa74466fb73529ebf0e6c907c2142505610 Message-Id: <20220831153305.A0774385840A@sourceware.org> Date: Wed, 31 Aug 2022 15:33:05 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Db49d7aa74466= fb73529ebf0e6c907c2142505610 commit b49d7aa74466fb73529ebf0e6c907c2142505610 Author: Andrew Burgess Date: Thu Aug 11 12:43:08 2022 +0100 gdb: Add tdesc_found_register function to tdesc API =20 This commit adds a new function to the target description API within GDB. This new function is not used in this commit, but will be used in the next commit, I'm splitting it out into a separate patch for easier review. =20 What I want to do in the next commit is check to see if a target description supplied a particular register, however, the register in question could appear in one of two possible features. =20 The new function allows me to ask the tdesc_arch_data whether a register was found and assigned a particular GDB register number once all of the features have been checked. I think this is a much simpler solution than adding code such that, while checking each feature, I spot if the register I'm processing is the one I care about. =20 No tests here as the new code is not used, but this code will be exercised in the next commit. Diff: --- gdb/target-descriptions.c | 11 +++++++++++ gdb/target-descriptions.h | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c index d5d795875c2..044b171ecd2 100644 --- a/gdb/target-descriptions.c +++ b/gdb/target-descriptions.c @@ -849,6 +849,17 @@ tdesc_numbered_register_choices (const struct tdesc_fe= ature *feature, return 0; } =20 +/* See target-descriptions.h. */ + +bool +tdesc_found_register (struct tdesc_arch_data *data, int regno) +{ + gdb_assert (regno >=3D 0); + + return (regno < data->arch_regs.size () + && data->arch_regs[regno].reg !=3D nullptr); +} + /* Search FEATURE for a register named NAME, and return its size in bits. The register must exist. */ =20 diff --git a/gdb/target-descriptions.h b/gdb/target-descriptions.h index 3b90dedcd80..3ab0ae2542d 100644 --- a/gdb/target-descriptions.h +++ b/gdb/target-descriptions.h @@ -170,6 +170,10 @@ int tdesc_numbered_register_choices (const struct tdes= c_feature *feature, struct tdesc_arch_data *data, int regno, const char *const names[]); =20 +/* Return true if DATA contains an entry for REGNO, a GDB register + number. */ + +extern bool tdesc_found_register (struct tdesc_arch_data *data, int regno); =20 /* Accessors for target descriptions. */