HP-UX Reference (11i v1 00/12) - 2 System Calls (vol 5)

__________________________________________________________________________________________________________________________________________________________________________________________________
__________________________________________________________________________________________________________________________________________________________________________________________________
STANDARD Printed by: Nora Chuang [nchuang] STANDARD
/build/1111/BRICK/man2/!!!intro.2
________________________________________________________________
___ ___
p
ptrace(2) ptrace(2)
the effective user ID of the tracing process is superuser. The calling process can use
the wait() system call to wait for process pid to stop. The addr, data, and addr2
arguments are ignored.
PT_DETACH This request detaches the traced process pid and allows it to continue its execution in
the manner of PT_CONTIN.
If the addr argument is not 1, the Instruction Address Offset Queue (program
counter) is loaded with the values addr and addr2.
PT_CONTIN1 This request causes the traced process to resume execution with all its pending signals
intact. If the data argument is 0, the signal that caused the traced process to stop is
canceled before the traced process resumes execution. If the data argument is a valid
signal number, the traced process resumes execution as if it had received that signal.
The addr argument must be equal to 1 for this request. The addr2 argument is
ignored. Upon successful completion, the value of data is returned to the tracing pro-
cess.
This request fails if data is not 0 or a valid signal number, in which case a value of 1
is returned to the tracing process and its errno
is set to [EIO].
PT_SINGLE1 This request causes a flag to be set so that an interrupt occurs upon the completion of
one machine instruction. It then executes the same steps as listed above for request
PT_CONTIN1. If the processor does not provide a trace bit, this request returns an
error. This effectively allows single stepping of the traced process.
Whether or not the trace bit remains set after this interrupt is a function of the
hardware.
As noted earlier, a tracing process can set event flags in the context of the traced process to make it
respond to specific events, during its execution. These events are:
PTRACE_SIGNAL
This event flag indicates that, when processing signals, the traced process needs to
examine signal mask bits set in its context by the tracing process. See the
ptrace_event structure description under PT_SET_EVENT_MASK
for further details.
If the signal being processed has its signal mask bit set, signal processing continues as
though the process were not traced. The traced process is not stopped and the tracing
process is not notified of the signal. If the signal mask bit is not set for the signal
being processed, the traced process is stopped and the tracing process is notified via
wait() (see wait(2)).
Note that the SIGKILL signal is an exception to this rule in that it can never be
unmasked; that is, it behaves as though its mask bit were always set, regardless of
whether or not its mask bit is in fact set. Consequently, a
SIGKILL signal cannot be
used to stop a traced process.
In this respect, a
SIGTRAP signal is also special in that it is specifically used to stop
traced processes. A SIGTRAP signal should therefore never be masked. Setting a
mask bit for SIGTRAP will result in unexpected system behavior.
PTRACE_FORK
This event flag indicates that the traced process needs to take special action when it
invokes fork(). When set, both the parent and child processes stop (the child after
marking itself as a traced process and adopting its parent’s debugger). Both processes
log the fact that they stopped in response to a PTRACE_FORK event. Further, the
child’s pid is logged in the parent’s context, and the parent’s pid is logged in the child’s
context. The child does not inherit its parent’s event flags. See the ptrace_state struc-
ture description under PT_GET_PROCESS_STATE for further details.
PTRACE_VFORK
This event flag indicates that the traced process needs to take special action when it
invokes vfork(). When set, the child process stops after marking itself as a traced
process and adopting its parent’s debugger. The fact that a PTRACE_VFORK event
was responded to is logged in the context of both the parent and child processes.
Further, the child’s pid is logged in the parent’s context, and the parent’s pid is logged
in the child’s context. The child does not inherit its parent’s event flags. See the
ptrace_state structure description under
PT_GET_PROCESS_STATE
for further
Section 2236 3 HP-UX Release 11i: December 2000
___
___