-
Notifications
You must be signed in to change notification settings - Fork 654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ptrace mac support #947
Comments
No objections at all. Sounds like a useful feature. |
So ptrace mac support looks like it's going to be a bit faffy as apple name their constants differently So from this I see a few potential approaches just wondering if there were any thoughts/opinions/preferences.
I've got a PR for the ptrace constants on macos being merged into libc. Bors is just merging it in as we speak so I'll start this properly once that's in. |
Nix should not attempt to provide a common interface between different OSes. That responsibility belongs to crates that live atop Nix. So don't do bullet 3. Bullet 1 is the easiest and would be fine. Bullet 2 is an option if the differences are so large that Bullet 1 becomes unreadable. |
Okay I thought that might be the case for bullet 3. My gut feeling is that going for the first approach would make it unreadable, but I'll try it out first and move ptrace into it's own module if that becomes the case. |
So the existing PTRACE interface for linux has this deprecated function, I'm guessing I shouldn't replicate duplicated functionality in the Apple/BSD interface. /// Performs a ptrace request. If the request in question is provided by a specialised function
/// this function will return an unsupported operation error.
#[deprecated(
since="0.10.0",
note="usages of `ptrace()` should be replaced with the specialized helper functions instead"
)]
pub unsafe fn ptrace(request: Request, pid: Pid, addr: *mut c_void, data: *mut c_void) -> Result<c_long> {
use self::Request::*;
match request {
PTRACE_PEEKTEXT | PTRACE_PEEKDATA | PTRACE_PEEKUSER => ptrace_peek(request, pid, addr, data),
PTRACE_GETSIGINFO | PTRACE_GETEVENTMSG | PTRACE_SETSIGINFO | PTRACE_SETOPTIONS => Err(Error::UnsupportedOperation),
_ => ptrace_other(request, pid, addr, data)
}
} Also none of the PTRACE events seem to be supported in BSD. Some are in headers I found online but libc test errored so they didn't make it into rust-lang/libc and as a result the ptrace interface for BSD will probably be smaller than linux |
They aren't supported in the BSDs because nobody has needed them yet. Feel free to add them, both to libc and Nix. |
Oh the Ptrace requests are in libc already I did a PR, but the events didn't work and not all BSDs offer them so I've left them out entirely. I've opened a PR now if you want to have a look at what I've done #949 |
949: ptrace support for BSDs r=Susurrus a=xd009642 This PR adds support to the ptrace API for BSDs to close #947. It also adds a read and write method for reading and writing to a traced processes memory. The ptrace API created for linux offers this via a deprecated function so I added this so they can be feature equivalent without replicating a deprecated part of the API. Due to the differences in ptrace on BSD and linux I've made a ptrace module to keep things readable. Still to do - revert travis config to remove my feature branch and update the changelog. Co-authored-by: xd009642 <danielmckenna93@gmail.com>
It's came up as part of xd009642/tarpaulin#152 but ptrace is partially supported in macos (source). I'll look into it myself this weekend but I think it would be useful to go through the ptrace api and cfg in the parts supported on Macs.
Any thoughts, opinions, objections?
The text was updated successfully, but these errors were encountered: