From patchwork Tue Dec 19 14:22:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 25010 Received: (qmail 23467 invoked by alias); 19 Dec 2017 14:23:14 -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 23419 invoked by uid 89); 19 Dec 2017 14:23:14 -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=H*RU:209.85.160.68, Hx-spam-relays-external:209.85.160.68, Individual, HX-Received:10.84.131.129 X-HELO: mail-pl0-f68.google.com Received: from mail-pl0-f68.google.com (HELO mail-pl0-f68.google.com) (209.85.160.68) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 19 Dec 2017 14:23:12 +0000 Received: by mail-pl0-f68.google.com with SMTP id g2so7040449pli.8 for ; Tue, 19 Dec 2017 06:23:12 -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=j1ulxdaczB1gImkpqaf/qtuE2Kqpo4yMHHU9pt/Gae0=; b=Ew/OH36fIpuxC00zFvsvkggW3vDN2KmXKh2ZmaOtXN30mEdU7GUrKkiLxpW6UBapXg /z5HiOLKuAzFntrCF9QRr8rQr6dLTYY/OnZeUg+D4YlQHAzJuq9kLnXolYo1L1to/b9C kLs7n6Z9uXCmyAGofPs5eosln/J60cL0Rawsd8YDlhLdkrDDCP0+n42QKzSDxQohz1o8 rjONKt7MdfO5PSyMszLJ46VbIP77u6/+5sNfN11aFbOAHOnQ2tzQnHRqA2eBjA9Q2IRn ckyCMW/xhghFhlGiuNVPF6nkGyQzWPJbYk2WrgA6eREZnLoRnSc+w6n1au5apGHjI2Oz p8uA== X-Gm-Message-State: AKGB3mJkQjrv008MkYSsLVWtHRFpdD9ADIIMbl1kC8w7/MJDMqO4mEra ADH3A+QYnNB1vJg1Q5OLOunhRBUn X-Google-Smtp-Source: ACJfBotCiB5uWBUWQkz7OesK94elrTGr5c3BeKLsjB6mf8Idt4QfvD5Spgv2fDOyYgA3v3SOhFdy7g== X-Received: by 10.84.131.129 with SMTP id d1mr3461585pld.242.1513693390991; Tue, 19 Dec 2017 06:23:10 -0800 (PST) Received: from localhost (g41.219-103-184.ppp.wakwak.ne.jp. [219.103.184.41]) by smtp.gmail.com with ESMTPSA id x1sm13863128pgp.65.2017.12.19.06.23.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Dec 2017 06:23:10 -0800 (PST) From: Stafford Horne To: GDB patches Cc: Openrisc , Stafford Horne Subject: [PATCH v3 2/4] reggroups: Convert reggroups from post_init to pre_init Date: Tue, 19 Dec 2017 23:22:55 +0900 Message-Id: <20171219142257.13402-3-shorne@gmail.com> In-Reply-To: <20171219142257.13402-1-shorne@gmail.com> References: <20171219142257.13402-1-shorne@gmail.com> X-IsSubscribed: yes Currently the reggroups gdbarch_data cannot be manipulated until after the gdbarch is completely initialized. This is usually done when the object init depends on architecture specific fields. In the case of reggroups it only depends on the obstack being available. Coverting this to pre_init allows using reggroups during gdbarch initialization. This is needed to allow registering arbitrary reggroups during gdbarch initializations. gdb/ChangeLog: 2017-06-06 Stafford Horne * reggroups.c (reggroups_init): Change to depend only on obstack rather than gdbarch. (reggroup_add): Remove logic for forcing premature init. (_initialize_reggroup): Set `reggroups_data` with gdbarch_data_register_pre_init() rather than gdbarch_data_register_post_init(). --- gdb/reggroups.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/gdb/reggroups.c b/gdb/reggroups.c index 2ecd0b494f..5d5e33f2a3 100644 --- a/gdb/reggroups.c +++ b/gdb/reggroups.c @@ -26,6 +26,7 @@ #include "regcache.h" #include "command.h" #include "gdbcmd.h" /* For maintenanceprintlist. */ +#include "gdb_obstack.h" /* Individual register groups. */ @@ -76,10 +77,9 @@ struct reggroups static struct gdbarch_data *reggroups_data; static void * -reggroups_init (struct gdbarch *gdbarch) +reggroups_init (struct obstack *obstack) { - struct reggroups *groups = GDBARCH_OBSTACK_ZALLOC (gdbarch, - struct reggroups); + struct reggroups *groups = OBSTACK_ZALLOC (obstack, struct reggroups); groups->last = &groups->first; return groups; @@ -105,13 +105,6 @@ reggroup_add (struct gdbarch *gdbarch, struct reggroup *group) struct reggroups *groups = (struct reggroups *) gdbarch_data (gdbarch, reggroups_data); - if (groups == NULL) - { - /* ULGH, called during architecture initialization. Patch - things up. */ - groups = (struct reggroups *) reggroups_init (gdbarch); - deprecated_set_gdbarch_data (gdbarch, reggroups_data, groups); - } add_group (groups, group, GDBARCH_OBSTACK_ZALLOC (gdbarch, struct reggroup_el)); } @@ -298,7 +291,7 @@ struct reggroup *const restore_reggroup = &restore_group; void _initialize_reggroup (void) { - reggroups_data = gdbarch_data_register_post_init (reggroups_init); + reggroups_data = gdbarch_data_register_pre_init (reggroups_init); /* The pre-defined list of groups. */ add_group (&default_groups, general_reggroup, XNEW (struct reggroup_el));