From patchwork Mon May 22 21:12:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Filippov X-Patchwork-Id: 20542 Received: (qmail 2120 invoked by alias); 22 May 2017 21:13:05 -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 1923 invoked by uid 89); 22 May 2017 21:13:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.2 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, FROM_LOCAL_NOVOWEL, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, HK_RANDOM_ENVFROM, HK_RANDOM_FROM, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Keeping, 1000000000 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-lf0-f67.google.com Received: from mail-lf0-f67.google.com (HELO mail-lf0-f67.google.com) (209.85.215.67) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 22 May 2017 21:13:01 +0000 Received: by mail-lf0-f67.google.com with SMTP id 99so6432818lfu.2; Mon, 22 May 2017 14:13:03 -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; bh=84ydWC80H/9IDfqXR3VUyi2RaT0Rxa4B37w8SaiTADc=; b=dzqc6mVDS/0LonaMlM0T0Sik4vc/4bz0wTd8cQqyH4YKNsrnw6upaNjpp2QQdNrLMM e1/0OwSh7ArGyf0rvvOSgTbsthgb5IPpVPqF52DFmvY0A6YNgsy80UCBILoP/ZnY/IHg BPs4UC6TWGoo7Y25gS5nJA2/X03h2Sciip+jOaLWld25CZrtHu//i1a7Zlilzei3t2qO l1ovB0sz4Yz0ekPlXrt1TTlNUmtoKQD7byHYEJU9IqGGho/oNKu82cv8A2GZ2bkcBv34 gtX+HaO4xq+YgeDk4azfCLARBtS7YLxUlINYrqe+QcJGwSaXNRWcprlqxDJIHa/4DQFc Zc2w== X-Gm-Message-State: AODbwcACu1f/pjKyIvExn8XZnmK/Hy5mlw7VMQ+NZRrQx47Jva5VQDwG OcQGb42KL+gARQ== X-Received: by 10.25.206.211 with SMTP id e202mr5826932lfg.127.1495487582217; Mon, 22 May 2017 14:13:02 -0700 (PDT) Received: from octofox.metropolis ([5.19.183.212]) by smtp.gmail.com with ESMTPSA id a7sm3335749ljb.44.2017.05.22.14.12.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 22 May 2017 14:13:01 -0700 (PDT) From: Max Filippov To: binutils@sourceware.org, gdb-patches@sourceware.org Cc: Sterling Augustine , David Weatherford , Maxim Grigoriev , Woody LaRue , Max Filippov Subject: [RFC 5/5] gdb: xtensa: make tdep and linux-nat dynamically configurable Date: Mon, 22 May 2017 14:12:33 -0700 Message-Id: <1495487553-19078-6-git-send-email-jcmvbkbc@gmail.com> In-Reply-To: <1495487553-19078-1-git-send-email-jcmvbkbc@gmail.com> References: <1495487553-19078-1-git-send-email-jcmvbkbc@gmail.com> Don't use xtensa_tdep directly, use function xtensa_config_get_tdep that potentially loads dynamic configuration and returns xtensa tdep pointer from there. Don't use xtensa_regmap_table directly, use function xtensa_config_get_regmap_table that potentially loads dynamic configuration and returns regmap table from there. gdb/ 2017-05-22 Max Filippov * xtensa-linux-nat.c (xtensa-dynconfig.h): New #include'd header. (xtensa_config_get_regmap_table): New function. (fetch_xtregs, store_xtregs, _initialize_xtensa_linux_nat): Call xtensa_config_get_regmap_table instead of taking address of xtensa_regmap_table. * xtensa-tdep.c (xtensa-dynconfig.h): New #include'd header. (xtensa_config_get_tdep): New function. (xtensa_gdbarch_init): Call xtensa_config_get_tdep instead of taking address of xtensa_tdep. --- gdb/xtensa-linux-nat.c | 18 +++++++++++++++--- gdb/xtensa-tdep.c | 13 +++++++++++-- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/gdb/xtensa-linux-nat.c b/gdb/xtensa-linux-nat.c index 836d3f8..7190e37 100644 --- a/gdb/xtensa-linux-nat.c +++ b/gdb/xtensa-linux-nat.c @@ -44,6 +44,18 @@ Keeping these definitions separately allows to introduce hardware-specific overlays. */ #include "xtensa-xtregs.c" +#include "xtensa-dynconfig.h" + +static xtensa_regtable_t *xtensa_config_get_regmap_table (void) +{ + static xtensa_regtable_t *regtable; + + if (!regtable) + regtable = (xtensa_regtable_t *) xtensa_load_config + ("xtensa_regmap_table", &xtensa_regmap_table); + + return regtable; +} void fill_gregset (const struct regcache *regcache, @@ -228,7 +240,7 @@ fetch_xtregs (struct regcache *regcache, int regnum) if (ptrace (PTRACE_GETXTREGS, tid, 0, (long)&xtregs) < 0) perror_with_name (_("Couldn't get extended registers")); - for (ptr = xtensa_regmap_table; ptr->name; ptr++) + for (ptr = xtensa_config_get_regmap_table (); ptr->name; ptr++) if (regnum == ptr->gdb_regnum || regnum == -1) regcache_raw_supply (regcache, ptr->gdb_regnum, xtregs + ptr->ptrace_offset); @@ -244,7 +256,7 @@ store_xtregs (struct regcache *regcache, int regnum) if (ptrace (PTRACE_GETXTREGS, tid, 0, (long)&xtregs) < 0) perror_with_name (_("Couldn't get extended registers")); - for (ptr = xtensa_regmap_table; ptr->name; ptr++) + for (ptr = xtensa_config_get_regmap_table (); ptr->name; ptr++) if (regnum == ptr->gdb_regnum || regnum == -1) regcache_raw_collect (regcache, ptr->gdb_regnum, xtregs + ptr->ptrace_offset); @@ -313,7 +325,7 @@ _initialize_xtensa_linux_nat (void) /* Calculate the number range for extended registers. */ xtreg_lo = 1000000000; xtreg_high = -1; - for (ptr = xtensa_regmap_table; ptr->name; ptr++) + for (ptr = xtensa_config_get_regmap_table (); ptr->name; ptr++) { if (ptr->gdb_regnum < xtreg_lo) xtreg_lo = ptr->gdb_regnum; diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c index e47c90a..f99ed90 100644 --- a/gdb/xtensa-tdep.c +++ b/gdb/xtensa-tdep.c @@ -51,7 +51,7 @@ #include "xtensa-isa.h" #include "xtensa-tdep.h" -#include "xtensa-config.h" +#include "xtensa-dynconfig.h" #include @@ -3184,6 +3184,15 @@ xtensa_derive_tdep (struct gdbarch_tdep *tdep) /* Module "constructor" function. */ extern struct gdbarch_tdep xtensa_tdep; +static struct gdbarch_tdep *xtensa_config_get_tdep (void) +{ + static struct gdbarch_tdep *tdep; + + if (!tdep) + tdep = (struct gdbarch_tdep *) xtensa_load_config ("xtensa_tdep", + &xtensa_tdep); + return tdep; +} static struct gdbarch * xtensa_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) @@ -3196,7 +3205,7 @@ xtensa_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* We have to set the byte order before we call gdbarch_alloc. */ info.byte_order = XCHAL_HAVE_BE ? BFD_ENDIAN_BIG : BFD_ENDIAN_LITTLE; - tdep = &xtensa_tdep; + tdep = xtensa_config_get_tdep (); gdbarch = gdbarch_alloc (&info, tdep); xtensa_derive_tdep (tdep);