|
|
# include <unistd.h>int ptrace(int request, pid_t pid, int addr, int data);
The request argument determines the precise action to be taken by ptrace and is one of the following:
On the 80386, the ptrace system call can be used to modify the debug registers.
The 80386 debug registers are used to specify an address to monitor in a user process. Any access to this location by the user process delivers a SIGTRAP (see signal(M)) to the user process and possibly restart the parent process.
The 80386 debug registers can be accessed by using the 3 or
6 options of the ptrace system call to read or
write a traced-process's u-area. The file
<sys/debugreg.h> should be included in the parent
process that wants to control the debug registers. This
header file defines bit masks that describe the
debug-registers in the u_debugreg
[] array in the
u-area.
The debug registers numbered u.u_debugreg
[DR_FIRSTADDR] (%dr0) to
u.u_debugreg
[DR_LASTADDR] (%dr3)
contain process addresses which are monitored according to
the instructions provided in
u.u_debugreg
[DR_CONTROL] (%dr7). Only
the DR_LOCAL_ENABLE_MASK and the various
read/write and length bits in
u.u_debugreg
[DR_CONTROL] can be set.
Setting DR_LOCAL_SLOWDOWN to slow down processing
is also highly recommended. The setting of all other bits
is undefined and should be set to zero to ensure
compatibility with future Intel processors.
In the process being debugged, these registers are
automatically loaded before entering user-mode (privilege
level 3) and cleared before entering the system for any
reason. In System V Release 3.2, if the location specified
by a debug-register is accessed during a system call,
core-dump, or interrupt service, no trap ensues.
AT&T SVID Issue 2 \, but has been withdrawn from XPG3.