Skip to content

Commit 172394c

Browse files
author
Kevin Frei
committed
A few final touches before tests
1 parent 87fdfe8 commit 172394c

File tree

3 files changed

+23
-20
lines changed

3 files changed

+23
-20
lines changed

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,15 @@ struct DWARFSection;
3333
class OutputCategoryAggregator {
3434
private:
3535
std::map<std::string, unsigned> Aggregation;
36-
bool CallDetail;
36+
bool IncludeDetail;
3737

3838
public:
39-
OutputCategoryAggregator(bool callDetail = false) : CallDetail(callDetail) {}
40-
void EnableDetail() { CallDetail = true; }
41-
void DisableDetail() { CallDetail = false; }
39+
OutputCategoryAggregator(bool includeDetail = false)
40+
: IncludeDetail(includeDetail) {}
41+
void EnableDetail() { IncludeDetail = true; }
42+
void DisableDetail() { IncludeDetail = false; }
4243
void Report(StringRef s, std::function<void()> detailCallback);
43-
void HandleAggregate(std::function<void(StringRef, unsigned)> handleCounts);
44+
void EnumerateResults(std::function<void(StringRef, unsigned)> handleCounts);
4445
};
4546

4647
/// A class that verifies DWARF debug information given a DWARF Context.
@@ -89,11 +90,12 @@ class DWARFVerifier {
8990
bool intersects(const DieRangeInfo &RHS) const;
9091
};
9192

93+
private:
9294
raw_ostream &OS;
9395
DWARFContext &DCtx;
94-
OutputCategoryAggregator ErrorCategory;
9596
DIDumpOptions DumpOpts;
9697
uint32_t NumDebugLineErrors = 0;
98+
OutputCategoryAggregator ErrorCategory;
9799
// Used to relax some checks that do not currently work portably
98100
bool IsObjectFile;
99101
bool IsMachOObject;
@@ -362,8 +364,8 @@ class DWARFVerifier {
362364
StringRef SectionName, const DWARFSection &Section, StringRef StrData,
363365
void (DWARFObject::*)(function_ref<void(const DWARFSection &)>) const);
364366

365-
/// Emits any aggregate information collection, depending on the dump options
366-
void finish(bool Success);
367+
/// Emits any aggregate information collected, depending on the dump options
368+
void summarize(bool Success);
367369
};
368370

369371
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(Success);
1411+
verifier.summarize(Success);
14121412
return Success;
14131413
}
14141414

llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ unsigned DWARFVerifier::verifyDebugInfoCallSite(const DWARFDie &Die) {
307307

308308
if (!Curr.isValid()) {
309309
ErrorCategory.Report(
310-
"Call site entry not nexted within valid subprogram", [&]() {
310+
"Call site entry not nested within valid subprogram", [&]() {
311311
error() << "Call site entry not nested within a valid subprogram:";
312312
Die.dump(OS);
313313
});
@@ -339,9 +339,9 @@ unsigned DWARFVerifier::verifyAbbrevSection(const DWARFDebugAbbrev *Abbrev) {
339339
Expected<const DWARFAbbreviationDeclarationSet *> AbbrDeclsOrErr =
340340
Abbrev->getAbbreviationDeclarationSet(0);
341341
if (!AbbrDeclsOrErr) {
342-
ErrorCategory.Report("Abbreviation Declaration error", [&]() {
343-
error() << toString(AbbrDeclsOrErr.takeError()) << "\n";
344-
});
342+
std::string ErrMsg = toString(AbbrDeclsOrErr.takeError());
343+
ErrorCategory.Report("Abbreviation Declaration error",
344+
[&]() { error() << ErrMsg << "\n"; });
345345
return 1;
346346
}
347347

@@ -863,8 +863,9 @@ unsigned DWARFVerifier::verifyDebugInfoForm(const DWARFDie &Die,
863863
case DW_FORM_line_strp: {
864864
if (Error E = AttrValue.Value.getAsCString().takeError()) {
865865
++NumErrors;
866+
std::string ErrMsg = toString(std::move(E));
866867
ErrorCategory.Report("Invalid DW_FORM attribute", [&]() {
867-
error() << toString(std::move(E)) << ":\n";
868+
error() << ErrMsg << ":\n";
868869
dump(Die) << '\n';
869870
});
870871
}
@@ -916,7 +917,7 @@ void DWARFVerifier::verifyDebugLineStmtOffsets() {
916917
if (LineTableOffset < DCtx.getDWARFObj().getLineSection().Data.size()) {
917918
if (!LineTable) {
918919
++NumDebugLineErrors;
919-
ErrorCategory.Report("Unparseable .debug_line entry", [&]() {
920+
ErrorCategory.Report("Unparsable .debug_line entry", [&]() {
920921
error() << ".debug_line[" << format("0x%08" PRIx64, LineTableOffset)
921922
<< "] was not able to be parsed for CU:\n";
922923
dump(Die) << '\n';
@@ -1584,7 +1585,7 @@ unsigned DWARFVerifier::verifyNameIndexEntries(
15841585
uint64_t DIEOffset = CUOffset + *EntryOr->getDIEUnitOffset();
15851586
DWARFDie DIE = DCtx.getDIEForOffset(DIEOffset);
15861587
if (!DIE) {
1587-
ErrorCategory.Report("NameIndex references nonexisten DIE", [&]() {
1588+
ErrorCategory.Report("NameIndex references nonexistent DIE", [&]() {
15881589
error() << formatv("Name Index @ {0:x}: Entry @ {1:x} references a "
15891590
"non-existing DIE @ {2:x}.\n",
15901591
NI.getUnitOffset(), EntryID, DIEOffset);
@@ -1986,21 +1987,21 @@ bool DWARFVerifier::verifyDebugStrOffsets(
19861987
void OutputCategoryAggregator::Report(
19871988
StringRef s, std::function<void(void)> detailCallback) {
19881989
Aggregation[std::string(s)]++;
1989-
if (CallDetail)
1990+
if (IncludeDetail)
19901991
detailCallback();
19911992
}
19921993

1993-
void OutputCategoryAggregator::HandleAggregate(
1994+
void OutputCategoryAggregator::EnumerateResults(
19941995
std::function<void(StringRef, unsigned)> handleCounts) {
19951996
for (auto &&[name, count] : Aggregation) {
19961997
handleCounts(name, count);
19971998
}
19981999
}
19992000

2000-
void DWARFVerifier::finish(bool Success) {
2001+
void DWARFVerifier::summarize(bool Success) {
20012002
if (!Success && DumpOpts.ShowAggregateErrors) {
20022003
error() << "Aggregated error category counts:\n";
2003-
ErrorCategory.HandleAggregate([&](StringRef s, unsigned count) {
2004+
ErrorCategory.EnumerateResults([&](StringRef s, unsigned count) {
20042005
error() << "Error category '" << s << "' occurred " << count
20052006
<< " time(s).\n";
20062007
});

0 commit comments

Comments
 (0)