gem5 v24.0.0.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. | |
bool | insert (const Symbol &symbol) |
Insert a new symbol in the table if it does not already exist. | |
bool | insert (const SymbolTable &other) |
Copies the symbols of another table to this table if there are no common symbols between the tables. | |
bool | empty () const |
Verifies whether the table is empty. | |
SymbolTablePtr | offset (Addr addr_offset) const |
Generate a new table by applying an offset to the symbols of the current table. | |
SymbolTablePtr | mask (Addr m) const |
Generate a new table by a mask to the symbols of the current table. | |
SymbolTablePtr | rename (std::function< std::string(const std::string &)> func) const |
Modify the symbols' name with a given transform function. | |
SymbolTablePtr | globals () const |
Generates a new symbol table containing only global symbols. | |
SymbolTablePtr | locals () const |
Generates a new symbol table containing only local symbols. | |
SymbolTablePtr | weaks () const |
Generates a new symbol table containing only weak symbols. | |
SymbolTablePtr | functionSymbols () const |
Generates a new symbol table containing only function symbols. | |
void | serialize (const std::string &base, CheckpointOut &cp) const |
Serialize the table's contents. | |
void | unserialize (const std::string &base, CheckpointIn &cp, Symbol::Binding default_binding=Symbol::Binding::Global) |
Populate the table by unserializing a checkpoint. | |
const_iterator | find (Addr address) const |
Search for a symbol by its address. | |
const_iterator | find (const std::string &name) const |
Search for a symbol by its name. | |
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). | |
const_iterator | findNearest (Addr addr) const |
Overload for findNearestSymbol() for callers who don't care about nextaddr. | |
Private Types | |
typedef std::vector< Symbol > | SymbolVector |
Vector containing all the symbols in the table. | |
typedef std::multimap< Addr, int > | AddrMap |
Map addresses to an index into the symbol vector. | |
typedef std::map< std::string, int > | NameMap |
Map a symbol name to an index into the symbol vector. | |
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. | |
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. | |
Private Member Functions | |
bool | upperBound (Addr addr, AddrMap::const_iterator &iter) const |
Get the first address larger than the given address, if any. | |
SymbolTablePtr | operate (SymTabOp op) const |
Create a derived symbol table by applying an operation on the symbols of the current table. | |
SymbolTablePtr | filter (SymTabFilter filter) const |
Applies a filter to the symbols of the table to generate a new table. | |
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. | |
SymbolTablePtr | filterBySymbolType (const Symbol::SymbolType &symbol_type) const |
Generate a new table by applying a filter that only accepts the symbols whose type matches the given symbol type. | |
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 275 of file symtab.hh.
References symbols.
Referenced by checkTable().
void gem5::loader::SymbolTable::clear | ( | ) |
Clears the table.
Definition at line 58 of file symtab.cc.
References addrMap, clear(), nameMap, and symbols.
Referenced by clear(), gem5::PowerProcess::initState(), TEST(), and unserialize().
|
inline |
|
inline |
Definition at line 278 of file symtab.hh.
References symbols.
Referenced by gem5::Workload::addFuncEvent(), checkTable(), gem5::linux::dumpDmesg(), find(), find(), findNearest(), findNearest(), gem5::PowerISA::BranchDispCondOp::generateDisassembly(), gem5::PowerISA::BranchOp::generateDisassembly(), gem5::SparcISA::BranchDisp::generateDisassembly(), gem5::ArmISA::FsFreebsd::initState(), gem5::ArmISA::FsLinux::initState(), gem5::ArmISA::ArmStaticInst::printMemSymbol(), gem5::ArmISA::ArmStaticInst::printTarget(), gem5::FunctionProfile::sample(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), 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 227 of file symtab.hh.
References filter(), insert(), and operate().
Referenced by filter(), filterByBinding(), and filterBySymbolType().
|
inlineprivate |
|
inlineprivate |
Generate a new table by applying a filter that only accepts the symbols whose type matches the given symbol type.
The | type that must be matched. |
Definition at line 262 of file symtab.hh.
References filter().
Referenced by functionSymbols().
|
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 435 of file symtab.hh.
References addrMap, end(), gem5::ArmISA::i, and symbols.
Referenced by gem5::Workload::addFuncEvent(), gem5::PowerISA::BranchDispCondOp::generateDisassembly(), gem5::PowerISA::BranchOp::generateDisassembly(), gem5::linux::ThreadInfo::get_data(), gem5::ArmISA::FsFreebsd::initState(), gem5::ArmISA::FsLinux::initState(), TEST(), TEST(), TEST(), TEST(), 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 454 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 496 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 474 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(), TEST(), TEST(), TEST(), TEST(), and gem5::BaseCPU::traceFunctionsInternal().
|
inline |
Generates a new symbol table containing only function symbols.
Definition at line 402 of file symtab.hh.
References filterBySymbolType(), and gem5::loader::Symbol::Function.
Referenced by gem5::RiscvISA::BootloaderKernelWorkload::loadKernelSymbolTable(), and TEST().
|
inline |
Generates a new symbol table containing only global symbols.
Definition at line 369 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 66 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::ArmISA::FsFreebsd::initState(), gem5::ArmISA::FsLinux::initState(), gem5::memory::AbstractMemory::initState(), gem5::PowerProcess::initState(), insert(), gem5::KernelWorkload::insertSymbol(), gem5::RiscvISA::BareMetal::insertSymbol(), gem5::RiscvISA::BootloaderKernelWorkload::insertSymbol(), gem5::SparcISA::FsWorkload::insertSymbol(), gem5::StubWorkload::insertSymbol(), gem5::KernelWorkload::KernelWorkload(), gem5::RiscvISA::BootloaderKernelWorkload::loadBootloaderSymbolTable(), gem5::RiscvISA::BootloaderKernelWorkload::loadKernelSymbolTable(), mask(), gem5::mmapFunc(), offset(), rename(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), 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 380 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 335 of file symtab.hh.
References insert(), gem5::ArmISA::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 316 of file symtab.hh.
References insert(), gem5::X86ISA::op, and operate().
Referenced by gem5::RiscvISA::BootloaderKernelWorkload::loadBootloaderSymbolTable(), and 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 204 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 353 of file symtab.hh.
References insert(), gem5::loader::Symbol::name(), gem5::X86ISA::op, operate(), and gem5::loader::Symbol::rename().
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 107 of file symtab.cc.
References gem5::X86ISA::base, gem5::csprintf(), gem5::ArmISA::i, gem5::paramOut(), and symbols.
Referenced by gem5::KernelWorkload::serialize(), gem5::RiscvISA::BootloaderKernelWorkload::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 127 of file symtab.cc.
References gem5::X86ISA::base, clear(), gem5::csprintf(), gem5::ArmISA::i, insert(), name(), gem5::optParamIn(), gem5::loader::Symbol::Other, gem5::paramIn(), gem5::X86ISA::type, and warn_once.
Referenced by TEST_F(), TEST_F(), TEST_F(), gem5::KernelWorkload::unserialize(), and gem5::RiscvISA::BootloaderKernelWorkload::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 176 of file symtab.hh.
References gem5::X86ISA::addr, and addrMap.
Referenced by findNearest(), and findNearest().
|
inline |
Generates a new symbol table containing only weak symbols.
Definition at line 391 of file symtab.hh.
References filterByBinding(), and gem5::loader::Symbol::Weak.
Referenced by TEST().
|
private |
Definition at line 165 of file symtab.hh.
Referenced by clear(), find(), findNearest(), findNearest(), insert(), and upperBound().
|
private |
|
private |
Definition at line 164 of file symtab.hh.
Referenced by begin(), clear(), empty(), end(), find(), find(), findNearest(), findNearest(), insert(), operate(), and serialize().