如何读取llvm cov json格式?
我能够通过LLVMCOV以json格式导出代码覆盖率数据,但内容对我来说似乎很神秘。如何读取llvm cov json格式?,llvm,code-coverage,llvm-cov,Llvm,Code Coverage,Llvm Cov,我能够通过LLVMCOV以json格式导出代码覆盖率数据,但内容对我来说似乎很神秘。段中的每个数字是什么意思 { "filename":"file.m", "segments":[ [ 11, 22, 23, 1, 1 ], [ 12, 11, 23, 1, 1
段中的每个数字是什么意思
{
"filename":"file.m",
"segments":[
[
11,
22,
23,
1,
1
],
[
12,
11,
23,
1,
1
],
...
],
"expansions":[
],
"summary":{
...
}
}
接着,JSON格式在源代码中进行了解释,我在中找到了源代码
包含以下说明:
The json code coverage export follows the following format
Root: dict => Root Element containing metadata
-- Data: array => Homogeneous array of one or more export objects
-- Export: dict => Json representation of one CoverageMapping
-- Files: array => List of objects describing coverage for files
-- File: dict => Coverage for a single file
-- Branches: array => List of Branches in the file
-- Branch: dict => Describes a branch of the file with counters
-- Segments: array => List of Segments contained in the file
-- Segment: dict => Describes a segment of the file with a counter
-- Expansions: array => List of expansion records
-- Expansion: dict => Object that descibes a single expansion
-- CountedRegion: dict => The region to be expanded
-- TargetRegions: array => List of Regions in the expansion
-- CountedRegion: dict => Single Region in the expansion
-- Branches: array => List of Branches in the expansion
-- Branch: dict => Describes a branch in expansion and counters
-- Summary: dict => Object summarizing the coverage for this file
-- LineCoverage: dict => Object summarizing line coverage
-- FunctionCoverage: dict => Object summarizing function coverage
-- RegionCoverage: dict => Object summarizing region coverage
-- BranchCoverage: dict => Object summarizing branch coverage
-- Functions: array => List of objects describing coverage for functions
-- Function: dict => Coverage info for a single function
-- Filenames: array => List of filenames that the function relates to
-- Summary: dict => Object summarizing the coverage for the entire binary
-- LineCoverage: dict => Object summarizing line coverage
-- FunctionCoverage: dict => Object summarizing function coverage
-- InstantiationCoverage: dict => Object summarizing inst. coverage
-- RegionCoverage: dict => Object summarizing region coverage
-- BranchCoverage: dict => Object summarizing branch coverage
可悲的是,对于一个片段是什么,或者它是如何构造的,这仍然不是很好的解释
更详细地查看代码,我们会发现以下两个片段:
json::Array renderSegment(const coverage::CoverageSegment&Segment){
返回json::数组({Segment.Line,Segment.Col,int64_t(Segment.Count),
Segment.hascont,Segment.IsRegionEntry});
}
json::Array renderRegion(const coverage::CountedRegion&Region){
返回json::数组({Region.LineStart,Region.ColumnStart,Region.LineEnd,
Region.ColumnEnd,int64_t(Region.ExecutionCount),
Region.FileID,Region.ExpandedFileID,
int64_t(Region.Kind)});
}
这会让你更好地理解这些条目的含义
文件ID似乎索引到了扩展中给出的文件名中。除了前面的答案之外,我还发现这个页面非常有用:。它有助于解释段
中的每个概念,如行
,列