From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id qC5RKBAZRmJQHAAAWB0awg (envelope-from ) for ; Thu, 31 Mar 2022 17:11:44 -0400 Received: by simark.ca (Postfix, from userid 112) id A20C51F163; Thu, 31 Mar 2022 17:11:44 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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.2 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 C16591E150 for ; Thu, 31 Mar 2022 17:11:43 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 640EA388CC2B for ; Thu, 31 Mar 2022 21:11:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 640EA388CC2B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1648761103; bh=W5l/Acs0KNFF7WLPCkqLpNHB2jG7qh8ynmmUEHoT+VA=; 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=kqkLkiX/HITTBylWqycG0vOOGFPVvnsaovWE6fWd24n1Lm9HMasV16WhiSWbWt1eb 074PQrY+jvtGlEPqMCxwUVo2FVLsoSFaAsE7KSbfZGniLTMRb6bTxi5DtVklGLPn97 MRVd/1DpfDttWFCGNSc0PM/UGkws1CtZVZiAvxzI= 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 E669D388703A for ; Thu, 31 Mar 2022 21:04:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E669D388703A Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-385-o7_eH4lcPAOY8qeV6WKKCA-1; Thu, 31 Mar 2022 17:04:55 -0400 X-MC-Unique: o7_eH4lcPAOY8qeV6WKKCA-1 Received: by mail-wm1-f70.google.com with SMTP id 2-20020a1c0202000000b0038c71e8c49cso1879587wmc.1 for ; Thu, 31 Mar 2022 14:04:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=W5l/Acs0KNFF7WLPCkqLpNHB2jG7qh8ynmmUEHoT+VA=; b=VN3ns+qTQXcnG16JjVfXkVVOMNr4d/7zAA8r6CXEfrS7t1ve855NCiV8uP/mNj96oA hNgrXLL4LyRwul0atL0NwVYPOIrHE4088n7NwtCySVW5+9Lcpo1qx0gcBrBKUP3asn6b a8hsfXI3bWuxOSSdS3eU/awywMVMk4oVeqdG9At9lWF3lGURvgmsHatTZLixw1C5P/XD M0AvdvquGahJk9eKsT2HK5CuLElhV6gE8pJlEQWZtO3SD4L/smM+dZJf3dU/OWC+ksli O46DRTvQ2tGWZRI9/pbRUrgnT4Q7WxK9VjxVZOV8Zvdoyk5V9Pdvf7mXlFxQVHF7HsUe 2Rqw== X-Gm-Message-State: AOAM533+gej2xRpS4pPajV6Nh3bTZ51StQh0H8f0OZELd3eLw3PzNY4n jI2VAj++nUUgy5VhEWP7zmz5j2+2JU536AE3no+UqAa9AXl/paSDy4x7mFOqTkMlqSGRmuCLIRj N0F+tH5aAIHe8t+TIFbcGc87NbymaVjfaDh/Y5MrR8K314orsjyV7phwMyD0SUdLpBA8N5thXUg == X-Received: by 2002:adf:d1e8:0:b0:203:fed6:9945 with SMTP id g8-20020adfd1e8000000b00203fed69945mr5317762wrd.152.1648760693362; Thu, 31 Mar 2022 14:04:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmAxDLEiQHL2ZG65qmw0iCwf5FFSGb2drC2ZzjiA5kLgN2104tsMNRVWbGrGXqzuwIpuHP+A== X-Received: by 2002:adf:d1e8:0:b0:203:fed6:9945 with SMTP id g8-20020adfd1e8000000b00203fed69945mr5317747wrd.152.1648760692954; Thu, 31 Mar 2022 14:04:52 -0700 (PDT) Received: from localhost (host86-169-131-113.range86-169.btcentralplus.com. [86.169.131.113]) by smtp.gmail.com with ESMTPSA id i5-20020adfaac5000000b00203fd04bf86sm391182wrc.66.2022.03.31.14.04.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Mar 2022 14:04:52 -0700 (PDT) To: gdb-patches@sourceware.org Subject: [PATCH 15/16] gdb: move struct reggroup into reggroups.h header Date: Thu, 31 Mar 2022 22:04:21 +0100 Message-Id: <2242fbe8bf67a841d84e146bfa8264155569c5b6.1648760270.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" Move 'struct reggroup' into the reggroups.h header. Remove the reggroup_name and reggroup_type accessor functions, and just use the name/type member functions within 'struct reggroup', update all uses of these removed functions. There should be no user visible changes after this commit. --- gdb/completer.c | 2 +- gdb/infcmd.c | 2 +- gdb/nds32-tdep.c | 2 +- gdb/python/py-registers.c | 3 +-- gdb/regcache-dump.c | 3 +-- gdb/reggroups.c | 41 --------------------------------------- gdb/reggroups.h | 32 +++++++++++++++++++++++++----- gdb/target-descriptions.c | 2 +- gdb/tui/tui-regs.c | 6 +++--- 9 files changed, 36 insertions(+), 57 deletions(-) diff --git a/gdb/completer.c b/gdb/completer.c index 8bb12f256af..019da9a0603 100644 --- a/gdb/completer.c +++ b/gdb/completer.c @@ -1897,7 +1897,7 @@ reg_or_group_completer_1 (completion_tracker &tracker, { for (const struct reggroup *group : gdbarch_reggroups (gdbarch)) { - name = reggroup_name (group); + name = group->name (); if (strncmp (word, name, len) == 0) tracker.add_completion (make_unique_xstrdup (name)); } diff --git a/gdb/infcmd.c b/gdb/infcmd.c index a28250a456d..fbbf3cdbc6f 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -2301,7 +2301,7 @@ registers_info (const char *addr_exp, int fpregs) /* Don't bother with a length check. Should the user enter a short register group name, go with the first group that matches. */ - if (strncmp (start, reggroup_name (g), end - start) == 0) + if (strncmp (start, g->name (), end - start) == 0) { group = g; break; diff --git a/gdb/nds32-tdep.c b/gdb/nds32-tdep.c index 06b129bdd31..e95ad7cc662 100644 --- a/gdb/nds32-tdep.c +++ b/gdb/nds32-tdep.c @@ -390,7 +390,7 @@ nds32_register_reggroup_p (struct gdbarch *gdbarch, int regnum, /* The NDS32 reggroup contains registers whose name is prefixed by reggroup name. */ reg_name = gdbarch_register_name (gdbarch, regnum); - group_name = reggroup_name (reggroup); + group_name = reggroup->name (); return !strncmp (reg_name, group_name, strlen (group_name)); } diff --git a/gdb/python/py-registers.c b/gdb/python/py-registers.c index 7a9d2e22403..725cab5d6fb 100644 --- a/gdb/python/py-registers.c +++ b/gdb/python/py-registers.c @@ -137,8 +137,7 @@ gdbpy_reggroup_to_string (PyObject *self) reggroup_object *group = (reggroup_object *) self; const reggroup *reggroup = group->reggroup; - const char *name = reggroup_name (reggroup); - return PyUnicode_FromString (name); + return PyUnicode_FromString (reggroup->name ()); } /* Implement gdb.RegisterGroup.name (self) -> String. diff --git a/gdb/regcache-dump.c b/gdb/regcache-dump.c index 409a868be76..0c5da0e241d 100644 --- a/gdb/regcache-dump.c +++ b/gdb/regcache-dump.c @@ -196,8 +196,7 @@ class register_dump_groups : public register_dump { if (gdbarch_register_reggroup_p (m_gdbarch, regnum, group)) { - gdb_printf (file, - "%s%s", sep, reggroup_name (group)); + gdb_printf (file, "%s%s", sep, group->name ()); sep = ","; } } diff --git a/gdb/reggroups.c b/gdb/reggroups.c index dfae60773bb..96d4ae4d1f8 100644 --- a/gdb/reggroups.c +++ b/gdb/reggroups.c @@ -28,33 +28,6 @@ #include "gdbcmd.h" /* For maintenanceprintlist. */ #include "gdbsupport/gdb_obstack.h" -/* Individual register groups. */ - -struct reggroup -{ - /* Create a new register group object. The NAME is not owned by the new - reggroup object, so must outlive the object. */ - reggroup (const char *name, enum reggroup_type type) - : m_name (name), - m_type (type) - { /* Nothing. */ } - - /* Return the name for this register group. */ - const char *name () const - { return m_name; } - - /* Return the type of this register group. */ - enum reggroup_type type () const - { return m_type; } - -private: - /* The name of this register group. */ - const char *m_name; - - /* The type of this register group. */ - enum reggroup_type m_type; -}; - const reggroup * reggroup_new (const char *name, enum reggroup_type type) { @@ -72,20 +45,6 @@ reggroup_gdbarch_new (struct gdbarch *gdbarch, const char *name, name, type); } -/* Register group attributes. */ - -const char * -reggroup_name (const struct reggroup *group) -{ - return group->name (); -} - -enum reggroup_type -reggroup_type (const struct reggroup *group) -{ - return group->type (); -} - /* A container holding all the register groups for a particular architecture. */ diff --git a/gdb/reggroups.h b/gdb/reggroups.h index ec1d79dfc30..db5625a53bd 100644 --- a/gdb/reggroups.h +++ b/gdb/reggroups.h @@ -23,10 +23,36 @@ #define REGGROUPS_H struct gdbarch; -struct reggroup; enum reggroup_type { USER_REGGROUP, INTERNAL_REGGROUP }; +/* Individual register group. */ + +struct reggroup +{ + /* Create a new register group object. The NAME is not owned by the new + reggroup object, so must outlive the object. */ + reggroup (const char *name, enum reggroup_type type) + : m_name (name), + m_type (type) + { /* Nothing. */ } + + /* Return the name for this register group. */ + const char *name () const + { return m_name; } + + /* Return the type of this register group. */ + enum reggroup_type type () const + { return m_type; } + +private: + /* The name of this register group. */ + const char *m_name; + + /* The type of this register group. */ + enum reggroup_type m_type; +}; + /* Pre-defined, user visible, register groups. */ extern const reggroup *const general_reggroup; extern const reggroup *const float_reggroup; @@ -50,10 +76,6 @@ extern const reggroup *reggroup_gdbarch_new (struct gdbarch *gdbarch, /* Add a register group (with attribute values) to the pre-defined list. */ extern void reggroup_add (struct gdbarch *gdbarch, const reggroup *group); -/* Register group attributes. */ -extern const char *reggroup_name (const struct reggroup *reggroup); -extern enum reggroup_type reggroup_type (const struct reggroup *reggroup); - /* Return the list of all register groups for GDBARCH. */ extern const std::vector gdbarch_reggroups (struct gdbarch *gdbarch); diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c index 33277c3d02d..85954ac2939 100644 --- a/gdb/target-descriptions.c +++ b/gdb/target-descriptions.c @@ -1012,7 +1012,7 @@ tdesc_register_in_reggroup_p (struct gdbarch *gdbarch, int regno, struct tdesc_reg *reg = tdesc_find_register (gdbarch, regno); if (reg != NULL && !reg->group.empty () - && (reg->group == reggroup_name (reggroup))) + && (reg->group == reggroup->name ())) return 1; if (reg != NULL diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c index 65ec8241370..2086ad4498c 100644 --- a/gdb/tui/tui-regs.c +++ b/gdb/tui/tui-regs.c @@ -216,7 +216,7 @@ tui_data_window::show_register_group (const reggroup *group, int regnum, pos; /* Make a new title showing which group we display. */ - title = string_printf ("Register group: %s", reggroup_name (group)); + title = string_printf ("Register group: %s", group->name ()); /* See how many registers must be displayed. */ nr_regs = 0; @@ -609,7 +609,7 @@ tui_reg_command (const char *args, int from_tty) group then the switch is made. */ for (const struct reggroup *group : gdbarch_reggroups (gdbarch)) { - if (strncmp (reggroup_name (group), args, len) == 0) + if (strncmp (group->name (), args, len) == 0) { if (match != NULL) error (_("ambiguous register group name '%s'"), args); @@ -635,7 +635,7 @@ tui_reg_command (const char *args, int from_tty) if (!first) gdb_printf (", "); first = false; - gdb_printf ("%s", reggroup_name (group)); + gdb_printf ("%s", group->name ()); } gdb_printf ("\n"); -- 2.25.4