---
title: Coverage
description: Generate LCOV coverage from SBF register traces.
---
`$ anchor coverage` maps executed SBF program counters back to Rust source lines and emits LCOV. Run it from inside a program directory. Pass `--skip-run` to reuse an existing trace set, or `--trace-dir` to read or write traces from a custom directory.
```console showLineNumbers=false
$ cd programs/counter
$ anchor coverage
```
By default, output lands at:
```text showLineNumbers=false
target/coverage/sbf.lcov
```
## Options
Useful flags:
| Flag | Effect |
| --- | --- |
| `--skip-run` | Reuse existing traces. |
| `--skip-build` | Skip `$ cargo build-sbf` when deploy artifacts are already fresh. |
| `--output ` | Write LCOV somewhere other than `target/coverage/sbf.lcov{:file}`. |
| `--trace-dir ` | Read or write traces from a custom directory. |
Coverage uses the same underlying trace data as profiling and debugger, so the same test-harness requirement applies. Tests should call `anchor_v2_testing::svm(){:rs}`.
## DWARF
The command builds programs with DWARF debug info so `addr2line` can resolve PCs to source. If source lines are missing, make sure the deploy `.so{:file}` exists and was built by the same source tree that produced the traces.