From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id SFBnD0Zt+2Ls4icAWB0awg (envelope-from ) for ; Tue, 16 Aug 2022 06:11:18 -0400 Received: by simark.ca (Postfix, from userid 112) id 3B0C21E5EA; Tue, 16 Aug 2022 06:11:18 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=H/XxRelH; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id E59401E13B for ; Tue, 16 Aug 2022 06:11:17 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 97B083858430 for ; Tue, 16 Aug 2022 10:11:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 97B083858430 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1660644677; bh=3MVcZb9LopUAWaHpYH1h7dJb7VY2Yh+/j2Ge5bE6GHg=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=H/XxRelHzcMg7oUuFilJIIh6husqdVj3Y5utux4QULKxGZd83pb6EhewZCe9li/GU bz7GlZ6igJ3STiFj4Z8BjfGKd7q2qUg5xJ0HnTPeD/wxG4LIn7r1pbLnSWAIu/Y2tI 7Zva0e0tUHXJQ+VDjGO7vHnlhj1I1ueSkP+kRiJM= 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) To: gdb-patches@sourceware.org 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-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: , From: Andrew Burgess via Gdb-patches Reply-To: Andrew Burgess Cc: Andrew Burgess Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" 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