Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Max Filippov <jcmvbkbc@gmail.com>
To: binutils@sourceware.org,	gdb-patches@sourceware.org
Cc: Sterling Augustine <augustine.sterling@gmail.com>,
	David Weatherford <weath@cadence.com>,
	Maxim Grigoriev <maxim2405@gmail.com>,
	Woody LaRue <larue@cadence.com>,
	Max Filippov <jcmvbkbc@gmail.com>
Subject: [RFC 5/5] gdb: xtensa: make tdep and linux-nat dynamically configurable
Date: Mon, 22 May 2017 21:13:00 -0000	[thread overview]
Message-ID: <1495487553-19078-6-git-send-email-jcmvbkbc@gmail.com> (raw)
In-Reply-To: <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  <jcmvbkbc@gmail.com>

	* 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 <algorithm>
 
 
@@ -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);
 
-- 
2.1.4


  parent reply	other threads:[~2017-05-22 21:13 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-22 21:12 [RFC 0/5] xtensa: support dynamic configuration Max Filippov
2017-05-22 21:12 ` [RFC 2/5] xtensa: make configuration dynamic Max Filippov
2017-05-26 18:10   ` augustine.sterling
2017-05-26 18:15     ` augustine.sterling
2017-06-06 12:53       ` Nick Clifton
2017-06-07 19:13         ` Max Filippov
2017-05-22 21:12 ` [RFC 1/5] xtensa: don't expect XCHAL_* macros to be constant Max Filippov
2017-05-26 17:36   ` augustine.sterling
2017-05-22 21:12 ` [RFC 3/5] xtensa: support dynconfig on windows Max Filippov
2017-06-12 15:45   ` Nick Clifton
2017-05-22 21:13 ` [RFC 4/5] xtensa: make xtensa_modules dynamic Max Filippov
2017-06-12 15:49   ` Nick Clifton
2017-05-22 21:13 ` Max Filippov [this message]
2017-06-06 12:41 ` [RFC 0/5] xtensa: support dynamic configuration Nick Clifton
2017-06-07 19:23   ` Max Filippov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1495487553-19078-6-git-send-email-jcmvbkbc@gmail.com \
    --to=jcmvbkbc@gmail.com \
    --cc=augustine.sterling@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=gdb-patches@sourceware.org \
    --cc=larue@cadence.com \
    --cc=maxim2405@gmail.com \
    --cc=weath@cadence.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox