From patchwork Tue Dec 19 14:22:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 25011 Received: (qmail 23764 invoked by alias); 19 Dec 2017 14:23:16 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 23733 invoked by uid 89); 19 Dec 2017 14:23:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-pg0-f68.google.com Received: from mail-pg0-f68.google.com (HELO mail-pg0-f68.google.com) (74.125.83.68) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 19 Dec 2017 14:23:15 +0000 Received: by mail-pg0-f68.google.com with SMTP id q20so10597502pgv.2 for ; Tue, 19 Dec 2017 06:23:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6n7QcuoREQXdrhS9cU2p/EqrlfOhoCLYtYXOrn+mZi8=; b=Aq0Z2eMUrTjfabV0laVg+1uUeQedZkbRGj5wZ80Pzi3qOwimUcP3e9XGHJkM3ulrwv KXoyCfX5wfNZHZnvTncRC3aXHnZkI6hgucGKzJwAegh+Rg7CjquGt1CZ+0MSRG5vxqJL vDRnrZj8Wz16QfiW2LV92ZBWtBJ7C/RvGFlDu0Jh8Yb2Q2hdeVtZ8YBjFRILsCR+gxUS ixRZhGT6GOIniBrFRnDgPoJEqFb6MXAmZi0BmZA7QdKN8wfJjYy8XgVoG4UhV1+PrO7x +wUxUGr+pxa3BT0TP/XUEiAvVxg97Wl+hIS/dLUR7roobCibv1iWUoisEHiszF84yk93 iZYQ== X-Gm-Message-State: AKGB3mJrmIqaCU+oJuMPqPF2Ezfn8vTK/g+RHbxARLGtPCFdTlhS8h9Z Qm5cvVViZgbA71VVoSN+XgDrIegg X-Google-Smtp-Source: ACJfBotFAERvi7YFIWXvYlDRz/fXW2kLRDPFoY0nBxGahdaig2TsBcrsv0hvW+ELb+YA3Js9zMrsoA== X-Received: by 10.99.155.9 with SMTP id r9mr3022561pgd.359.1513693393341; Tue, 19 Dec 2017 06:23:13 -0800 (PST) Received: from localhost (g41.219-103-184.ppp.wakwak.ne.jp. [219.103.184.41]) by smtp.gmail.com with ESMTPSA id 84sm28359128pfy.59.2017.12.19.06.23.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Dec 2017 06:23:12 -0800 (PST) From: Stafford Horne To: GDB patches Cc: Openrisc , Stafford Horne Subject: [PATCH v3 3/4] reggroups: Create reggroup_gdbarch_new for dynamic reggroups Date: Tue, 19 Dec 2017 23:22:56 +0900 Message-Id: <20171219142257.13402-4-shorne@gmail.com> In-Reply-To: <20171219142257.13402-1-shorne@gmail.com> References: <20171219142257.13402-1-shorne@gmail.com> X-IsSubscribed: yes Traditionally reggroups have been created via reggroup_new() during initialization code and never freed. Now, if we want to initialize reggroups dynamically (i.e. in target description) we should be able to free them. Create this function reggroup_gdbarch_new() which will allocate the reggroup memory onto the passed gdbarch obstack. gdb/ChangeLog: 2017-06-10 Stafford Horne * reggroups.c (reggroup_gdbarch_new): New function. * reggroups.h (reggroup_gdbarch_new): New function. --- gdb/reggroups.c | 12 ++++++++++++ gdb/reggroups.h | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/gdb/reggroups.c b/gdb/reggroups.c index 5d5e33f2a3..acad91a0ab 100644 --- a/gdb/reggroups.c +++ b/gdb/reggroups.c @@ -46,6 +46,18 @@ reggroup_new (const char *name, enum reggroup_type type) return group; } +struct 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; +} + /* Register group attributes. */ const char * diff --git a/gdb/reggroups.h b/gdb/reggroups.h index 18fc1bf294..c1653cd39d 100644 --- a/gdb/reggroups.h +++ b/gdb/reggroups.h @@ -41,6 +41,10 @@ extern struct reggroup *const restore_reggroup; /* Create a new local register group. */ extern struct reggroup *reggroup_new (const char *name, enum reggroup_type type); +/* Create a new register group allocated onto the gdbarch obstack. */ +extern struct reggroup *reggroup_gdbarch_new (struct gdbarch *gdbarch, + const char *name, + enum reggroup_type type); /* Add a register group (with attribute values) to the pre-defined list. */ extern void reggroup_add (struct gdbarch *gdbarch, struct reggroup *group);