Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using the library in stable rust #9

Closed
tailhook opened this issue Feb 14, 2018 · 3 comments
Closed

Using the library in stable rust #9

tailhook opened this issue Feb 14, 2018 · 3 comments

Comments

@tailhook
Copy link

Is there any chance this kind of library be available for stable rust? It's ugly to use nightly just for adding USDT.

I don't know how this works internally to figure out way on my own. But maybe we can use some attributes like link_section for markers (or is it unstable too?). Or just use a piece of C code for embedding asm instead of using feature(asm) ?

@cuviper
Copy link
Owner

cuviper commented Feb 14, 2018

First off, I'm pleased that someone is still interested in this! 😄

Unfortunately, I don't see a real path forward without feature(asm). There's more to it than just declaring a section, especially all the content of that note. Some of it could be generated in a static byte array, but the probe address currently references a asm label. I don't know how you'd do that without the assembler and linker's cooperation.

You could do a bit of external C code already, using the original sdt.h in a function that Rust can call as FFI, but that means having a function call for every probe even when disabled. Maybe LTO could inline that -- I'm not sure.

There's an alternate rust-usdt which is a compiler plugin instead, but that's a nightly feature too, and it still needs feature(asm). See also their post on internals:
https://internals.rust-lang.org/t/tracing-in-rust-with-uprobes/4756

@No9
Copy link

No9 commented Apr 3, 2018

@tailhook FYI I put together a sample to show how you wrap a C based USDT probe into a rust stable build
https://github.com/No9/rust-usdt-helloworld
It works but the flow has a few edges.

@cuviper
Copy link
Owner

cuviper commented Jan 14, 2022

Per #15, this now works on beta without unstable features, so it will be stable in Rust 1.59!

@cuviper cuviper closed this as completed Apr 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants