From patchwork Sat Jun 10 13:59:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 20893 Received: (qmail 66342 invoked by alias); 10 Jun 2017 13:59:47 -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 66236 invoked by uid 89); 10 Jun 2017 13:59:46 -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:2497 X-HELO: mail-pf0-f194.google.com Received: from mail-pf0-f194.google.com (HELO mail-pf0-f194.google.com) (209.85.192.194) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 10 Jun 2017 13:59:45 +0000 Received: by mail-pf0-f194.google.com with SMTP id w12so1533636pfk.0 for ; Sat, 10 Jun 2017 06:59:49 -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=N+Pj7VzU3QMxZN8amfypNmvUAGYdV/DX/IksvXmnqOnWP/2l+okhCBW5T/uMhLTDPL 7c+Y22fwiGIlgdqtBWI5DrGZdaSXdYQDOtVzYeNueceA6IphKZBvy09HcyrVMU3f+9oN pAMgwHL+8aq+nyeO93MqQxU/sbeF/PSBQbBv9TEoUpy7U+DvAJbTTMHDRQ9InVLeXt4r yrAYBdfx+UMWmZIbM8E6xw8v+ljKFEIyqD811vR4ZcS+zSPj6JN+Fhphi3I4/yA4Yi/1 7ksgY3v98xsIJSpflum6636Nl+t8AOyihfNBg8lOsEAtsT1AkY7rRiVg/RsZd7aScFa3 3/Yg== X-Gm-Message-State: AODbwcAHG6yTpcS5I5bZ6ddExZ6KTF9f3U/PjOBkrUF04vVp5JlsO/Bg BKhq9NBuQo6Zfi8F7HQ7OA== X-Received: by 10.99.44.67 with SMTP id s64mr38816910pgs.111.1497103188215; Sat, 10 Jun 2017 06:59:48 -0700 (PDT) Received: from localhost (g212.61-193-241.ppp.wakwak.ne.jp. [61.193.241.212]) by smtp.gmail.com with ESMTPSA id r77sm8540335pfg.95.2017.06.10.06.59.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 10 Jun 2017 06:59:47 -0700 (PDT) From: Stafford Horne To: GDB patches Cc: Stafford Horne Subject: [PATCH v2 2/4] reggroups: Convert reggroups from post_init to pre_init Date: Sat, 10 Jun 2017 22:59:31 +0900 Message-Id: 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));