From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 8971C3858429 for ; Tue, 16 Aug 2022 10:10:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8971C3858429 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-625-8yorgW6RMryylw3MwdbpPA-1; Tue, 16 Aug 2022 06:10:12 -0400 X-MC-Unique: 8yorgW6RMryylw3MwdbpPA-1 Received: by mail-wm1-f69.google.com with SMTP id z16-20020a05600c0a1000b003a5c18a66f0so4720636wmp.6 for ; Tue, 16 Aug 2022 03:10:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=3MVcZb9LopUAWaHpYH1h7dJb7VY2Yh+/j2Ge5bE6GHg=; b=eEQP5vPACrNJqeiT5AZQnm4bYaMeMXoWcwrxGuR22ZaTItjEAeshK3IQ3wQj4C8UeO /dBkQ3o3YaxnBso4GFiqPkjKVP93bN8avAEldflgjfo93b41RI0PI86KfadrpJ6foTNS AoIqthSTzW7SIPbJgO078kDEJnHKFkhoFCMShHcmjuMwhGAqcmTncptP1P5lfsZLiD/+ rCVkvVUEEdBq6VdKL8zcqTqze/wDYJK3YF1mghk5OsxtoNUxPqVdlgT9++dTs+ZK8F+A kZhpYscBlwgJ50hekpzcTeKU1Q86jeDZCsHV6irT7A6qu4afGyR7POsxbvXhT7LxX/q6 3WHg== X-Gm-Message-State: ACgBeo3ThyJcN47HzYMqsh3aMREY2uc7hHFsIvW95VoXOVLmZgFHcNEB vv9A25C9bk3wfMp9Q5ILTD9+FLVC71U40oR/MyDiyL8YImPfGMx2dcJg3wBEzoXnSv3F8DloS5N Cr3oKYGD3hsypTFXXNIbfe0F+YVaDnzvrpHw5JU/ry/isbnSU/w+yNnjpkFEXfbo5i2L3Tg1now == X-Received: by 2002:a5d:5550:0:b0:221:6d3a:1984 with SMTP id g16-20020a5d5550000000b002216d3a1984mr11167334wrw.326.1660644610732; Tue, 16 Aug 2022 03:10:10 -0700 (PDT) X-Google-Smtp-Source: AA6agR6nzzbBDXyydYjdqVScJL7W5A2dqAPSVqtSjM+Vo2SYUY5+BzFXyO2JRauCvka/mAALJTHY/w== X-Received: by 2002:a5d:5550:0:b0:221:6d3a:1984 with SMTP id g16-20020a5d5550000000b002216d3a1984mr11167314wrw.326.1660644610530; Tue, 16 Aug 2022 03:10:10 -0700 (PDT) Received: from localhost ([31.111.84.229]) by smtp.gmail.com with ESMTPSA id m17-20020a7bce11000000b003a536d5aa2esm12965624wmc.11.2022.08.16.03.10.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Aug 2022 03:10:10 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 2/3] gdb: Add tdesc_found_register function to tdesc API Date: Tue, 16 Aug 2022 11:09:57 +0100 Message-Id: <8d6f1d573eefa6949ff1b72f58d4c0366d34951c.1660644464.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Tue, 16 Aug 2022 10:10:23 -0000 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. 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. 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. No tests here as the new code is not used, but this code will be exercised in the next commit. --- 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_feature *feature, return 0; } +/* See target-descriptions.h. */ + +bool +tdesc_found_register (struct tdesc_arch_data *data, int regno) +{ + gdb_assert (regno >= 0); + + return (regno < data->arch_regs.size () + && data->arch_regs[regno].reg != nullptr); +} + /* Search FEATURE for a register named NAME, and return its size in bits. The register must exist. */ 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 tdesc_feature *feature, struct tdesc_arch_data *data, int regno, const char *const names[]); +/* 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); /* Accessors for target descriptions. */ -- 2.25.4