Skip to content

Initial 'design' for aggregating verification errors in llvm-dwarfdump #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ class DWARFDebugAbbrev;
class DataExtractor;
struct DWARFSection;

class OutputCategoryAggregator {
private:
std::map<std::string, unsigned> Aggregation;
bool CallDetail;

public:
OutputCategoryAggregator(bool callDetail = false) : CallDetail(callDetail) {}
void EnableDetail() { CallDetail = true; }
void DisableDetail() { CallDetail = false; }
void Report(StringRef s, std::function<void()> detailCallback);
void HandleAggregate(std::function<void(StringRef, unsigned)> handleCounts);
};

/// A class that verifies DWARF debug information given a DWARF Context.
class DWARFVerifier {
public:
Expand Down Expand Up @@ -76,9 +89,9 @@ class DWARFVerifier {
bool intersects(const DieRangeInfo &RHS) const;
};

private:
raw_ostream &OS;
DWARFContext &DCtx;
OutputCategoryAggregator ErrorCategory;
DIDumpOptions DumpOpts;
uint32_t NumDebugLineErrors = 0;
// Used to relax some checks that do not currently work portably
Expand Down Expand Up @@ -348,6 +361,9 @@ class DWARFVerifier {
bool verifyDebugStrOffsets(
StringRef SectionName, const DWARFSection &Section, StringRef StrData,
void (DWARFObject::*)(function_ref<void(const DWARFSection &)>) const);

/// Emits any aggregate information collection, depending on the dump options
void finish(bool Success);
};

static inline bool operator<(const DWARFVerifier::DieRangeInfo &LHS,
Expand Down
1 change: 1 addition & 0 deletions llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1408,6 +1408,7 @@ bool DWARFContext::verify(raw_ostream &OS, DIDumpOptions DumpOpts) {
if (DumpOpts.DumpType & DIDT_DebugStrOffsets)
Success &= verifier.handleDebugStrOffsets();
Success &= verifier.handleAccelTables();
verifier.finish(Success);
return Success;
}

Expand Down
Loading