Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up dead code in dwarfWalker.C #1566

Merged
merged 2 commits into from
Oct 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
58 changes: 10 additions & 48 deletions symtabAPI/src/dwarfWalker.C
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,6 @@ bool DwarfWalker::parse() {
{
if(!dwarf_offdie_types(dbg(), cu_off + cu_header_length, &current_cu_die))
continue;
/*Dwarf_Half moduleTag = dwarf_tag(&current_cu_die);
if (moduleTag == DW_TAG_partial_unit) {
continue;
}*/
module_dies.push_back(current_cu_die);
compile_offset = next_cu_header;
}
Expand All @@ -166,10 +162,6 @@ bool DwarfWalker::parse() {
{
if(!dwarf_offdie(dbg(), cu_off + cu_header_length, &current_cu_die))
continue;
/*Dwarf_Half moduleTag = dwarf_tag(&current_cu_die);
if (moduleTag == DW_TAG_partial_unit) {
continue;
}*/
module_dies.push_back(current_cu_die);
compile_offset = next_cu_header;
}
Expand Down Expand Up @@ -209,7 +201,7 @@ bool DwarfWalker::parse() {
for (;typeIter!=moduleTypes->typesByID.end();typeIter++)
{
typeIter->second->fixupUnknowns(fixUnknownMod);
} /* end iteration over types. */
}

/* Fix the types of variables. */
std::string variableName;
Expand All @@ -220,8 +212,8 @@ bool DwarfWalker::parse() {
moduleTypes->findType( variableIter->second->getID(), Type::share ) != NULL )
{
variableIter->second = moduleTypes->findType(variableIter->second->getID(), Type::share);
} /* end if data class is unknown but the type exists. */
} /* end iteration over variables. */
}
}

moduleTypes->setDwarfParsed();
return true;
Expand All @@ -234,7 +226,6 @@ bool DwarfWalker::parseModule(Dwarf_Die moduleDIE, Module *&fixUnknownMod) {
return false;
}

/* Extract the name of this module. */
std::string moduleName = DwarfDyninst::die_name(moduleDIE);

auto moduleTag = dwarf_tag(&moduleDIE);
Expand All @@ -249,7 +240,6 @@ bool DwarfWalker::parseModule(Dwarf_Die moduleDIE, Module *&fixUnknownMod) {

/* Set the language, if any. */
Dwarf_Attribute languageAttribute;
//DWARF_ERROR_RET(dwarf_attr( moduleDIE, DW_AT_language, & languageAttribute, NULL ));
dwarf_attr(&moduleDIE, DW_AT_language, &languageAttribute);

// Set low and high ranges; this can fail, so don't check return addr.
Expand Down Expand Up @@ -308,7 +298,6 @@ bool DwarfWalker::buildSrcFiles(::Dwarf * /*dbg*/, Dwarf_Die entry, StringTableP
if(!filename) continue;
srcFiles->emplace_back(DwarfDyninst::detail::absolute_path(filename, comp_dir),"");
}
//cerr << "pointer: " << srcFiles.get() << endl << *(srcFiles.get()) << endl;
return true;
}

Expand Down Expand Up @@ -457,7 +446,6 @@ bool DwarfWalker::parse_int(Dwarf_Die e, bool parseSib, bool dissociate_context)
if (ret && parseChild() ) {
// Parse children
Dwarf_Die childDwarf;
//Dwarf_Die e = entry();
int status = dwarf_child(&e, &childDwarf);
if(status == -1)
return false;
Expand Down Expand Up @@ -511,9 +499,6 @@ bool DwarfWalker::parseCallsite()
return false;

InlinedFunction *ifunc = static_cast<InlinedFunction *>(curFunc());
// cout << "Found inline call site in func (0x" << hex << id() << ") "
// << curFunc()->getName() << " at " << curFunc()->getOffset() << dec
// << ", file " << inline_file << ": " << inline_line << endl;
ifunc->setFile(inline_file.get());
ifunc->callsite_line = inline_line;
return true;
Expand Down Expand Up @@ -623,7 +608,6 @@ bool DwarfWalker::parseSubprogram(DwarfWalker::inline_t func_type) {
// Name first
FunctionBase *func = curFunc();
name_result = findFuncName();
// if(func) cout << hex << "Begin parseSubprogram for (" << id() << ") " << func->getName() << " at " << func->getOffset() << dec << endl;
if (curEnclosure() && !func) {
// This is a member function; create the type entry
// Since curFunc is false, we're not going back to reparse this
Expand Down Expand Up @@ -678,15 +662,13 @@ bool DwarfWalker::parseSubprogram(DwarfWalker::inline_t func_type) {
}
// Only keep pretty names around for inlines, which probably don't have mangled names
else {
// printf("(0x%lx) Adding %s as pretty name to inline at 0x%lx\n", id(), curName().c_str(), func->getOffset());
dwarf_printf("(0x%lx) Adding as pretty name to inline\n", id());
func->addPrettyName(curName(), true);
}
}

//Collect callsite information for inlined functions.
if (func_type == InlinedFunc) {
// cout << "Parsing callsite for (0x" << hex << id() << ") " << curName() << " at " << func->getOffset() << dec << endl;
parseCallsite();
}

Expand Down Expand Up @@ -744,9 +726,7 @@ void DwarfWalker::setRanges(FunctionBase *func) {
dyn_mutex::unique_lock l(func->ranges_lock);
if(func->ranges.empty()) {
Address last_low = 0, last_high = 0;
// func->ranges.reserve(rangesSize());
for (auto i = ranges_begin(); i != ranges_end(); i++) {
// cerr << "Adding " << rangesSize() << " ranges\n";
Address low = i->first;
Address high = i->second;
if (last_low == low && last_high == high)
Expand All @@ -764,8 +744,6 @@ bool DwarfWalker::parseRangeTypes(Dwarf_Die die) {

clearRanges();
std::vector<AddressRange> newRanges = getDieRanges(die);
// cerr << "parseRangeTypes generating new ranges, size is " << newRanges.size()
// << ", DIE offset is " << die.addr << endl;
for(auto r = newRanges.begin();
r != newRanges.end();
++r)
Expand Down Expand Up @@ -881,8 +859,6 @@ bool DwarfWalker::parseVariable() {
if (locs.empty()) return true;

for (unsigned i=0; i<locs.size(); i++) {
//if (locs[i].stClass != storageAddr)
//continue;
if (locs[i].lowPC) {
locs[i].lowPC = convertDebugOffset(locs[i].lowPC);
}
Expand All @@ -907,7 +883,7 @@ bool DwarfWalker::parseVariable() {
if (!curFunc() && !curEnclosure()) {
createGlobalVariable(locs, type);

} /* end if this variable is a global */
}
else
{
if (!getLineInformation(variableLineNo, hasLineNumber, fileName))
Expand All @@ -919,12 +895,12 @@ bool DwarfWalker::parseVariable() {

createLocalVariable(locs, type, variableLineNo, fileName);

} /* end if a local or static variable. */
}
else {
auto ret = addStaticClassVariable(locs, type);
return ret;
}
} /* end if this variable is not global */
}
return true;
}

Expand Down Expand Up @@ -1056,8 +1032,6 @@ void DwarfWalker::createParameter(const vector<VariableLocation> &locs,
id(),
curName().c_str(),
(void*)paramType.get(), paramType->getName().c_str(),
// ((curFunc() && !curFunc()->getAllMangledNames().empty()) ?
//curFunc()->getAllMangledNames()[0].c_str() : ""),
(void*)curFunc());

for (unsigned int i = 0; i < locs.size(); ++i)
Expand Down Expand Up @@ -1564,7 +1538,6 @@ bool DwarfWalker::hasDeclaration(bool &isDecl) {
bool DwarfWalker::findTag() {
Dwarf_Die e = entry();
Dwarf_Half dieTag = dwarf_tag(&e);
//DWARF_FAIL_RET(dieTag);
setTag(dieTag);
return true;
}
Expand Down Expand Up @@ -1811,7 +1784,6 @@ bool DwarfWalker::findDieOffset(Dwarf_Attribute attr, Dwarf_Off &offset) {
auto ret_p = dwarf_formref_die(&attr, &die);
if(!ret_p) return false;
offset = dwarf_dieoffset(&die);
//if(form==DW_FORM_GNU_ref_alt) is_sup = true;
return true;
}
/* Then there's DW_FORM_sec_offset which refer other sections, or
Expand Down Expand Up @@ -2141,9 +2113,8 @@ bool DwarfWalker::findVisibility(visibility_t &visibility) {
case DW_ACCESS_protected: visibility = visProtected; break;
case DW_ACCESS_private: visibility = visPrivate; break;
default:
//bperr ( "Uknown visibility, ignoring.\n" );
break;
} /* end visibility switch */
}

return true;
}
Expand Down Expand Up @@ -2201,7 +2172,7 @@ bool DwarfWalker::fixBitFields(std::vector<VariableLocation> &locs,
if (locs.size())
locs[0].frameOffset *= 8;
size *= 8;
} /* end if not a bit field member. */
}
return true;
}

Expand Down Expand Up @@ -2328,10 +2299,8 @@ bool DwarfWalker::decodeExpression(Dwarf_Attribute &locationAttribute,
ld.dwarfOp = exprs;
ld.opLen = exprlen;
locDescs.push_back(ld);
//if(start==0 && end==-1) break;
}while(offset > 0);

//assert(locDescs.size()!=1);
bool ret = decodeLocationListForStaticOffsetOrAddress(locDescs, 1, locs);
return ret;
}
Expand Down Expand Up @@ -2447,7 +2416,7 @@ bool DwarfWalker::decodeLocationListForStaticOffsetOrAddress(

/* decode successful */
return !locs.empty();
} /* end decodeLocationListForStaticOffsetOrAddress() */
}


void DwarfWalker::setEntry(Dwarf_Die entry) {
Expand Down Expand Up @@ -2575,15 +2544,8 @@ bool DwarfWalker::parseModuleSig8(bool is_info)
{
if (!DwarfDyninst::is_type_unit(current_cu_die))
return false;
/* typeoffset is relative to the type unit; we want the global offset. */
//FIXME
//Dwarf_Off cu_off, cu_length;
//DWARF_FAIL_RET(dwarf_die_CU_offset_range(typeDIE, &cu_off, &cu_length, NULL ));
//cerr << "a) " << dwarf_dieoffset(&typeDIE) << endl;
//cerr << "b) " << dwarf_cuoffset(&typeDIE) << endl;

uint64_t sig8 = * reinterpret_cast<uint64_t*>(&signature);
typeId_t type_id = get_type_id(/*cu_off +*/ typeoffset, is_info, false);
typeId_t type_id = get_type_id(typeoffset, is_info, false);

{
dyn_c_hash_map<uint64_t, typeId_t>::accessor a;
Expand Down