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 7B9CE388E826 for ; Thu, 31 Mar 2022 21:05:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7B9CE388E826 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.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-7-yvC-N8rnNNKJr3rhAa5jzA-1; Thu, 31 Mar 2022 17:04:53 -0400 X-MC-Unique: yvC-N8rnNNKJr3rhAa5jzA-1 Received: by mail-wm1-f69.google.com with SMTP id v191-20020a1cacc8000000b0038ce818d2efso339039wme.1 for ; Thu, 31 Mar 2022 14:04:53 -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=DjVcVmw71m+fbTT51RbNHHw2eRlkiaCUfPsDVfPYcQs=; b=K+g2myW3YtayswSIeyMz7UovDSEi+ylAS8+QmoNCk3YP30xFikVJTlzOPb6bsip5bv JYKaYYb0QKTrbnycPfimz61TIRyOtCnhq4sGaVqDLp7n1ElyEMimekF3/NxlG+tfroW6 vyC186e4R38xZ6AVWsRn1cNCBwmA3R4T3VcWRpIfcy9NYlDvyjBvVCzLy/bfVaKoVw3/ 9Q1oVoDz9MOPzmUjh5RNuoVz5xyLUahn9u54OjQsakMj19qq8TAznEtrVTkVXH+5qn38 jsNN/eePytfk5jUeBehpYPBCGmazuwco85rP2X3S+RU7lWqDoArtOBiYmOrJFq0RdjdI LhMw== X-Gm-Message-State: AOAM533mr19SqQ4mvF3aExlp428IA6YNpx8BN2J6OpfyXcH5zzEZ2CwV hm2o+F9JjKuzbdJHN8/POUzM0TWE5ooeNBgN9se4Fd0YtU62xX4Pq4ei4FDFWQHb1gg4k58FRTv n5WugZ4hZNf8uogQ534I+6CyyjXjcWyViLYoV5G2N9NFgVCqbkVx3wCebDnKCqtU2Z5BS+wQF6w == X-Received: by 2002:a05:6000:1688:b0:205:a693:134c with SMTP id y8-20020a056000168800b00205a693134cmr5502728wrd.558.1648760691740; Thu, 31 Mar 2022 14:04:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzO4UhB8l4eHVQPYd20eDdXLYs3ByKTQLbnxHmffRUpdY87z52w9DFLuNZY1V2xEEGR/dKM7w== X-Received: by 2002:a05:6000:1688:b0:205:a693:134c with SMTP id y8-20020a056000168800b00205a693134cmr5502714wrd.558.1648760691471; Thu, 31 Mar 2022 14:04:51 -0700 (PDT) Received: from localhost (host86-169-131-113.range86-169.btcentralplus.com. [86.169.131.113]) by smtp.gmail.com with ESMTPSA id f9-20020a05600c4e8900b0038cc29bb0e1sm10281395wmq.4.2022.03.31.14.04.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Mar 2022 14:04:51 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 14/16] gdb: convert reggroup to a C++ class with constructor, etc Date: Thu, 31 Mar 2022 22:04:20 +0100 Message-Id: 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.3 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, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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: Thu, 31 Mar 2022 21:05:03 -0000 Convert the 'struct reggroup' into a real class, with a constructor and getter methods. There should be no user visible changes after this commit. --- gdb/reggroups.c | 48 ++++++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/gdb/reggroups.c b/gdb/reggroups.c index 2888704f2d2..dfae60773bb 100644 --- a/gdb/reggroups.c +++ b/gdb/reggroups.c @@ -32,18 +32,33 @@ struct reggroup { - const char *name; - enum reggroup_type type; + /* 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) { - struct reggroup *group = XNEW (struct reggroup); - - group->name = name; - group->type = type; - return group; + return new reggroup (name, type); } /* See reggroups.h. */ @@ -52,12 +67,9 @@ const reggroup * reggroup_gdbarch_new (struct gdbarch *gdbarch, const char *name, enum reggroup_type type) { - struct reggroup *group = GDBARCH_OBSTACK_ZALLOC (gdbarch, - struct reggroup); - - group->name = gdbarch_obstack_strdup (gdbarch, name); - group->type = type; - return group; + name = gdbarch_obstack_strdup (gdbarch, name); + return obstack_new (gdbarch_obstack (gdbarch), + name, type); } /* Register group attributes. */ @@ -65,13 +77,13 @@ reggroup_gdbarch_new (struct gdbarch *gdbarch, const char *name, const char * reggroup_name (const struct reggroup *group) { - return group->name; + return group->name (); } enum reggroup_type reggroup_type (const struct reggroup *group) { - return group->type; + return group->type (); } /* A container holding all the register groups for a particular @@ -194,7 +206,7 @@ reggroup_find (struct gdbarch *gdbarch, const char *name) { for (const struct reggroup *group : gdbarch_reggroups (gdbarch)) { - if (strcmp (name, reggroup_name (group)) == 0) + if (strcmp (name, group->name ()) == 0) return group; } return NULL; @@ -212,12 +224,12 @@ reggroups_dump (struct gdbarch *gdbarch, struct ui_file *file) for (const struct reggroup *group : gdbarch_reggroups (gdbarch)) { /* Group name. */ - const char *name = reggroup_name (group); + const char *name = group->name (); /* Group type. */ const char *type; - switch (reggroup_type (group)) + switch (group->type ()) { case USER_REGGROUP: type = "user"; -- 2.25.4