[llvm] 5f2d4b2 - Add --quiet option to llvm-gsymutil to suppress output of warnings.
Simon Giesecke via llvm-commits
llvm-commits at lists.llvm.org
Thu May 27 05:39:11 PDT 2021
Author: Simon Giesecke
Date: 2021-05-27T12:36:34Z
New Revision: 5f2d4b23b4c2229e27f1ee9c14c8bc82631b4861
URL: https://github.com/llvm/llvm-project/commit/5f2d4b23b4c2229e27f1ee9c14c8bc82631b4861
DIFF: https://github.com/llvm/llvm-project/commit/5f2d4b23b4c2229e27f1ee9c14c8bc82631b4861.diff
LOG: Add --quiet option to llvm-gsymutil to suppress output of warnings.
Differential Revision: https://reviews.llvm.org/D102829
Added:
Modified:
llvm/include/llvm/DebugInfo/GSYM/GsymCreator.h
llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp
llvm/lib/DebugInfo/GSYM/GsymCreator.cpp
llvm/test/tools/llvm-gsymutil/cmdline.test
llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/DebugInfo/GSYM/GsymCreator.h b/llvm/include/llvm/DebugInfo/GSYM/GsymCreator.h
index b04b662d2633e..da49b4592ee8d 100644
--- a/llvm/include/llvm/DebugInfo/GSYM/GsymCreator.h
+++ b/llvm/include/llvm/DebugInfo/GSYM/GsymCreator.h
@@ -144,10 +144,10 @@ class GsymCreator {
AddressRanges Ranges;
llvm::Optional<uint64_t> BaseAddress;
bool Finalized = false;
+ bool Quiet;
public:
-
- GsymCreator();
+ GsymCreator(bool Quiet = false);
/// Save a GSYM file to a stand alone file.
///
@@ -289,6 +289,9 @@ class GsymCreator {
void setBaseAddress(uint64_t Addr) {
BaseAddress = Addr;
}
+
+ /// Whether the transformation should be quiet, i.e. not output warnings.
+ bool isQuiet() const { return Quiet; }
};
} // namespace gsym
diff --git a/llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp b/llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp
index 1e527ab3916e7..cdea0e39486de 100644
--- a/llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp
+++ b/llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp
@@ -310,8 +310,10 @@ static void convertFunctionLineTable(raw_ostream &Log, CUInfo &CUI,
// so break out after printing a warning.
auto FirstLE = FI.OptLineTable->first();
if (FirstLE && *FirstLE == LE) {
- Log << "warning: duplicate line table detected for DIE:\n";
- Die.dump(Log, 0, DIDumpOptions::getForSingleDIE());
+ if (!Gsym.isQuiet()) {
+ Log << "warning: duplicate line table detected for DIE:\n";
+ Die.dump(Log, 0, DIDumpOptions::getForSingleDIE());
+ }
} else {
// Print out (ignore if os == nulls as this is expensive)
Log << "error: line table has addresses that do not "
@@ -390,11 +392,14 @@ void DwarfTransformer::handleDie(raw_ostream &OS, CUInfo &CUI, DWARFDie Die) {
// and the debug info wasn't able to be stripped from the DWARF. If
// the LowPC isn't zero or -1, then we should emit an error.
if (Range.LowPC != 0) {
- // Unexpected invalid address, emit an error
- Log << "warning: DIE has an address range whose start address is "
- "not in any executable sections (" <<
- *Gsym.GetValidTextRanges() << ") and will not be processed:\n";
- Die.dump(Log, 0, DIDumpOptions::getForSingleDIE());
+ if (!Gsym.isQuiet()) {
+ // Unexpected invalid address, emit a warning
+ Log << "warning: DIE has an address range whose start address is "
+ "not in any executable sections ("
+ << *Gsym.GetValidTextRanges()
+ << ") and will not be processed:\n";
+ Die.dump(Log, 0, DIDumpOptions::getForSingleDIE());
+ }
}
break;
}
diff --git a/llvm/lib/DebugInfo/GSYM/GsymCreator.cpp b/llvm/lib/DebugInfo/GSYM/GsymCreator.cpp
index 988caad24e62c..5d0f01382c2ec 100644
--- a/llvm/lib/DebugInfo/GSYM/GsymCreator.cpp
+++ b/llvm/lib/DebugInfo/GSYM/GsymCreator.cpp
@@ -20,7 +20,8 @@
using namespace llvm;
using namespace gsym;
-GsymCreator::GsymCreator() : StrTab(StringTableBuilder::ELF) {
+GsymCreator::GsymCreator(bool Quiet)
+ : StrTab(StringTableBuilder::ELF), Quiet(Quiet) {
insertFile(StringRef());
}
@@ -248,25 +249,30 @@ llvm::Error GsymCreator::finalize(llvm::raw_ostream &OS) {
// the latter.
return true;
} else {
- OS << "warning: same address range contains "
- "
diff erent debug "
- << "info. Removing:\n"
- << Prev << "\nIn favor of this one:\n"
- << Curr << "\n";
+ if (!Quiet) {
+ OS << "warning: same address range contains "
+ "
diff erent debug "
+ << "info. Removing:\n"
+ << Prev << "\nIn favor of this one:\n"
+ << Curr << "\n";
+ }
return true;
}
}
} else {
- // print warnings about overlaps
- OS << "warning: function ranges overlap:\n"
- << Prev << "\n"
- << Curr << "\n";
+ if (!Quiet) { // print warnings about overlaps
+ OS << "warning: function ranges overlap:\n"
+ << Prev << "\n"
+ << Curr << "\n";
+ }
}
} else if (Prev.Range.size() == 0 &&
Curr.Range.contains(Prev.Range.Start)) {
- OS << "warning: removing symbol:\n"
- << Prev << "\nKeeping:\n"
- << Curr << "\n";
+ if (!Quiet) {
+ OS << "warning: removing symbol:\n"
+ << Prev << "\nKeeping:\n"
+ << Curr << "\n";
+ }
return true;
}
diff --git a/llvm/test/tools/llvm-gsymutil/cmdline.test b/llvm/test/tools/llvm-gsymutil/cmdline.test
index 1f940270492cb..9191309f5ca56 100644
--- a/llvm/test/tools/llvm-gsymutil/cmdline.test
+++ b/llvm/test/tools/llvm-gsymutil/cmdline.test
@@ -8,6 +8,7 @@ HELP: --arch=<arch>
HELP: --convert=<path>
HELP: --num-threads=<n>
HELP: --out-file=<path>
+HELP: --quiet
HELP: --verify
HELP: Generic Options:
HELP: --help
diff --git a/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp b/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp
index 167d34cb9ab90..1173ae950de34 100644
--- a/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp
+++ b/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp
@@ -108,6 +108,10 @@ static opt<unsigned>
"number of cores on the current machine."),
cl::value_desc("n"), cat(ConversionOptions));
+static opt<bool>
+ Quiet("quiet", desc("Do not output warnings about the debug information"),
+ cat(ConversionOptions));
+
static list<uint64_t> LookupAddresses("address",
desc("Lookup an address in a GSYM file"),
cl::value_desc("addr"),
@@ -281,7 +285,7 @@ static llvm::Error handleObjectFile(ObjectFile &Obj,
NumThreads > 0 ? NumThreads : std::thread::hardware_concurrency();
auto &OS = outs();
- GsymCreator Gsym;
+ GsymCreator Gsym(Quiet);
// See if we can figure out the base address for a given object file, and if
// we can, then set the base address to use to this value. This will ease
More information about the llvm-commits
mailing list