probe-0.5.1/.cargo_vcs_info.json0000644000000001360000000000100121460ustar { "git": { "sha1": "884250f0013de5de56b6252d5bcb5dbb7919d049" }, "path_in_vcs": "" }probe-0.5.1/.gitignore000064400000000000000000000000331046102023000127220ustar 00000000000000/doc/ /target/ /Cargo.lock probe-0.5.1/AUTHORS.txt000064400000000000000000000000401046102023000126160ustar 00000000000000Josh Stone probe-0.5.1/Cargo.lock0000644000000002250000000000100101200ustar # This file is automatically @generated by Cargo. # It is not intended for manual editing. version = 3 [[package]] name = "probe" version = "0.5.1" probe-0.5.1/Cargo.toml0000644000000016060000000000100101470ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies. # # If you are reading this file be aware that the original Cargo.toml # will likely look very different (and much more reasonable). # See Cargo.toml.orig for the original contents. [package] edition = "2021" rust-version = "1.66" name = "probe" version = "0.5.1" authors = ["Josh Stone "] exclude = ["/.github/**"] description = "Static instrumentation probes" homepage = "https://github.com/cuviper/probe-rs" documentation = "https://docs.rs/probe/" readme = "README.md" license = "Apache-2.0 OR MIT" repository = "https://github.com/cuviper/probe-rs" [lib] name = "probe" crate-type = ["rlib"] probe-0.5.1/Cargo.toml.orig000064400000000000000000000006361046102023000136320ustar 00000000000000[package] name = "probe" version = "0.5.1" authors = ["Josh Stone "] description = "Static instrumentation probes" documentation = "https://docs.rs/probe/" homepage = "https://github.com/cuviper/probe-rs" repository = "https://github.com/cuviper/probe-rs" license = "Apache-2.0 OR MIT" edition = "2021" rust-version = "1.66" exclude = ["/.github/**"] [lib] name = "probe" crate-type = ["rlib"] probe-0.5.1/LICENSE-APACHE000064400000000000000000000251371046102023000126720ustar 00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. probe-0.5.1/LICENSE-MIT000064400000000000000000000020571046102023000123760ustar 00000000000000Copyright (c) 2014 The Rust Project Developers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. probe-0.5.1/README.md000064400000000000000000000033741046102023000122240ustar 00000000000000# probe: Static probes for Rust [![probe crate](https://img.shields.io/crates/v/probe.svg)](https://crates.io/crates/probe) ![minimum rustc 1.66](https://img.shields.io/badge/rustc-1.66+-red.svg) [![probe documentation](https://docs.rs/probe/badge.svg)](https://docs.rs/probe) [![build status](https://github.com/cuviper/probe-rs/workflows/CI/badge.svg)](https://github.com/cuviper/probe-rs/actions) With the `probe!` macro, programmers can place static instrumentation points in their code to mark events of interest. These are compiled into platform-specific implementations, e.g. SystemTap SDT on Linux. Probes are designed to have negligible overhead during normal operation, so they can be present in all builds, and only activated using those external tools. [Documentation](https://docs.rs/probe/) ## Using probe [`probe!` is available on crates.io](https://crates.io/crates/probe). The recommended way to use it is to add a line into your Cargo.toml such as: ```toml [dependencies] probe = "0.5" ``` Then `use probe::probe;` in your code and insert macro calls wherever you want to mark something, `probe!(provider, name, args...)`. The `provider` and `name` are identifiers of your choice, and any additional arguments are runtime expressions that will be cast `as isize` for the probe consumer to read. There is also a `probe_lazy!` variant that tries to avoid evaluating the argument expressions when probes aren't in use, if the platform-specific implementation allows that to be determined. ## License `probe` is distributed under the terms of both the MIT license and the Apache License (Version 2.0). See [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT) for details. Opening a pull request is assumed to signal agreement with these licensing terms. probe-0.5.1/examples/loop.rs000064400000000000000000000003271046102023000140750ustar 00000000000000use probe::probe; fn main() { probe!(foo, begin); let mut total = 0; for i in 0..100 { total += i; probe!(foo, loop, i, total); } assert_eq!(total, 4950); probe!(foo, end); } probe-0.5.1/examples/semaphore.rs000064400000000000000000000007511046102023000151100ustar 00000000000000use probe::probe_lazy; fn main() { let mut iter = 0; loop { iter += 1; probe_lazy!(foo, iter, { // This delay is an exaggeration of the overhead of a probe argument, but it's only // incurred while something is attached to the probe, thanks to the semaphore. std::thread::sleep(std::time::Duration::from_secs(1)); iter }); } } // bcc/tools/trace.py -p $(pidof semaphore) 'u::foo:iter "iter = %d", arg1' probe-0.5.1/src/lib.rs000064400000000000000000000107331046102023000126450ustar 00000000000000//! This crate provides static instrumentation macros. //! //! With the `probe!` macro, programmers can place static instrumentation //! points in their code to mark events of interest. These are compiled into //! platform-specific implementations, e.g. SystemTap SDT on Linux. Probes are //! designed to have negligible overhead during normal operation, so they can //! be present in all builds, and only activated using those external tools. //! //! # Example //! //! This simple example instruments the beginning and end of program, as well //! as every iteration through the loop with arguments for the counter and //! intermediate total. //! //! ```rust //! use probe::probe; //! fn main() { //! probe!(foo, begin); //! let mut total = 0; //! for i in 0..100 { //! total += i; //! probe!(foo, loop, i, total); //! } //! assert_eq!(total, 4950); //! probe!(foo, end); //! } //! ``` //! //! ## Using probes with SystemTap //! //! For the program above, a SystemTap script could double-check the totals: //! //! ```notrust //! global check //! //! probe process.provider("foo").mark("loop") { //! check += $arg1; //! if (check != $arg2) //! printf("foo total is out of sync! (%d != %d)\n", check, $arg2); //! } //! //! // .provider is optional //! probe process.mark("begin"), process.mark("end") { //! printf("%s:%s\n", $$provider, $$name); //! } //! ``` //! //! Since this program behaves as expected, this script will not have any complaint. //! //! ```notrust //! $ stap --dyninst foo.stp -c ./foo //! foo:begin //! foo:end //! ``` //! //! ## Using probes with GDB //! //! Starting in version 7.5, GDB can set breakpoints on probes and read arguments. //! //! ```notrust //! (gdb) info probes //! Provider Name Where Semaphore Object //! foo begin 0x0000000000402e70 /tmp/foo //! foo end 0x000000000040315c /tmp/foo //! foo loop 0x0000000000402f25 /tmp/foo //! (gdb) break -probe foo:loop //! Breakpoint 1 at 0x402f25 //! (gdb) condition 1 $_probe_arg1 > 1000 //! (gdb) run //! Starting program: /tmp/foo //! [Thread debugging using libthread_db enabled] //! Using host libthread_db library "/lib64/libthread_db.so.1". //! //! Breakpoint 1, 0x0000000000402f25 in main::hd67360886023c1c6faa::v0.0 () //! (gdb) print $_probe_arg0 //! $1 = 45 //! (gdb) print $_probe_arg1 //! $2 = 1035 //! ``` #![no_std] mod platform; /// Define a static probe point. /// /// This annotates a code location with a name and arguments, and compiles /// in metadata to let debugging tools locate it. /// /// # Arguments /// /// * `provider` - An identifier for naming probe groups. /// /// * `name` - An identifier for this specific probe. /// /// * `arg`... - Optional data to provide with the probe. Any expression which /// can be cast `as isize` is allowed as an argument. The arguments are always /// evaluated, even on platforms that have a no-op implementation of probes. /// /// # Example /// /// ``` /// # use probe::probe; /// // Probes are unit-typed expressions. /// let () = probe!(foo, main); /// /// let x = 42; /// probe!(foo, show_x, x); /// /// let y = Some(x); /// probe!(foo, show_y, match y { /// Some(n) => n, /// None => -1 /// }); /// /// let mut z = 0; /// probe!(foo, inc_z, { z += 1; z }); /// assert_eq!(z, 1, "arguments are always evaluated"); /// ``` #[macro_export] macro_rules! probe( ($provider:ident, $name:ident $(, $arg:expr)* $(,)?) => ($crate::platform_probe!($provider, $name, $($arg,)*)); ); /// Define a static probe point with lazy argument evaluation. /// /// This annotates a code location with a name and arguments, and compiles /// in metadata to let debugging tools locate it. This works the same way as /// [`probe!`] except that arguments are only evaluated when a debugger or /// tracing tool is attached to the probe. However, if a platform implementation /// can't determine that, it might always evaluate arguments. /// /// Returns `true` if the probe is executed (and its arguments evaluated). /// /// # Example /// /// ``` /// # use probe::probe_lazy; /// let enabled = probe_lazy!(foo, main); /// assert!(!enabled, "lazy probes only return true when they're active"); /// /// let mut z = 0; /// probe_lazy!(foo, inc_z, { z += 1; z }); /// assert_eq!(z, 0, "arguments are not evaluated by default"); /// ``` #[macro_export] macro_rules! probe_lazy( ($provider:ident, $name:ident $(, $arg:expr)* $(,)?) => ($crate::platform_probe_lazy!($provider, $name, $($arg,)*)); ); probe-0.5.1/src/platform/default.rs000064400000000000000000000007541046102023000153510ustar 00000000000000#[doc(hidden)] #[macro_export] macro_rules! platform_probe( ($provider:ident, $name:ident, $($arg:expr,)*) => ({ // Non-lazy probes always evaluate the arguments. let _ = ($($arg,)*); }) ); #[doc(hidden)] #[macro_export] macro_rules! platform_probe_lazy( ($provider:ident, $name:ident, $($arg:expr,)*) => ({ // Expand the arguments so they don't cause unused warnings. if false { let _ = ($($arg,)*); } false }) ); probe-0.5.1/src/platform/mod.rs000064400000000000000000000002221046102023000144720ustar 00000000000000#[cfg(any(target_os = "linux", target_os = "android"))] mod systemtap; #[cfg(not(any(target_os = "linux", target_os = "android")))] mod default; probe-0.5.1/src/platform/systemtap.rs000064400000000000000000000127551046102023000157620ustar 00000000000000//! SystemTap static probes //! //! This is a mechanism for developers to provide static annotations for //! meaningful points in code, with arguments that indicate some relevant //! state. Such locations may be probed by SystemTap `process.mark("name")`, //! and GDB can also locate them with `info probes` and `break -probe name`. //! //! The impact on code generation is designed to be minimal: just a single //! `NOP` placeholder is added inline for instrumentation, and ELF notes //! contain metadata to name the probe and describe the location of its //! arguments. //! //! # Links: //! //! * (see `process.mark`) //! * //! * //! * // // DEVELOPER NOTES // // Arguments are currently type-casted as isize for the supposed maximum // register size, whereas SystemTap's long is i64 no matter the architecture. // However, if we could figure out types here, they could be annotated more // specifically, for example an argstr of "4@$0 -2@$1" indicates u32 and i16 // respectively. Any pointer would be fine too, like *c_char, simply 4@ or 8@ // for target_word_size. // // The macros in sdt.h don't know types either, so they split each argument // into two asm inputs, roughly: // asm("[...]" // ".asciz \"%n[_SDT_S0]@%[_SDT_A0]\"" // "[...]" // : : // [_SDT_S0] "n" ((_SDT_ARGSIGNED (x) ? 1 : -1) * (int) sizeof (x)), // [_SDT_A0] "nor" (x) // ); // where _SDT_ARGSIGNED is a macro using gcc builtins, so it's still resolved a // compile time, and %n makes it a raw literal rather than an asm number. // // This might be a possible direction for Rust SDT to follow. For LLVM // InlineAsm, the string would look like "${0:n}@$1", but we need the size/sign // for that first input, and that must be a numeric constant no matter what // optimization level we're at. With Rust RFC 2850 `asm!`, it might be possible // to use positional `{}@{}` with a `const` operand for the size, but calling // things like `mem::size_of::()` is still hard when we don't know `T`. // // FIXME semaphores - SDT can define a short* that debuggers will increment when // they attach, and decrement on detach. Thus a `probe_enabled!(provider,name)` // could return if that value != 0, to be used similarly to log_enabled!(). It // is difficult with mangling and macro hygene to connect two `probe!` and // `probe_enabled!` calls to the same symbol, unless we forced `#[no_mangle]`. // For now, we only use semaphores in `probe_lazy!` to skip argument evaluation // when there's nobody attached to see the probe. // #[doc(hidden)] #[macro_export] macro_rules! platform_probe( ($provider:ident, $name:ident, $($arg:expr,)*) => ({ $crate::sdt!([sym 0], $provider, $name, $($arg,)*); }) ); #[doc(hidden)] #[macro_export] macro_rules! platform_probe_lazy( ($provider:ident, $name:ident, $($arg:expr,)*) => ({ #[link_section = ".probes"] static mut SEMAPHORE: u16 = 0; let enabled = unsafe { ::core::ptr::read_volatile(&SEMAPHORE) } != 0; if enabled { $crate::sdt!([sym "{}" SEMAPHORE], $provider, $name, $($arg,)*); } enabled }) ); // Since we can't #include , we have to reinvent it... // but once you take out the C/C++ type handling, there's not a lot to it. #[doc(hidden)] #[macro_export] macro_rules! sdt( ([sym $symstr:literal $($sym:ident)?], $provider:ident, $name:ident, $($arg:expr,)* ) => ( #[cfg(any(target_arch = "x86_64", target_arch = "x86"))] $crate::sdt!([sym $symstr $($sym)?, opt att_syntax], $provider, $name, $($arg,)*); #[cfg(not(any(target_arch = "x86_64", target_arch = "x86")))] $crate::sdt!([sym $symstr $($sym)?, opt], $provider, $name, $($arg,)*); ); ([sym $symstr:literal $($sym:ident)?, opt $($opt:ident)?], $provider:ident, $name:ident, $($arg1:expr, $($arg:expr,)*)? ) => ( #[cfg(target_pointer_width = "32")] $crate::sdt!([sym $symstr $($sym)?, opt $($opt)?, size 4], $provider, $name, $("-4@{}", $arg1, $(" -4@{}", $arg,)*)?); #[cfg(target_pointer_width = "64")] $crate::sdt!([sym $symstr $($sym)?, opt $($opt)?, size 8], $provider, $name, $("-8@{}", $arg1, $(" -8@{}", $arg,)*)?); ); ([sym $symstr:literal $($sym:ident)?, opt $($opt:ident)?, size $size:literal], $provider:ident, $name:ident, $($argstr:literal, $arg:expr,)* ) => (unsafe { ::core::arch::asm!(concat!(r#" 990: nop .pushsection .note.stapsdt,"?","note" .balign 4 .4byte 992f-991f, 994f-993f, 3 991: .asciz "stapsdt" 992: .balign 4 993: ."#, $size, r#"byte 990b ."#, $size, r#"byte _.stapsdt.base ."#, $size, r#"byte "#, $symstr, r#" .asciz ""#, stringify!($provider), r#"" .asciz ""#, stringify!($name), r#"" .asciz ""#, $($argstr,)* r#"" 994: .balign 4 .popsection .ifndef _.stapsdt.base .pushsection .stapsdt.base,"aG","progbits",.stapsdt.base,comdat .weak _.stapsdt.base .hidden _.stapsdt.base _.stapsdt.base: .space 1 .size _.stapsdt.base, 1 .popsection .endif"#), $(sym $sym,)? $(in(reg) ($arg) as isize,)* options(readonly, nostack, preserves_flags $(, $opt)?), ) }); ); probe-0.5.1/tests/readelf.rs000064400000000000000000000016301046102023000140500ustar 00000000000000#![cfg(any(target_os = "linux", target_os = "android"))] use probe::probe; use std::env; use std::process::Command; #[test] fn check_notes() { // First let's create probes with and without arguments probe!(test, foo); probe!(test, bar, 42); // Now make sure readelf can find "stapsdt" ELF notes in this test executable let test_exe = env::current_exe().unwrap(); let output = Command::new("readelf") .arg("-n") .arg(&test_exe) .output() .unwrap(); assert!(output.status.success()); for error in String::from_utf8_lossy(&output.stderr).lines() { if error.contains("Warning: Gap in build notes detected") { continue; } panic!("{}", error); } let count = String::from_utf8_lossy(&output.stdout) .lines() .filter(|line| line.contains("NT_STAPSDT")) .count(); assert_eq!(count, 2); }