From 407e945ca0edb0029b1d06aa761a54c1c1b4413f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= Date: Tue, 26 Mar 2024 16:10:43 +0100 Subject: [PATCH] feat(examples): add rftrace-example MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Kröning --- .github/workflows/ci.yml | 9 ++++++++- Cargo.toml | 1 + examples/rftrace-example/Cargo.toml | 16 ++++++++++++++++ examples/rftrace-example/src/main.rs | 26 ++++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 examples/rftrace-example/Cargo.toml create mode 100644 examples/rftrace-example/src/main.rs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6067fc7ae..5dffb0f09 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,8 +17,11 @@ jobs: - uses: actions/checkout@v4 with: submodules: true + - uses: dtolnay/rust-toolchain@nightly + with: + components: rust-src - uses: mkroening/rust-toolchain-toml@main - - run: rustup component add clippy + - run: rustup component add clippy llvm-tools - name: Clippy run: | cargo clippy --all-targets @@ -43,7 +46,11 @@ jobs: - uses: actions/checkout@v4 with: submodules: true + - uses: dtolnay/rust-toolchain@nightly + with: + components: rust-src - uses: mkroening/rust-toolchain-toml@main + - run: rustup component add llvm-tools - name: Check docs run: cargo doc --no-deps --document-private-items diff --git a/Cargo.toml b/Cargo.toml index b24faee1b..f36477489 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,7 @@ members = [ "examples/miotcp", "examples/mioudp", "examples/polling", + "examples/rftrace-example", "examples/testtcp", "examples/testudp", "examples/tls", diff --git a/examples/rftrace-example/Cargo.toml b/examples/rftrace-example/Cargo.toml new file mode 100644 index 000000000..9d763702d --- /dev/null +++ b/examples/rftrace-example/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "rftrace-example" +version = "0.1.0" +authors = ["Martin Kröning "] +edition = "2021" +publish = false + +[dependencies] +rftrace = "0.2" +rftrace-frontend = "0.2" + +[target.'cfg(target_os = "hermit")'.dependencies] +hermit = { path = "../../hermit" } + +[features] +instrument-kernel = ["hermit/instrument"] diff --git a/examples/rftrace-example/src/main.rs b/examples/rftrace-example/src/main.rs new file mode 100644 index 000000000..d9f97cd89 --- /dev/null +++ b/examples/rftrace-example/src/main.rs @@ -0,0 +1,26 @@ +#[cfg(target_os = "hermit")] +use hermit as _; + +extern crate rftrace as _; +use rftrace_frontend as rftrace; + +fn main() { + let events = rftrace::init(2000, false); + rftrace::enable(); + f1(); + // Uhyve mounts at `/host`, virtiofsd mounts to `/root` + rftrace::dump_full_uftrace(events, "/root/tracedir", "rftrace-example").unwrap(); +} + +#[inline(never)] +fn f1() { + f2(); +} + +#[inline(never)] +fn f2() { + f3(); +} + +#[inline(never)] +fn f3() {}