#valgrind #callgrind #api-bindings #cachegrind #massif #helgrind

crabgrind

Rust bindings to "Valgrind Client Request" interface

3 releases

Uses old Rust 2015

0.1.11 Jul 20, 2024
0.1.10 Nov 1, 2023
0.1.9 Mar 26, 2023
0.1.8 Dec 14, 2022

#42 in Profiling

Download history 2156/week @ 2024-07-24 2119/week @ 2024-07-31 2206/week @ 2024-08-07 2061/week @ 2024-08-14 2256/week @ 2024-08-21 1937/week @ 2024-08-28 2106/week @ 2024-09-04 1965/week @ 2024-09-11 3003/week @ 2024-09-18 3957/week @ 2024-09-25 3082/week @ 2024-10-02 3371/week @ 2024-10-09 4544/week @ 2024-10-16 3593/week @ 2024-10-23 4137/week @ 2024-10-30 3863/week @ 2024-11-06

16,918 downloads per month
Used in 5 crates (4 directly)

MIT license

60KB
720 lines

crabgrind

Valgrind Client Request interface for Rust programs

crates.io libs.rs documentation license

crabgrind is a small library that enables Rust programs to tap into Valgrind's tools and virtualized environment.

Valgrind offers a "client request interface" that is accessible through C macros in its header files. However, these macros can’t be used in languages fortunate enough to lack C preprocessor support, such as Rust. To address this,crabgrind wraps those macros in C functions and expose this API via FFI.

Essentially, crabgrind acts as a thin wrapper. It adds some type conversions and structure, but all the real things are done by Valgrind itself.

Quickstart

crabgrind does not link against Valgrind but instead reads its header files, which must be accessible during build.

If you have installed Valgrind using OS-specific package manager, the paths to the headers are likely to be resolved automatically by cc.

In case of manual installation, you can set the path to the Valgrind headers location through the DEP_VALGRIND environment variable. For example:

DEP_VALGRIND=/usr/include cargo build

Next, add dependency to Cargo.toml

[dependencies]
crabgrind = "0.1"

Then, use some of Valgrind's API

use crabgrind as cg;

fn main() {
    if matches!(cg::run_mode(), cg::RunMode::Native) {
        println!("run me under Valgrind");
    } else {
        cg::println!("Hey, Valgrind!");
    }
}

and run under Valgrind

cargo build
valgrind ./target/debug/appname

and finally, for more details and code examples, be sure to check out the documentation.

License

crabgrind is distributed under MIT license.

Valgrind itself is a GPL2, however valgrind/*.h headers are distributed under a BSD-style license, so we can use them without worrying about license conflicts.

No runtime deps

~0–295KB