From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 37857 invoked by alias); 26 Dec 2017 13:48:55 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 37761 invoked by uid 89); 26 Dec 2017 13:48:54 -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=7610 X-HELO: mail-pg0-f66.google.com Received: from mail-pg0-f66.google.com (HELO mail-pg0-f66.google.com) (74.125.83.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 26 Dec 2017 13:48:53 +0000 Received: by mail-pg0-f66.google.com with SMTP id q12so807246pgt.7 for ; Tue, 26 Dec 2017 05:48:53 -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=R1JdYDBS71C0p9WHxzHJ3pJ77Af6mW06xGFbLTtJQSE=; b=iJCLFvb9o5EsxfHdOatWI4iZB/szSjIZ0VE3JO/z8URfjn1R7OA3MaXe/Bk6pqgtx1 0P/1MdHiQjJrI37300fGq36HwtsulbghmC5QkygUf1yIPGEDgPwE/yUIrDY4c8Ou6uU+ EW6Tcux2pXNYF+EQBxPCr577N3X+ukIdmA6WX15GWW9rXu9c6oqOupxgBvnyImkg6ySV YtUMT8Z/URoxzrUFtLKqGaho7vSZrTqJmTGS6wlgK8ie2aex61Uu6vwuOoBqMVQeD9dk AEnEjcnzapCIW6yhhD9ni5lqSj7qY2JptNRKQEQkG2g0HvcBmhZKV8cvrMD3kOoXANer 3g4g== X-Gm-Message-State: AKGB3mIXtdOuMPFjZaQw006wWwCf+S9q0J/DkEbIHDWP+ZE388WQaM3J 6lnv3yE8AbJn5ZIb56gki/atTPRx X-Google-Smtp-Source: ACJfBoulce8Rl0b3K/K8qdAe4nw9ItqynhQpCW/NT50bEo2bBsod3igX8cRVnbD9kjHz1kDmLHUhlw== X-Received: by 10.99.152.70 with SMTP id l6mr21336393pgo.400.1514296131749; Tue, 26 Dec 2017 05:48:51 -0800 (PST) Received: from localhost (g121.222-224-191.ppp.wakwak.ne.jp. [222.224.191.121]) by smtp.gmail.com with ESMTPSA id m65sm58566602pfm.41.2017.12.26.05.48.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Dec 2017 05:48:51 -0800 (PST) From: Stafford Horne To: GDB patches Cc: Simon Marchi , Eli Zaretskii , Stafford Horne Subject: [PATCH v4 2/4] reggroups: Convert reggroups from post_init to pre_init Date: Tue, 26 Dec 2017 13:48:00 -0000 Message-Id: <20171226134832.23497-3-shorne@gmail.com> In-Reply-To: <20171226134832.23497-1-shorne@gmail.com> References: <20171226134832.23497-1-shorne@gmail.com> X-IsSubscribed: yes X-SW-Source: 2017-12/txt/msg00495.txt.bz2 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: yyyy-mm-dd 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(). --- Changes since v3 * No changes. 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)); -- 2.13.6