gem5
[DEVELOP-FOR-23.0]
|
#include <symtab.hh>
Public Types | |
typedef std::shared_ptr< SymbolTable > | SymbolTablePtr |
typedef SymbolVector::iterator | iterator |
typedef SymbolVector::const_iterator | const_iterator |
Public Member Functions | |
const_iterator | begin () const |
const_iterator | end () const |
void | clear () |
Clears the table. More... | |
bool | insert (const Symbol &symbol) |
Insert a new symbol in the table if it does not already exist. More... | |
bool | insert (const SymbolTable &other) |
Copies the symbols of another table to this table if there are no common symbols between the tables. More... | |
bool | empty () const |
Verifies whether the table is empty. More... | |
SymbolTablePtr | offset (Addr addr_offset) const |
Generate a new table by applying an offset to the symbols of the current table. More... | |
SymbolTablePtr | mask (Addr m) const |
Generate a new table by a mask to the symbols of the current table. More... | |
SymbolTablePtr | rename (std::function< void(std::string &)> func) const |
Modify the symbols' name with a given transform function. More... | |
SymbolTablePtr | globals () const |
Generates a new symbol table containing only global symbols. More... | |
SymbolTablePtr | locals () const |
Generates a new symbol table containing only local symbols. More... | |
SymbolTablePtr | weaks () const |
Generates a new symbol table containing only weak symbols. More... | |
void | serialize (const std::string &base, CheckpointOut &cp) const |
Serialize the table's contents. More... | |
void | unserialize (const std::string &base, CheckpointIn &cp, Symbol::Binding default_binding=Symbol::Binding::Global) |
Populate the table by unserializing a checkpoint. More... | |
const_iterator | find (Addr address) const |
Search for a symbol by its address. More... | |
const_iterator | find (const std::string &name) const |
Search for a symbol by its name. More... | |
const_iterator | findNearest (Addr addr, Addr &next_addr) const |
Find the nearest symbol equal to or less than the supplied address (e.g., the label for the enclosing function). More... | |
const_iterator | findNearest (Addr addr) const |
Overload for findNearestSymbol() for callers who don't care about nextaddr. More... | |
Private Types | |
typedef std::vector< Symbol > | SymbolVector |
Vector containing all the symbols in the table. More... | |
typedef std::multimap< Addr, int > | AddrMap |
Map addresses to an index into the symbol vector. More... | |
typedef std::map< std::string, int > | NameMap |
Map a symbol name to an index into the symbol vector. More... | |
typedef std::function< void(SymbolTable &symtab, const Symbol &symbol)> | SymTabOp |
A function that applies an operation on a symbol with respect to a symbol table. More... | |
typedef std::function< bool(const Symbol &symbol)> | SymTabFilter |
A function that applies a condition to the symbol provided to decide whether the symbol is accepted, or if it must be filtered out. More... | |
Private Member Functions | |
bool | upperBound (Addr addr, AddrMap::const_iterator &iter) const |
Get the first address larger than the given address, if any. More... | |
SymbolTablePtr | operate (SymTabOp op) const |
Create a derived symbol table by applying an operation on the symbols of the current table. More... | |
SymbolTablePtr | filter (SymTabFilter filter) const |
Applies a filter to the symbols of the table to generate a new table. More... | |
SymbolTablePtr | filterByBinding (Symbol::Binding binding) const |
Generate a new table by applying a filter that only accepts the symbols whose binding matches the given binding. More... | |
Private Attributes | |
SymbolVector | symbols |
AddrMap | addrMap |
NameMap | nameMap |
|
private |
typedef SymbolVector::const_iterator gem5::loader::SymbolTable::const_iterator |
typedef SymbolVector::iterator gem5::loader::SymbolTable::iterator |
|
private |
typedef std::shared_ptr<SymbolTable> gem5::loader::SymbolTable::SymbolTablePtr |
|
private |
|
private |
|
private |
|
inline |
Definition at line 172 of file symtab.hh.
References symbols.
Referenced by checkTable().
void gem5::loader::SymbolTable::clear | ( | ) |
Clears the table.
Definition at line 46 of file symtab.cc.
References addrMap, nameMap, and symbols.
Referenced by gem5::PowerProcess::initState(), TEST(), and unserialize().
|
inline |
|
inline |
Definition at line 175 of file symtab.hh.
References symbols.
Referenced by gem5::Workload::addFuncEvent(), checkTable(), find(), findNearest(), gem5::SparcISA::BranchDisp::generateDisassembly(), gem5::PowerISA::BranchOp::generateDisassembly(), gem5::PowerISA::BranchDispCondOp::generateDisassembly(), gem5::ArmISA::FsFreebsd::initState(), gem5::ArmISA::FsLinux::initState(), gem5::ArmISA::ArmStaticInst::printMemSymbol(), gem5::ArmISA::ArmStaticInst::printTarget(), gem5::FunctionProfile::sample(), TEST(), and gem5::BaseStackTrace::tryGetSymbol().
|
inlineprivate |
Applies a filter to the symbols of the table to generate a new table.
The filter decides whether the symbols will be inserted in the new table or not.
filter | The filter to be applied. |
Definition at line 140 of file symtab.hh.
References insert(), and operate().
Referenced by filterByBinding().
|
inlineprivate |
|
inline |
Search for a symbol by its address.
Since many symbols can map to the same address, this function returns the first found. If the symbol is not found this function returns the end() iterator.
address | The address of the symbol being searched for. |
Definition at line 321 of file symtab.hh.
References addrMap, end(), gem5::ArmISA::i, and symbols.
Referenced by gem5::Workload::addFuncEvent(), gem5::PowerISA::BranchOp::generateDisassembly(), gem5::PowerISA::BranchDispCondOp::generateDisassembly(), gem5::linux::ThreadInfo::get_data(), gem5::ArmISA::FsFreebsd::initState(), gem5::ArmISA::FsLinux::initState(), TEST(), and gem5::BaseStackTrace::tryGetSymbol().
|
inline |
Search for a symbol by its name.
If the symbol is not found this function returns the end() iterator.
name | The name of the symbol being searched for. |
Definition at line 340 of file symtab.hh.
References end(), gem5::ArmISA::i, name(), nameMap, and symbols.
|
inline |
Overload for findNearestSymbol() for callers who don't care about nextaddr.
Definition at line 382 of file symtab.hh.
References gem5::X86ISA::addr, addrMap, end(), gem5::ArmISA::i, symbols, and upperBound().
|
inline |
Find the nearest symbol equal to or less than the supplied address (e.g., the label for the enclosing function).
If there is no valid next address, next_addr is assigned 0.
addr | The address to look up. |
next_addr | Address of following symbol (to determine the valid range of the symbol). |
A | const_iterator which points to the symbol if found, or end. |
Definition at line 360 of file symtab.hh.
References gem5::X86ISA::addr, addrMap, end(), gem5::ArmISA::i, symbols, and upperBound().
Referenced by gem5::SparcISA::BranchDisp::generateDisassembly(), gem5::ArmISA::ArmStaticInst::printMemSymbol(), gem5::ArmISA::ArmStaticInst::printTarget(), gem5::FunctionProfile::sample(), TEST(), and gem5::BaseCPU::traceFunctionsInternal().
|
inline |
Generates a new symbol table containing only global symbols.
Definition at line 266 of file symtab.hh.
References filterByBinding(), and gem5::loader::Symbol::Global.
Referenced by gem5::ArmISA::FsWorkload::FsWorkload(), gem5::ArmISA::FsFreebsd::initState(), gem5::ArmISA::FsLinux::initState(), and TEST().
bool gem5::loader::SymbolTable::insert | ( | const Symbol & | symbol | ) |
Insert a new symbol in the table if it does not already exist.
The symbol must have a defined name.
symbol | The symbol to be inserted. |
Definition at line 54 of file symtab.cc.
References gem5::loader::Symbol::address, addrMap, gem5::loader::Symbol::name, nameMap, and symbols.
Referenced by gem5::pseudo_inst::addsymbol(), gem5::RiscvISA::BareMetal::BareMetal(), gem5::loader::ElfObject::ElfObject(), filter(), gem5::ArmISA::FsWorkload::FsWorkload(), gem5::PowerProcess::initState(), gem5::ArmISA::FsFreebsd::initState(), gem5::ArmISA::FsLinux::initState(), gem5::memory::AbstractMemory::initState(), insert(), gem5::RiscvISA::BareMetal::insertSymbol(), gem5::SparcISA::FsWorkload::insertSymbol(), gem5::KernelWorkload::insertSymbol(), gem5::StubWorkload::insertSymbol(), gem5::KernelWorkload::KernelWorkload(), mask(), gem5::mmapFunc(), offset(), rename(), TEST(), TEST_F(), and unserialize().
bool gem5::loader::SymbolTable::insert | ( | const SymbolTable & | other | ) |
|
inline |
Generates a new symbol table containing only local symbols.
Definition at line 277 of file symtab.hh.
References filterByBinding(), and gem5::loader::Symbol::Local.
Referenced by TEST().
|
inline |
Generate a new table by a mask to the symbols of the current table.
The current table is not modified.
m | The mask to be applied. |
Definition at line 232 of file symtab.hh.
References gem5::loader::Symbol::address, insert(), gem5::VegaISA::m, gem5::X86ISA::op, and operate().
Referenced by gem5::KernelWorkload::KernelWorkload(), and TEST().
|
inline |
Generate a new table by applying an offset to the symbols of the current table.
The current table is not modified.
addr_offset | The offset to be applied. |
Definition at line 213 of file symtab.hh.
References gem5::loader::Symbol::address, insert(), gem5::X86ISA::op, and operate().
Referenced by TEST().
|
inlineprivate |
Create a derived symbol table by applying an operation on the symbols of the current table.
The current table is not modified.
op | The operation to be applied to the new table. |
Definition at line 117 of file symtab.hh.
References gem5::X86ISA::op, and symbols.
|
inline |
Modify the symbols' name with a given transform function.
func | The transform function accepting the reference of the symbol's name. |
SymbolTablePtr | A pointer to the modified SymbolTable copy. |
Definition at line 250 of file symtab.hh.
References insert(), gem5::loader::Symbol::name, gem5::X86ISA::op, and operate().
Referenced by TEST().
void gem5::loader::SymbolTable::serialize | ( | const std::string & | base, |
CheckpointOut & | cp | ||
) | const |
Serialize the table's contents.
base | The base section. |
cp | The checkpoint to use. |
Definition at line 92 of file symtab.cc.
References gem5::X86ISA::base, gem5::csprintf(), gem5::ArmISA::i, gem5::paramOut(), and symbols.
Referenced by gem5::KernelWorkload::serialize(), and TEST_F().
void gem5::loader::SymbolTable::unserialize | ( | const std::string & | base, |
CheckpointIn & | cp, | ||
Symbol::Binding | default_binding = Symbol::Binding::Global |
||
) |
Populate the table by unserializing a checkpoint.
base | The base section. |
cp | The checkpoint to use. |
default_binding | The binding to be used if an unserialized symbol's binding is not found. |
Definition at line 106 of file symtab.cc.
References gem5::X86ISA::base, clear(), gem5::csprintf(), gem5::ArmISA::i, insert(), name(), gem5::optParamIn(), and gem5::paramIn().
Referenced by TEST_F(), and gem5::KernelWorkload::unserialize().
|
inlineprivate |
Get the first address larger than the given address, if any.
addr | The address to compare against. |
iter | An iterator to the larger-address entry. |
Definition at line 89 of file symtab.hh.
References gem5::X86ISA::addr, and addrMap.
Referenced by findNearest().
|
inline |
Generates a new symbol table containing only weak symbols.
Definition at line 288 of file symtab.hh.
References filterByBinding(), and gem5::loader::Symbol::Weak.
Referenced by TEST().
|
private |
Definition at line 78 of file symtab.hh.
Referenced by clear(), find(), findNearest(), insert(), and upperBound().
|
private |
|
private |