Macro probe::probe

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

Define a static probe point.

This annotates a code location with a name and arguments, and compiles in metadata to let debugging tools locate it.

Arguments

  • provider - An identifier for naming probe groups.

  • name - An identifier for this specific probe.

  • arg… - Optional data to provide with the probe. Any expression which can be cast as isize is allowed as an argument. The arguments are always evaluated, even on platforms that have a no-op implementation of probes.

Example

// Probes are unit-typed expressions.
let () = probe!(foo, main);

let x = 42;
probe!(foo, show_x, x);

let y = Some(x);
probe!(foo, show_y, match y {
    Some(n) => n,
    None    => -1
});

let mut z = 0;
probe!(foo, inc_z, { z += 1; z });
assert_eq!(z, 1, "arguments are always evaluated");