Skip to content

Commit 5a8f290

Browse files
authored
[llvm-gsymutil] Print one-time DWO file missing warning under --quiet flag (#79882)
FileCheck test added ``` ./bin/llvm-lit -sv llvm/test/tools/llvm-gsymutil/X86/elf-dwo.yaml ``` Manual test steps: - Create binary with split-dwarf: ``` clang++ -g -gdwarf-4 -gsplit-dwarf main.cpp -o main_split ``` - Remove or remane the dwo file to a different name so llvm-gsymutil can't find it ``` mv main_split-main.dwo main_split-main__.dwo ``` - Now run llvm-gsymutil conversion, it should print out warning with and without the `--quiet` flag ``` $ ./bin/llvm-gsymutil --convert=./main_split Input file: ./main_split Output file (x86_64): ./main_split.gsym warning: Unable to retrieve DWO .debug_info section for main_split-main.dwo Loaded 0 functions from DWARF. Loaded 12 functions from symbol table. Pruned 0 functions, ended with 12 total ``` ``` $ ./bin/llvm-gsymutil --convert=./main_split --quiet Input file: ./main_split Output file (x86_64): ./main_split.gsym warning: Unable to retrieve DWO .debug_info section for some object files. (Remove the --quiet flag for full output) Pruned 0 functions, ended with 12 total ```
1 parent 995d21b commit 5a8f290

File tree

2 files changed

+582
-7
lines changed

2 files changed

+582
-7
lines changed

llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -537,17 +537,27 @@ void DwarfTransformer::handleDie(raw_ostream *OS, CUInfo &CUI, DWARFDie Die) {
537537

538538
Error DwarfTransformer::convert(uint32_t NumThreads, raw_ostream *OS) {
539539
size_t NumBefore = Gsym.getNumFunctionInfos();
540+
std::once_flag flag;
540541
auto getDie = [&](DWARFUnit &DwarfUnit) -> DWARFDie {
541542
DWARFDie ReturnDie = DwarfUnit.getUnitDIE(false);
542543
if (DwarfUnit.getDWOId()) {
543544
DWARFUnit *DWOCU = DwarfUnit.getNonSkeletonUnitDIE(false).getDwarfUnit();
544-
if (OS && !DWOCU->isDWOUnit()) {
545-
std::string DWOName = dwarf::toString(
546-
DwarfUnit.getUnitDIE().find(
547-
{dwarf::DW_AT_dwo_name, dwarf::DW_AT_GNU_dwo_name}),
548-
"");
549-
*OS << "warning: Unable to retrieve DWO .debug_info section for "
550-
<< DWOName << "\n";
545+
if (!DWOCU->isDWOUnit()) {
546+
if (OS) {
547+
std::string DWOName = dwarf::toString(
548+
DwarfUnit.getUnitDIE().find(
549+
{dwarf::DW_AT_dwo_name, dwarf::DW_AT_GNU_dwo_name}),
550+
"");
551+
*OS << "warning: Unable to retrieve DWO .debug_info section for "
552+
<< DWOName << "\n";
553+
} else {
554+
std::call_once(flag, []() {
555+
outs()
556+
<< "warning: Unable to retrieve DWO .debug_info section for "
557+
"some "
558+
"object files. (Remove the --quiet flag for full output)\n";
559+
});
560+
}
551561
} else {
552562
ReturnDie = DWOCU->getUnitDIE(false);
553563
}

0 commit comments

Comments
 (0)