public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb/sim: add support for exporting memory map
@ 2021-01-06  6:04 Mike Frysinger
  2021-01-06  9:49 ` Andrew Burgess
  2021-01-06 11:04 ` [PATCH v2] " Mike Frysinger
  0 siblings, 2 replies; 7+ messages in thread
From: Mike Frysinger @ 2021-01-06  6:04 UTC (permalink / raw)
  To: gdb-patches

This allows gdb to quickly dump & process the memory map that the sim
knows about.  This isn't fully accurate, but is largely limited by the
gdb memory map format.  While the sim supports RWX bits, gdb can only
handle RW or RO regions.
---
 gdb/remote-sim.c         | 16 +++++++++++
 include/gdb/remote-sim.h |  9 +++++++
 sim/common/sim-core.c    | 58 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 83 insertions(+)

gdb/:

	* remote-sim.c: Include memory-map.h.
	(gdbsim_target): Define memory_map override.
	(gdbsim_target::memory_map): Define.

include/gdb/:

	* remote-sim.h (sim_memory_map): Define.

sim/common/:

	* sim-core.c (sim_memory_map): Define.

diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c
index c4f3913edbad..e44add538afb 100644
--- a/gdb/remote-sim.c
+++ b/gdb/remote-sim.c
@@ -42,6 +42,7 @@
 #include "readline/readline.h"
 #include "gdbthread.h"
 #include "gdbsupport/byte-vector.h"
+#include "memory-map.h"
 
 /* Prototypes */
 
@@ -164,6 +165,7 @@ struct gdbsim_target final
 
   bool has_all_memory ()  override;
   bool has_memory ()  override;
+  std::vector<mem_region> memory_map () override;
 
 private:
   sim_inferior_data *get_inferior_data_by_ptid (ptid_t ptid,
@@ -1270,6 +1272,20 @@ gdbsim_target::has_memory ()
   return true;
 }
 
+std::vector<mem_region>
+gdbsim_target::memory_map ()
+{
+  struct sim_inferior_data *sim_data
+    = get_sim_inferior_data (current_inferior (), SIM_INSTANCE_NEEDED);
+  std::vector<mem_region> result;
+  gdb::unique_xmalloc_ptr<char> text(sim_memory_map (sim_data->gdbsim_desc));
+
+  if (text)
+    result = parse_memory_map (text.get ());
+
+  return result;
+}
+
 void _initialize_remote_sim ();
 void
 _initialize_remote_sim ()
diff --git a/include/gdb/remote-sim.h b/include/gdb/remote-sim.h
index 73fb670c17e5..a3ba3aa36cd2 100644
--- a/include/gdb/remote-sim.h
+++ b/include/gdb/remote-sim.h
@@ -213,6 +213,15 @@ int sim_store_register (SIM_DESC sd, int regno, unsigned char *buf, int length);
 void sim_info (SIM_DESC sd, int verbose);
 
 
+/* Return a memory map in XML format.
+
+   The caller must free the returned string.
+
+   For details on the format, see GDB's Memory Map Format documentation.  */
+
+char *sim_memory_map (SIM_DESC sd);
+
+
 /* Run (or resume) the simulated program.
 
    STEP, when non-zero indicates that only a single simulator cycle
diff --git a/sim/common/sim-core.c b/sim/common/sim-core.c
index 74369aa99fe2..eb40d2588f58 100644
--- a/sim/common/sim-core.c
+++ b/sim/common/sim-core.c
@@ -452,6 +452,64 @@ sim_core_translate (sim_core_mapping *mapping,
 }
 
 
+#if EXTERN_SIM_CORE_P
+char *
+sim_memory_map (SIM_DESC sd)
+{
+  sim_core *core = STATE_CORE (sd);
+  unsigned map;
+  char *s1, *s2, *entry;
+
+  s1 = xstrdup (
+    "<?xml version='1.0'?>\n"
+    "<!DOCTYPE memory-map PUBLIC '+//IDN gnu.org//DTD GDB Memory Map V1.0//EN'"
+    " 'http://sourceware.org/gdb/gdb-memory-map.dtd'>\n"
+    "<memory-map>\n");
+
+  for (map = 0;
+       map < nr_maps;
+       map++)
+    {
+      sim_core_mapping *mapping = core->common.map[map].first;
+
+      while (mapping != NULL)
+	{
+	  if (mapping->level != 0)
+	    goto next;
+
+	  entry = xasprintf ("<memory type='ram' start='%#x' length='%#x'/>\n",
+			     mapping->base, mapping->nr_bytes);
+	  /* The sim memory map is organized by access, not by addresses.
+	     So a RWX memory map will have three independent mappings.
+	     GDB's format cannot support overlapping regions, so we have
+	     to filter those out.
+
+	     Further, GDB can only handle RX ("rom") or RWX ("ram") mappings.
+	     We just emit "ram" everywhere to keep it simple.  If GDB ever
+	     gains support for more stuff, we can expand this.
+
+	     Using strstr is kind of hacky, but as long as the map is not huge
+	     (we're talking <10K), should be fine.  */
+	  if (strstr (s1, entry) == NULL)
+	    {
+	      s2 = concat (s1, entry, NULL);
+	      free (s1);
+	      s1 = s2;
+	    }
+	  free (entry);
+
+ next:
+	  mapping = mapping->next;
+	}
+    }
+
+  s2 = concat (s1, "</memory-map>", NULL);
+  free (s1);
+  return s2;
+}
+#endif
+
+
 #if EXTERN_SIM_CORE_P
 unsigned
 sim_core_read_buffer (SIM_DESC sd,
-- 
2.28.0


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

* Re: [PATCH] gdb/sim: add support for exporting memory map
  2021-01-06  6:04 [PATCH] gdb/sim: add support for exporting memory map Mike Frysinger
@ 2021-01-06  9:49 ` Andrew Burgess
  2021-01-06 11:04 ` [PATCH v2] " Mike Frysinger
  1 sibling, 0 replies; 7+ messages in thread
From: Andrew Burgess @ 2021-01-06  9:49 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: gdb-patches

* Mike Frysinger via Gdb-patches <gdb-patches@sourceware.org> [2021-01-06 01:04:33 -0500]:

> This allows gdb to quickly dump & process the memory map that the sim
> knows about.  This isn't fully accurate, but is largely limited by the
> gdb memory map format.  While the sim supports RWX bits, gdb can only
> handle RW or RO regions.
> ---
>  gdb/remote-sim.c         | 16 +++++++++++
>  include/gdb/remote-sim.h |  9 +++++++
>  sim/common/sim-core.c    | 58 ++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 83 insertions(+)
> 
> gdb/:
> 
> 	* remote-sim.c: Include memory-map.h.
> 	(gdbsim_target): Define memory_map override.
> 	(gdbsim_target::memory_map): Define.
> 
> include/gdb/:
> 
> 	* remote-sim.h (sim_memory_map): Define.
> 
> sim/common/:
> 
> 	* sim-core.c (sim_memory_map): Define.
> 
> diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c
> index c4f3913edbad..e44add538afb 100644
> --- a/gdb/remote-sim.c
> +++ b/gdb/remote-sim.c
> @@ -42,6 +42,7 @@
>  #include "readline/readline.h"
>  #include "gdbthread.h"
>  #include "gdbsupport/byte-vector.h"
> +#include "memory-map.h"
>  
>  /* Prototypes */
>  
> @@ -164,6 +165,7 @@ struct gdbsim_target final
>  
>    bool has_all_memory ()  override;
>    bool has_memory ()  override;
> +  std::vector<mem_region> memory_map () override;
>  
>  private:
>    sim_inferior_data *get_inferior_data_by_ptid (ptid_t ptid,
> @@ -1270,6 +1272,20 @@ gdbsim_target::has_memory ()
>    return true;
>  }
>  
> +std::vector<mem_region>
> +gdbsim_target::memory_map ()

This should have a header comment, even if its just:

  /* Implement target_ops::memory_map.  */

> +{
> +  struct sim_inferior_data *sim_data
> +    = get_sim_inferior_data (current_inferior (), SIM_INSTANCE_NEEDED);
> +  std::vector<mem_region> result;
> +  gdb::unique_xmalloc_ptr<char> text(sim_memory_map (sim_data->gdbsim_desc));

Whitespace missing after 'text'.

> +
> +  if (text)

GDB prefers 'if (text != nullptr)'.

> +    result = parse_memory_map (text.get ());
> +
> +  return result;
> +}
> +
>  void _initialize_remote_sim ();
>  void
>  _initialize_remote_sim ()
> diff --git a/include/gdb/remote-sim.h b/include/gdb/remote-sim.h
> index 73fb670c17e5..a3ba3aa36cd2 100644
> --- a/include/gdb/remote-sim.h
> +++ b/include/gdb/remote-sim.h
> @@ -213,6 +213,15 @@ int sim_store_register (SIM_DESC sd, int regno, unsigned char *buf, int length);
>  void sim_info (SIM_DESC sd, int verbose);
>  
>  
> +/* Return a memory map in XML format.
> +
> +   The caller must free the returned string.
> +
> +   For details on the format, see GDB's Memory Map Format documentation.  */
> +
> +char *sim_memory_map (SIM_DESC sd);
> +
> +
>  /* Run (or resume) the simulated program.
>  
>     STEP, when non-zero indicates that only a single simulator cycle
> diff --git a/sim/common/sim-core.c b/sim/common/sim-core.c
> index 74369aa99fe2..eb40d2588f58 100644
> --- a/sim/common/sim-core.c
> +++ b/sim/common/sim-core.c
> @@ -452,6 +452,64 @@ sim_core_translate (sim_core_mapping *mapping,
>  }
>  
>  
> +#if EXTERN_SIM_CORE_P
> +char *
> +sim_memory_map (SIM_DESC sd)
> +{

I would like to start following the GDB convention of requiring a
header comment on all functions, so here we'd just say:

  /* See include/gdb/remote-sim.h.  */

> +  sim_core *core = STATE_CORE (sd);
> +  unsigned map;
> +  char *s1, *s2, *entry;
> +
> +  s1 = xstrdup (
> +    "<?xml version='1.0'?>\n"
> +    "<!DOCTYPE memory-map PUBLIC '+//IDN gnu.org//DTD GDB Memory Map V1.0//EN'"
> +    " 'http://sourceware.org/gdb/gdb-memory-map.dtd'>\n"
> +    "<memory-map>\n");
> +
> +  for (map = 0;
> +       map < nr_maps;
> +       map++)
> +    {
> +      sim_core_mapping *mapping = core->common.map[map].first;
> +
> +      while (mapping != NULL)

Instead of using while here and then 'goto next' inside, could we not
say:

  for (mapping = core->common.map[map].first;
       mapping != NULL;
       mapping = mapping->next)

and then replace the 'goto next' with 'continue' ?

> +	{
> +	  if (mapping->level != 0)
> +	    goto next;
> +
> +	  entry = xasprintf ("<memory type='ram' start='%#x' length='%#x'/>\n",
> +			     mapping->base, mapping->nr_bytes);
> +	  /* The sim memory map is organized by access, not by addresses.
> +	     So a RWX memory map will have three independent mappings.
> +	     GDB's format cannot support overlapping regions, so we have
> +	     to filter those out.
> +
> +	     Further, GDB can only handle RX ("rom") or RWX ("ram") mappings.
> +	     We just emit "ram" everywhere to keep it simple.  If GDB ever
> +	     gains support for more stuff, we can expand this.
> +
> +	     Using strstr is kind of hacky, but as long as the map is not huge
> +	     (we're talking <10K), should be fine.  */
> +	  if (strstr (s1, entry) == NULL)
> +	    {
> +	      s2 = concat (s1, entry, NULL);
> +	      free (s1);
> +	      s1 = s2;
> +	    }
> +	  free (entry);
> +
> + next:
> +	  mapping = mapping->next;
> +	}
> +    }
> +
> +  s2 = concat (s1, "</memory-map>", NULL);
> +  free (s1);
> +  return s2;
> +}
> +#endif
> +
> +
>  #if EXTERN_SIM_CORE_P
>  unsigned
>  sim_core_read_buffer (SIM_DESC sd,
> -- 
> 2.28.0
> 

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

* [PATCH v2] gdb/sim: add support for exporting memory map
  2021-01-06  6:04 [PATCH] gdb/sim: add support for exporting memory map Mike Frysinger
  2021-01-06  9:49 ` Andrew Burgess
@ 2021-01-06 11:04 ` Mike Frysinger
  2021-01-07  9:28   ` Andrew Burgess
  2021-01-08  5:17   ` Sebastian Huber
  1 sibling, 2 replies; 7+ messages in thread
From: Mike Frysinger @ 2021-01-06 11:04 UTC (permalink / raw)
  To: gdb-patches

This allows gdb to quickly dump & process the memory map that the sim
knows about.  This isn't fully accurate, but is largely limited by the
gdb memory map format.  While the sim supports RWX bits, gdb can only
handle RW or RO regions.
---
 gdb/remote-sim.c         | 18 +++++++++++++
 include/gdb/remote-sim.h |  9 +++++++
 sim/common/sim-core.c    | 57 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 84 insertions(+)

diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c
index c4f3913edbad..b21a4e80ee6a 100644
--- a/gdb/remote-sim.c
+++ b/gdb/remote-sim.c
@@ -42,6 +42,7 @@
 #include "readline/readline.h"
 #include "gdbthread.h"
 #include "gdbsupport/byte-vector.h"
+#include "memory-map.h"
 
 /* Prototypes */
 
@@ -164,6 +165,7 @@ struct gdbsim_target final
 
   bool has_all_memory ()  override;
   bool has_memory ()  override;
+  std::vector<mem_region> memory_map () override;
 
 private:
   sim_inferior_data *get_inferior_data_by_ptid (ptid_t ptid,
@@ -1270,6 +1272,22 @@ gdbsim_target::has_memory ()
   return true;
 }
 
+/* Get memory map from the simulator.  */
+
+std::vector<mem_region>
+gdbsim_target::memory_map ()
+{
+  struct sim_inferior_data *sim_data
+    = get_sim_inferior_data (current_inferior (), SIM_INSTANCE_NEEDED);
+  std::vector<mem_region> result;
+  gdb::unique_xmalloc_ptr<char> text (sim_memory_map (sim_data->gdbsim_desc));
+
+  if (text != nullptr)
+    result = parse_memory_map (text.get ());
+
+  return result;
+}
+
 void _initialize_remote_sim ();
 void
 _initialize_remote_sim ()
diff --git a/include/gdb/remote-sim.h b/include/gdb/remote-sim.h
index 73fb670c17e5..a3ba3aa36cd2 100644
--- a/include/gdb/remote-sim.h
+++ b/include/gdb/remote-sim.h
@@ -213,6 +213,15 @@ int sim_store_register (SIM_DESC sd, int regno, unsigned char *buf, int length);
 void sim_info (SIM_DESC sd, int verbose);
 
 
+/* Return a memory map in XML format.
+
+   The caller must free the returned string.
+
+   For details on the format, see GDB's Memory Map Format documentation.  */
+
+char *sim_memory_map (SIM_DESC sd);
+
+
 /* Run (or resume) the simulated program.
 
    STEP, when non-zero indicates that only a single simulator cycle
diff --git a/sim/common/sim-core.c b/sim/common/sim-core.c
index 74369aa99fe2..538230635bc9 100644
--- a/sim/common/sim-core.c
+++ b/sim/common/sim-core.c
@@ -452,6 +452,63 @@ sim_core_translate (sim_core_mapping *mapping,
 }
 
 
+#if EXTERN_SIM_CORE_P
+/* See include/gdb/remote-sim.h.  */
+char *
+sim_memory_map (SIM_DESC sd)
+{
+  sim_core *core = STATE_CORE (sd);
+  unsigned map;
+  char *s1, *s2, *entry;
+
+  s1 = xstrdup (
+    "<?xml version='1.0'?>\n"
+    "<!DOCTYPE memory-map PUBLIC '+//IDN gnu.org//DTD GDB Memory Map V1.0//EN'"
+    " 'http://sourceware.org/gdb/gdb-memory-map.dtd'>\n"
+    "<memory-map>\n");
+
+  for (map = 0; map < nr_maps; ++map)
+    {
+      sim_core_mapping *mapping;
+
+      for (mapping = core->common.map[map].first;
+	   mapping != NULL;
+	   mapping = mapping->next)
+	{
+	  /* GDB can only handle a single address space.  */
+	  if (mapping->level != 0)
+	    continue;
+
+	  entry = xasprintf ("<memory type='ram' start='%#x' length='%#x'/>\n",
+			     mapping->base, mapping->nr_bytes);
+	  /* The sim memory map is organized by access, not by addresses.
+	     So a RWX memory map will have three independent mappings.
+	     GDB's format cannot support overlapping regions, so we have
+	     to filter those out.
+
+	     Further, GDB can only handle RX ("rom") or RWX ("ram") mappings.
+	     We just emit "ram" everywhere to keep it simple.  If GDB ever
+	     gains support for more stuff, we can expand this.
+
+	     Using strstr is kind of hacky, but as long as the map is not huge
+	     (we're talking <10K), should be fine.  */
+	  if (strstr (s1, entry) == NULL)
+	    {
+	      s2 = concat (s1, entry, NULL);
+	      free (s1);
+	      s1 = s2;
+	    }
+	  free (entry);
+	}
+    }
+
+  s2 = concat (s1, "</memory-map>", NULL);
+  free (s1);
+  return s2;
+}
+#endif
+
+
 #if EXTERN_SIM_CORE_P
 unsigned
 sim_core_read_buffer (SIM_DESC sd,
-- 
2.28.0


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

* Re: [PATCH v2] gdb/sim: add support for exporting memory map
  2021-01-06 11:04 ` [PATCH v2] " Mike Frysinger
@ 2021-01-07  9:28   ` Andrew Burgess
  2021-01-08  5:17   ` Sebastian Huber
  1 sibling, 0 replies; 7+ messages in thread
From: Andrew Burgess @ 2021-01-07  9:28 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: gdb-patches

* Mike Frysinger via Gdb-patches <gdb-patches@sourceware.org> [2021-01-06 06:04:30 -0500]:

> This allows gdb to quickly dump & process the memory map that the sim
> knows about.  This isn't fully accurate, but is largely limited by the
> gdb memory map format.  While the sim supports RWX bits, gdb can only
> handle RW or RO regions.
> ---
>  gdb/remote-sim.c         | 18 +++++++++++++
>  include/gdb/remote-sim.h |  9 +++++++
>  sim/common/sim-core.c    | 57 ++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 84 insertions(+)

LGTM.

Thanks,
Andrew


> 
> diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c
> index c4f3913edbad..b21a4e80ee6a 100644
> --- a/gdb/remote-sim.c
> +++ b/gdb/remote-sim.c
> @@ -42,6 +42,7 @@
>  #include "readline/readline.h"
>  #include "gdbthread.h"
>  #include "gdbsupport/byte-vector.h"
> +#include "memory-map.h"
>  
>  /* Prototypes */
>  
> @@ -164,6 +165,7 @@ struct gdbsim_target final
>  
>    bool has_all_memory ()  override;
>    bool has_memory ()  override;
> +  std::vector<mem_region> memory_map () override;
>  
>  private:
>    sim_inferior_data *get_inferior_data_by_ptid (ptid_t ptid,
> @@ -1270,6 +1272,22 @@ gdbsim_target::has_memory ()
>    return true;
>  }
>  
> +/* Get memory map from the simulator.  */
> +
> +std::vector<mem_region>
> +gdbsim_target::memory_map ()
> +{
> +  struct sim_inferior_data *sim_data
> +    = get_sim_inferior_data (current_inferior (), SIM_INSTANCE_NEEDED);
> +  std::vector<mem_region> result;
> +  gdb::unique_xmalloc_ptr<char> text (sim_memory_map (sim_data->gdbsim_desc));
> +
> +  if (text != nullptr)
> +    result = parse_memory_map (text.get ());
> +
> +  return result;
> +}
> +
>  void _initialize_remote_sim ();
>  void
>  _initialize_remote_sim ()
> diff --git a/include/gdb/remote-sim.h b/include/gdb/remote-sim.h
> index 73fb670c17e5..a3ba3aa36cd2 100644
> --- a/include/gdb/remote-sim.h
> +++ b/include/gdb/remote-sim.h
> @@ -213,6 +213,15 @@ int sim_store_register (SIM_DESC sd, int regno, unsigned char *buf, int length);
>  void sim_info (SIM_DESC sd, int verbose);
>  
>  
> +/* Return a memory map in XML format.
> +
> +   The caller must free the returned string.
> +
> +   For details on the format, see GDB's Memory Map Format documentation.  */
> +
> +char *sim_memory_map (SIM_DESC sd);
> +
> +
>  /* Run (or resume) the simulated program.
>  
>     STEP, when non-zero indicates that only a single simulator cycle
> diff --git a/sim/common/sim-core.c b/sim/common/sim-core.c
> index 74369aa99fe2..538230635bc9 100644
> --- a/sim/common/sim-core.c
> +++ b/sim/common/sim-core.c
> @@ -452,6 +452,63 @@ sim_core_translate (sim_core_mapping *mapping,
>  }
>  
>  
> +#if EXTERN_SIM_CORE_P
> +/* See include/gdb/remote-sim.h.  */
> +char *
> +sim_memory_map (SIM_DESC sd)
> +{
> +  sim_core *core = STATE_CORE (sd);
> +  unsigned map;
> +  char *s1, *s2, *entry;
> +
> +  s1 = xstrdup (
> +    "<?xml version='1.0'?>\n"
> +    "<!DOCTYPE memory-map PUBLIC '+//IDN gnu.org//DTD GDB Memory Map V1.0//EN'"
> +    " 'http://sourceware.org/gdb/gdb-memory-map.dtd'>\n"
> +    "<memory-map>\n");
> +
> +  for (map = 0; map < nr_maps; ++map)
> +    {
> +      sim_core_mapping *mapping;
> +
> +      for (mapping = core->common.map[map].first;
> +	   mapping != NULL;
> +	   mapping = mapping->next)
> +	{
> +	  /* GDB can only handle a single address space.  */
> +	  if (mapping->level != 0)
> +	    continue;
> +
> +	  entry = xasprintf ("<memory type='ram' start='%#x' length='%#x'/>\n",
> +			     mapping->base, mapping->nr_bytes);
> +	  /* The sim memory map is organized by access, not by addresses.
> +	     So a RWX memory map will have three independent mappings.
> +	     GDB's format cannot support overlapping regions, so we have
> +	     to filter those out.
> +
> +	     Further, GDB can only handle RX ("rom") or RWX ("ram") mappings.
> +	     We just emit "ram" everywhere to keep it simple.  If GDB ever
> +	     gains support for more stuff, we can expand this.
> +
> +	     Using strstr is kind of hacky, but as long as the map is not huge
> +	     (we're talking <10K), should be fine.  */
> +	  if (strstr (s1, entry) == NULL)
> +	    {
> +	      s2 = concat (s1, entry, NULL);
> +	      free (s1);
> +	      s1 = s2;
> +	    }
> +	  free (entry);
> +	}
> +    }
> +
> +  s2 = concat (s1, "</memory-map>", NULL);
> +  free (s1);
> +  return s2;
> +}
> +#endif
> +
> +
>  #if EXTERN_SIM_CORE_P
>  unsigned
>  sim_core_read_buffer (SIM_DESC sd,
> -- 
> 2.28.0
> 

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

* Re: [PATCH v2] gdb/sim: add support for exporting memory map
  2021-01-06 11:04 ` [PATCH v2] " Mike Frysinger
  2021-01-07  9:28   ` Andrew Burgess
@ 2021-01-08  5:17   ` Sebastian Huber
  2021-01-08  6:05     ` Mike Frysinger
  1 sibling, 1 reply; 7+ messages in thread
From: Sebastian Huber @ 2021-01-08  5:17 UTC (permalink / raw)
  To: Mike Frysinger, gdb-patches

Hello Mike,

On 06/01/2021 12:04, Mike Frysinger via Gdb-patches wrote:
> This allows gdb to quickly dump & process the memory map that the sim
> knows about.  This isn't fully accurate, but is largely limited by the
> gdb memory map format.  While the sim supports RWX bits, gdb can only
> handle RW or RO regions.
> ---
>   gdb/remote-sim.c         | 18 +++++++++++++
>   include/gdb/remote-sim.h |  9 +++++++
>   sim/common/sim-core.c    | 57 ++++++++++++++++++++++++++++++++++++++++
>   3 files changed, 84 insertions(+)

I think this change broke the powerpc simulator (target "powerpc-rtems6" 
for example):

   CXXLD  gdb
/usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/bin/ld: 
remote-sim.o: in function `gdbsim_target::memory_map()':
/tmp/sh/src/rsb/rtems/build/powerpc-rtems6-gdb-0f8e278-x86_64-linux-gnu-1/build/gdb/../../sourceware-mirror-binutils-gdb-0f8e278/gdb/remote-sim.c:1283: 
undefined reference to `sim_memory_map'

-- 
embedded brains GmbH
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.huber@embedded-brains.de
phone: +49-89-18 94 741 - 16
fax:   +49-89-18 94 741 - 08

Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/


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

* Re: [PATCH v2] gdb/sim: add support for exporting memory map
  2021-01-08  5:17   ` Sebastian Huber
@ 2021-01-08  6:05     ` Mike Frysinger
  2021-01-08 10:20       ` Sebastian Huber
  0 siblings, 1 reply; 7+ messages in thread
From: Mike Frysinger @ 2021-01-08  6:05 UTC (permalink / raw)
  To: Sebastian Huber; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1751 bytes --]

On 08 Jan 2021 06:17, Sebastian Huber wrote:
> On 06/01/2021 12:04, Mike Frysinger via Gdb-patches wrote:
> > This allows gdb to quickly dump & process the memory map that the sim
> > knows about.  This isn't fully accurate, but is largely limited by the
> > gdb memory map format.  While the sim supports RWX bits, gdb can only
> > handle RW or RO regions.
> > ---
> >   gdb/remote-sim.c         | 18 +++++++++++++
> >   include/gdb/remote-sim.h |  9 +++++++
> >   sim/common/sim-core.c    | 57 ++++++++++++++++++++++++++++++++++++++++
> >   3 files changed, 84 insertions(+)
> 
> I think this change broke the powerpc simulator (target "powerpc-rtems6" 
> for example):
> 
>    CXXLD  gdb
> /usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/bin/ld: 
> remote-sim.o: in function `gdbsim_target::memory_map()':
> /tmp/sh/src/rsb/rtems/build/powerpc-rtems6-gdb-0f8e278-x86_64-linux-gnu-1/build/gdb/../../sourceware-mirror-binutils-gdb-0f8e278/gdb/remote-sim.c:1283: 
> undefined reference to `sim_memory_map'

indeed, sorry about that.  i've pushed this fix.
-mike

[PATCH] sim: ppc: stub out sim_memory_map

Not clear how to implement this in the ppc-specific sim, so just
stub it out.  This is as good as it was previously.
---
 sim/ppc/ChangeLog   | 4 ++++
 sim/ppc/sim_calls.c | 6 ++++++
 2 files changed, 10 insertions(+)

2021-01-08  Mike Frysinger  <vapier@gentoo.org>

	* sim_calls.c (sim_memory_map): Define.

--- a/sim/ppc/sim_calls.c
+++ b/sim/ppc/sim_calls.c
@@ -265,6 +265,12 @@ sim_complete_command (SIM_DESC sd, const char *text, const char *word)
   return NULL;
 }
 
+char *
+sim_memory_map (SIM_DESC sd)
+{
+  return NULL;
+}
+
 /* Polling, if required */
 
 void

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH v2] gdb/sim: add support for exporting memory map
  2021-01-08  6:05     ` Mike Frysinger
@ 2021-01-08 10:20       ` Sebastian Huber
  0 siblings, 0 replies; 7+ messages in thread
From: Sebastian Huber @ 2021-01-08 10:20 UTC (permalink / raw)
  To: gdb-patches

On 08/01/2021 07:05, Mike Frysinger wrote:

> On 08 Jan 2021 06:17, Sebastian Huber wrote:
>> On 06/01/2021 12:04, Mike Frysinger via Gdb-patches wrote:
>>> This allows gdb to quickly dump & process the memory map that the sim
>>> knows about.  This isn't fully accurate, but is largely limited by the
>>> gdb memory map format.  While the sim supports RWX bits, gdb can only
>>> handle RW or RO regions.
>>> ---
>>>    gdb/remote-sim.c         | 18 +++++++++++++
>>>    include/gdb/remote-sim.h |  9 +++++++
>>>    sim/common/sim-core.c    | 57 ++++++++++++++++++++++++++++++++++++++++
>>>    3 files changed, 84 insertions(+)
>> I think this change broke the powerpc simulator (target "powerpc-rtems6"
>> for example):
>>
>>     CXXLD  gdb
>> /usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/bin/ld:
>> remote-sim.o: in function `gdbsim_target::memory_map()':
>> /tmp/sh/src/rsb/rtems/build/powerpc-rtems6-gdb-0f8e278-x86_64-linux-gnu-1/build/gdb/../../sourceware-mirror-binutils-gdb-0f8e278/gdb/remote-sim.c:1283:
>> undefined reference to `sim_memory_map'
> indeed, sorry about that.  i've pushed this fix.
> -mike
>
> [PATCH] sim: ppc: stub out sim_memory_map
>
> Not clear how to implement this in the ppc-specific sim, so just
> stub it out.  This is as good as it was previously.
Thanks, this fixed the problem.

-- 
embedded brains GmbH
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.huber@embedded-brains.de
phone: +49-89-18 94 741 - 16
fax:   +49-89-18 94 741 - 08

Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/


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

end of thread, other threads:[~2021-01-08 10:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-06  6:04 [PATCH] gdb/sim: add support for exporting memory map Mike Frysinger
2021-01-06  9:49 ` Andrew Burgess
2021-01-06 11:04 ` [PATCH v2] " Mike Frysinger
2021-01-07  9:28   ` Andrew Burgess
2021-01-08  5:17   ` Sebastian Huber
2021-01-08  6:05     ` Mike Frysinger
2021-01-08 10:20       ` Sebastian Huber

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).