base: Add encapsulation to the loader::Symbol class
This commit converts `gem5::loader::Symbol` to a full class with private members, enforcing encapsulation. Until now client code has been able to (and does) access members directly. This change will enable class invariants to be enforced via accessor methods. Change-Id: Ia0b5b080d4f656637a211808e13dce1ddca74541 Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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, ">");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011-2013, 2019 ARM Limited
|
||||
* Copyright (c) 2011-2013, 2019, 2023 Arm Limited
|
||||
* All rights reserved
|
||||
*
|
||||
* The license below extends only to copyright in the software and shall
|
||||
@@ -178,48 +178,51 @@ ElfObject::ElfObject(ImageFileDataPtr ifd) : ObjectFile(ifd)
|
||||
if (!sym_name || sym_name[0] == '$')
|
||||
continue;
|
||||
|
||||
loader::Symbol symbol;
|
||||
symbol.address = sym.st_value;
|
||||
symbol.name = sym_name;
|
||||
|
||||
loader::Symbol::Binding binding =
|
||||
loader::Symbol::Binding::Global;
|
||||
switch (GELF_ST_BIND(sym.st_info)) {
|
||||
case STB_GLOBAL:
|
||||
symbol.binding = loader::Symbol::Binding::Global;
|
||||
binding = loader::Symbol::Binding::Global;
|
||||
break;
|
||||
case STB_LOCAL:
|
||||
symbol.binding = loader::Symbol::Binding::Local;
|
||||
binding = loader::Symbol::Binding::Local;
|
||||
break;
|
||||
case STB_WEAK:
|
||||
symbol.binding = loader::Symbol::Binding::Weak;
|
||||
binding = loader::Symbol::Binding::Weak;
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
loader::Symbol::SymbolType symbol_type =
|
||||
loader::Symbol::SymbolType::NoType;
|
||||
switch (GELF_ST_TYPE(sym.st_info)) {
|
||||
case STT_NOTYPE:
|
||||
symbol.type = loader::Symbol::SymbolType::NoType;
|
||||
symbol_type = loader::Symbol::SymbolType::NoType;
|
||||
break;
|
||||
case STT_OBJECT:
|
||||
symbol.type = loader::Symbol::SymbolType::Object;
|
||||
symbol_type = loader::Symbol::SymbolType::Object;
|
||||
break;
|
||||
case STT_FUNC:
|
||||
symbol.type = loader::Symbol::SymbolType::Function;
|
||||
symbol_type = loader::Symbol::SymbolType::Function;
|
||||
break;
|
||||
case STT_SECTION:
|
||||
symbol.type = loader::Symbol::SymbolType::Section;
|
||||
symbol_type = loader::Symbol::SymbolType::Section;
|
||||
break;
|
||||
case STT_FILE:
|
||||
symbol.type = loader::Symbol::SymbolType::File;
|
||||
symbol_type = loader::Symbol::SymbolType::File;
|
||||
break;
|
||||
default:
|
||||
symbol.type = loader::Symbol::SymbolType::Other;
|
||||
symbol_type = loader::Symbol::SymbolType::Other;
|
||||
break;
|
||||
}
|
||||
|
||||
loader::Symbol symbol(
|
||||
binding, symbol_type, sym_name, sym.st_value);
|
||||
|
||||
if (_symtab.insert(symbol)) {
|
||||
DPRINTF(Loader, "Symbol: %-40s value %#x.\n",
|
||||
symbol.name, symbol.address);
|
||||
symbol.name(), symbol.address());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,16 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Arm Limited
|
||||
* All rights reserved
|
||||
*
|
||||
* The license below extends only to copyright in the software and shall
|
||||
* not be construed as granting a license to any other intellectual
|
||||
* property including but not limited to intellectual property relating
|
||||
* to a hardware implementation of the functionality of the software
|
||||
* licensed hereunder. You may use the software subject to the license
|
||||
* terms below provided that you ensure that this notice is replicated
|
||||
* unmodified and in its entirety in all distributions of the software,
|
||||
* modified or unmodified, in source code or in binary form.
|
||||
*
|
||||
* Copyright (c) 2002-2005 The Regents of The University of Michigan
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -53,17 +65,17 @@ SymbolTable::clear()
|
||||
bool
|
||||
SymbolTable::insert(const Symbol &symbol)
|
||||
{
|
||||
if (symbol.name.empty())
|
||||
if (symbol.name().empty())
|
||||
return false;
|
||||
|
||||
int idx = symbols.size();
|
||||
|
||||
if (!nameMap.insert({ symbol.name, idx }).second)
|
||||
if (!nameMap.insert({ symbol.name(), idx }).second)
|
||||
return false;
|
||||
|
||||
// There can be multiple symbols for the same address, so always
|
||||
// update the addrTable multimap when we see a new symbol name.
|
||||
addrMap.insert({ symbol.address, idx });
|
||||
addrMap.insert({ symbol.address(), idx });
|
||||
|
||||
symbols.emplace_back(symbol);
|
||||
|
||||
@@ -98,10 +110,11 @@ SymbolTable::serialize(const std::string &base, CheckpointOut &cp) const
|
||||
|
||||
int i = 0;
|
||||
for (auto &symbol: symbols) {
|
||||
paramOut(cp, csprintf("%s.addr_%d", base, i), symbol.address);
|
||||
paramOut(cp, csprintf("%s.symbol_%d", base, i), symbol.name);
|
||||
paramOut(cp, csprintf("%s.binding_%d", base, i), (int)symbol.binding);
|
||||
paramOut(cp, csprintf("%s.type_%d", base, i), (int)symbol.type);
|
||||
paramOut(cp, csprintf("%s.addr_%d", base, i), symbol.address());
|
||||
paramOut(cp, csprintf("%s.symbol_%d", base, i), symbol.name());
|
||||
paramOut(cp, csprintf("%s.binding_%d", base, i),
|
||||
(int)symbol.binding());
|
||||
paramOut(cp, csprintf("%s.type_%d", base, i), (int)symbol.type());
|
||||
i++;
|
||||
}
|
||||
}
|
||||
@@ -125,7 +138,7 @@ SymbolTable::unserialize(const std::string &base, CheckpointIn &cp,
|
||||
binding = default_binding;
|
||||
if (!optParamIn(cp, csprintf("%s.type_%d", base, i), type))
|
||||
type = Symbol::SymbolType::Other;
|
||||
insert({binding, type, name, address});
|
||||
insert(Symbol(binding, type, name, address));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,16 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Arm Limited
|
||||
* All rights reserved
|
||||
*
|
||||
* The license below extends only to copyright in the software and shall
|
||||
* not be construed as granting a license to any other intellectual
|
||||
* property including but not limited to intellectual property relating
|
||||
* to a hardware implementation of the functionality of the software
|
||||
* licensed hereunder. You may use the software subject to the license
|
||||
* terms below provided that you ensure that this notice is replicated
|
||||
* unmodified and in its entirety in all distributions of the software,
|
||||
* modified or unmodified, in source code or in binary form.
|
||||
*
|
||||
* Copyright (c) 2021 Daniel R. Carvalho
|
||||
* Copyright (c) 2002-2005 The Regents of The University of Michigan
|
||||
* All rights reserved.
|
||||
@@ -47,8 +59,9 @@ namespace gem5
|
||||
namespace loader
|
||||
{
|
||||
|
||||
struct Symbol
|
||||
class Symbol
|
||||
{
|
||||
public:
|
||||
enum class Binding
|
||||
{
|
||||
Global,
|
||||
@@ -67,12 +80,46 @@ struct Symbol
|
||||
Other
|
||||
};
|
||||
|
||||
Binding binding;
|
||||
SymbolType type;
|
||||
std::string name;
|
||||
Addr address;
|
||||
Symbol(const Binding binding, const SymbolType type,
|
||||
const std::string & name, const Addr addr)
|
||||
: _binding(binding), _type(type), _name(name), _address(addr)
|
||||
{}
|
||||
|
||||
Symbol(const Symbol & other) = default;
|
||||
Symbol & operator=(const Symbol & other) = default;
|
||||
|
||||
Binding binding() const {
|
||||
return _binding;
|
||||
}
|
||||
|
||||
SymbolType type() const {
|
||||
return _type;
|
||||
}
|
||||
|
||||
std::string name() const {
|
||||
return _name;
|
||||
}
|
||||
|
||||
void rename(const std::string & new_name) {
|
||||
_name = new_name;
|
||||
}
|
||||
|
||||
Addr address() const {
|
||||
return _address;
|
||||
}
|
||||
|
||||
void relocate(const Addr new_addr) {
|
||||
_address = new_addr;
|
||||
}
|
||||
|
||||
private:
|
||||
Binding _binding;
|
||||
SymbolType _type;
|
||||
std::string _name;
|
||||
Addr _address;
|
||||
};
|
||||
|
||||
|
||||
class SymbolTable
|
||||
{
|
||||
public:
|
||||
@@ -171,7 +218,7 @@ class SymbolTable
|
||||
filterByBinding(Symbol::Binding binding) const
|
||||
{
|
||||
auto filt = [binding](const Symbol &symbol) {
|
||||
return symbol.binding == binding;
|
||||
return symbol.binding() == binding;
|
||||
};
|
||||
return filter(filt);
|
||||
}
|
||||
@@ -187,7 +234,7 @@ class SymbolTable
|
||||
filterBySymbolType(const Symbol::SymbolType& symbol_type) const
|
||||
{
|
||||
auto filt = [symbol_type](const Symbol &symbol) {
|
||||
return symbol.type == symbol_type;
|
||||
return symbol.type() == symbol_type;
|
||||
};
|
||||
return filter(filt);
|
||||
}
|
||||
@@ -242,9 +289,9 @@ class SymbolTable
|
||||
{
|
||||
SymTabOp op =
|
||||
[addr_offset](SymbolTable &symtab, const Symbol &symbol) {
|
||||
Symbol sym = symbol;
|
||||
sym.address += addr_offset;
|
||||
symtab.insert(sym);
|
||||
symtab.insert(
|
||||
Symbol(symbol.binding(), symbol.type(), symbol.name(),
|
||||
symbol.address() + addr_offset));
|
||||
};
|
||||
return operate(op);
|
||||
}
|
||||
@@ -260,9 +307,9 @@ class SymbolTable
|
||||
mask(Addr m) const
|
||||
{
|
||||
SymTabOp op = [m](SymbolTable &symtab, const Symbol &symbol) {
|
||||
Symbol sym = symbol;
|
||||
sym.address &= m;
|
||||
symtab.insert(sym);
|
||||
symtab.insert(
|
||||
Symbol(symbol.binding(), symbol.type(), symbol.name(),
|
||||
symbol.address() & m));
|
||||
};
|
||||
return operate(op);
|
||||
}
|
||||
@@ -275,11 +322,11 @@ class SymbolTable
|
||||
* @retval SymbolTablePtr A pointer to the modified SymbolTable copy.
|
||||
*/
|
||||
SymbolTablePtr
|
||||
rename(std::function<void(std::string&)> func) const
|
||||
rename(std::function<std::string (const std::string&)> func) const
|
||||
{
|
||||
SymTabOp op = [func](SymbolTable &symtab, const Symbol &symbol) {
|
||||
Symbol sym = symbol;
|
||||
func(sym.name);
|
||||
sym.rename(func(sym.name()));
|
||||
symtab.insert(sym);
|
||||
};
|
||||
return operate(op);
|
||||
|
||||
@@ -52,26 +52,26 @@ getSymbolError(const loader::Symbol& symbol, const loader::Symbol& expected)
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
||||
if (symbol.binding != expected.binding) {
|
||||
if (symbol.binding() != expected.binding()) {
|
||||
ss << " symbols' bindings do not match: seen `" <<
|
||||
(int)symbol.binding << "`, expected `" <<
|
||||
(int)expected.binding << "`.\n";
|
||||
(int)symbol.binding() << "`, expected `" <<
|
||||
(int)expected.binding() << "`.\n";
|
||||
}
|
||||
|
||||
if (symbol.type != expected.type) {
|
||||
if (symbol.type() != expected.type()) {
|
||||
ss << " symbols' types do not match: seen `" <<
|
||||
(int)symbol.type << "`, expected `" <<
|
||||
(int)expected.type << "`.\n";
|
||||
(int)symbol.type() << "`, expected `" <<
|
||||
(int)expected.type() << "`.\n";
|
||||
}
|
||||
|
||||
if (symbol.name != expected.name) {
|
||||
ss << " symbols' names do not match: seen `" << symbol.name <<
|
||||
"`, expected `" << expected.name << "`.\n";
|
||||
if (symbol.name() != expected.name()) {
|
||||
ss << " symbols' names do not match: seen `" << symbol.name() <<
|
||||
"`, expected `" << expected.name() << "`.\n";
|
||||
}
|
||||
|
||||
if (symbol.address != expected.address) {
|
||||
if (symbol.address() != expected.address()) {
|
||||
ss << " symbols' addresses do not match: seen `" <<
|
||||
symbol.address << "`, expected `" << expected.address << "`.\n";
|
||||
symbol.address() << "`, expected `" << expected.address() << "`.\n";
|
||||
}
|
||||
|
||||
// No error, symbols match
|
||||
@@ -273,12 +273,12 @@ TEST(LoaderSymtabTest, Offset)
|
||||
|
||||
// Check that the new table is offset
|
||||
loader::Symbol expected_symbols[] = {
|
||||
{symbols[0].binding, symbols[0].type, symbols[0].name,
|
||||
symbols[0].address + offset},
|
||||
{symbols[1].binding, symbols[1].type, symbols[1].name,
|
||||
symbols[1].address + offset},
|
||||
{symbols[2].binding, symbols[2].type, symbols[2].name,
|
||||
symbols[2].address + offset},
|
||||
{symbols[0].binding(), symbols[0].type(), symbols[0].name(),
|
||||
symbols[0].address() + offset},
|
||||
{symbols[1].binding(), symbols[1].type(), symbols[1].name(),
|
||||
symbols[1].address() + offset},
|
||||
{symbols[2].binding(), symbols[2].type(), symbols[2].name(),
|
||||
symbols[2].address() + offset},
|
||||
};
|
||||
ASSERT_TRUE(checkTable(*symtab_new, {expected_symbols[0],
|
||||
expected_symbols[1], expected_symbols[2]}));
|
||||
@@ -316,14 +316,14 @@ TEST(LoaderSymtabTest, Mask)
|
||||
|
||||
// Check that the new table is masked
|
||||
loader::Symbol expected_symbols[] = {
|
||||
{symbols[0].binding, symbols[0].type, symbols[0].name,
|
||||
symbols[0].address & mask},
|
||||
{symbols[1].binding, symbols[1].type, symbols[1].name,
|
||||
symbols[1].address & mask},
|
||||
{symbols[2].binding, symbols[2].type, symbols[2].name,
|
||||
symbols[2].address & mask},
|
||||
{symbols[3].binding, symbols[3].type, symbols[3].name,
|
||||
symbols[3].address & mask},
|
||||
{symbols[0].binding(), symbols[0].type(), symbols[0].name(),
|
||||
symbols[0].address() & mask},
|
||||
{symbols[1].binding(), symbols[1].type(), symbols[1].name(),
|
||||
symbols[1].address() & mask},
|
||||
{symbols[2].binding(), symbols[2].type(), symbols[2].name(),
|
||||
symbols[2].address() & mask},
|
||||
{symbols[3].binding(), symbols[3].type(), symbols[3].name(),
|
||||
symbols[3].address() & mask},
|
||||
};
|
||||
ASSERT_TRUE(checkTable(*symtab_new, {expected_symbols[0],
|
||||
expected_symbols[1], expected_symbols[2], expected_symbols[3]}));
|
||||
@@ -353,7 +353,7 @@ TEST(LoaderSymtabTest, Rename)
|
||||
EXPECT_TRUE(symtab.insert(symbols[3]));
|
||||
|
||||
const auto symtab_new =
|
||||
symtab.rename([](std::string &name) { name = name + "_suffix"; });
|
||||
symtab.rename([](const std::string &name) { return name + "_suffix"; });
|
||||
|
||||
// Check that the original table is not modified
|
||||
ASSERT_TRUE(checkTable(symtab, {symbols[0], symbols[1], symbols[2],
|
||||
@@ -361,14 +361,14 @@ TEST(LoaderSymtabTest, Rename)
|
||||
|
||||
// Check that the new table's symbols have been renamed
|
||||
loader::Symbol expected_symbols[] = {
|
||||
{symbols[0].binding, symbols[0].type, symbols[0].name + "_suffix",
|
||||
symbols[0].address},
|
||||
{symbols[1].binding, symbols[1].type, symbols[1].name + "_suffix",
|
||||
symbols[1].address},
|
||||
{symbols[2].binding, symbols[2].type, symbols[2].name + "_suffix",
|
||||
symbols[2].address},
|
||||
{symbols[3].binding, symbols[3].type, symbols[3].name + "_suffix",
|
||||
symbols[3].address},
|
||||
{symbols[0].binding(), symbols[0].type(), symbols[0].name() + "_suffix",
|
||||
symbols[0].address()},
|
||||
{symbols[1].binding(), symbols[1].type(), symbols[1].name() + "_suffix",
|
||||
symbols[1].address()},
|
||||
{symbols[2].binding(), symbols[2].type(), symbols[2].name() + "_suffix",
|
||||
symbols[2].address()},
|
||||
{symbols[3].binding(), symbols[3].type(), symbols[3].name() + "_suffix",
|
||||
symbols[3].address()},
|
||||
};
|
||||
ASSERT_TRUE(checkTable(*symtab_new, {expected_symbols[0],
|
||||
expected_symbols[1], expected_symbols[2], expected_symbols[3]}));
|
||||
@@ -398,10 +398,12 @@ TEST(LoaderSymtabTest, RenameNonUnique)
|
||||
EXPECT_TRUE(symtab.insert(symbols[3]));
|
||||
|
||||
int i = 0;
|
||||
const auto symtab_new = symtab.rename([&i](std::string &name)
|
||||
const auto symtab_new = symtab.rename([&i](const std::string &name)
|
||||
{
|
||||
if ((i++ % 2) == 0) {
|
||||
name = "NonUniqueName";
|
||||
return std::string("NonUniqueName");
|
||||
} else {
|
||||
return name;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -412,12 +414,12 @@ TEST(LoaderSymtabTest, RenameNonUnique)
|
||||
// Check that the new table's symbols have been renamed, yet it does not
|
||||
// contain the symbols with duplicated names
|
||||
loader::Symbol expected_symbols[] = {
|
||||
{symbols[0].binding, symbols[0].type, "NonUniqueName",
|
||||
symbols[0].address},
|
||||
{symbols[1].binding, symbols[1].type, symbols[1].name,
|
||||
symbols[1].address},
|
||||
{symbols[3].binding, symbols[3].type, symbols[3].name,
|
||||
symbols[3].address},
|
||||
{symbols[0].binding(), symbols[0].type(), "NonUniqueName",
|
||||
symbols[0].address()},
|
||||
{symbols[1].binding(), symbols[1].type(), symbols[1].name(),
|
||||
symbols[1].address()},
|
||||
{symbols[3].binding(), symbols[3].type(), symbols[3].name(),
|
||||
symbols[3].address()},
|
||||
};
|
||||
ASSERT_TRUE(checkTable(*symtab_new, {expected_symbols[0],
|
||||
expected_symbols[1], expected_symbols[2]}));
|
||||
@@ -597,7 +599,7 @@ TEST(LoaderSymtabTest, FindUniqueAddress)
|
||||
EXPECT_TRUE(symtab.insert(symbols[1]));
|
||||
EXPECT_TRUE(symtab.insert(symbols[2]));
|
||||
|
||||
const auto it = symtab.find(symbols[2].address);
|
||||
const auto it = symtab.find(symbols[2].address());
|
||||
ASSERT_NE(it, symtab.end());
|
||||
ASSERT_PRED_FORMAT2(checkSymbol, *it, symbols[2]);
|
||||
}
|
||||
@@ -622,7 +624,7 @@ TEST(LoaderSymtabTest, FindNonUniqueAddress)
|
||||
EXPECT_TRUE(symtab.insert(symbols[1]));
|
||||
EXPECT_TRUE(symtab.insert(symbols[2]));
|
||||
|
||||
const auto it = symtab.find(symbols[1].address);
|
||||
const auto it = symtab.find(symbols[1].address());
|
||||
ASSERT_NE(it, symtab.end());
|
||||
ASSERT_PRED_FORMAT2(checkSymbol, *it, symbols[1]);
|
||||
}
|
||||
@@ -658,7 +660,7 @@ TEST(LoaderSymtabTest, FindExistingName)
|
||||
EXPECT_TRUE(symtab.insert(symbols[1]));
|
||||
EXPECT_TRUE(symtab.insert(symbols[2]));
|
||||
|
||||
const auto it = symtab.find(symbols[1].name);
|
||||
const auto it = symtab.find(symbols[1].name());
|
||||
ASSERT_NE(it, symtab.end());
|
||||
ASSERT_PRED_FORMAT2(checkSymbol, *it, symbols[1]);
|
||||
}
|
||||
@@ -677,7 +679,7 @@ TEST(LoaderSymtabTest, FindNearestExact)
|
||||
EXPECT_TRUE(symtab.insert(symbols[0]));
|
||||
EXPECT_TRUE(symtab.insert(symbols[1]));
|
||||
|
||||
const auto it = symtab.findNearest(symbols[1].address);
|
||||
const auto it = symtab.findNearest(symbols[1].address());
|
||||
ASSERT_NE(it, symtab.end());
|
||||
ASSERT_PRED_FORMAT2(checkSymbol, *it, symbols[1]);
|
||||
}
|
||||
@@ -695,7 +697,7 @@ TEST(LoaderSymtabTest, FindNearestRound)
|
||||
"symbol", 0x10};
|
||||
EXPECT_TRUE(symtab.insert(symbol));
|
||||
|
||||
const auto it = symtab.findNearest(symbol.address + 0x1);
|
||||
const auto it = symtab.findNearest(symbol.address() + 0x1);
|
||||
ASSERT_NE(it, symtab.end());
|
||||
ASSERT_PRED_FORMAT2(checkSymbol, *it, symbol);
|
||||
}
|
||||
@@ -719,10 +721,10 @@ TEST(LoaderSymtabTest, FindNearestRoundWithNext)
|
||||
EXPECT_TRUE(symtab.insert(symbols[1]));
|
||||
|
||||
Addr next_addr;
|
||||
const auto it = symtab.findNearest(symbols[0].address + 0x1, next_addr);
|
||||
const auto it = symtab.findNearest(symbols[0].address() + 0x1, next_addr);
|
||||
ASSERT_NE(it, symtab.end());
|
||||
ASSERT_PRED_FORMAT2(checkSymbol, *it, symbols[0]);
|
||||
ASSERT_EQ(next_addr, symbols[1].address);
|
||||
ASSERT_EQ(next_addr, symbols[1].address());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -740,7 +742,7 @@ TEST(LoaderSymtabTest, FindNearestRoundWithNextNonExistent)
|
||||
EXPECT_TRUE(symtab.insert(symbol));
|
||||
|
||||
Addr next_addr;
|
||||
const auto it = symtab.findNearest(symbol.address + 0x1, next_addr);
|
||||
const auto it = symtab.findNearest(symbol.address() + 0x1, next_addr);
|
||||
ASSERT_NE(it, symtab.end());
|
||||
ASSERT_PRED_FORMAT2(checkSymbol, *it, symbol);
|
||||
ASSERT_EQ(next_addr, 0);
|
||||
@@ -759,7 +761,7 @@ TEST(LoaderSymtabTest, FindNearestNonExistent)
|
||||
"symbol", 0x10};
|
||||
EXPECT_TRUE(symtab.insert(symbol));
|
||||
|
||||
const auto it = symtab.findNearest(symbol.address - 0x1);
|
||||
const auto it = symtab.findNearest(symbol.address() - 0x1);
|
||||
ASSERT_EQ(it, symtab.end());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011-2012,2016-2017, 2019-2020 ARM Limited
|
||||
* Copyright (c) 2011-2012,2016-2017, 2019-2020 Arm Limited
|
||||
* All rights reserved
|
||||
*
|
||||
* The license below extends only to copyright in the software and shall
|
||||
@@ -795,8 +795,8 @@ BaseCPU::traceFunctionsInternal(Addr pc)
|
||||
currentFunctionStart = pc;
|
||||
currentFunctionEnd = pc + 1;
|
||||
} else {
|
||||
sym_str = it->name;
|
||||
currentFunctionStart = it->address;
|
||||
sym_str = it->name();
|
||||
currentFunctionStart = it->address();
|
||||
}
|
||||
|
||||
ccprintf(*functionTraceStream, " (%d)\n%d: %s",
|
||||
|
||||
@@ -81,11 +81,11 @@ ExeTracerRecord::traceInst(const StaticInstPtr &inst, bool ran)
|
||||
if (debug::ExecSymbol && (!FullSystem || !in_user_mode) &&
|
||||
(it = loader::debugSymbolTable.findNearest(cur_pc)) !=
|
||||
loader::debugSymbolTable.end()) {
|
||||
Addr delta = cur_pc - it->address;
|
||||
Addr delta = cur_pc - it->address();
|
||||
if (delta)
|
||||
ccprintf(outs, " @%s+%d", it->name, delta);
|
||||
ccprintf(outs, " @%s+%d", it->name(), delta);
|
||||
else
|
||||
ccprintf(outs, " @%s", it->name);
|
||||
ccprintf(outs, " @%s", it->name());
|
||||
}
|
||||
|
||||
if (inst->isMicroop()) {
|
||||
|
||||
@@ -63,7 +63,7 @@ BaseStackTrace::tryGetSymbol(std::string &symbol, Addr addr,
|
||||
const auto it = symtab->find(addr);
|
||||
if (it == symtab->end())
|
||||
return false;
|
||||
symbol = it->name;
|
||||
symbol = it->name();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ FunctionProfile::sample(ProfileNode *node, Addr pc)
|
||||
|
||||
auto it = symtab.findNearest(pc);
|
||||
if (it != symtab.end()) {
|
||||
pc_count[it->address]++;
|
||||
pc_count[it->address()]++;
|
||||
} else {
|
||||
// record PC even if we don't have a symbol to avoid
|
||||
// silently biasing the histogram
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 2022 Arm Limited
|
||||
* Copyright (c) 2016, 2022-2023 Arm Limited
|
||||
* All rights reserved
|
||||
*
|
||||
* The license below extends only to copyright in the software and shall
|
||||
@@ -125,9 +125,9 @@ dumpDmesg(ThreadContext *tc, std::ostream &os)
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t log_buf_len = proxy.read<uint32_t>(lb_len->address, bo);
|
||||
uint32_t log_first_idx = proxy.read<uint32_t>(first->address, bo);
|
||||
uint32_t log_next_idx = proxy.read<uint32_t>(next->address, bo);
|
||||
uint32_t log_buf_len = proxy.read<uint32_t>(lb_len->address(), bo);
|
||||
uint32_t log_first_idx = proxy.read<uint32_t>(first->address(), bo);
|
||||
uint32_t log_next_idx = proxy.read<uint32_t>(next->address(), bo);
|
||||
|
||||
if (log_first_idx >= log_buf_len || log_next_idx >= log_buf_len) {
|
||||
warn("dmesg pointers/length corrupted\n");
|
||||
@@ -143,7 +143,7 @@ dumpDmesg(ThreadContext *tc, std::ostream &os)
|
||||
warn("Unexpected dmesg buffer length\n");
|
||||
return;
|
||||
}
|
||||
proxy.readBlob(lb->address + log_first_idx, log_buf.data(), length);
|
||||
proxy.readBlob(lb->address() + log_first_idx, log_buf.data(), length);
|
||||
} else {
|
||||
const int length_2 = log_buf_len - log_first_idx;
|
||||
if (length_2 < 0 || length_2 + log_next_idx > log_buf.size()) {
|
||||
@@ -151,8 +151,10 @@ dumpDmesg(ThreadContext *tc, std::ostream &os)
|
||||
return;
|
||||
}
|
||||
length = log_buf_len;
|
||||
proxy.readBlob(lb->address + log_first_idx, log_buf.data(), length_2);
|
||||
proxy.readBlob(lb->address, log_buf.data() + length_2, log_next_idx);
|
||||
proxy.readBlob(
|
||||
lb->address() + log_first_idx, log_buf.data(), length_2);
|
||||
proxy.readBlob(
|
||||
lb->address(), log_buf.data() + length_2, log_next_idx);
|
||||
}
|
||||
|
||||
// Print dmesg buffer content
|
||||
@@ -498,7 +500,8 @@ dumpDmesgImpl(ThreadContext *tc, std::ostream &os)
|
||||
ringbuffer_t dynamic_rb;
|
||||
auto dynamic_rb_symbol = symtab.find("printk_rb_dynamic");
|
||||
if (dynamic_rb_symbol != symtab_end_it) {
|
||||
dynamic_rb = ringbuffer_t::read(proxy, dynamic_rb_symbol->address, bo);
|
||||
dynamic_rb =
|
||||
ringbuffer_t::read(proxy, dynamic_rb_symbol->address(), bo);
|
||||
} else {
|
||||
warn("Failed to find required dmesg symbols.\n");
|
||||
return;
|
||||
@@ -508,7 +511,7 @@ dumpDmesgImpl(ThreadContext *tc, std::ostream &os)
|
||||
ringbuffer_t static_rb;
|
||||
auto static_rb_symbol = symtab.find("printk_rb_static");
|
||||
if (static_rb_symbol != symtab_end_it) {
|
||||
static_rb = ringbuffer_t::read(proxy, static_rb_symbol->address, bo);
|
||||
static_rb = ringbuffer_t::read(proxy, static_rb_symbol->address(), bo);
|
||||
} else {
|
||||
warn("Failed to find required dmesg symbols.\n");
|
||||
return;
|
||||
@@ -521,21 +524,22 @@ dumpDmesgImpl(ThreadContext *tc, std::ostream &os)
|
||||
auto active_ringbuffer_ptr_symbol = symtab.find("prb");
|
||||
if (active_ringbuffer_ptr_symbol != symtab_end_it) {
|
||||
active_ringbuffer_ptr =
|
||||
proxy.read<guest_ptr_t>(active_ringbuffer_ptr_symbol->address, bo);
|
||||
proxy.read<guest_ptr_t>(active_ringbuffer_ptr_symbol->address(),
|
||||
bo);
|
||||
} else {
|
||||
warn("Failed to find required dmesg symbols.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (active_ringbuffer_ptr == 0 ||
|
||||
(active_ringbuffer_ptr != dynamic_rb_symbol->address &&
|
||||
active_ringbuffer_ptr != static_rb_symbol->address)) {
|
||||
(active_ringbuffer_ptr != dynamic_rb_symbol->address() &&
|
||||
active_ringbuffer_ptr != static_rb_symbol->address())) {
|
||||
warn("Kernel Dmesg ringbuffer appears to be invalid.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
ringbuffer_t & rb =
|
||||
(active_ringbuffer_ptr == dynamic_rb_symbol->address)
|
||||
(active_ringbuffer_ptr == dynamic_rb_symbol->address())
|
||||
? dynamic_rb : static_rb;
|
||||
|
||||
atomic_var_t head_offset = rb.data.head_offset;
|
||||
|
||||
@@ -66,8 +66,8 @@ KernelWorkload::KernelWorkload(const Params &p) : Workload(p),
|
||||
kernelSymtab = kernelObj->symtab();
|
||||
auto initKernelSymtab = kernelSymtab.mask(_loadAddrMask)
|
||||
->offset(_loadAddrOffset)
|
||||
->rename([](std::string &name) {
|
||||
name = "kernel_init." + name;
|
||||
->rename([](const std::string &name) {
|
||||
return "kernel_init." + name;
|
||||
});
|
||||
|
||||
loader::debugSymbolTable.insert(*initKernelSymtab);
|
||||
|
||||
@@ -141,7 +141,7 @@ class Workload : public SimObject
|
||||
if (it == symtab.end())
|
||||
return nullptr;
|
||||
|
||||
return new T(system, desc, fixFuncEventAddr(it->address),
|
||||
return new T(system, desc, fixFuncEventAddr(it->address()),
|
||||
std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user