Macro usdt::dtrace_provider [−][src]
dtrace_provider!() { /* proc-macro */ }
Generate DTrace probe macros from a provider definition file.
This macro parses a DTrace provider.d file, given as a single literal string path. It then generates a Rust macro for each of the DTrace probe definitions.
For example, let’s say the file "test.d"
has the following contents:
provider test { probe start(uint8_t); probe stop(char *, uint8_t); };
In a Rust library or application, write:
dtrace_provider!("test.d");
The macro looks for the file relative to the root of the package, so "test.d"
in this case would be in the same directory as "Cargo.toml"
.
By default probe macros are named {provider}_{probe}!
. Arguments are passed
via a closure that returns a tuple. Note that the provided closure is only
evaluated when the probe is enabled. One can then add points of instrumentation
by invoking the macro:
fn do_stuff(count: u8, name: String) { // doing stuff test_stop!(|| (name, count)); }
The probe macro names can be customized by adding , format = my_prefix_{provider}_{probe}
to the macro invocation where {provider}
and
{probe}
are optional and will be substituted with the actual provider and
probe names:
dtrace_provider!("test.d", format = "dtrace_{provider}_{probe}");
Note
The only supported types are integers of specific bit-width (e.g., uint16_t
) and char *
.