{"id":33935830,"url":"https://github.com/2dav/crabgrind","last_synced_at":"2026-04-04T12:57:49.667Z","repository":{"id":64309069,"uuid":"574791090","full_name":"2dav/crabgrind","owner":"2dav","description":"\"Valgrind Client Request\" interface for Rust programs","archived":false,"fork":false,"pushed_at":"2026-01-23T11:07:00.000Z","size":195,"stargazers_count":18,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-01-24T03:19:14.714Z","etag":null,"topics":["bindings","cachegrind","callgrind","ffi","helgrind","massif","performance-analysis","profiling","valgrind"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/2dav.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE/MIT.LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-12-06T04:32:23.000Z","updated_at":"2026-01-23T10:52:35.000Z","dependencies_parsed_at":"2023-09-25T07:13:19.344Z","dependency_job_id":"575374e3-9119-4f1d-80d6-1331b184ddfc","html_url":"https://github.com/2dav/crabgrind","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/2dav/crabgrind","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2dav%2Fcrabgrind","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2dav%2Fcrabgrind/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2dav%2Fcrabgrind/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2dav%2Fcrabgrind/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/2dav","download_url":"https://codeload.github.com/2dav/crabgrind/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2dav%2Fcrabgrind/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31400460,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-04T10:20:44.708Z","status":"ssl_error","status_checked_at":"2026-04-04T10:20:06.846Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bindings","cachegrind","callgrind","ffi","helgrind","massif","performance-analysis","profiling","valgrind"],"created_at":"2025-12-12T14:02:40.416Z","updated_at":"2026-04-04T12:57:49.634Z","avatar_url":"https://github.com/2dav.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv style=\"text-align: center;\" align=\"center\"\u003e\n\n# `crabgrind`\n\n### [Valgrind Client Request][vg-client.req] interface for Rust\n\n[![crates.io](https://img.shields.io/crates/v/crabgrind)][crates.io]\n[![libs.rs](https://img.shields.io/badge/libs.rs-crabgrind-orange)][libs.rs]\n[![documentation](https://img.shields.io/docsrs/crabgrind)][documentation]\n[![license](https://img.shields.io/crates/l/crabgrind)][license]\n\n\u003c/div\u003e\n\n## Summary\n\n`crabgrind` is a small library that enables Rust programs to tap into\nValgrind's tools and environment.\n\nIt exposes full set of [Valgrind's client requests][vg-client.req] in Rust,\nmanages the structure, type conversions and enforces static typing where\npossible.\n\n## Usage\n\n**Minimum Supported Rust Version:** 1.64\n\nFirst, add `crabgrind` as a dependency in `Cargo.toml`\n\n```toml\n[dependencies]\ncrabgrind = \"0.2\"\n```\n\n\u003e Note: This crate is `no_std` and dependency-free\n\n### Build Configuration\n\nThe crate needs access to a local Valgrind installation(or at least its headers)\nin order to read C macro definitions, constants, and supported requests.\n\nThe build script (`build.rs`) attempts to locate headers in this order:\n\n1. **Environment Variable:** If `VALGRIND_INCLUDE` is set, it's value is added\n   to the search paths.\n1. **pkg-config:** The system is queried via `pkg-config`.\n1. **Compiler defaults:** No additional include paths are provided, and the\n   compiler’s default include paths are used.\n\nIf headers cannot be located, the crate will still compile without errors,\nhowever any request will panic at runtime.\n\n### Example\n\nUse some of the [Client Requests][crabgrind.modules]:\n\n```rust, no_run\nuse crabgrind::valgrind::{running_mode, RunningMode};\n\nfn main() {\n    assert_eq!(\n        running_mode(), RunningMode::Valgrind,\n        \":~$ valgrind {}\", std::env::current_exe().unwrap().display()\n    );\n\n    crabgrind::println!(\"Hey, Valgrind!\");\n}\n```\n\nAnd run under Valgrind\n\n\u003e ```bash\n\u003e :~$ cargo build\n\u003e :~$ valgrind ./target/debug/app\n\u003e ```\n\n## Features\n\nIf you need your builds to be free of Valgrind artifacts, enable the `opt-out`\nfeature. This turns every request into no-op.\n\n\u003e ```toml\n\u003e crabgrind = { version = \"0.2\", features = [\"opt-out\"] }\n\u003e ```\n\n## More Examples\n\n- [Valgrind: Deterministic regression testing(e.g. CI or unit tests)](https://docs.rs/crabgrind/latest/crabgrind/valgrind/fn.count_errors.html#example)\n- [Callgrind: Profiling specific code blocks in isolation](https://docs.rs/crabgrind/latest/crabgrind/callgrind/fn.toggle_collect.html#example)\n- [Callgrind: Clearing setup costs to isolate some operation](https://docs.rs/crabgrind/latest/crabgrind/callgrind/fn.zero_stats.html#example)\n- [Memcheck: Checking for memory leaks at runtime(e.g. CI or unit tests)](https://docs.rs/crabgrind/latest/crabgrind/memcheck/fn.leak_check.html#example)\n- [Memcheck: Enforcing bounds in a custom allocator](https://docs.rs/crabgrind/latest/crabgrind/memcheck/fn.mark_memory.html#example)\n- [Memcheck: Checking for memory 'definedness' feat. MaybeUninit](https://docs.rs/crabgrind/latest/crabgrind/memcheck/fn.check_mem_defined.html#example)\n- [DHAT: Tracking data volumes](https://docs.rs/crabgrind/latest/crabgrind/dhat/fn.ad_hoc_event.html#example)\n- [DRD: Tracking races in a custom shared memory](https://docs.rs/crabgrind/latest/crabgrind/drd/fn.annotate_new_memory.html#example)\n- [DRD: Tracing memory accesses over some memory](https://docs.rs/crabgrind/latest/crabgrind/drd/fn.trace_var.html#example)\n\n## Implementation\n\n[Valgrind's client request][vg-client.req] mechanism is a C implementation\ndetail, exposed strictly via C macros. Since Rust does not support C\npreprocessor, these macros cannot be used directly.\n\n`crabgrind` wraps the foundational `VALGRIND_DO_CLIENT_REQUEST_EXPR` macro via\nFFI binding. All higher-level client requests are implemented in Rust on top of\nthis binding.\n\nThe overhead per request, compared to using C macros directly is strictly the\ncost of a single function call.\n\nThe implementation is independent of any specific Valgrind version. Instead,\nmismatches between requests and local Valgrind instance are handled at\ncompile-time.\n\n## Runtime Behavior\n\nWe are coupled to the Valgrind version present during compilation.\n\nIf a request is invoked at runtime that is unsupported by the active Valgrind\ninstance (e.g. running under an older Valgrind), the call panics immediately,\nshowing the version mismatch message and request requirements.\n\nIf your application is running **without** Valgrind, these\nrequests execute as harmless machine code. They will not panic or segfault, and\noverhead is probably undetectable except in a tight loops.\n\n## License\n\n`crabgrind` is distributed under `MIT` license.\n\n`Valgrind` itself is a GPL3, however `valgrind/*.h` headers are distributed\nunder a BSD-style license, so we can use them without worrying about license\nconflicts.\n\n[crabgrind.modules]: https://docs.rs/crabgrind/latest/crabgrind/#modules\n[crates.io]: https://crates.io/crates/crabgrind\n[documentation]: https://docs.rs/crabgrind\n[libs.rs]: https://lib.rs/crates/crabgrind\n[license]: https://github.com/2dav/crabgrind/blob/main/LICENSE/MIT.LICENSE\n[vg-client.req]: https://valgrind.org/docs/manual/manual-core-adv.html#manual-core-adv.clientreq\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F2dav%2Fcrabgrind","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F2dav%2Fcrabgrind","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F2dav%2Fcrabgrind/lists"}