aboutsummaryrefslogtreecommitdiff
path: root/gdb/remote-sim.c
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2015-12-29 23:52:57 -0500
committerMike Frysinger <vapier@gentoo.org>2021-01-07 12:18:59 -0500
commite904f56d02afd68ffd9333435fe8b026f1e14b5f (patch)
tree21af166171abe5a1aa80ed2b2b37b8cbc9b64bcf /gdb/remote-sim.c
parentf478212851a25cd9849ad7f41112d08f91ab308b (diff)
downloadgdb-e904f56d02afd68ffd9333435fe8b026f1e14b5f.zip
gdb-e904f56d02afd68ffd9333435fe8b026f1e14b5f.tar.gz
gdb-e904f56d02afd68ffd9333435fe8b026f1e14b5f.tar.bz2
gdb/sim: add support for exporting memory map
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.
Diffstat (limited to 'gdb/remote-sim.c')
-rw-r--r--gdb/remote-sim.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c
index c4f3913..b21a4e8 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 ()