Macro usdt::dtrace_provider[][src]

dtrace_provider!() { /* proc-macro */ }

Parse a DTrace provider file into Rust code.

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. This is a simple way of generating Rust code that can be called normally, but which ultimately hooks up to DTrace probe points.

For example, assume 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");

One can then instrument the application or library as one might expect:

fn do_stuff(count: u8, name: String) {
    // doing stuff
    test_stop!(|| (name, count));
}

Note

This macro currently supports only a subset of the full D language, with the focus being on parsing a provider definition. As such, predicates and actions are not supported. Integers of specific bit-width, e.g., uint16_t, and char * are supported.