本文整理汇总了C++中SymbolTable::ForEachSymbol方法的典型用法代码示例。如果您正苦于以下问题:C++ SymbolTable::ForEachSymbol方法的具体用法?C++ SymbolTable::ForEachSymbol怎么用?C++ SymbolTable::ForEachSymbol使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SymbolTable
的用法示例。
在下文中一共展示了SymbolTable::ForEachSymbol方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ForEachSymbol
void MemoryUtils::ForEachSymbol(void *handle, const std::function<bool(Symbol *)>& functor)
{
/* do a bogus symbol lookup to force everything into the symbol table cache */
assert(ResolveSymbol(handle, "________________") == nullptr);
#ifdef PLATFORM_LINUX
struct link_map *dlmap;
LibSymbolTable *libtable;
SymbolTable *table;
dlmap = (struct link_map *)handle;
table = NULL;
/* See if we already have a symbol table for this library */
for (size_t i = 0; i < m_SymTables.size(); i++)
{
libtable = m_SymTables[i];
if (libtable->lib_base == dlmap->l_addr)
{
table = &libtable->table;
break;
}
}
/* If we don't have a symbol table for this library, then create one */
if (table == NULL)
{
libtable = new LibSymbolTable();
libtable->table.Initialize();
libtable->lib_base = dlmap->l_addr;
libtable->last_pos = 0;
table = &libtable->table;
m_SymTables.push_back(libtable);
}
table->ForEachSymbol(functor);
#elif defined PLATFORM_APPLE
uintptr_t dlbase;
uint32_t image_count;
LibSymbolTable *libtable;
SymbolTable *table;
Symbol *symbol_entry;
dlbase = 0;
image_count = m_ImageList->infoArrayCount;
table = NULL;
/* Loop through mach-o images in process.
* We can skip index 0 since that is just the executable.
*/
for (uint32_t i = 1; i < image_count; i++)
{
const struct dyld_image_info &info = m_ImageList->infoArray[i];
/* "Load" each one until we get a matching handle */
void *h = dlopen(info.imageFilePath, RTLD_NOLOAD);
if (h == handle)
{
dlbase = (uintptr_t)info.imageLoadAddress;
dlclose(h);
break;
}
dlclose(h);
}
if (!dlbase)
{
/* Uh oh, we couldn't find a matching handle */
return;
}
/* See if we already have a symbol table for this library */
for (size_t i = 0; i < m_SymTables.size(); i++)
{
libtable = m_SymTables[i];
if (libtable->lib_base == dlbase)
{
table = &libtable->table;
break;
}
}
/* If we don't have a symbol table for this library, then create one */
if (table == NULL)
{
libtable = new LibSymbolTable();
libtable->table.Initialize();
libtable->lib_base = dlbase;
libtable->last_pos = 0;
table = &libtable->table;
m_SymTables.push_back(libtable);
}
table->ForEachSymbol(functor);
#endif
}