Skip to content

Don't warn about missing DWO files when converting mach-o files. #152598

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions llvm/include/llvm/DebugInfo/GSYM/DwarfTransformer.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,14 @@ class DwarfTransformer {
///
/// \param LDCS Flag to indicate whether we should load the call site
/// information from DWARF `DW_TAG_call_site` entries
DwarfTransformer(DWARFContext &D, GsymCreator &G, bool LDCS = false)
: DICtx(D), Gsym(G), LoadDwarfCallSites(LDCS) {}
///
/// \param MachO Flag to indicate if the object file is mach-o (Apple's
/// executable format). Apple has some compile unit attributes that look like
/// split DWARF, but they aren't and they can cause warnins to be emitted
/// about missing DWO files.
DwarfTransformer(DWARFContext &D, GsymCreator &G, bool LDCS = false,
bool MachO = false)
: DICtx(D), Gsym(G), LoadDwarfCallSites(LDCS), IsMachO(MachO) {}

/// Extract the DWARF from the supplied object file and convert it into the
/// Gsym format in the GsymCreator object that is passed in. Returns an
Expand All @@ -63,7 +69,6 @@ class DwarfTransformer {
LLVM_ABI llvm::Error verify(StringRef GsymPath, OutputAggregator &OS);

private:

/// Parse the DWARF in the object file and convert it into the GsymCreator.
Error parse();

Expand Down Expand Up @@ -97,6 +102,7 @@ class DwarfTransformer {
DWARFContext &DICtx;
GsymCreator &Gsym;
bool LoadDwarfCallSites;
bool IsMachO;

friend class DwarfTransformerTest;
};
Expand Down
19 changes: 10 additions & 9 deletions llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ struct llvm::gsym::CUInfo {
}
};


static DWARFDie GetParentDeclContextDIE(DWARFDie &Die) {
if (DWARFDie SpecDie =
Die.getAttributeValueAsReferencedDie(dwarf::DW_AT_specification)) {
Expand Down Expand Up @@ -170,7 +169,7 @@ getQualifiedNameIndex(DWARFDie &Die, uint64_t Language, GsymCreator &Gsym) {
// templates
if (ParentName.front() == '<' && ParentName.back() == '>')
Name = "{" + ParentName.substr(1, ParentName.size() - 2).str() + "}" +
"::" + Name;
"::" + Name;
else
Name = ParentName.str() + "::" + Name;
}
Expand Down Expand Up @@ -432,7 +431,7 @@ static void convertFunctionLineTable(OutputAggregator &Out, CUInfo &CUI,
// Skip multiple line entries for the same file and line.
auto LastLE = FI.OptLineTable->last();
if (LastLE && LastLE->File == FileIdx && LastLE->Line == Row.Line)
continue;
continue;
// Only push a row if it isn't an end sequence. End sequence markers are
// included for the last address in a function or the last contiguous
// address in a sequence.
Expand Down Expand Up @@ -629,6 +628,10 @@ Error DwarfTransformer::convert(uint32_t NumThreads, OutputAggregator &Out) {
size_t NumBefore = Gsym.getNumFunctionInfos();
auto getDie = [&](DWARFUnit &DwarfUnit) -> DWARFDie {
DWARFDie ReturnDie = DwarfUnit.getUnitDIE(false);
// Apple uses DW_AT_GNU_dwo_id for things other than split DWARF.
if (IsMachO)
return ReturnDie;

if (DwarfUnit.getDWOId()) {
DWARFUnit *DWOCU = DwarfUnit.getNonSkeletonUnitDIE(false).getDwarfUnit();
if (!DWOCU->isDWOUnit())
Expand Down Expand Up @@ -718,8 +721,8 @@ llvm::Error DwarfTransformer::verify(StringRef GsymPath,
for (uint32_t I = 0; I < NumAddrs; ++I) {
auto FuncAddr = Gsym->getAddress(I);
if (!FuncAddr)
return createStringError(std::errc::invalid_argument,
"failed to extract address[%i]", I);
return createStringError(std::errc::invalid_argument,
"failed to extract address[%i]", I);

auto FI = Gsym->getFunctionInfo(*FuncAddr);
if (!FI)
Expand All @@ -734,8 +737,7 @@ llvm::Error DwarfTransformer::verify(StringRef GsymPath,
if (!LR)
return LR.takeError();

auto DwarfInlineInfos =
DICtx.getInliningInfoForAddress(SectAddr, DLIS);
auto DwarfInlineInfos = DICtx.getInliningInfoForAddress(SectAddr, DLIS);
uint32_t NumDwarfInlineInfos = DwarfInlineInfos.getNumberOfFrames();
if (NumDwarfInlineInfos == 0) {
DwarfInlineInfos.addFrame(
Expand Down Expand Up @@ -773,8 +775,7 @@ llvm::Error DwarfTransformer::verify(StringRef GsymPath,
continue;
}

for (size_t Idx = 0, count = LR->Locations.size(); Idx < count;
++Idx) {
for (size_t Idx = 0, count = LR->Locations.size(); Idx < count; ++Idx) {
const auto &gii = LR->Locations[Idx];
if (Idx < NumDwarfInlineInfos) {
const auto &dii = DwarfInlineInfos.getFrame(Idx);
Expand Down
9 changes: 5 additions & 4 deletions llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,19 +374,20 @@ static llvm::Error handleObjectFile(ObjectFile &Obj, const std::string &OutFile,
// Make sure there is DWARF to convert first.
std::unique_ptr<DWARFContext> DICtx = DWARFContext::create(
Obj,
/*RelocAction=*/DWARFContext::ProcessDebugRelocations::Process,
nullptr,
/*RelocAction=*/DWARFContext::ProcessDebugRelocations::Process, nullptr,
/*DWPName=*/"",
/*RecoverableErrorHandler=*/WithColor::defaultErrorHandler,
/*WarningHandler=*/WithColor::defaultWarningHandler,
/*ThreadSafe*/true);
/*ThreadSafe*/ true);
if (!DICtx)
return createStringError(std::errc::invalid_argument,
"unable to create DWARF context");

// Make a DWARF transformer object and populate the ranges of the code
// so we don't end up adding invalid functions to GSYM data.
DwarfTransformer DT(*DICtx, Gsym, LoadDwarfCallSites);
bool IsMachO = dyn_cast<object::MachOObjectFile>(&Obj) != nullptr;

DwarfTransformer DT(*DICtx, Gsym, LoadDwarfCallSites, IsMachO);
if (!TextRanges.empty())
Gsym.SetValidTextRanges(TextRanges);

Expand Down
Loading