-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[llvm-gsymutil] Print one-time DWO file missing warning under --quiet flag #79882
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
Conversation
@llvm/pr-subscribers-debuginfo Author: kusmour (kusmour) ChangesFileCheck test added
Manual test steps:
Full diff: https://github.com/llvm/llvm-project/pull/79882.diff 6 Files Affected:
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
|
e572b36
to
e1ee27b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very close, just one inline comment
FWIW, these days we tend to avoid checking in binaries for testing these tools - instead checking in assembly and generating dwarf objects from that in the test with llvm-mc, or similar pipelines, where possible. |
""); | ||
*OS << "warning: Unable to retrieve DWO .debug_info section for " | ||
<< DWOName << "\n"; | ||
if (!DWOCU->isDWOUnit()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there is --verbose option. Maybe have the same path for default verbosity and no OS, and print all the files for higher verbosity?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems the --verbose
is only used for lookups. We will need to expose that option (the same way as --quiet
) to Transformer
level. If we want to go this path I will do it in a separate patch. Let's focus on the changing the --quiet
behavior here :D
+1 on assembly. bolt/test/X86 has bunch of examples. |
… 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 ```
e1ee27b
to
d03fc83
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
… flag (llvm#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 ```
… flag (llvm#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 ```
FileCheck test added
Manual test steps:
--quiet
flag