[llvm] [llvm-gsymutil] Print one-time DWO file missing warning under --quiet flag (PR #79882)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 29 10:39:19 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-debuginfo
Author: kusmour (kusmour)
<details>
<summary>Changes</summary>
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
```
---
Full diff: https://github.com/llvm/llvm-project/pull/79882.diff
6 Files Affected:
- (modified) llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp (+17-7)
- (added) llvm/test/tools/llvm-gsymutil/X86/Inputs/main.cpp (+13)
- (added) llvm/test/tools/llvm-gsymutil/X86/Inputs/main_split ()
- (added) llvm/test/tools/llvm-gsymutil/X86/Inputs/main_split-main__.dwo ()
- (added) llvm/test/tools/llvm-gsymutil/X86/Inputs/main_split.gsym ()
- (added) llvm/test/tools/llvm-gsymutil/X86/dwo-warning.test (+32)
``````````diff
diff --git a/llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp b/llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp
index 0b225376349ece..6268c7845a142a 100644
--- a/llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp
+++ b/llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp
@@ -537,17 +537,27 @@ void DwarfTransformer::handleDie(raw_ostream *OS, CUInfo &CUI, DWARFDie Die) {
Error DwarfTransformer::convert(uint32_t NumThreads, raw_ostream *OS) {
size_t NumBefore = Gsym.getNumFunctionInfos();
+ std::once_flag flag;
auto getDie = [&](DWARFUnit &DwarfUnit) -> DWARFDie {
DWARFDie ReturnDie = DwarfUnit.getUnitDIE(false);
if (DwarfUnit.getDWOId()) {
DWARFUnit *DWOCU = DwarfUnit.getNonSkeletonUnitDIE(false).getDwarfUnit();
- if (OS && !DWOCU->isDWOUnit()) {
- std::string DWOName = dwarf::toString(
- DwarfUnit.getUnitDIE().find(
- {dwarf::DW_AT_dwo_name, dwarf::DW_AT_GNU_dwo_name}),
- "");
- *OS << "warning: Unable to retrieve DWO .debug_info section for "
- << DWOName << "\n";
+ if (!DWOCU->isDWOUnit()) {
+ if (OS) {
+ std::string DWOName = dwarf::toString(
+ DwarfUnit.getUnitDIE().find(
+ {dwarf::DW_AT_dwo_name, dwarf::DW_AT_GNU_dwo_name}),
+ "");
+ *OS << "warning: Unable to retrieve DWO .debug_info section for "
+ << DWOName << "\n";
+ } else {
+ std::call_once(flag, []() {
+ outs()
+ << "warning: Unable to retrieve DWO .debug_info section for "
+ "some "
+ "object files. (Remove the --quiet flag for full output)\n";
+ });
+ }
} else {
ReturnDie = DWOCU->getUnitDIE(false);
}
diff --git a/llvm/test/tools/llvm-gsymutil/X86/Inputs/main.cpp b/llvm/test/tools/llvm-gsymutil/X86/Inputs/main.cpp
new file mode 100644
index 00000000000000..4c72cdf16a232a
--- /dev/null
+++ b/llvm/test/tools/llvm-gsymutil/X86/Inputs/main.cpp
@@ -0,0 +1,13 @@
+#include <iostream>
+#include <unistd.h>
+
+void foo() {
+ std::cout << "This is foo" << std::endl;
+}
+
+int main() {
+ std::cout << "hello world" << std::endl;
+ foo();
+ std::cout << "after foo" << std::endl;
+ return 0;
+}
diff --git a/llvm/test/tools/llvm-gsymutil/X86/Inputs/main_split b/llvm/test/tools/llvm-gsymutil/X86/Inputs/main_split
new file mode 100755
index 00000000000000..a448f1bdf93b2b
Binary files /dev/null and b/llvm/test/tools/llvm-gsymutil/X86/Inputs/main_split differ
diff --git a/llvm/test/tools/llvm-gsymutil/X86/Inputs/main_split-main__.dwo b/llvm/test/tools/llvm-gsymutil/X86/Inputs/main_split-main__.dwo
new file mode 100644
index 00000000000000..4bb34ae7bd6bdf
Binary files /dev/null and b/llvm/test/tools/llvm-gsymutil/X86/Inputs/main_split-main__.dwo differ
diff --git a/llvm/test/tools/llvm-gsymutil/X86/Inputs/main_split.gsym b/llvm/test/tools/llvm-gsymutil/X86/Inputs/main_split.gsym
new file mode 100644
index 00000000000000..c9e074bb3568d8
Binary files /dev/null and b/llvm/test/tools/llvm-gsymutil/X86/Inputs/main_split.gsym differ
diff --git a/llvm/test/tools/llvm-gsymutil/X86/dwo-warning.test b/llvm/test/tools/llvm-gsymutil/X86/dwo-warning.test
new file mode 100644
index 00000000000000..0a57c8dfe8791d
--- /dev/null
+++ b/llvm/test/tools/llvm-gsymutil/X86/dwo-warning.test
@@ -0,0 +1,32 @@
+$ cat > main.cpp
+#include <iostream>
+#include <unistd.h>
+
+void foo() {
+ std::cout << "This is foo" << std::endl;
+}
+
+int main() {
+ std::cout << "hello world" << std::endl;
+ foo();
+ std::cout << "after foo" << std::endl;
+ return 0;
+}
+
+$ clang++ -g -gdwarf-4 -gsplit-dwarf main.cpp -o main_split
+$ mv main_split-main.dwo main_split-main__.dwo
+
+// RUN: llvm-gsymutil --convert=%p/Inputs/main_split | FileCheck %s --check-prefix=WARNING
+// RUN: llvm-gsymutil --convert=%p/Inputs/main_split --quiet 2>&1 | FileCheck %s --check-prefix=WARNING-QUIET
+
+// WARNING: Input file: {{.*\/main_split}}
+// WARNING: Output file (x86_64): {{.*\.gsym}}
+// WARNING: warning: Unable to retrieve DWO .debug_info section for main_split-main.dwo
+// WARNING: Loaded 0 functions from DWARF.
+// WARNING: Loaded 12 functions from symbol table.
+// WARNING: Pruned 0 functions, ended with 12 total
+
+// WARNING-QUIET: Input file: {{.*\/main_split}}
+// WARNING-QUIET: Output file (x86_64): {{.*\.gsym}}
+// WARNING-QUIET: warning: Unable to retrieve DWO .debug_info section for some object files. (Remove the --quiet flag for full output)
+// WARNING-QUIET: Pruned 0 functions, ended with 12 total
``````````
</details>
https://github.com/llvm/llvm-project/pull/79882
More information about the llvm-commits
mailing list