Back to index

glibc  2.9
ptrace.h
Go to the documentation of this file.
00001 /* `ptrace' debugger support interface.  Linux version.
00002    Copyright (C) 2000, 2006, 2007 Free Software Foundation, Inc.
00003    Contributed by Denis Joseph Barrow (djbarrow@de.ibm.com).
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 __BEGIN_DECLS
00027 #ifdef _LINUX_PTRACE_H
00028 /* Kludge to stop stuff gdb & strace compiles from getting upset
00029  */
00030 #undef PTRACE_TRACEME
00031 #undef PTRACE_PEEKTEXT
00032 #undef PTRACE_PEEKDATA
00033 #undef PTRACE_PEEKUSR
00034 #undef PTRACE_POKETEXT
00035 #undef PTRACE_POKEDATA
00036 #undef PTRACE_POKEUSR
00037 #undef PTRACE_CONT
00038 #undef PTRACE_KILL
00039 #undef PTRACE_SINGLESTEP
00040 
00041 #undef PTRACE_ATTACH
00042 #undef PTRACE_DETACH
00043 
00044 #undef PTRACE_SYSCALL
00045 #endif
00046 /* Type of the REQUEST argument to `ptrace.'  */
00047 enum __ptrace_request
00048 {
00049   /* Indicate that the process making this request should be traced.
00050      All signals received by this process can be intercepted by its
00051      parent, and its parent can use the other `ptrace' requests.  */
00052   PTRACE_TRACEME = 0,
00053 #define PT_TRACE_ME PTRACE_TRACEME
00054 
00055   /* Return the word in the process's text space at address ADDR.  */
00056   PTRACE_PEEKTEXT = 1,
00057 #define PT_READ_I PTRACE_PEEKTEXT
00058 
00059   /* Return the word in the process's data space at address ADDR.  */
00060   PTRACE_PEEKDATA = 2,
00061 #define PT_READ_D PTRACE_PEEKDATA
00062 
00063   /* Return the word in the process's user area at offset ADDR.  */
00064   PTRACE_PEEKUSER = 3,
00065 #define PT_READ_U PTRACE_PEEKUSER
00066 
00067   /* Write the word DATA into the process's text space at address ADDR.  */
00068   PTRACE_POKETEXT = 4,
00069 #define PT_WRITE_I PTRACE_POKETEXT
00070 
00071   /* Write the word DATA into the process's data space at address ADDR.  */
00072   PTRACE_POKEDATA = 5,
00073 #define PT_WRITE_D PTRACE_POKEDATA
00074 
00075   /* Write the word DATA into the process's user area at offset ADDR.  */
00076   PTRACE_POKEUSER = 6,
00077 #define PT_WRITE_U PTRACE_POKEUSER
00078 
00079   /* Continue the process.  */
00080   PTRACE_CONT = 7,
00081 #define PT_CONTINUE PTRACE_CONT
00082 
00083   /* Kill the process.  */
00084   PTRACE_KILL = 8,
00085 #define PT_KILL PTRACE_KILL
00086 
00087   /* Single step the process.
00088      This is not supported on all machines.  */
00089   PTRACE_SINGLESTEP = 9,
00090 #define PT_STEP PTRACE_SINGLESTEP
00091 
00092   /* Get all general purpose registers used by a processes.
00093      This is not supported on all machines.  */
00094    PTRACE_GETREGS = 12,
00095 #define PT_GETREGS PTRACE_GETREGS
00096 
00097   /* Set all general purpose registers used by a processes.
00098      This is not supported on all machines.  */
00099    PTRACE_SETREGS = 13,
00100 #define PT_SETREGS PTRACE_SETREGS
00101 
00102   /* Get all floating point registers used by a processes.
00103      This is not supported on all machines.  */
00104    PTRACE_GETFPREGS = 14,
00105 #define PT_GETFPREGS PTRACE_GETFPREGS
00106 
00107   /* Set all floating point registers used by a processes.
00108      This is not supported on all machines.  */
00109    PTRACE_SETFPREGS = 15,
00110 #define PT_SETFPREGS PTRACE_SETFPREGS
00111 
00112   /* Attach to a process that is already running. */
00113   PTRACE_ATTACH = 16,
00114 #define PT_ATTACH PTRACE_ATTACH
00115 
00116   /* Detach from a process attached to with PTRACE_ATTACH.  */
00117   PTRACE_DETACH = 17,
00118 #define PT_DETACH PTRACE_DETACH
00119 
00120   /* Continue and stop at the next (return from) syscall.  */
00121   PTRACE_SYSCALL = 24,
00122 #define PT_SYSCALL PTRACE_SYSCALL
00123 
00124   /* Set ptrace filter options.  */
00125   PTRACE_SETOPTIONS = 0x4200,
00126 #define PT_SETOPTIONS PTRACE_SETOPTIONS
00127 
00128   /* Get last ptrace message.  */
00129   PTRACE_GETEVENTMSG = 0x4201,
00130 #define PT_GETEVENTMSG PTRACE_GETEVENTMSG
00131 
00132   /* Get siginfo for process.  */
00133   PTRACE_GETSIGINFO = 0x4202,
00134 #define PT_GETSIGINFO PTRACE_GETSIGINFO
00135 
00136   /* Set new siginfo for process.  */
00137   PTRACE_SETSIGINFO = 0x4203
00138 #define PT_SETSIGINFO PTRACE_SETSIGINFO
00139 };
00140 
00141 /* Options set using PTRACE_SETOPTIONS.  */
00142 enum __ptrace_setoptions {
00143   PTRACE_O_TRACESYSGOOD     = 0x00000001,
00144   PTRACE_O_TRACEFORK = 0x00000002,
00145   PTRACE_O_TRACEVFORK   = 0x00000004,
00146   PTRACE_O_TRACECLONE       = 0x00000008,
00147   PTRACE_O_TRACEEXEC = 0x00000010,
00148   PTRACE_O_TRACEVFORKDONE = 0x00000020,
00149   PTRACE_O_TRACEEXIT = 0x00000040,
00150   PTRACE_O_MASK             = 0x0000007f
00151 };
00152 
00153 /* Wait extended result codes for the above trace options.  */
00154 enum __ptrace_eventcodes {
00155   PTRACE_EVENT_FORK  = 1,
00156   PTRACE_EVENT_VFORK = 2,
00157   PTRACE_EVENT_CLONE = 3,
00158   PTRACE_EVENT_EXEC  = 4,
00159   PTRACE_EVENT_VFORK_DONE = 5,
00160   PTRACE_EVENT_EXIT  = 6
00161 };
00162 
00163 /* Perform process tracing functions.  REQUEST is one of the values
00164    above, and determines the action to be taken.
00165    For all requests except PTRACE_TRACEME, PID specifies the process to be
00166    traced.
00167 
00168    PID and the other arguments described above for the various requests should
00169    appear (those that are used for the particular request) as:
00170      pid_t PID, void *ADDR, int DATA, void *ADDR2
00171    after REQUEST.  */
00172 extern long int ptrace (enum __ptrace_request __request, ...);
00173 
00174 __END_DECLS
00175 
00176 #endif /* _SYS_PTRACE_H */