Skip to content

Commit

Permalink
Remove DwarfWalker::setModuleFromName
Browse files Browse the repository at this point in the history
It's replaced with the updated Symtab::findModuleByOffset. Finding by
name was always unnecessary as we know the offset of the current DIE.
  • Loading branch information
hainest committed Sep 29, 2023
1 parent 500af25 commit 1713880
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
26 changes: 10 additions & 16 deletions symtabAPI/src/dwarfWalker.C
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,16 @@ bool DwarfWalker::parseModule(Dwarf_Die moduleDIE, Module *&fixUnknownMod) {
/* Extract the name of this module. */
std::string moduleName = DwarfDyninst::die_name(moduleDIE);

// DIEs without name or named <artificial> will be associated to
// the default module (whose name is ELF filename)
setModuleFromName(moduleName);
dwarf_printf("Mapped to Symtab module 0x%p %s\n", (void*)mod(), mod()->fileName().c_str());
// Find the Symtab Module corresponding to this CU
mod() = [this]() {
SymtabAPI::Module* m = symtab()->findModuleByOffset(offset());
if(!m) {
m = symtab()->getDefaultModule();
}
return m;
}();

dwarf_printf("Mapped to Symtab module 0x%p from '%s' at offset %zx\n", (void*)mod(), mod()->fileName().c_str(), offset());

auto moduleTag = dwarf_tag(&moduleDIE);
if (moduleName.empty() && moduleTag == DW_TAG_type_unit) {
Expand Down Expand Up @@ -283,18 +289,6 @@ bool DwarfWalker::parseModule(Dwarf_Die moduleDIE, Module *&fixUnknownMod) {
return true;
}


void DwarfParseActions::setModuleFromName(std::string moduleName)
{
if (!symtab()->findModuleByName(mod(), moduleName))
{
moduleName = symtab()->file();
if (!symtab()->findModuleByName(mod(), moduleName)) {
mod() = (symtab()->getDefaultModule());
}
}
}

bool DwarfWalker::buildSrcFiles(::Dwarf * /*dbg*/, Dwarf_Die entry, StringTablePtr srcFiles) {
size_t cnt = 0;
Dwarf_Files * df;
Expand Down
1 change: 0 additions & 1 deletion symtabAPI/src/dwarfWalker.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ class DwarfParseActions {
{
return symtab()->file();
}
virtual void setModuleFromName(std::string moduleName);
virtual Dyninst::Architecture getArchitecture() const
{
return symtab()->getArchitecture();
Expand Down

0 comments on commit 1713880

Please sign in to comment.