Giter Site home page Giter Site logo

rust-usdt's Introduction

rust-usdt

Inject USDT probes into rust code. Requires nightly.

Based on work done by Josh Stone [https://github.com/cuviper/rust-libprobe]

Build status

For more details, see documentation

Usage:

Cargo.toml:

[dependencies.rust-usdt]
git = "https://github.com/Fiedzia/rust-usdt"

in src/main.rs (as example, but you can insert probes in any place in your code)

#![feature(asm)]
#![feature(plugin)]
#![plugin(rust_usdt)]


fn main() {
    let a = 0i64;
	let b = 1i64;
    static_probe!(provider="foo", name="bar"; a,  i64, b, i64);
}

compile:

cargo build

Make sure probes were generated:

readelf -n ./target/debug/demo | grep NT_STAPSDT -A 4
  stapsdt              0x00000048       NT_STAPSDT (SystemTap probe descriptors)
    Provider: foo
    Name: bar
    Location: 0x000000000000741b, Base: 0x000000000003dc21, Semaphore: 0x0000000000000000
    Arguments: 8@-281(%rbp) 8@-289(%rbp)

Run bcc trace to trace them:

sudo /usr/share/bcc/tools/trace 'u:/home/maciej/git/rust-usdt/demo/demo1/target/debug/usdt_demo:bar "%d", arg1' 

PID    TID    COMM         FUNC             -
8163   8163   demo         bar              0

(you will need to run your app in separate terminal window to see the results)

rust-usdt's People

Contributors

fiedzia avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

rust-usdt's Issues

failed to build the demo

I got two errors when tried to build the demo and rust-usdt

error[E0557]: feature has been removed
  --> /root/src/github.com/rust-usdt/src/lib.rs:26:12
   |
26 | #![feature(quote, plugin_registrar, rustc_private)]
   |            ^^^^^ feature has been removed

error[E0463]: can't find crate for `syntax`
  --> /root/src/github.com/rust-usdt/src/lib.rs:29:1
   |
29 | extern crate syntax;
   | ^^^^^^^^^^^^^^^^^^^^ can't find crate

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0463, E0557.
For more information about an error, try `rustc --explain E0463`.
error: could not compile `rust-usdt`.

the version of rustc and cargo I'm using

# rustc --version
rustc 1.46.0-nightly (346aec9b0 2020-07-11)
# cargo --version
cargo 1.46.0-nightly (4f74d9b2a 2020-07-08)

All I did is following the instruction in the Readme, can anyone help?

Publish on crates.io

This doesn't seem to be available on crates.io yet -- is that intentional? It'd be awesome to publish this as, say, usdt, so that people could start using it in their applications :)

Q: Is the platform target really correct?

In mod platform, this is using #[cfg(target_os = "...)] to select the appropriate probe implementation.

However, AIUI compiler plugins are compiled for the host platform, since they have to be loaded in rustc, so this code will see target_os of the host. But this may be different than the target platform that you're generating code for, set by cargo build --target ....

So I suspect this is incorrect for cross-compilation. It probably should use some runtime condition to detect the target and select the probe implementation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.