Skip to content

Commit c6f9e23

Browse files
Merge #2009
2009: Add more detail for ptrace documentation r=asomers a=thomasqueirozb All functions are documented with the equivalent C call example except for `read`, `read_user`, `write` & `write_user`. I was looking for the function that used `PTRACE_PEEKDATA` and couldn't find it using the documentation and had to go to the source code to find it out. In hindsight, it's pretty obvious that it was read... But still I think it would be nice to have it documented Co-authored-by: Thomas de Queiroz Barros <[email protected]>
2 parents dfc689a + f18ceb9 commit c6f9e23

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/sys/ptrace/linux.rs

+10-8
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ unsafe fn ptrace_other(
269269
.map(|_| 0)
270270
}
271271

272-
/// Set options, as with `ptrace(PTRACE_SETOPTIONS,...)`.
272+
/// Set options, as with `ptrace(PTRACE_SETOPTIONS, ...)`.
273273
pub fn setoptions(pid: Pid, options: Options) -> Result<()> {
274274
let res = unsafe {
275275
libc::ptrace(
@@ -282,17 +282,17 @@ pub fn setoptions(pid: Pid, options: Options) -> Result<()> {
282282
Errno::result(res).map(drop)
283283
}
284284

285-
/// Gets a ptrace event as described by `ptrace(PTRACE_GETEVENTMSG,...)`
285+
/// Gets a ptrace event as described by `ptrace(PTRACE_GETEVENTMSG, ...)`
286286
pub fn getevent(pid: Pid) -> Result<c_long> {
287287
ptrace_get_data::<c_long>(Request::PTRACE_GETEVENTMSG, pid)
288288
}
289289

290-
/// Get siginfo as with `ptrace(PTRACE_GETSIGINFO,...)`
290+
/// Get siginfo as with `ptrace(PTRACE_GETSIGINFO, ...)`
291291
pub fn getsiginfo(pid: Pid) -> Result<siginfo_t> {
292292
ptrace_get_data::<siginfo_t>(Request::PTRACE_GETSIGINFO, pid)
293293
}
294294

295-
/// Set siginfo as with `ptrace(PTRACE_SETSIGINFO,...)`
295+
/// Set siginfo as with `ptrace(PTRACE_SETSIGINFO, ...)`
296296
pub fn setsiginfo(pid: Pid, sig: &siginfo_t) -> Result<()> {
297297
let ret = unsafe {
298298
Errno::clear();
@@ -517,12 +517,14 @@ pub fn sysemu_step<T: Into<Option<Signal>>>(pid: Pid, sig: T) -> Result<()> {
517517
}
518518
}
519519

520-
/// Reads a word from a processes memory at the given address
520+
/// Reads a word from a processes memory at the given address, as with
521+
/// ptrace(PTRACE_PEEKDATA, ...)
521522
pub fn read(pid: Pid, addr: AddressType) -> Result<c_long> {
522523
ptrace_peek(Request::PTRACE_PEEKDATA, pid, addr, ptr::null_mut())
523524
}
524525

525-
/// Writes a word into the processes memory at the given address
526+
/// Writes a word into the processes memory at the given address, as with
527+
/// ptrace(PTRACE_POKEDATA, ...)
526528
///
527529
/// # Safety
528530
///
@@ -536,13 +538,13 @@ pub unsafe fn write(
536538
ptrace_other(Request::PTRACE_POKEDATA, pid, addr, data).map(drop)
537539
}
538540

539-
/// Reads a word from a user area at `offset`.
541+
/// Reads a word from a user area at `offset`, as with ptrace(PTRACE_PEEKUSER, ...).
540542
/// The user struct definition can be found in `/usr/include/sys/user.h`.
541543
pub fn read_user(pid: Pid, offset: AddressType) -> Result<c_long> {
542544
ptrace_peek(Request::PTRACE_PEEKUSER, pid, offset, ptr::null_mut())
543545
}
544546

545-
/// Writes a word to a user area at `offset`.
547+
/// Writes a word to a user area at `offset`, as with ptrace(PTRACE_POKEUSER, ...).
546548
/// The user struct definition can be found in `/usr/include/sys/user.h`.
547549
///
548550
/// # Safety

0 commit comments

Comments
 (0)