@@ -30,6 +30,20 @@ class DWARFDebugAbbrev;
30
30
class DataExtractor ;
31
31
struct DWARFSection ;
32
32
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
+
33
47
// / A class that verifies DWARF debug information given a DWARF Context.
34
48
class DWARFVerifier {
35
49
public:
@@ -76,49 +90,16 @@ class DWARFVerifier {
76
90
bool intersects (const DieRangeInfo &RHS) const ;
77
91
};
78
92
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
-
97
93
raw_ostream &OS;
98
94
DWARFContext &DCtx;
99
- ErrorAggregator ErrAggregation ;
95
+ OutputCategoryAggregator ErrorCategory ;
100
96
DIDumpOptions DumpOpts;
101
97
uint32_t NumDebugLineErrors = 0 ;
102
98
// Used to relax some checks that do not currently work portably
103
99
bool IsObjectFile;
104
100
bool IsMachOObject;
105
101
using ReferenceMap = std::map<uint64_t , std::set<uint64_t >>;
106
102
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
-
122
103
raw_ostream &error () const ;
123
104
raw_ostream &warn () const ;
124
105
raw_ostream ¬e () const ;
0 commit comments