From a2a1b4dbd277b2557976c3526640ccec33ce3980 Mon Sep 17 00:00:00 2001 From: Martin Geisler Date: Fri, 16 Jun 2023 15:28:46 +0200 Subject: [PATCH] Document `fuzzing_repro` in guide.md This is for https://github.com/rust-fuzz/cargo-fuzz/pull/344, assuming it gets merged. --- src/cargo-fuzz/guide.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/cargo-fuzz/guide.md b/src/cargo-fuzz/guide.md index b55e779..d1c5dc7 100644 --- a/src/cargo-fuzz/guide.md +++ b/src/cargo-fuzz/guide.md @@ -26,6 +26,15 @@ unsafe = ["project/unsafe"] Every crate instrumented for fuzzing -- the `fuzz_targets` crate, the project crate, and their entire dependency tree -- is compiled with the `--cfg fuzzing` rustc option. This makes it possible to disable code paths that prevent fuzzing from working, e.g. verification of cryptographic signatures, with a simple `#[cfg(not(fuzzing))]`, and without the need for an externally visible Cargo feature that must be maintained throughout every dependency. +## `#[cfg(fuzzing_repro)]` + +When you run `cargo fuzz `, every crate is compiled with the `--cfg fuzzing_repro` rustc option. This allows you to leave debugging statements in your fuzz targets behind a `#[cfg(fuzzing_repro)]`: + +```rust +#[cfg(fuzzing_repro)] +eprintln!("Input dat: {}", expensive_pretty_print(&data)); +``` + ## libFuzzer configuration options See all the libFuzzer options: