Macro probe::probe_lazy

source ·
macro_rules! probe_lazy {
    ($provider:ident, $name:ident $(, $arg:expr)* $(,)?) => { ... };
}
Expand description

Define a static probe point with lazy argument evaluation.

This annotates a code location with a name and arguments, and compiles in metadata to let debugging tools locate it. This works the same way as probe! except that arguments are only evaluated when a debugger or tracing tool is attached to the probe. However, if a platform implementation can’t determine that, it might always evaluate arguments.

Returns true if the probe is executed (and its arguments evaluated).

Example

let enabled = probe_lazy!(foo, main);
assert!(!enabled, "lazy probes only return true when they're active");

let mut z = 0;
probe_lazy!(foo, inc_z, { z += 1; z });
assert_eq!(z, 0, "arguments are not evaluated by default");