reverie/safeptrace
Andres Suarez 859e996c28 Apply rustc fixes
Summary:
Basically `arc lint -e extra --take RUSTFIX --apply-patches` over all of
fbcode. Actually done with
`fbcode/common/rust/tools/rustfix2/scripts/rustfix_codemod`.

Some of these fixes don't actually convey the intent of the code, but I
am applying them anyway because they've been outstanding forever. This
diff actually fixes all machine fixable rustfix issues.

Manual changes:

- `fbcode/security/tools/sush2/src/lib/tw.rs` because the pattern match
  on a variable is not a thing. (There's a good Learning Rust question
  with a good answer on this)
- `fbcode/zippydb/lib/rust/rodos/lib.rs` needed the `#[cfg(test)]`,
  otherwise too many unused imports would be removed.

Reviewed By: dtolnay

Differential Revision: D44823936

fbshipit-source-id: 20a35e4977dc362f71b4f88b93b8c2b9a4a7c06a
2023-04-09 19:03:53 -07:00
..
src Apply rustc fixes 2023-04-09 19:03:53 -07:00
Cargo.toml (reland) rust/third-party: update to futures 0.3.28 2023-04-04 10:14:43 -07:00
README.md Prepare safeptrace to be published as a crate 2023-03-25 16:12:24 -07:00

A safe ptrace interface

This crate provides a safe and Rustic alternative to the infamous ptrace API. There are many extremely subtle aspects of the raw ptrace API and this crate helps avoid common pitfalls.

Note that this library is still rather low-level and does not claim to solve all your ptrace problems. You have been warned!

Features

  • Ergonomic interface that provides a state machine for ptrace states. This avoids the infamous ESRCH errors that can happen when you use the ptrace API incorrectly.
  • Provides an interface to read/write guest's memory (see "memory" feature flag).
  • Provides an optional and semi-experimental async interface, which can be used with tokio (see "notifier" feature).

Usage

Add this to your Cargo.toml file:

safeptrace = "0.1"

Feature Flags

"memory" (off by default)

Provides access to the guest's memory. Memory can only be safely accessed when the guest is in a stopped state, thus the MemoryAccess trait is only implemented for the Stopped type.

"notifier" (off by default)

Provides an async interface for ptrace using notifier threads. This is semi-experimental, but testing shows that it has very good performance. It works by spawning a separate thread for each thread being traced, waiting for ptrace events in a loop. Thus, there will be 1 thread per guest thread.

Use with:

safeptrace = { version = "0.1", features = ["async"] }