ptrace.2: Make it clearer that glibc and syscall APIs differ for PTRACE_PEEK*

Thanks to Denys Vlasenko's additions in 78686915ae
this page does note that the glibc API for PTRACE_PEEK*
differs from the raw syscall interface. But, as the report
at https://bugzilla.kernel.org/show_bug.cgi?id=70801 shows,
this information could be more obvious. This patch makes its so.

Reported-by: Andrew Hunter <ahh@google.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
Michael Kerrisk 2014-02-19 11:30:24 +01:00
parent 36f5dd10ba
commit 051ec121f0
1 changed files with 18 additions and 12 deletions

View File

@ -41,7 +41,7 @@
.\" (Thanks to Blaisorblade, Daniel Jacobowitz and others who helped.)
.\" 2011-09, major update by Denys Vlasenko <vda.linux@googlemail.com>
.\"
.TH PTRACE 2 2014-01-20 "Linux" "Linux Programmer's Manual"
.TH PTRACE 2 2014-02-20 "Linux" "Linux Programmer's Manual"
.SH NAME
ptrace \- process trace
.SH SYNOPSIS
@ -163,7 +163,7 @@ call.
Linux does not have separate text and data address spaces,
so these two requests are currently equivalent.
.RI ( data
is ignored.)
is ignored; but see NOTES.)
.TP
.B PTRACE_PEEKUSER
.\" PTRACE_PEEKUSR in kernel source, but glibc uses PTRACE_PEEKUSER,
@ -181,7 +181,7 @@ Typically, the offset must be word-aligned, though this might vary by
architecture.
See NOTES.
.RI ( data
is ignored.)
is ignored; but see NOTES.)
.TP
.BR PTRACE_POKETEXT ", " PTRACE_POKEDATA
Copy the word
@ -1851,16 +1851,10 @@ whole multithreaded process exits).
If the tracer and the real parent are the same process,
the report is sent only once.
.SH RETURN VALUE
On success,
On success, the
.B PTRACE_PEEK*
requests return the requested data, while other requests return zero.
(On Linux, this is done in the libc wrapper around ptrace system call.
On the system call level,
.B PTRACE_PEEK*
requests have a different API: they store the result
at the address specified by
.I data
parameter, and return value is the error flag.)
requests return the requested data (but see NOTES),
while other requests return zero.
.LP
On error, all requests return \-1, and
.I errno
@ -1932,6 +1926,18 @@ setting unused/ignored arguments to
or
.IR "(void\ *)\ 0".
.LP
At the system call level, the
.BR PTRACE_PEEKTEXT ,
.BR PTRACE_PEEKDATA ,
and
.BR PTRACE_PEEKUSER
requests have a different API: they store the result
at the address specified by the
.I data
parameter, and the return value is the error flag.
The glibc wrapper function provides the API given in DESCRIPTION above,
with the result being returned via the function return value.
.LP
In Linux kernels before 2.6.26,
.\" See commit 00cd5c37afd5f431ac186dd131705048c0a11fdb
.BR init (8),