Skip to content

Commit 87fdfe8

Browse files
author
Kevin Frei
committed
Set up the flags in a reasonable way
1 parent 282f677 commit 87fdfe8

File tree

5 files changed

+25
-7
lines changed

5 files changed

+25
-7
lines changed

llvm/include/llvm/DebugInfo/DIContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ struct DIDumpOptions {
205205
bool DisplayRawContents = false;
206206
bool IsEH = false;
207207
bool DumpNonSkeleton = false;
208-
bool DumpAggregateErrors = true;
208+
bool ShowAggregateErrors = false;
209209
std::function<llvm::StringRef(uint64_t DwarfRegNum, bool IsEH)>
210210
GetNameForDWARFReg;
211211

llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ class DWARFVerifier {
363363
void (DWARFObject::*)(function_ref<void(const DWARFSection &)>) const);
364364

365365
/// Emits any aggregate information collection, depending on the dump options
366-
void finish();
366+
void finish(bool Success);
367367
};
368368

369369
static inline bool operator<(const DWARFVerifier::DieRangeInfo &LHS,

llvm/lib/DebugInfo/DWARF/DWARFContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1408,7 +1408,7 @@ bool DWARFContext::verify(raw_ostream &OS, DIDumpOptions DumpOpts) {
14081408
if (DumpOpts.DumpType & DIDT_DebugStrOffsets)
14091409
Success &= verifier.handleDebugStrOffsets();
14101410
Success &= verifier.handleAccelTables();
1411-
verifier.finish();
1411+
verifier.finish(Success);
14121412
return Success;
14131413
}
14141414

llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1997,11 +1997,14 @@ void OutputCategoryAggregator::HandleAggregate(
19971997
}
19981998
}
19991999

2000-
void DWARFVerifier::finish() {
2001-
if (DumpOpts.DumpAggregateErrors)
2000+
void DWARFVerifier::finish(bool Success) {
2001+
if (!Success && DumpOpts.ShowAggregateErrors) {
2002+
error() << "Aggregated error category counts:\n";
20022003
ErrorCategory.HandleAggregate([&](StringRef s, unsigned count) {
2003-
error() << s << ": " << count << '\n';
2004+
error() << "Error category '" << s << "' occurred " << count
2005+
<< " time(s).\n";
20042006
});
2007+
}
20052008
}
20062009

20072010
raw_ostream &DWARFVerifier::error() const { return WithColor::error(OS); }

llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,14 @@ static cl::opt<bool>
276276
cat(DwarfDumpCategory));
277277
static opt<bool> Verify("verify", desc("Verify the DWARF debug info."),
278278
cat(DwarfDumpCategory));
279+
static opt<bool> OnlyAggregateErrors(
280+
"only-aggregate-errors",
281+
desc("Only display the aggregate errors when verifying."),
282+
cat(DwarfDumpCategory));
283+
static opt<bool> NoAggregateErrors(
284+
"no-aggregate-errors",
285+
desc("Do not display the aggregate errors when verifying."),
286+
cat(DwarfDumpCategory));
279287
static opt<bool> Quiet("quiet", desc("Use with -verify to not emit to STDOUT."),
280288
cat(DwarfDumpCategory));
281289
static opt<bool> DumpUUID("uuid", desc("Show the UUID for each architecture."),
@@ -326,7 +334,8 @@ static DIDumpOptions getDumpOpts(DWARFContext &C) {
326334
DumpOpts.RecoverableErrorHandler = C.getRecoverableErrorHandler();
327335
// In -verify mode, print DIEs without children in error messages.
328336
if (Verify) {
329-
// DumpOpts.Verbose = true;
337+
DumpOpts.Verbose = !OnlyAggregateErrors;
338+
DumpOpts.ShowAggregateErrors = !NoAggregateErrors;
330339
return DumpOpts.noImplicitRecursion();
331340
}
332341
return DumpOpts;
@@ -812,6 +821,12 @@ int main(int argc, char **argv) {
812821
"-verbose is currently not supported";
813822
return 1;
814823
}
824+
if (Verify && NoAggregateErrors && OnlyAggregateErrors) {
825+
WithColor::error() << "incompatible arguments: specifying both "
826+
" -no-aggregate-errors, and -only-aggregate-errors "
827+
"is not supported";
828+
return 1;
829+
}
815830

816831
std::error_code EC;
817832
ToolOutputFile OutputFile(OutputFilename, EC, sys::fs::OF_TextWithCRLF);

0 commit comments

Comments
 (0)