| Skip Navigation Links | |
| Exit Print View | |
![]() | man pages section 3: Basic Library Functions Oracle Solaris 11 Information Library |
enable_extended_FILE_stdio(3C)
posix_spawnattr_getschedparam(3C)
posix_spawnattr_getschedpolicy(3C)
posix_spawnattr_getsigdefault(3C)
posix_spawnattr_getsigignore_np(3C)
posix_spawnattr_getsigmask(3C)
posix_spawnattr_setschedparam(3C)
posix_spawnattr_setschedpolicy(3C)
posix_spawnattr_setsigdefault(3C)
posix_spawnattr_setsigignore_np(3C)
posix_spawnattr_setsigmask(3C)
posix_spawn_file_actions_addclose(3C)
posix_spawn_file_actions_addclosefrom_np(3C)
posix_spawn_file_actions_adddup2(3C)
posix_spawn_file_actions_addopen(3C)
posix_spawn_file_actions_destroy(3C)
posix_spawn_file_actions_init(3C)
pthread_attr_getdetachstate(3C)
pthread_attr_getinheritsched(3C)
pthread_attr_getschedparam(3C)
pthread_attr_getschedpolicy(3C)
pthread_attr_setdetachstate(3C)
pthread_attr_setinheritsched(3C)
pthread_attr_setschedparam(3C)
pthread_attr_setschedpolicy(3C)
pthread_barrierattr_destroy(3C)
pthread_barrierattr_getpshared(3C)
pthread_barrierattr_setpshared(3C)
pthread_condattr_getpshared(3C)
pthread_condattr_setpshared(3C)
pthread_cond_reltimedwait_np(3C)
pthread_key_create_once_np(3C)
pthread_mutexattr_getprioceiling(3C)
pthread_mutexattr_getprotocol(3C)
pthread_mutexattr_getpshared(3C)
pthread_mutexattr_getrobust(3C)
pthread_mutexattr_setprioceiling(3C)
pthread_mutexattr_setprotocol(3C)
pthread_mutexattr_setpshared(3C)
pthread_mutexattr_setrobust(3C)
pthread_mutex_getprioceiling(3C)
pthread_mutex_reltimedlock_np(3C)
pthread_mutex_setprioceiling(3C)
pthread_rwlockattr_destroy(3C)
pthread_rwlockattr_getpshared(3C)
pthread_rwlockattr_setpshared(3C)
pthread_rwlock_reltimedrdlock_np(3C)
pthread_rwlock_reltimedwrlock_np(3C)
pthread_rwlock_timedrdlock(3C)
pthread_rwlock_timedwrlock(3C)
rctlblk_get_enforced_value(3C)
- allows a parent process to control the execution of a child process
#include <unistd.h>#include <sys/types.h>intptrace(intrequest,pid_tpid,intaddr,intdata);
Theptrace() function allows a parent process to control the execution ofa child process. Its primary use is for the implementation of breakpointdebugging. The child process behaves normally until it encounters a signal (seesignal.h(3HEAD)),at which time it enters a stopped state and its parent isnotified by thewait(3C) function. When the child is in the stoppedstate, its parent can examine and modify its “core image” usingptrace().Also, the parent can cause the child either to terminate or continue,with the possibility of ignoring the signal that caused it to stop.
Therequest argument determines the action to be taken byptrace() andis one of the following:
This request must be issued by the child process if it is to be traced by its parent. It turns on the child's trace flag that stipulates that the child should be left in a stopped state on receipt of a signal rather than the state specified byfunc (seesignal(3C)). Thepid,addr, anddata arguments are ignored, and a return value is not defined for this request. Peculiar results ensue if the parent does not expect to trace the child.
The remainder of the requests can only be used by the parentprocess. For each,pid is the process ID of the child. Thechild must be in a stopped state before these requests are made.
With these requests, the word at locationaddr in the address space of the child is returned to the parent process. If instruction and data space are separated, request1 returns a word from instruction space, and request2 returns a word from data space. If instruction and data space are not separated, either request1 or request2 may be used with equal results. Thedata argument is ignored. These two requests fail ifaddr is not the start address of a word, in which case-1 is returned to the parent process and the parent'serrno is set toEIO.
With this request, the word at locationaddr in the child's user area in the system's address space (see <sys/user.h>) is returned to the parent process. Thedata argument is ignored. This request fails ifaddr is not the start address of a word or is outside the user area, in which case-1 is returned to the parent process and the parent'serrno is set toEIO.
With these requests, the value given by thedata argument is written into the address space of the child at locationaddr. If instruction and data space are separated, request4 writes a word into instruction space, and request5 writes a word into data space. If instruction and data space are not separated, either request4 or request5 may be used with equal results. On success, the value written into the address space of the child is returned to the parent. These two requests fail ifaddr is not the start address of a word. On failure-1 is returned to the parent process and the parent'serrno is set toEIO.
With this request, a few entries in the child's user area can be written.data gives the value that is to be written andaddr is the location of the entry. The few entries that can be written are the general registers and the condition codes of the Processor Status Word.
This request causes the child to resume execution. If thedata argument is 0, all pending signals including the one that caused the child to stop are canceled before it resumes execution. If thedata argument is a valid signal number, the child resumes execution as if it had incurred that signal, and any other pending signals are canceled. Theaddr argument must be equal to 1 for this request. On success, the value ofdata is returned to the parent. This request fails ifdata is not 0 or a valid signal number, in which case-1 is returned to the parent process and the parent'serrno is set toEIO.
This request causes the child to terminate with the same consequences asexit(2).
This request sets the trace bit in the Processor Status Word of the child and then executes the same steps as listed above for request7. The trace bit causes an interrupt on completion of one machine instruction. This effectively allows single stepping of the child.
To forestall possible fraud,ptrace() inhibits the set-user-ID facility on subsequent callsto one of theexec family of functions (seeexec(2)). If atraced process calls one of these functions, it stops before executing thefirst instruction of the new image showing signalSIGTRAP.
Theptrace() function will fail if:
Therequest argument is an illegal number.
The calling process does not have appropriate privileges to control the calling process. Seeproc(4).
Thepid argument identifies a child that does not exist or has not executed aptrace() call with request0.
Theptrace() function is available only with the 32-bit version oflibc(3LIB).It is not available with the 64-bit version of this library.
The/proc debugging interfaces should be used instead ofptrace(), which providesquite limited debugger support and is itself implemented using the/proc interfaces.There is no actualptrace() system call in the kernel. Seeproc(4) fordescriptions of the/proc debugging interfaces.
Seeattributes(5) for descriptions of the following attributes:
|
exec(2),exit(2),libc(3LIB),signal(3C),signal.h(3HEAD),wait(3C),proc(4),attributes(5)
Copyright © 2011, Oracle and/or its affiliates. All rights reserved.Legal Notices | ![]() ![]() |