Skip to content

Commit e1ee27b

Browse files
committed
[llvm-gsymutil] Print one-time DWO file missing warning under --quiet flag
FileCheck test added ``` ./bin/llvm-lit -sv llvm/test/tools/llvm-gsymutil/X86/dwo-warning.test ``` Manual test steps: - Create binary with split-dwarf: ``` clang++ -g -gdwarf-4 -gsplit-dwarf main.cpp -o main_split ``` - 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 659ce8f commit e1ee27b

File tree

6 files changed

+62
-7
lines changed

6 files changed

+62
-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
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <iostream>
2+
#include <unistd.h>
3+
4+
void foo() {
5+
std::cout << "This is foo" << std::endl;
6+
}
7+
8+
int main() {
9+
std::cout << "hello world" << std::endl;
10+
foo();
11+
std::cout << "after foo" << std::endl;
12+
return 0;
13+
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
$ cat > main.cpp
2+
#include <iostream>
3+
#include <unistd.h>
4+
5+
void foo() {
6+
std::cout << "This is foo" << std::endl;
7+
}
8+
9+
int main() {
10+
std::cout << "hello world" << std::endl;
11+
foo();
12+
std::cout << "after foo" << std::endl;
13+
return 0;
14+
}
15+
16+
$ clang++ -g -gdwarf-4 -gsplit-dwarf main.cpp -o main_split
17+
$ mv main_split-main.dwo main_split-main__.dwo
18+
19+
// RUN: llvm-gsymutil --convert=%p/Inputs/main_split | FileCheck %s --check-prefix=WARNING
20+
// RUN: llvm-gsymutil --convert=%p/Inputs/main_split --quiet 2>&1 | FileCheck %s --check-prefix=WARNING-QUIET
21+
22+
// WARNING: Input file: {{.*\/main_split}}
23+
// WARNING: Output file (x86_64): {{.*\.gsym}}
24+
// WARNING: warning: Unable to retrieve DWO .debug_info section for main_split-main.dwo
25+
// WARNING: Loaded 0 functions from DWARF.
26+
// WARNING: Loaded 12 functions from symbol table.
27+
// WARNING: Pruned 0 functions, ended with 12 total
28+
29+
// WARNING-QUIET: Input file: {{.*\/main_split}}
30+
// WARNING-QUIET: Output file (x86_64): {{.*\.gsym}}
31+
// WARNING-QUIET: warning: Unable to retrieve DWO .debug_info section for some object files. (Remove the --quiet flag for full output)
32+
// WARNING-QUIET: Pruned 0 functions, ended with 12 total

0 commit comments

Comments
 (0)