Back to index

glibc  2.9
ptrace.h
Go to the documentation of this file.
00001 /* `ptrace' debugger support interface.  Linux/SPARC version.
00002    Copyright (C) 1996, 1997, 1998, 1999, 2000, 2006, 2007
00003    Free Software Foundation, Inc.
00004    This file is part of the GNU C Library.
00005 
00006    The GNU C Library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Lesser General Public
00008    License as published by the Free Software Foundation; either
00009    version 2.1 of the License, or (at your option) any later version.
00010 
00011    The GNU C Library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Lesser General Public License for more details.
00015 
00016    You should have received a copy of the GNU Lesser General Public
00017    License along with the GNU C Library; if not, write to the Free
00018    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00019    02111-1307 USA.  */
00020 
00021 #ifndef _SYS_PTRACE_H
00022 #define _SYS_PTRACE_H       1
00023 
00024 #include <features.h>
00025 
00026 #include <bits/wordsize.h>
00027 
00028 /* Linux/SPARC kernels up to 2.3.18 do not care much
00029    about what namespace polution, so use a kludge now.  */
00030 #undef PTRACE_GETREGS
00031 #undef PTRACE_SETREGS
00032 #undef PTRACE_GETFPREGS
00033 #undef PTRACE_SETFPREGS
00034 #undef PTRACE_READDATA
00035 #undef PTRACE_WRITEDATA
00036 #undef PTRACE_READTEXT
00037 #undef PTRACE_WRITETEXT
00038 #undef PTRACE_SUNDETACH
00039 
00040 __BEGIN_DECLS
00041 
00042 /* Type of the REQUEST argument to `ptrace.'  */
00043 enum __ptrace_request
00044 {
00045   /* Indicate that the process making this request should be traced.
00046      All signals received by this process can be intercepted by its
00047      parent, and its parent can use the other `ptrace' requests.  */
00048   PTRACE_TRACEME = 0,
00049 #define PT_TRACE_ME PTRACE_TRACEME
00050 
00051   /* Return the word in the process's text space at address ADDR.  */
00052   PTRACE_PEEKTEXT = 1,
00053 #define PT_READ_I PTRACE_PEEKTEXT
00054 
00055   /* Return the word in the process's data space at address ADDR.  */
00056   PTRACE_PEEKDATA = 2,
00057 #define PT_READ_D PTRACE_PEEKDATA
00058 
00059   /* Return the word in the process's user area at offset ADDR.  */
00060   PTRACE_PEEKUSER = 3,
00061 #define PT_READ_U PTRACE_PEEKUSER
00062 
00063   /* Write the word DATA into the process's text space at address ADDR.  */
00064   PTRACE_POKETEXT = 4,
00065 #define PT_WRITE_I PTRACE_POKETEXT
00066 
00067   /* Write the word DATA into the process's data space at address ADDR.  */
00068   PTRACE_POKEDATA = 5,
00069 #define PT_WRITE_D PTRACE_POKEDATA
00070 
00071   /* Write the word DATA into the process's user area at offset ADDR.  */
00072   PTRACE_POKEUSER = 6,
00073 #define PT_WRITE_U PTRACE_POKEUSER
00074 
00075   /* Continue the process.  */
00076   PTRACE_CONT = 7,
00077 #define PT_CONTINUE PTRACE_CONT
00078 
00079   /* Kill the process.  */
00080   PTRACE_KILL = 8,
00081 #define PT_KILL PTRACE_KILL
00082 
00083   /* Single step the process.
00084      This is not supported on all machines.  */
00085   PTRACE_SINGLESTEP = 9,
00086 #define PT_STEP PTRACE_SINGLESTEP
00087 
00088   /* Detach from a process attached to with PTRACE_ATTACH.  */
00089   PTRACE_DETACH = 11,
00090 #define PT_DETACH PTRACE_DETACH
00091 
00092   /* This define is needed for older programs which were
00093      trying to work around sparc-linux ptrace nastiness.  */
00094 #define PTRACE_SUNDETACH PTRACE_DETACH
00095 
00096 #if __WORDSIZE == 32
00097 
00098   /* Get all general purpose registers used by a processes.
00099      This is not supported on all machines.  */
00100    PTRACE_GETREGS = 12,
00101 #define PT_GETREGS PTRACE_GETREGS
00102 
00103   /* Set all general purpose registers used by a processes.
00104      This is not supported on all machines.  */
00105    PTRACE_SETREGS = 13,
00106 #define PT_SETREGS PTRACE_SETREGS
00107 
00108   /* Get all floating point registers used by a processes.
00109      This is not supported on all machines.  */
00110    PTRACE_GETFPREGS = 14,
00111 #define PT_GETFPREGS PTRACE_GETFPREGS
00112 
00113   /* Set all floating point registers used by a processes.
00114      This is not supported on all machines.  */
00115    PTRACE_SETFPREGS = 15,
00116 #define PT_SETFPREGS PTRACE_SETFPREGS
00117 
00118 #endif
00119 
00120   /* Attach to a process that is already running. */
00121   PTRACE_ATTACH = 16,
00122 #define PT_ATTACH PTRACE_ATTACH
00123 
00124   /* Write several bytes at a time. */
00125   PTRACE_WRITEDATA = 17,
00126 #define PTRACE_WRITEDATA PTRACE_WRITEDATA
00127 
00128   /* Read several bytes at a time. */
00129   PTRACE_READTEXT = 18,
00130 #define PTRACE_READTEXT PTRACE_READTEXT
00131 #define PTRACE_READDATA PTRACE_READTEXT
00132 
00133   /* Write several bytes at a time. */
00134   PTRACE_WRITETEXT = 19,
00135 #define PTRACE_WRITETEXT PTRACE_WRITETEXT
00136 
00137 #if __WORDSIZE == 64
00138 
00139   /* Get all general purpose registers used by a processes.
00140      This is not supported on all machines.  */
00141    PTRACE_GETREGS = 22,
00142 #define PT_GETREGS PTRACE_GETREGS
00143 
00144   /* Set all general purpose registers used by a processes.
00145      This is not supported on all machines.  */
00146    PTRACE_SETREGS = 23,
00147 #define PT_SETREGS PTRACE_SETREGS
00148 
00149 #endif
00150 
00151   /* Continue and stop at the next (return from) syscall.  */
00152   PTRACE_SYSCALL = 24,
00153 #define PTRACE_SYSCALL PTRACE_SYSCALL
00154 
00155 #if __WORDSIZE == 64
00156 
00157   /* Get all floating point registers used by a processes.
00158      This is not supported on all machines.  */
00159    PTRACE_GETFPREGS = 25,
00160 #define PT_GETFPREGS PTRACE_GETFPREGS
00161 
00162   /* Set all floating point registers used by a processes.
00163      This is not supported on all machines.  */
00164    PTRACE_SETFPREGS = 26,
00165 #define PT_SETFPREGS PTRACE_SETFPREGS
00166 
00167 #endif
00168 
00169   /* Set ptrace filter options.  */
00170   PTRACE_SETOPTIONS = 0x4200,
00171 #define PT_SETOPTIONS PTRACE_SETOPTIONS
00172 
00173   /* Get last ptrace message.  */
00174   PTRACE_GETEVENTMSG = 0x4201,
00175 #define PT_GETEVENTMSG PTRACE_GETEVENTMSG
00176 
00177   /* Get siginfo for process.  */
00178   PTRACE_GETSIGINFO = 0x4202,
00179 #define PT_GETSIGINFO PTRACE_GETSIGINFO
00180 
00181   /* Set new siginfo for process.  */
00182   PTRACE_SETSIGINFO = 0x4203
00183 #define PT_SETSIGINFO PTRACE_SETSIGINFO
00184 };
00185 
00186 /* Options set using PTRACE_SETOPTIONS.  */
00187 enum __ptrace_setoptions {
00188   PTRACE_O_TRACESYSGOOD     = 0x00000001,
00189   PTRACE_O_TRACEFORK = 0x00000002,
00190   PTRACE_O_TRACEVFORK   = 0x00000004,
00191   PTRACE_O_TRACECLONE       = 0x00000008,
00192   PTRACE_O_TRACEEXEC = 0x00000010,
00193   PTRACE_O_TRACEVFORKDONE = 0x00000020,
00194   PTRACE_O_TRACEEXIT = 0x00000040,
00195   PTRACE_O_MASK             = 0x0000007f
00196 };
00197 
00198 /* Wait extended result codes for the above trace options.  */
00199 enum __ptrace_eventcodes {
00200   PTRACE_EVENT_FORK  = 1,
00201   PTRACE_EVENT_VFORK = 2,
00202   PTRACE_EVENT_CLONE = 3,
00203   PTRACE_EVENT_EXEC  = 4,
00204   PTRACE_EVENT_VFORK_DONE = 5,
00205   PTRACE_EVENT_EXIT  = 6
00206 };
00207 
00208 /* Perform process tracing functions.  REQUEST is one of the values
00209    above, and determines the action to be taken.
00210    For all requests except PTRACE_TRACEME, PID specifies the process to be
00211    traced.
00212 
00213    PID and the other arguments described above for the various requests should
00214    appear (those that are used for the particular request) as:
00215      pid_t PID, void *ADDR, int DATA, void *ADDR2
00216    after REQUEST.  */
00217 extern long int ptrace (enum __ptrace_request __request, ...) __THROW;
00218 
00219 __END_DECLS
00220 
00221 #endif /* _SYS_PTRACE_H */