Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[llvm-cov] Add support for exporting coverage data to JSON
This enables users to export coverage information as portable JSON for use by analysis tools and storage in document based databases. The export sub-command is invoked just like the others: llvm-cov export -instr-profile path/to/foo.profdata path/to/foo.binary The resulting JSON contains a list of files and functions. Every file object contains a list of segments, expansions, and a summary of the file's region, function, and line coverage. Every function object contains the function's name and regions. There is also a total summary for the entire object file. Patch by Eddie Hurtig! Differential Revision: https://reviews.llvm.org/D22651 llvm-svn: 276813
- Loading branch information
Showing
17 changed files
with
759 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
llvm/test/tools/llvm-cov/Inputs/binary-formats.canonical.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Metadata section | ||
// CHECK: {"version":"1.0.0","type":"llvm.coverage.json.export","data":[ | ||
|
||
// Open Export | ||
// CHECK-SAME: {"object":"{{[^\"]+}}","files":[ | ||
|
||
// File Object | ||
// CHECK-SAME: {"filename":"{{[^\"]+}}/binary-formats.c", | ||
// CHECK-SAME: "segments":[ | ||
// CHECK-SAME: [4,40,100,1,1],[4,42,0,0,0]], | ||
// CHECK-SAME: "expansions":[], | ||
|
||
// Verify the Summary Section for the first file | ||
// CHECK-SAME: "summary":{ | ||
// CHECK-SAME: "lines":{"count":1,"covered":1,"percent":100,"noncode":0}, | ||
// CHECK-SAME: "functions":{"count":1,"covered":1,"percent":100}, | ||
// CHECK-SAME: "regions":{"count":1,"covered":1,"notcovered":0,"percent":100}}} | ||
|
||
// Close Files Array | ||
// CHECK-SAME: ], | ||
|
||
// Functions List | ||
// CHECK-SAME: "functions":[ | ||
// CHECK-SAME: {"name":"main","count":100,"regions":[ | ||
// CHECK-SAME: [4,40,4,42,100,0,0,0] | ||
// CHECK-SAME: ], | ||
// CHECK-SAME: "filenames":["{{[^\"]+}}/binary-formats.c"] | ||
// CHECK-SAME: }], | ||
|
||
|
||
// Full Export Summary | ||
// CHECK-SAME: "totals":{ | ||
// CHECK-SAME: "lines":{"count":1,"covered":1,"percent":100,"noncode":0}, | ||
// CHECK-SAME: "functions":{"count":1,"covered":1,"percent":100}, | ||
// CHECK-SAME: "regions":{"count":1,"covered":1,"notcovered":0,"percent":100}} | ||
|
||
// Close the export object, data array, and root object | ||
// CHECK-SAME: }]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Metadata section | ||
// CHECK: {"version":"1.0.0","type":"llvm.coverage.json.export","data":[ | ||
|
||
// Open Export | ||
// CHECK-SAME: {"object":"{{[^\"]+}}","files":[ | ||
|
||
// File Object | ||
// CHECK-SAME: {"filename":"{{[^\"]+}}/showHighlightedRanges.cpp", | ||
// CHECK-SAME: "segments":[ | ||
// CHECK-SAME: {{(\[[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+\],?)+}}], | ||
// CHECK-SAME: "expansions":[], | ||
|
||
// Verify the Summary Section for the first file | ||
// CHECK-SAME: "summary":{ | ||
// CHECK-SAME: "lines":{"count":40,"covered":26,"percent":65,"noncode":0}, | ||
// CHECK-SAME: "functions":{"count":4,"covered":4,"percent":100}, | ||
// CHECK-SAME: "regions":{"count":19,"covered":11,"notcovered":8,"percent":57}}} | ||
|
||
// Close Files Array | ||
// CHECK-SAME: ], | ||
|
||
// Functions List | ||
// CHECK-SAME: "functions":[ | ||
// CHECK-SAME: {"name":"_Z4funcv","count":1,"regions":[ | ||
// CHECK-SAME: {{(\[[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+\],?)+}} | ||
// CHECK-SAME: ], | ||
// CHECK-SAME: "filenames":["{{[^\"]+}}/showHighlightedRanges.cpp"] | ||
// CHECK-SAME: } | ||
// CHECK-SAME: {"name":"_Z5func2i","count":1,"regions":[ | ||
// CHECK-SAME: {{(\[[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+\],?)+}} | ||
// CHECK-SAME: ], | ||
// CHECK-SAME: "filenames":["{{[^\"]+}}/showHighlightedRanges.cpp"] | ||
// CHECK-SAME: } | ||
// CHECK-SAME: {"name":"_Z4testv","count":1,"regions":[ | ||
// CHECK-SAME: {{(\[[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+\],?)+}} | ||
// CHECK-SAME: ], | ||
// CHECK-SAME: "filenames":["{{[^\"]+}}/showHighlightedRanges.cpp"] | ||
// CHECK-SAME: } | ||
// CHECK-SAME: {"name":"main","count":1,"regions":[ | ||
// CHECK-SAME: {{(\[[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+\],?)+}} | ||
// CHECK-SAME: ], | ||
// CHECK-SAME: "filenames":["{{[^\"]+}}/showHighlightedRanges.cpp"] | ||
// CHECK-SAME: }], | ||
|
||
|
||
// Full Export Summary | ||
// CHECK-SAME: "totals":{ | ||
// CHECK-SAME: "lines":{"count":40,"covered":26,"percent":65,"noncode":0}, | ||
// CHECK-SAME: "functions":{"count":4,"covered":4,"percent":100}, | ||
// CHECK-SAME: "regions":{"count":19,"covered":11,"notcovered":8,"percent":57}} | ||
|
||
// Close the export object, data array, and root object | ||
// CHECK-SAME: }]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Metadata section | ||
// CHECK: {"version":"1.0.0","type":"llvm.coverage.json.export","data":[ | ||
|
||
// Open Export | ||
// CHECK-SAME: {"object":"{{[^\"]+}}","files":[ | ||
|
||
// File Object | ||
// CHECK-SAME: {"filename":"{{[^\"]+}}/showLineExecutionCounts.cpp", | ||
// CHECK-SAME: "segments":[ | ||
// CHECK-SAME: {{(\[[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+\],?)+}}], | ||
// CHECK-SAME: "expansions":[], | ||
|
||
// Verify the Summary Section for the first file | ||
// CHECK-SAME: "summary":{ | ||
// CHECK-SAME: "lines":{"count":20,"covered":16,"percent":80,"noncode":0}, | ||
// CHECK-SAME: "functions":{"count":1,"covered":1,"percent":100}, | ||
// CHECK-SAME: "regions":{"count":10,"covered":7,"notcovered":3,"percent":70}}} | ||
|
||
// Close Files Array | ||
// CHECK-SAME: ], | ||
|
||
// Functions List | ||
// CHECK-SAME: "functions":[ | ||
// CHECK-SAME: {"name":"main","count":161,"regions":[ | ||
// CHECK-SAME: {{(\[[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+\],?)+}} | ||
// CHECK-SAME: ], | ||
// CHECK-SAME: "filenames":["{{[^\"]+}}/showLineExecutionCounts.cpp"] | ||
// CHECK-SAME: }], | ||
|
||
|
||
// Full Export Summary | ||
// CHECK-SAME: "totals":{ | ||
// CHECK-SAME: "lines":{"count":20,"covered":16,"percent":80,"noncode":0}, | ||
// CHECK-SAME: "functions":{"count":1,"covered":1,"percent":100}, | ||
// CHECK-SAME: "regions":{"count":10,"covered":7,"notcovered":3,"percent":70}} | ||
|
||
// Close the export object, data array, and root object | ||
// CHECK-SAME: }]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Metadata section | ||
// CHECK: {"version":"1.0.0","type":"llvm.coverage.json.export","data":[ | ||
|
||
// Open Export | ||
// CHECK-SAME: {"object":"{{[^\"]+}}","files":[ | ||
|
||
// File Object | ||
// CHECK-SAME: {"filename":"{{[^\"]+}}/showRegionMarkers.cpp", | ||
// CHECK-SAME: "segments":[ | ||
// CHECK-SAME: {{(\[[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+\],?)+}}], | ||
// CHECK-SAME: "expansions":[], | ||
|
||
// Verify the Summary Section for the first file | ||
// CHECK-SAME: "summary":{ | ||
// CHECK-SAME: "lines":{"count":21,"covered":17,"percent":80,"noncode":0}, | ||
// CHECK-SAME: "functions":{"count":1,"covered":1,"percent":100}, | ||
// CHECK-SAME: "regions":{"count":10,"covered":7,"notcovered":3,"percent":70}} | ||
|
||
// Close Files Array | ||
// CHECK-SAME: ], | ||
|
||
// Functions List | ||
// CHECK-SAME: "functions":[ | ||
// CHECK-SAME: {"name":"main","count":1111000,"regions":[ | ||
// CHECK-SAME: {{(\[[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+\],?)+}} | ||
// CHECK-SAME: ], | ||
// CHECK-SAME: "filenames":["{{[^\"]+}}/showRegionMarkers.cpp"] | ||
// CHECK-SAME: }], | ||
|
||
// Full Export Summary | ||
// CHECK-SAME: "totals":{ | ||
// CHECK-SAME: "lines":{"count":21,"covered":17,"percent":80,"noncode":0}, | ||
// CHECK-SAME: "functions":{"count":1,"covered":1,"percent":100}, | ||
// CHECK-SAME: "regions":{"count":10,"covered":7,"notcovered":3,"percent":70}} | ||
|
||
// Close the export object, data array, and root object | ||
// CHECK-SAME: }]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Metadata section | ||
// CHECK: {"version":"1.0.0","type":"llvm.coverage.json.export","data":[ | ||
|
||
// Open Export | ||
// CHECK-SAME: {"object":"{{[^\"]+}}","files":[ | ||
|
||
// File Object | ||
// CHECK-SAME: {"filename":"{{[^\"]+}}/showExpansions.cpp", | ||
// CHECK-SAME: "segments":[ | ||
// CHECK-SAME: {{(\[[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+\],?)+}}], | ||
// CHECK-SAME: "expansions":[ | ||
// CHECK-SAME: {"source_region":[24,5,24,17,100,0,1,1], | ||
// CHECK-SAME: "target_regions":[ | ||
// CHECK-SAME: {{(\[[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+\],?)+}} | ||
// CHECK-SAME: ], | ||
|
||
// Yes, 4 of the same filename in a row | ||
// CHECK-SAME: "filenames":[ | ||
// CHECK-SAME: "{{[^\"]+}}/showExpansions.cpp","{{[^\"]+}}/showExpansions.cpp", | ||
// CHECK-SAME: "{{[^\"]+}}/showExpansions.cpp","{{[^\"]+}}/showExpansions.cpp"] | ||
// CHECK-SAME: }], | ||
|
||
// Verify the Summary Section for the first file | ||
// CHECK-SAME: "summary":{ | ||
// CHECK-SAME: "lines":{"count":17,"covered":15,"percent":88,"noncode":0}, | ||
// CHECK-SAME: "functions":{"count":1,"covered":1,"percent":100}, | ||
// CHECK-SAME: "regions":{"count":13,"covered":12,"notcovered":1,"percent":92}} | ||
|
||
// Close Files Array | ||
// CHECK-SAME: ], | ||
|
||
// Functions List | ||
// CHECK-SAME: "functions":[ | ||
// CHECK-SAME: {"name":"main","count":1,"regions":[ | ||
// CHECK-SAME: {{(\[[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+\],?)+}} | ||
// CHECK-SAME: ], | ||
// CHECK-SAME: "filenames":[ | ||
// CHECK-SAME: "{{[^\"]+}}/showExpansions.cpp", | ||
// CHECK-SAME: "{{[^\"]+}}/showExpansions.cpp", | ||
// CHECK-SAME: "{{[^\"]+}}/showExpansions.cpp", | ||
// CHECK-SAME: "{{[^\"]+}}/showExpansions.cpp"] | ||
// CHECK-SAME: }], | ||
|
||
// Full Export Summary | ||
// CHECK-SAME: "totals":{ | ||
// CHECK-SAME: "lines":{"count":17,"covered":15,"percent":88,"noncode":0}, | ||
// CHECK-SAME: "functions":{"count":1,"covered":1,"percent":100}, | ||
// CHECK-SAME: "regions":{"count":13,"covered":12,"notcovered":1,"percent":92}} | ||
|
||
// Close the export object, data array, and root object | ||
// CHECK-SAME: }]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Metadata section | ||
// CHECK: {"version":"1.0.0","type":"llvm.coverage.json.export","data":[ | ||
|
||
// Open Export | ||
// CHECK-SAME: {"object":"{{[^\"]+}}","files":[ | ||
|
||
// File Object | ||
// CHECK-SAME: {"filename":"{{[^\"]+}}/universal-binary.c", | ||
// CHECK-SAME: "segments":[ | ||
// CHECK-SAME: {{(\[[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+\],?)+}}], | ||
// CHECK-SAME: "expansions":[], | ||
|
||
// Verify the Summary Section for the first file | ||
// CHECK-SAME: "summary":{ | ||
// CHECK-SAME: "lines":{"count":1,"covered":1,"percent":100,"noncode":0}, | ||
// CHECK-SAME: "functions":{"count":1,"covered":1,"percent":100}, | ||
// CHECK-SAME: "regions":{"count":1,"covered":1,"notcovered":0,"percent":100}} | ||
|
||
// Close Files Array | ||
// CHECK-SAME: ], | ||
|
||
// Functions List | ||
// CHECK-SAME: "functions":[ | ||
// CHECK-SAME: {"name":"main","count":100,"regions":[ | ||
// CHECK-SAME: {{(\[[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+\],?)+}}], | ||
// CHECK-SAME: "filenames":["{{[^\"]+}}/universal-binary.c"] | ||
// CHECK-SAME: }], | ||
|
||
// Full Export Summary | ||
// CHECK-SAME: "totals":{ | ||
// CHECK-SAME: "lines":{"count":1,"covered":1,"percent":100,"noncode":0}, | ||
// CHECK-SAME: "functions":{"count":1,"covered":1,"percent":100}, | ||
// CHECK-SAME: "regions":{"count":1,"covered":1,"notcovered":0,"percent":100} | ||
|
||
// Close the export object, data array, and root object | ||
// CHECK-SAME: }]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.