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
Copy file name to clipboardExpand all lines: src/doc/rustc/src/instrument-coverage.md
+14-24Lines changed: 14 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -119,29 +119,21 @@ If `LLVM_PROFILE_FILE` contains a path to a non-existent directory, the missing
119
119
120
120
LLVM's supplies two tools—`llvm-profdata` and `llvm-cov`—that process coverage data and generate reports. There are several ways to find and/or install these tools, but note that the coverage mapping data generated by the Rust compiler requires LLVM version 12 or higher. (`llvm-cov --version` typically shows the tool's LLVM version number.):
121
121
122
-
-The LLVM tools may be installed (or installable) directly to your OS (such as via `apt-get`, for Linux).
122
+
-You can install the LLVM tools from your operating system distribution, or from your distribution of LLVM.
123
123
- If you are building the Rust compiler from source, you can optionally use the bundled LLVM tools, built from source. Those tool binaries can typically be found in your build platform directory at something like: `rust/build/x86_64-unknown-linux-gnu/llvm/bin/llvm-*`.
124
-
- You can install compatible versions of these tools via `rustup`.
124
+
- You can install compatible versions of these tools via the `rustup` component `llvm-tools-preview`, though this is still considered experimental. In this case, you may also find `cargo-binutils` useful as a wrapper around these tools.
125
125
126
-
The `rustup` option is guaranteed to install a compatible version of the LLVM tools, but they can be hard to find. We recommend [`cargo-binutils`], which installs Rust-specific wrappers around these and other LLVM tools, so you can invoke them via `cargo` commands!
127
-
128
-
```shell
129
-
$ rustup component add llvm-tools-preview
130
-
$ cargo install cargo-binutils
131
-
$ cargo profdata -- --help # note the additional "--" preceding the tool-specific arguments
The examples in this document show how to use the llvm tools directly.
135
127
136
128
## Creating coverage reports
137
129
138
-
Raw profiles have to be indexed before they can be used to generate coverage reports. This is done using [`llvm-profdata merge`] (or `cargo profdata -- merge`), which can combine multiple raw profiles and index them at the same time:
130
+
Raw profiles have to be indexed before they can be used to generate coverage reports. This is done using [`llvm-profdata merge`], which can combine multiple raw profiles and index them at the same time:
Finally, the `.profdata` file is used, in combination with the coverage map (from the program binary) to generate coverage reports using [`llvm-cov report`] (or `cargo cov -- report`), for a coverage summaries; and [`llvm-cov show`] (or `cargo cov -- show`), to see detailed coverage of lines and regions (character ranges) overlaid on the original source code.
136
+
Finally, the `.profdata` file is used, in combination with the coverage map (from the program binary) to generate coverage reports using [`llvm-cov report`], for a coverage summaries; and [`llvm-cov show`], to see detailed coverage of lines and regions (character ranges) overlaid on the original source code.
145
137
146
138
These commands have several display and filtering options. For example:
147
139
@@ -218,19 +210,18 @@ test result: ok. 31 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
218
210
You should have one or more `.profraw` files now, one for each test binary. Run the `profdata` tool to merge them:
0 commit comments