Skip to content

Commit 9e0ef03

Browse files
Kevin Freikevinfrei
Kevin Frei
authored andcommitted
Fixing file format and actually outputting the file
1 parent d501dad commit 9e0ef03

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2039,20 +2039,24 @@ void DWARFVerifier::summarize() {
20392039
if (!DumpOpts.AggregateErrJsonFile.empty()) {
20402040
std::error_code EC;
20412041
raw_fd_ostream JsonStream(DumpOpts.AggregateErrJsonFile, EC,
2042-
sys::fs::OF_Text | sys::fs::OF_None);
2042+
sys::fs::OF_Text);
20432043
if (EC) {
20442044
error() << "error opening aggregate error json file '"
20452045
<< DumpOpts.AggregateErrJsonFile
20462046
<< "' for writing: " << EC.message() << '\n';
20472047
return;
20482048
}
20492049
JsonStream << "{\"errors\":[\n";
2050+
bool prev = false;
20502051
ErrorCategory.EnumerateResults([&](StringRef category, unsigned count) {
2051-
JsonStream << "\"category\":\"";
2052+
if (prev)
2053+
JsonStream << ",\n";
2054+
JsonStream << "{\"category\":\"";
20522055
llvm::printEscapedString(category, JsonStream);
2053-
JsonStream << "\",\"count\":" << count;
2056+
JsonStream << "\",\"count\":" << count << "}";
2057+
prev = true;
20542058
});
2055-
JsonStream << "]}\n";
2059+
JsonStream << "\n]}\n";
20562060
}
20572061
}
20582062

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,8 @@ static opt<ErrorDetailLevel> ErrorDetails(
297297
cat(DwarfDumpCategory));
298298
static opt<std::string> AggregationJsonFile(
299299
"aggregate-output-file", cl::init(""),
300-
cl::desc("Output JSON-formatted error summary to the specified file."),
300+
cl::desc("When using --verify, output JSON-formatted error summary to the "
301+
"specified file."),
301302
cl::value_desc("filename.json"), cat(DwarfDumpCategory));
302303
static opt<bool> Quiet("quiet", desc("Use with -verify to not emit to STDOUT."),
303304
cat(DwarfDumpCategory));
@@ -353,6 +354,7 @@ static DIDumpOptions getDumpOpts(DWARFContext &C) {
353354
ErrorDetails != NoDetailsOrSummary;
354355
DumpOpts.ShowAggregateErrors = ErrorDetails != OnlyDetailsNoSummary &&
355356
ErrorDetails != NoDetailsOnlySummary;
357+
DumpOpts.AggregateErrJsonFile = AggregationJsonFile;
356358
return DumpOpts.noImplicitRecursion();
357359
}
358360
return DumpOpts;
@@ -841,7 +843,8 @@ int main(int argc, char **argv) {
841843
if (!Verify && ErrorDetails != Unspecified)
842844
WithColor::warning() << "-error-detail has no affect without -verify";
843845
if (!Verify && !AggregationJsonFile.empty())
844-
WithColor::warning() << "-aggregation-json has no affect without -verify";
846+
WithColor::warning()
847+
<< "-aggregate-output-file has no affect without -verify";
845848

846849
std::error_code EC;
847850
ToolOutputFile OutputFile(OutputFilename, EC, sys::fs::OF_TextWithCRLF);

0 commit comments

Comments
 (0)