mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 10:11:27 +01:00
c/s a3a99df44 "docs/cmdline: Rewrite the cpuid_mask_* section" completely
forgot about how markdown gets rendered to HTML (as opposed to PDF), because
we use different translators depending on the destination format.
markdown and pandoc are very similar markup languages, but a couple of details
about pandoc cause it to have far more user-friendly inline markup.
Switch all markdown documents to be pandoc (so we are using a single
translator, and therefore a single flavour of markdown), which fixes the
rendered docs on xenbits.xen.org/docs.
While changing the format, fix the remainder of the escaped underscores in the
same mannor as the previous patch. The two problem cases here are __LINE__
and __FILE__ where the first underscore still needs escaping.
In addition, dmop.markdown and dom0less.markdown didn't used to get processed,
as only .markdown files in the misc/ directory got considered.
dom0less.pandoc gets picked up automatically now, due to being in the
features/ directory, but designs/ needs adding to the pandoc directory list
for dmop.pandoc to get processed.
While edting in appropriate areas, take the opportunity to fix some markup to
the surrounding style, and drop trailing whitespace.
No change in content - only formatting. This results in the text being easier
to read and grep.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
125 lines
3.7 KiB
Plaintext
125 lines
3.7 KiB
Plaintext
# Coverage support for Xen
|
|
|
|
Coverage support allows you to get coverage information from Xen execution.
|
|
You can see how many times a line is executed.
|
|
|
|
Some compilers have specific options that enable the collection of this
|
|
information. Every basic block in the code will be instrumented by the compiler
|
|
to compute these statistics. It should not be used in production as it slows
|
|
down your hypervisor.
|
|
|
|
# GCOV (GCC coverage)
|
|
|
|
## Enable coverage
|
|
|
|
Test coverage support can be turned on compiling Xen with the `CONFIG_COVERAGE`
|
|
option set to `y`.
|
|
|
|
Change your `.config` or run `make -C xen menuconfig`.
|
|
|
|
## Extract coverage data
|
|
|
|
To extract data you use a simple utility called `xencov`.
|
|
It allows you to do 2 operations:
|
|
|
|
* `xencov read` extract data
|
|
* `xencov reset` reset all coverage counters
|
|
|
|
Another utility (`xencov_split`) is used to split extracted data file into
|
|
files needed by userspace tools.
|
|
|
|
## Split coverage data
|
|
|
|
Once you extracted data from Xen, it is time to create files which the coverage
|
|
tools can understand. To do it you need to run `xencov_split` utility.
|
|
|
|
The utility just takes an input file and splits the blob into gcc .gcda files
|
|
in the same directory that you execute the script. As file names are generated
|
|
relative to the current directory, it could be a good idea to run the script
|
|
from `/` on your build machine.
|
|
|
|
Code for splitting the blob is put in another utility for some reason:
|
|
* It is simpler to maintain a high level script than a C program;
|
|
* You don't need to execute on the Xen host so you just need to copy the file to
|
|
your development box (you usually need development files anyway).
|
|
|
|
## Possible use
|
|
|
|
**This section is just an example on how to use these tools!**
|
|
|
|
This example assumes you compiled Xen from `~/xen-unstable` and installed into
|
|
the host. **Consider that if you even recompile Xen you are not able to use
|
|
blob extracted from xencov!**
|
|
|
|
* Ensure the `lcov` package is installed
|
|
* From the Xen host machine extract the coverage blob
|
|
|
|
cd /root
|
|
xencov read coverage.dat
|
|
|
|
* Copy the extracted blob to your dev machine
|
|
|
|
cd ~
|
|
scp root@myhost:coverage.dat
|
|
|
|
* Extract the coverage information
|
|
|
|
(cd / && xencov_split ~/coverage.dat)
|
|
|
|
* Produce coverage html output
|
|
|
|
cd ~/xen-unstable
|
|
rm -rf cov.info cov
|
|
geninfo -o cov.info xen
|
|
mkdir cov
|
|
genhtml -o cov cov.info
|
|
|
|
* See output in a browser
|
|
|
|
firefox cov/index.html
|
|
|
|
# LLVM coverage
|
|
|
|
## Enable coverage
|
|
|
|
Coverage can be enabled using a Kconfig option, from the top-level directory
|
|
use the following command to display the Kconfig menu:
|
|
|
|
make -C xen menuconfig clang=y
|
|
|
|
The code coverage option can be found inside of the "Debugging Options"
|
|
section. After enabling it just compile Xen as you would normally do:
|
|
|
|
make xen clang=y
|
|
|
|
## Extract coverage data
|
|
|
|
LLVM coverage can be extracted from the hypervisor using the `xencov` tool.
|
|
The following actions are available:
|
|
|
|
* `xencov read` extract data
|
|
* `xencov reset` reset all coverage counters
|
|
* `xencov read-reset` extract data and reset counters at the same time.
|
|
|
|
## Possible use
|
|
|
|
**This section is just an example on how to use these tools!**
|
|
|
|
This example assumes you compiled Xen and copied the xen-syms file from
|
|
xen/xen-syms into your current directory.
|
|
|
|
* Extract the coverage data from Xen:
|
|
|
|
xencov read xen.profraw
|
|
|
|
* Convert the data into a profile. Note that you can merge more than one
|
|
profraw file into a single profdata file.
|
|
|
|
llvm-profdata merge xen.profraw -o xen.profdata
|
|
|
|
* Generate a HTML report of the code coverage:
|
|
|
|
llvm-cov show -format=html -output-dir=cov/ xen-syms -instr-profile=xen.profdata
|
|
|
|
* Open cov/index.html with your browser in order to display the profile.
|