You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reland "[llvm-cov] Support multi-source object files for convert-for-testing"
`llvm-cov convert-for-testing` only functions properly when the input binary contains a single source file. When the binary has multiple source files, a `Malformed coverage data` error will occur when the generated .covmapping is read back. This is because the testing format lacks support for indicating the size of its file records, and current implementation just assumes there's only one record in it. This patch fixes this problem by introducing a new testing format version.
Changes to the code:
- Add a new format version. The version number is stored in the the last 8 bytes of the orignial magic number field to be backward-compatible.
- Output a LEB128 number before the file records section to indicate its size in the new version.
- Change the format parsing code correspondingly.
- Update the document to formalize the testing format.
- Additionally, fix the bug when converting COFF binaries.
Reviewed By: phosek, gulfem
Differential Revision: https://reviews.llvm.org/D156611
Copy file name to clipboardExpand all lines: llvm/docs/CoverageMappingFormat.rst
+69-2Lines changed: 69 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -318,15 +318,15 @@ In version 2, the function record for *foo* was defined as follows:
318
318
Coverage Mapping Header:
319
319
------------------------
320
320
321
-
The coverage mapping header has the following fields:
321
+
As shown above, the coverage mapping header has the following fields:
322
322
323
323
* The number of function records affixed to the coverage header. Always 0, but present for backwards compatibility.
324
324
325
325
* The length of the string in the third field of *__llvm_coverage_mapping* that contains the encoded translation unit filenames.
326
326
327
327
* The length of the string in the third field of *__llvm_coverage_mapping* that contains any encoded coverage mapping data affixed to the coverage header. Always 0, but present for backwards compatibility.
328
328
329
-
* The format version. The current version is 4 (encoded as a 3).
329
+
* The format version. The current version is 6 (encoded as a 5).
330
330
331
331
.. _function records:
332
332
@@ -610,3 +610,70 @@ The source range record contains the following fields:
610
610
* *columnEnd*: The ending column of the mapping region. If the high bit is set,
611
611
the current mapping region is a gap area. A count for a gap area is only used
612
612
as the line execution count if there are no other regions on a line.
613
+
614
+
Testing Format
615
+
==============
616
+
617
+
.. warning::
618
+
This section is for the LLVM developers who are working on ``llvm-cov`` only.
619
+
620
+
``llvm-cov`` uses a special file format (called ``.covmapping`` below) for
621
+
testing purposes. This format is private and should have no use for general
622
+
users. As a developer, you can get such files by the ``convert-for-testing``
623
+
subcommand of ``llvm-cov``.
624
+
625
+
The structure of the ``.covmapping`` files follows:
626
+
627
+
``[magicNumber : u64, version : u64, profileNames, coverageMapping, coverageRecords]``
628
+
629
+
Magic Number and Version
630
+
------------------------
631
+
632
+
The magic is ``0x6d766f636d766c6c``, which is the ASCII string
633
+
``llvmcovm`` in little-endian.
634
+
635
+
There are two versions for now:
636
+
637
+
- Version1, encoded as ``0x6174616474736574`` (ASCII string ``testdata``).
638
+
- Version2, encoded as 1.
639
+
640
+
The only difference between Version1 and Version2 is in the encoding of the
641
+
``coverageMapping`` fields, which is explained later.
642
+
643
+
Profile Names
644
+
------------
645
+
646
+
``profileNames``, ``coverageMapping`` and ``coverageRecords`` are 3 sections
647
+
extracted from the original binary file.
648
+
649
+
``profileNames`` encodes the size, address and the raw data of the section:
0 commit comments