Fix for gem5 Issue #550 (#636)

This Pull-Request addresses gem5 Issue #550. The code that dumps the
Dmesg buffer is now templated on the two variants of the `Metadata`
structure, and the correct one is chosen based on the detected Kernel
version.

To support this functionality, the pull request also adds Symbol Size
data to the loader Symbol Table, and adds a method to query the Kernel
Version from the image in guest memory. The new attributes in the Symbol
class are de-serialized speculatively, so no checkpoint upgrader is
required to support this change.
This commit is contained in:
Bobby R. Bruce
2023-12-01 18:06:20 -08:00
committed by GitHub
17 changed files with 409 additions and 147 deletions

View File

@@ -401,8 +401,8 @@ ArmStaticInst::printTarget(std::ostream &os, Addr target,
if (symtab) {
auto it = symtab->findNearest(target);
if (it != symtab->end()) {
ccprintf(os, "<%s", it->name);
Addr delta = target - it->address;
ccprintf(os, "<%s", it->name());
Addr delta = target - it->address();
if (delta)
ccprintf(os, "+%d>", delta);
else
@@ -486,9 +486,9 @@ ArmStaticInst::printMemSymbol(std::ostream &os,
if (symtab) {
auto it = symtab->findNearest(addr);
if (it != symtab->end()) {
ccprintf(os, "%s%s", prefix, it->name);
if (it->address != addr)
ccprintf(os, "+%d", addr - it->address);
ccprintf(os, "%s%s", prefix, it->name());
if (it->address() != addr)
ccprintf(os, "+%d", addr - it->address());
ccprintf(os, suffix);
}
}

View File

@@ -60,7 +60,7 @@ class ThreadInfo
return false;
}
data = TranslatingPortProxy(tc).read<T>(it->address, byteOrder);
data = TranslatingPortProxy(tc).read<T>(it->address(), byteOrder);
return true;
}

View File

@@ -194,7 +194,7 @@ output decoder {{
loader::SymbolTable::const_iterator it;
if (symtab && (it = symtab->find(target)) != symtab->end())
ss << it->name;
ss << it->name();
else
ccprintf(ss, "%#x", target);
@@ -214,7 +214,7 @@ output decoder {{
} else if (_numSrcRegs == 0) {
loader::SymbolTable::const_iterator it;
if (symtab && (it = symtab->find(disp)) != symtab->end())
ss << it->name;
ss << it->name();
else
ccprintf(ss, "0x%x", disp);
} else if (_numSrcRegs == 1) {

View File

@@ -97,7 +97,7 @@ BranchOp::generateDisassembly(
loader::SymbolTable::const_iterator it;
if (symtab && (it = symtab->find(target)) != symtab->end())
ss << it->name;
ss << it->name();
else
ccprintf(ss, "%#x", target);
@@ -149,7 +149,7 @@ BranchDispCondOp::generateDisassembly(
loader::SymbolTable::const_iterator it;
if (symtab && (it = symtab->find(target)) != symtab->end())
ss << it->name;
ss << it->name();
else
ccprintf(ss, "%#x", target);

View File

@@ -122,8 +122,8 @@ PowerProcess::initState()
loader::Symbol symbol = sym;
// Try to read entry point from function descriptor
if (initVirtMem->tryReadBlob(sym.address, &entry, sizeof(Addr)))
symbol.address = gtoh(entry, byteOrder);
if (initVirtMem->tryReadBlob(sym.address(), &entry, sizeof(Addr)))
symbol.relocate(gtoh(entry, byteOrder));
symbolTable->insert(symbol);
}

View File

@@ -86,8 +86,8 @@ BootloaderKernelWorkload::loadBootloaderSymbolTable()
bootloaderSymbolTable.offset(
bootloader_paddr_offset
)->functionSymbols()->rename(
[](std::string &name) {
name = "bootloader." + name;
[](const std::string &name) {
return "bootloader." + name;
}
);
loader::debugSymbolTable.insert(*renamedBootloaderSymbolTable);
@@ -102,8 +102,8 @@ BootloaderKernelWorkload::loadKernelSymbolTable()
kernelSymbolTable = kernel->symtab();
auto renamedKernelSymbolTable = \
kernelSymbolTable.functionSymbols()->rename(
[](std::string &name) {
name = "kernel." + name;
[](const std::string &name) {
return "kernel." + name;
}
);
loader::debugSymbolTable.insert(*renamedKernelSymbolTable);

View File

@@ -88,9 +88,9 @@ BranchDisp::generateDisassembly(
loader::SymbolTable::const_iterator it;
if (symtab && (it = symtab->findNearest(target)) != symtab->end()) {
ccprintf(response, " <%s", it->name);
if (it->address != target)
ccprintf(response, "+%d>", target - it->address);
ccprintf(response, " <%s", it->name());
if (it->address() != target)
ccprintf(response, "+%d>", target - it->address());
else
ccprintf(response, ">");
}