From patchwork Wed Jun 7 22:15:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 20837 Received: (qmail 6416 invoked by alias); 7 Jun 2017 22:15:56 -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 6373 invoked by uid 89); 7 Jun 2017 22:15:55 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.1 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= X-HELO: mail-pf0-f193.google.com Received: from mail-pf0-f193.google.com (HELO mail-pf0-f193.google.com) (209.85.192.193) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 07 Jun 2017 22:15:53 +0000 Received: by mail-pf0-f193.google.com with SMTP id y7so2854689pfd.3 for ; Wed, 07 Jun 2017 15:15:57 -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=ndcKPoquP/lLDaf7WzVo96QMnLMot8cnWuOr2SVNCFc=; b=sq3AxBkzunsQBX9BOBpQJWbcJnClfVq6jyLFYA1d4uAn9/qmowHRd6g0ms7jOdpKBZ kVehlk/yiaefFweeij5QndNHrYBIdKwhO3wJJFyBZ8Sk7bpKMcqzomH1P4Q80fOjHTcd /0+HJCBOySN2Z6YZKOD/v3rlLUAB1NrgY8P4xI+pdXtbh+qtnWx/sF0aECICfENXT4JK KV5bKDDydUunHTeMuQTXsW0gwFoCxjDbEzNQDGjjrFG2iVoA6Wts1pfUwDzg6Be3bNDO XVuON21ZztJBFungxnRjFLi1mxIrUklmJzGivT83G9XgTnWe44qp5y2wPCgRCzJ4O2sz JgxA== X-Gm-Message-State: AODbwcDuslE7AFpWoXCWGqDNoFUAJpnuahTpu9rVsZPTspL7atslV83U Z8+sVG76A1jWQ6lN/sY= X-Received: by 10.99.161.25 with SMTP id b25mr34312265pgf.26.1496873756093; Wed, 07 Jun 2017 15:15:56 -0700 (PDT) Received: from localhost (g212.61-193-241.ppp.wakwak.ne.jp. [61.193.241.212]) by smtp.gmail.com with ESMTPSA id c4sm6091325pfg.31.2017.06.07.15.15.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 07 Jun 2017 15:15:55 -0700 (PDT) From: Stafford Horne To: GDB patches Cc: Stafford Horne Subject: [PATCH 2/3] reggroups: Convert reggroups from post_init to pre_init Date: Thu, 8 Jun 2017 07:15:46 +0900 Message-Id: <7d5fc46e43702683b82839e26d7392ac46af1121.1496871270.git.shorne@gmail.com> In-Reply-To: References: In-Reply-To: References: 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 ae7d4ce..bf40964 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)); } @@ -300,7 +293,7 @@ extern initialize_file_ftype _initialize_reggroup; /* -Wmissing-prototypes */ 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));