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.
This commit is contained in:
Mike Frysinger
2015-12-29 23:52:57 -05:00
parent f478212851
commit e904f56d02
6 changed files with 98 additions and 0 deletions

View File

@@ -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 ()