Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions dynamic_instrumentation/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
```sh
cargo run -- analysis_metadata.bc ../analysis/tests/misc/src/main.rs -L ~/.rustup/toolchains/nightly-2022-02-14-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/ -L ../target/debug/deps/ --extern c2rust_analysis_rt=../target/debug/deps/libc2rust_analysis_rt-4c5a3dcb09c8161c.rlib
INSTRUMENT_BACKEND=debug METADATA_FILE=analysis_metadata.bc ./main
cargo build
${CARGO_TARGET_DIR:-../target/debug/c2rust-instrument} --metadata instrument.target/debug/metadata.bc -- build --manifest-path analysis/tests/misc/Cargo.toml
(cd analysis/tests/misc/instrument.target/debug; INSTRUMENT_BACKEND=debug INSTRUMENT_RUNTIME=bg METADATA_FILE=metadata.bc ./c2rust-analysis-tests-misc)
Comment on lines +3 to +4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this still might be broken, which is why I hadn't approved it earlier. The ${CARGO_TARGET_DIR:-../target/debug/c2rust-instrument} assumes the cwd is dynamic_instrumentation/ (I think, or at least some other directory), but analysis/tests/misc/Cargo.toml is relative to the repo root. Also, I don't remember if --metadata is supposed to be relative to the cwd or to the manifest dir.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed a fix that works correctly with the repo root as cwd. Even when building the entire repo with cargo build in the repo root, c2rust-instrument ends up in the debug subdir of the cargo target directory; the other commands already expected to be there.

--metadata is relative to the cwd, which does mean that we need it to include the base path of the Cargo.toml.

```

This instruments the binary built from main.rs with dynamic memory tracing, and
outputs the necessary metadata to match up instrumentation points to source code
into `analysis_metadata.bc`. We then run the binary, printing output to the
into `metadata.bc`. We then run the binary, printing output to the
debug console and using the aformentioned metadata file.