From patchwork Sat Jun 10 13:59:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 20894 Received: (qmail 66723 invoked by alias); 10 Jun 2017 13:59:50 -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 66662 invoked by uid 89); 10 Jun 2017 13:59:49 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=AWL, 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=Hx-languages-length:1901 X-HELO: mail-pf0-f195.google.com Received: from mail-pf0-f195.google.com (HELO mail-pf0-f195.google.com) (209.85.192.195) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 10 Jun 2017 13:59:48 +0000 Received: by mail-pf0-f195.google.com with SMTP id u26so11545979pfd.2 for ; Sat, 10 Jun 2017 06:59:52 -0700 (PDT) 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:in-reply-to:references; bh=4XBEHxRd7vep3lOGbGrET23g+5xfKXZ4UXV/qu1QU8E=; b=aw9WVW29+T3MppqnlPvOgiVGrIds7qRerRAwH/hai/kOF04KXeIBLtGmmTNvkNKW5q /TTFB7/0ANzYuhVvtXX3J739J2dqu6VOQEdwCS049BHNunkYMjertRlDe573Wy9mOv23 EPe2goko3KFVc/e3DINnTIIx2kwd3m4GZtqKh51BAEQxAUsd8YEQdI++1bNcwtjivV1d pbZAD8B+NIKVn/BGYV9XfsB5ViU3DFHkZXBy7/WijeIfQWHTFXIKx/QuFQVkM+OKVRP4 BJrqWlWQwI5sxyLLikmBaVuL0EMMlwadPR6hEErKzUqg6w3jIzIZ9p2EHJjS7P02HFL/ 6YFQ== X-Gm-Message-State: AODbwcDvROcyKhSmXJh9kDNg1mdN1vflSuYGFj84jCzg/st1PiJHqC3+ v/IMOnUX3v4gNhuMb6fUAg== X-Received: by 10.84.230.137 with SMTP id e9mr47169988plk.100.1497103190940; Sat, 10 Jun 2017 06:59:50 -0700 (PDT) Received: from localhost (g212.61-193-241.ppp.wakwak.ne.jp. [61.193.241.212]) by smtp.gmail.com with ESMTPSA id i68sm10679664pfi.72.2017.06.10.06.59.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 10 Jun 2017 06:59:50 -0700 (PDT) From: Stafford Horne To: GDB patches Cc: Stafford Horne Subject: [PATCH v2 3/4] reggroups: Create reggroup_gdbarch_new for dynamic reggroups Date: Sat, 10 Jun 2017 22:59:32 +0900 Message-Id: <93dc2d143055d0bd79375d7f0e7f2b730c668ed9.1497102900.git.shorne@gmail.com> In-Reply-To: References: In-Reply-To: References: 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 bf40964..c7126f7 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 18fc1bf..c1653cd 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);