public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb: xtensa: use rmap from dynconfig library
@ 2024-04-03 14:24 Alexey Lapshin
  2024-04-03 15:08 ` Tom Tromey
  0 siblings, 1 reply; 3+ messages in thread
From: Alexey Lapshin @ 2024-04-03 14:24 UTC (permalink / raw)
  To: gdb-patches; +Cc: Alexey Gerenkov, Ivan Grokhotkov, jcmvbkbc

---
 gdb/xtensa-config.c |  4 ++--
 gdb/xtensa-tdep.c   |  6 ++----
 gdb/xtensa-tdep.h   | 11 +++++++----
 3 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/gdb/xtensa-config.c b/gdb/xtensa-config.c
index a40ce9380dc..a0153b037ec 100644
--- a/gdb/xtensa-config.c
+++ b/gdb/xtensa-config.c
@@ -21,7 +21,7 @@
 
 #define XTENSA_CONFIG_VERSION 0x60
 
-#include "xtensa-config.h"
+#include "xtensa-dynconfig.h"
 #include "xtensa-tdep.h"
 
 
@@ -62,7 +62,7 @@ const xtensa_mask_t xtensa_mask15 = { 1, xtensa_submask15 };
 
 
 /* Register map.  */
-xtensa_register_t xtensa_rmap[] =
+xtensa_register_t xtensa_rmap_default[] =
 {
   /*    idx ofs bi sz al targno  flags cp typ group name  */
   XTREG(  0,  0,32, 4, 4,0x0020,0x0006,-2, 9,0x0100,pc,          0,0,0,0,0,0)
diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c
index e8a143fadab..d14caeb232e 100644
--- a/gdb/xtensa-tdep.c
+++ b/gdb/xtensa-tdep.c
@@ -42,7 +42,7 @@
 
 #include "xtensa-isa.h"
 #include "xtensa-tdep.h"
-#include "xtensa-config.h"
+#include "xtensa-dynconfig.h"
 #include <algorithm>
 
 
@@ -3160,8 +3160,6 @@ xtensa_derive_tdep (xtensa_gdbarch_tdep *tdep)
 
 /* Module "constructor" function.  */
 
-extern xtensa_register_t xtensa_rmap[];
-
 static struct gdbarch *
 xtensa_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 {
@@ -3175,7 +3173,7 @@ xtensa_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   gdbarch *gdbarch
     = gdbarch_alloc (&info,
-		     gdbarch_tdep_up (new xtensa_gdbarch_tdep (xtensa_rmap)));
+		     gdbarch_tdep_up (new xtensa_gdbarch_tdep ()));
   xtensa_gdbarch_tdep *tdep = gdbarch_tdep<xtensa_gdbarch_tdep> (gdbarch);
   xtensa_derive_tdep (tdep);
 
diff --git a/gdb/xtensa-tdep.h b/gdb/xtensa-tdep.h
index ba1101b7b5b..3be26a5eedf 100644
--- a/gdb/xtensa-tdep.h
+++ b/gdb/xtensa-tdep.h
@@ -22,7 +22,7 @@
 
 #include "arch/xtensa.h"
 #include "gdbarch.h"
-#include "xtensa-config.h"
+#include "xtensa-dynconfig.h"
 
 /* XTENSA_TDEP_VERSION can/should be changed along with XTENSA_CONFIG_VERSION
    whenever the "tdep" structure changes in an incompatible way.  */
@@ -169,9 +169,12 @@ struct ctype_cache
 
 struct xtensa_gdbarch_tdep : gdbarch_tdep_base
 {
-  xtensa_gdbarch_tdep (xtensa_register_t *regmap)
-    : regmap (regmap)
-  {}
+  xtensa_gdbarch_tdep ()
+  {
+    extern xtensa_register_t xtensa_rmap_default[];
+    regmap = (xtensa_register_t *) xtensa_load_config ("rmap", NULL, NULL);
+    regmap = regmap ? regmap : xtensa_rmap_default;
+  }
 
   unsigned int target_flags = 0;
 
-- 
2.34.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gdb: xtensa: use rmap from dynconfig library
  2024-04-03 14:24 [PATCH] gdb: xtensa: use rmap from dynconfig library Alexey Lapshin
@ 2024-04-03 15:08 ` Tom Tromey
  2024-04-03 15:25   ` Alexey Lapshin
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2024-04-03 15:08 UTC (permalink / raw)
  To: Alexey Lapshin; +Cc: gdb-patches, Alexey Gerenkov, Ivan Grokhotkov, jcmvbkbc

>>>>> "Alexey" == Alexey Lapshin <alexey.lapshin@espressif.com> writes:

Alexey> ---

Normally there should be an explanation of & motivation for the patch
here.

Alexey>  struct xtensa_gdbarch_tdep : gdbarch_tdep_base
Alexey>  {
Alexey> -  xtensa_gdbarch_tdep (xtensa_register_t *regmap)
Alexey> -    : regmap (regmap)
Alexey> -  {}
Alexey> +  xtensa_gdbarch_tdep ()
Alexey> +  {
Alexey> +    extern xtensa_register_t xtensa_rmap_default[];

It's better to declare this in the header.

Alexey> +    regmap = (xtensa_register_t *) xtensa_load_config ("rmap", NULL, NULL);

I don't know anything about xtensa but this cast seems pretty
questionable to me.  IIUC this is calling into some shared library and
hoping it uses gdb's internal type?

Also, do you have a copyright assignment on file?  We will need one.
Let me know if not and I can get you started.

thanks,
Tom

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gdb: xtensa: use rmap from dynconfig library
  2024-04-03 15:08 ` Tom Tromey
@ 2024-04-03 15:25   ` Alexey Lapshin
  0 siblings, 0 replies; 3+ messages in thread
From: Alexey Lapshin @ 2024-04-03 15:25 UTC (permalink / raw)
  To: tom; +Cc: gdb-patches, Alexey Gerenkov, Ivan Grokhotkov, jcmvbkbc

On Wed, 2024-04-03 at 09:08 -0600, Tom Tromey wrote:
> I don't know anything about xtensa but this cast seems pretty
> questionable to me.  IIUC this is calling into some shared library and
> hoping it uses gdb's internal type?
> 
Yes, the library is expected. Source code is here 
https://github.com/jcmvbkbc/xtensa-dynconfig

Max Filippov (jcmvbkbc@gmail.com) is in CC list for review.
> 
> Also, do you have a copyright assignment on file?  We will need one.
> Let me know if not and I can get you started.

IDK, probably I don't have

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-04-03 15:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-03 14:24 [PATCH] gdb: xtensa: use rmap from dynconfig library Alexey Lapshin
2024-04-03 15:08 ` Tom Tromey
2024-04-03 15:25   ` Alexey Lapshin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).