.B ptrace(request, pid, addr, data)
provides a means by which a parent process
may control the execution of a child process,
and examine and change its core image.
Its primary use is for the implementation of breakpoint debugging.
There are four arguments whose interpretation
is the process ID of the traced process,
which must be a child (no more distant descendant)
behaves normally until it encounters some signal whether internally generated
like `illegal instruction' or externally generated like `interrupt.'
Then the traced process enters a stopped state
and its parent is notified via
When the child is in the stopped state,
its core image can be examined and modified
request can then cause the child either to terminate
or to continue, possibly ignoring the signal.
argument determines the precise
This request is the only one used by the child process;
it declares that the process is to be traced by its parent.
All the other arguments are ignored.
Peculiar results will ensue
if the parent does not expect to trace the child.
word in the child process's address space
If I and D space are separated, request 1 indicates I space,
The child must be stopped.
of the system's per-process data area corresponding to
must be even and less than 512.
This space contains the registers and other information about
its layout corresponds to the
is written at the word in the process's address space corresponding to
No useful value is returned.
If I and D space are separated, request 4 indicates I space,
Attempts to write in pure procedure
fail if another process is executing the same file.
The process's system data is written,
as it is read with request 3.
Only a few locations can be written in this way:
the floating point status and registers,
and certain bits of the processor status word.
argument is taken as a signal number
and the child's execution continues
as if it had incurred that signal.
Normally the signal number will be
either 0 to indicate that the signal that caused the stop
or that value fetched out of the
process's image indicating which signal caused
is (int *)1 then execution continues from where it stopped.
The traced process terminates.
Execution continues as in request 7;
however, as soon as possible after execution of at least one instruction,
The signal number from the stop is
(On the PDP-11 and VAX-11 the T-bit is used and just one instruction
on the Interdata the stop does not take place
until a store instruction is executed.)
This is part of the mechanism for implementing breakpoints.
can be used only when the subject process has stopped.
call is used to determine
in such a case the `termination' status
has the value 0177 to indicate stoppage rather
than genuine termination.
To forestall possible fraud,
inhibits the set-user-id facility
If a traced process calls
it will stop before executing the first instruction of the new image
`word' means a 32-bit word and `even' means 0 mod 4.
On a VAX-11, `word' also means a 32-bit integer, but the `even' restriction
wait(2), signal(2), adb(1)
The value \-1 is returned if
is not a traceable process,
specifies an illegal signal number.
`as soon as possible' (request 7)
means `as soon as a store instruction has been executed.'
The request 0 call should be able to specify
signals which are to be treated normally and not cause a stop.
In this way, for example,
programs with simulated floating point (which
use `illegal instruction' signals at a very high rate)
could be efficiently debugged.
The error indication, \-1, is a legitimate function value;
can be used to disambiguate.
It should be possible to stop a process on occurrence of a system
in this way a completely controlled environment could
.B sys ptrace; pid; addr; request