base: Dump page table over RSP

Add a non-standard extension to the RSP protocol: the "." command
requests a dump of the simulated page table.
The dump consists of concatenated records, one record per page table
entry.  Each record contains the entry's "virtual" value written as
hex, followed by a colon (:), followed by the entry's "physical" value
written as hex, followed by a semicolon (;).

At the time of writing, one practical use of this feature (in
combination with the "shared_backstore" parameter) is extremely fast
Miranda-Ingalls simulation of JIT compilers.

Change-Id: I333ed11d4ce671251d0b93cddae3bbcea44ea4ca
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/47719
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Boris Shingarov
2021-07-06 04:18:06 -04:00
parent 9a2efa07c5
commit c046e61216
4 changed files with 27 additions and 0 deletions

View File

@@ -153,6 +153,7 @@
#include "mem/port.hh"
#include "mem/port_proxy.hh"
#include "sim/full_system.hh"
#include "sim/process.hh"
#include "sim/system.hh"
namespace gem5
@@ -872,6 +873,8 @@ std::map<char, BaseRemoteGDB::GdbCommand> BaseRemoteGDB::commandMap = {
{ 'z', { "KGDB_CLR_HW_BKPT", &BaseRemoteGDB::cmdClrHwBkpt } },
// insert breakpoint or watchpoint
{ 'Z', { "KGDB_SET_HW_BKPT", &BaseRemoteGDB::cmdSetHwBkpt } },
// non-standard RSP extension: dump page table
{ '.', { "GET_PAGE_TABLE", &BaseRemoteGDB::cmdDumpPageTable } },
};
bool
@@ -1218,6 +1221,13 @@ BaseRemoteGDB::encodeXferResponse(const std::string &unencoded,
encodeBinaryData(unencoded.substr(offset, unencoded_length), encoded);
}
bool
BaseRemoteGDB::cmdDumpPageTable(GdbCommand::Context &ctx)
{
send(tc->getProcessPtr()->pTable->externalize().c_str());
return true;
}
bool
BaseRemoteGDB::cmdAsyncStep(GdbCommand::Context &ctx)
{

View File

@@ -336,6 +336,7 @@ class BaseRemoteGDB
bool cmdAsyncStep(GdbCommand::Context &ctx);
bool cmdClrHwBkpt(GdbCommand::Context &ctx);
bool cmdSetHwBkpt(GdbCommand::Context &ctx);
bool cmdDumpPageTable(GdbCommand::Context &ctx);
struct QuerySetCommand
{

View File

@@ -206,4 +206,14 @@ EmulationPageTable::unserialize(CheckpointIn &cp)
}
}
const std::string
EmulationPageTable::externalize() const
{
std::stringstream ss;
for (PTable::const_iterator it=pTable.begin(); it != pTable.end(); ++it) {
ss << std::hex << it->first << ":" << it->second.paddr << ";";
}
return ss.str();
}
} // namespace gem5

View File

@@ -162,6 +162,12 @@ class EmulationPageTable : public Serializable
*/
Fault translate(const RequestPtr &req);
/**
* Dump all items in the pTable, to a concatenation of strings of the form
* Addr:Entry;
*/
const std::string externalize() const;
void getMappings(std::vector<std::pair<Addr, Addr>> *addr_mappings);
void serialize(CheckpointOut &cp) const override;