Skip to content

Commit d7577d2

Browse files
author
Kevin Frei
committed
Updated with Greg's suggestion for the reporter
1 parent 0a529f2 commit d7577d2

File tree

2 files changed

+151
-162
lines changed

2 files changed

+151
-162
lines changed

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

Lines changed: 15 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,20 @@ class DWARFDebugAbbrev;
3030
class DataExtractor;
3131
struct DWARFSection;
3232

33+
class OutputCategoryAggregator {
34+
private:
35+
std::map<std::string, int> Aggregator;
36+
bool Output;
37+
38+
public:
39+
OutputCategoryAggregator(bool DetailedOutput = false)
40+
: Output(DetailedOutput) {}
41+
void EnableDetail() { Output = true; }
42+
void DisableDetail() { Output = false; }
43+
void Report(StringRef s, std::function<void()> detailCallback);
44+
void DumpAggregation(raw_ostream *o);
45+
};
46+
3347
/// A class that verifies DWARF debug information given a DWARF Context.
3448
class DWARFVerifier {
3549
public:
@@ -76,49 +90,16 @@ class DWARFVerifier {
7690
bool intersects(const DieRangeInfo &RHS) const;
7791
};
7892

79-
private:
80-
class ErrorAggregator {
81-
private:
82-
DWARFVerifier &Verifier;
83-
std::map<std::string, int> UniqueErrors;
84-
raw_ostream *NextLineOverride;
85-
86-
static std::string Clean(const char *s);
87-
88-
public:
89-
ErrorAggregator(DWARFVerifier &v) : Verifier(v), NextLineOverride(nullptr) {}
90-
raw_ostream &operator<<(const char *s);
91-
ErrorAggregator &NextLineStreamOverride(raw_ostream &o);
92-
raw_ostream &Collect(const std::string &s);
93-
void Dump();
94-
};
95-
friend class ErrorAggregator;
96-
9793
raw_ostream &OS;
9894
DWARFContext &DCtx;
99-
ErrorAggregator ErrAggregation;
95+
OutputCategoryAggregator ErrorCategory;
10096
DIDumpOptions DumpOpts;
10197
uint32_t NumDebugLineErrors = 0;
10298
// Used to relax some checks that do not currently work portably
10399
bool IsObjectFile;
104100
bool IsMachOObject;
105101
using ReferenceMap = std::map<uint64_t, std::set<uint64_t>>;
106102

107-
// For errors that have sensible names as the first (or only) string
108-
// you can just use aggregate() << "DIE is damaged: " << details...
109-
// and it will get aggregated as "DIE is damaged".
110-
ErrorAggregator &aggregate();
111-
// For errors that have the useful aggregated category in a non-error stream
112-
// you can do things like this (aggregated as 'Die size is wrong')
113-
// aggregate(note()) << "DIE size is wrong.\n"
114-
ErrorAggregator &aggregate(raw_ostream &);
115-
116-
// For errors that have valuable detail before text that is the appropriate
117-
// aggregate category, you can provide the aggregated name for the error like
118-
// this:
119-
// aggregate("CU index is broken") << "CU index [" << n << "] is broken"
120-
raw_ostream &aggregate(const char *);
121-
122103
raw_ostream &error() const;
123104
raw_ostream &warn() const;
124105
raw_ostream &note() const;

0 commit comments

Comments
 (0)