Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Commit

Permalink
add srcview crate (#1142)
Browse files Browse the repository at this point in the history
  • Loading branch information
jopletchMSFT authored Aug 11, 2021
1 parent f6923f9 commit 332dfd9
Show file tree
Hide file tree
Showing 18 changed files with 1,645 additions and 39 deletions.
132 changes: 93 additions & 39 deletions src/agent/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/agent/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ members = [
"onefuzz-supervisor",
"onefuzz-telemetry",
"reqwest-retry",
"srcview",
"storage-queue",
"win-util",
"libclusterfuzz",
Expand Down
18 changes: 18 additions & 0 deletions src/agent/srcview/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "srcview"
version = "0.1.0"
edition = "2018"
license = "MIT"

[features]
# Feature to gate tests that depend on binary artifacts, should be removed when
# #1143 is resolved.
binary-tests = []

[dependencies]
log = "0.4"
nom = "6"
pdb = "0.7"
regex = "1"
serde = { version = "1", features = ["derive"] }
xml-rs = "0.8"
34 changes: 34 additions & 0 deletions src/agent/srcview/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# srcview

A library for mapping module+offset to source:line. Note that you'll get
significantly better results if you use instruction level coverage as
opposed to branch. Alternatively you're welcome to post-process branch
coverage into instruction, but this project does not assist with that.

## Docs

`cargo doc --open`

## Usage

See [`examples/dump_cobertura.rs`](examples/dump_cobertura.rs).

This can be run with `cargo run --example dump_cobertura res\example.pdb res\example.txt`.

The biggest challenge when making this work is likely getting the absolute PDB
paths to match relative paths inside your repo. To make this a bit easier, you
can dump the PDB paths with: `cargo run --example dump_paths res\example.pdb`

## ADO Integration

See [`azure-pipelines.yml`](azure-pipelines.yml).

## VSCode Integration

Install [Coverage Gutters](https://marketplace.visualstudio.com/items?itemName=ryanluker.vscode-coverage-gutters),
then place a file named `coverage.xml` at a location such that the relative
file paths match your repo. Note that this is a file you should generate
yourself, and that the `coverage.xml` included in this repo will probably not
help you. From there, navigate to any file you expect to see coverage in. If
the paths and coverage file correctly line up, you should see red or green bars
next to the source lines.
6 changes: 6 additions & 0 deletions src/agent/srcview/TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# TODO
- add trace/info/warn
- flesh out modoff parser error
- consider using Cow to reduce memory usage
- consider mixed case module names?
- redo xml generation to not be hand-rolled
Loading

0 comments on commit 332dfd9

Please sign in to comment.