- Enhance
ObjectYAML
to handle covmap sections.obj2yaml
can dump optionally covmap sections as prettyprinted.yaml2obj
can parse and emit covmap described by YAML.
Backgrounds
llvm/test/tools/llvm-cov/Inputs
has some object files. Since they are assumed as blobs, it would be not easy to know what they are. Especially for updating, it would be difficult to know what would be changed.
We can know what they are and track them if they are describe in text-formatted YAML. Changes will be shown as diff. We can expect cleaner view for coming binary format changes.
Currently, obj2yaml
dumps covmap-specific sections as blobs. obj2yaml
may show understand covmap sections and dump them as prettyprinted. yaml2obj
may be used for generating object files for testing.
There is the discussion for removing test binaries.
Requirements
(by importance)
yaml2obj
should emit object files that are available asllvm-cov
tests.obj2yaml
should emit YAML files that can be understood and parsed byyaml2obj
.obj2yaml
should emit covmap sections as optionally prettyprinted.- YAML structure may be tolerant of content changes. It is better if its diff view is simple.
- YAML structure may be flexble and applicable not only for the current version but also past and future versions.
Steps
I am implementing and testing a prototype.
Enhance ObjectYAML
Since ObjectYAML
is less extensible for plugins, enhancements may be implemented into ObjectYAML
. Changes for tools (obj2yaml
and yaml2obj
) will be lesser.
Migrate llvm-cov
tests to yaml2obj
FYI, we can reduce test inputs to reduce sections to __llvm_prf_names
, __llvm_covmap
, and __llvm_covfun
. It can be;
llvm-objcopy \
--only-section=__llvm_covfun \
--only-section=__llvm_covmap \
--only-section=__llvm_prf_names \
--strip-unneeded
Make YAML output more prettyprinted
Hash values and opaque indices are less readable. I think YAML may be decorated more with information in other sections.
I donāt think it would be our goal to make YAML more human-readable as possible. Itād be more important for development and CI.
Integrate covmap encoder and decoder with LLVMCoverage
ās
This may be the future work. Currently my prototype implementations is individual.
Enhance YAML for non-current covmap versions
This may be the future work.
Appendix: Example YAML snippets
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
OSABI: ELFOSABI_GNU
Type: ET_REL
Machine: EM_X86_64
SectionHeaderStringTable: .strtab
Sections:
- CustomSectionName: __llvm_covfun
CovFun:
- FnRef: 0x92FEBEFF6DCBC98A
Signature: 0x8844F3EA913AC6F7
FilenamesRef: 0x936D2263272E38EB
fns: [ 1 ]
Expressions:
- [ { Ref: 0 }, { Ref: 3 } ]
- [ { Ref: 3 }, { Ref: 4 } ]
- [ { Ref: 2 }, { Ref: 5 } ]
- [ { Ref: 5 }, { Ref: 6 } ]
- [ { Ref: 0 }, { Ref: 8 } ]
- [ { Ref: 8 }, { Ref: 9 } ]
- [ { Ref: 7 }, { Ref: 11 } ]
- [ { Ref: 11 }, { Ref: 12 } ]
- [ { Ref: 0 }, { Ref: 15 } ]
- [ { Ref: 15 }, { Ref: 16 } ]
- [ { Ref: 14 }, { Ref: 17 } ]
- [ { Ref: 17 }, { Ref: 18 } ]
Records:
- { File: 0, dLoc: [ 10, 43, 11, 2 ], Ref: 0 }
- { File: 0, dLoc: [ 1, 1, 0, 1 ], Skip: { } }
- { File: 0, dLoc: [ 1, 7, 0, 15 ], Ref: 0 }
- { File: 0, dLoc: [ 0, 7, 0, 27 ], Ref: 0 }
- { File: 0, dLoc: [ 0, 7, 0, 27 ], Decision: { BIdx: 7, NCond: 4 } }
- { File: 0, dLoc: [ 0, 8, 0, 9 ], Ref: 0 }
- { File: 0, dLoc: [ 0, 8, 0, 9 ], Branch: { True: { Ref: 3 }, False: { Sub: 0 }, MCDC: [ 1, 3, 2 ] } }
- { File: 0, dLoc: [ 0, 13, 0, 14 ], Ref: 3 }
- { File: 0, dLoc: [ 0, 13, 0, 14 ], Branch: { True: { Ref: 4 }, False: { Sub: 1 }, MCDC: [ 3, 0, 2 ] } }
- { File: 0, dLoc: [ 0, 19, 0, 27 ], Ref: 2 }
- { File: 0, dLoc: [ 0, 20, 0, 21 ], Ref: 2 }
- { File: 0, dLoc: [ 0, 20, 0, 21 ], Branch: { True: { Ref: 5 }, False: { Sub: 2 }, MCDC: [ 2, 4, 0 ] } }
- { File: 0, dLoc: [ 0, 25, 0, 26 ], Ref: 5 }
- { File: 0, dLoc: [ 0, 25, 0, 26 ], Branch: { True: { Ref: 6 }, False: { Sub: 3 }, MCDC: [ 4, 0, 0 ] } }
- { File: 0, dLoc: [ 0, 28, 1, 5 ], isGap: true, Ref: 1 }
- { File: 0, dLoc: [ 1, 5, 0, 36 ], Ref: 1 }
- { File: 0, dLoc: [ 1, 1, 0, 1 ], Skip: { } }
- { File: 0, dLoc: [ 1, 7, 0, 8 ], Ref: 0 }
- { File: 0, dLoc: [ 0, 7, 0, 13 ], Ref: 0 }
- { File: 0, dLoc: [ 0, 7, 0, 13 ], Decision: { BIdx: 10, NCond: 2 } }
- { File: 0, dLoc: [ 0, 7, 0, 8 ], Branch: { True: { Ref: 8 }, False: { Sub: 4 }, MCDC: [ 1, 2, 0 ] } }
- { File: 0, dLoc: [ 0, 12, 0, 13 ], Ref: 8 }
- { File: 0, dLoc: [ 0, 12, 0, 13 ], Branch: { True: { Ref: 9 }, False: { Sub: 5 }, MCDC: [ 2, 0, 0 ] } }
- { File: 0, dLoc: [ 0, 14, 0, 15 ], isGap: true, Ref: 7 }
- { File: 0, dLoc: [ 0, 15, 1, 36 ], Ref: 7 }
- { File: 0, dLoc: [ 0, 19, 0, 20 ], Ref: 7 }
- { File: 0, dLoc: [ 0, 19, 0, 25 ], Ref: 7 }
- { File: 0, dLoc: [ 0, 19, 0, 25 ], Decision: { BIdx: 13, NCond: 2 } }
- { File: 0, dLoc: [ 0, 19, 0, 20 ], Branch: { True: { Ref: 11 }, False: { Sub: 6 }, MCDC: [ 1, 2, 0 ] } }
- { File: 0, dLoc: [ 0, 24, 0, 25 ], Ref: 11 }
- { File: 0, dLoc: [ 0, 24, 0, 25 ], Branch: { True: { Ref: 12 }, False: { Sub: 7 }, MCDC: [ 2, 0, 0 ] } }
- { File: 0, dLoc: [ 0, 26, 1, 5 ], isGap: true, Ref: 10 }
- { File: 0, dLoc: [ 1, 5, 0, 36 ], Ref: 10 }
- { File: 0, dLoc: [ 1, 1, 0, 1 ], Skip: { } }
- { File: 0, dLoc: [ 1, 7, 0, 15 ], Ref: 0 }
- { File: 0, dLoc: [ 0, 7, 1, 15 ], Ref: 0 }
- { File: 0, dLoc: [ 0, 7, 1, 15 ], Decision: { BIdx: 18, NCond: 4 } }
- { File: 0, dLoc: [ 0, 8, 0, 9 ], Ref: 0 }
- { File: 0, dLoc: [ 0, 8, 0, 9 ], Branch: { True: { Ref: 15 }, False: { Sub: 8 }, MCDC: [ 1, 3, 0 ] } }
- { File: 0, dLoc: [ 0, 13, 0, 14 ], Ref: 15 }
- { File: 0, dLoc: [ 0, 13, 0, 14 ], Branch: { True: { Ref: 16 }, False: { Sub: 9 }, MCDC: [ 3, 2, 0 ] } }
- { File: 0, dLoc: [ 1, 7, 0, 15 ], Ref: 14 }
- { File: 0, dLoc: [ 0, 8, 0, 9 ], Ref: 14 }
- { File: 0, dLoc: [ 0, 8, 0, 9 ], Branch: { True: { Ref: 17 }, False: { Sub: 10 }, MCDC: [ 2, 4, 0 ] } }
- { File: 0, dLoc: [ 0, 13, 0, 14 ], Ref: 17 }
- { File: 0, dLoc: [ 0, 13, 0, 14 ], Branch: { True: { Ref: 18 }, False: { Sub: 11 }, MCDC: [ 4, 0, 0 ] } }
- { File: 0, dLoc: [ 0, 16, 1, 5 ], isGap: true, Ref: 13 }
- { File: 0, dLoc: [ 1, 5, 0, 36 ], Ref: 13 }
- CustomSectionName: '__llvm_covfun (1)'
CovFun:
- FnRef: 0xDB956436E78DD5FA
Signature: 0x18
FilenamesRef: 0x936D2263272E38EB
fns: [ 1 ]
Expressions: []
Records:
- { File: 0, dLoc: [ 24, 1, 12, 2 ], Ref: 0 }
- { File: 0, dLoc: [ 5, 1, 0, 1 ], Skip: { } }
- { File: 0, dLoc: [ 4, 1, 0, 1 ], Skip: { } }
- CustomSectionName: __llvm_covmap
CovMap:
- FnBlobHash: 0x936D2263272E38EB
WD: ''
Filenames:
- mcdc-general.cpp
- CustomSectionName: __llvm_prf_names
PrfNames:
- Names:
- _Z4testbbbb
- main
- Type: SectionHeaderTable
Sections:
- Name: .strtab
- Name: __llvm_covfun
- Name: '__llvm_covfun (1)'
- Name: __llvm_covmap
- Name: __llvm_prf_names
- Name: .symtab
Symbols:
- Name: __llvm_covmap
Type: STT_SECTION
Section: __llvm_covmap
- Name: __llvm_prf_names
Type: STT_SECTION
Section: __llvm_prf_names
- Name: __covrec_92FEBEFF6DCBC98Au
Type: STT_OBJECT
Section: __llvm_covfun
Binding: STB_WEAK
Size: 0x17C
Other: [ STV_HIDDEN ]
- Name: __covrec_DB956436E78DD5FAu
Type: STT_OBJECT
Section: '__llvm_covfun (1)'
Binding: STB_WEAK
Size: 0x2F
Other: [ STV_HIDDEN ]
...