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) 1996-1999,2000,2006,2007 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 #ifndef _SYS_PTRACE_H
00021 #define _SYS_PTRACE_H       1
00022 
00023 #include <features.h>
00024 
00025 __BEGIN_DECLS
00026 
00027 /* Type of the REQUEST argument to `ptrace.'  */
00028 enum __ptrace_request
00029 {
00030   /* Indicate that the process making this request should be traced.
00031      All signals received by this process can be intercepted by its
00032      parent, and its parent can use the other `ptrace' requests.  */
00033   PTRACE_TRACEME = 0,
00034 #define PT_TRACE_ME PTRACE_TRACEME
00035 
00036   /* Return the word in the process's text space at address ADDR.  */
00037   PTRACE_PEEKTEXT = 1,
00038 #define PT_READ_I PTRACE_PEEKTEXT
00039 
00040   /* Return the word in the process's data space at address ADDR.  */
00041   PTRACE_PEEKDATA = 2,
00042 #define PT_READ_D PTRACE_PEEKDATA
00043 
00044   /* Return the word in the process's user area at offset ADDR.  */
00045   PTRACE_PEEKUSER = 3,
00046 #define PT_READ_U PTRACE_PEEKUSER
00047 
00048   /* Write the word DATA into the process's text space at address ADDR.  */
00049   PTRACE_POKETEXT = 4,
00050 #define PT_WRITE_I PTRACE_POKETEXT
00051 
00052   /* Write the word DATA into the process's data space at address ADDR.  */
00053   PTRACE_POKEDATA = 5,
00054 #define PT_WRITE_D PTRACE_POKEDATA
00055 
00056   /* Write the word DATA into the process's user area at offset ADDR.  */
00057   PTRACE_POKEUSER = 6,
00058 #define PT_WRITE_U PTRACE_POKEUSER
00059 
00060   /* Continue the process.  */
00061   PTRACE_CONT = 7,
00062 #define PT_CONTINUE PTRACE_CONT
00063 
00064   /* Kill the process.  */
00065   PTRACE_KILL = 8,
00066 #define PT_KILL PTRACE_KILL
00067 
00068   /* Single step the process.
00069      This is not supported on all machines.  */
00070   PTRACE_SINGLESTEP = 9,
00071 #define PT_STEP PTRACE_SINGLESTEP
00072 
00073   /* Get all general purpose registers used by a processes.
00074      This is not supported on all machines.  */
00075    PTRACE_GETREGS = 12,
00076 #define PT_GETREGS PTRACE_GETREGS
00077 
00078   /* Set all general purpose registers used by a processes.
00079      This is not supported on all machines.  */
00080    PTRACE_SETREGS = 13,
00081 #define PT_SETREGS PTRACE_SETREGS
00082 
00083   /* Get all floating point registers used by a processes.
00084      This is not supported on all machines.  */
00085    PTRACE_GETFPREGS = 14,
00086 #define PT_GETFPREGS PTRACE_GETFPREGS
00087 
00088   /* Set all floating point registers used by a processes.
00089      This is not supported on all machines.  */
00090    PTRACE_SETFPREGS = 15,
00091 #define PT_SETFPREGS PTRACE_SETFPREGS
00092 
00093   /* Attach to a process that is already running. */
00094   PTRACE_ATTACH = 16,
00095 #define PT_ATTACH PTRACE_ATTACH
00096 
00097   /* Detach from a process attached to with PTRACE_ATTACH.  */
00098   PTRACE_DETACH = 17,
00099 #define PT_DETACH PTRACE_DETACH
00100 
00101   /* Get all extended floating point registers used by a processes.
00102      This is not supported on all machines.  */
00103    PTRACE_GETFPXREGS = 18,
00104 #define PT_GETFPXREGS PTRACE_GETFPXREGS
00105 
00106   /* Set all extended floating point registers used by a processes.
00107      This is not supported on all machines.  */
00108    PTRACE_SETFPXREGS = 19,
00109 #define PT_SETFPXREGS PTRACE_SETFPXREGS
00110 
00111   /* Continue and stop at the next (return from) syscall.  */
00112   PTRACE_SYSCALL = 24,
00113 #define PT_SYSCALL PTRACE_SYSCALL
00114 
00115   /* Set ptrace filter options.  */
00116   PTRACE_SETOPTIONS = 0x4200,
00117 #define PT_SETOPTIONS PTRACE_SETOPTIONS
00118 
00119   /* Get last ptrace message.  */
00120   PTRACE_GETEVENTMSG = 0x4201,
00121 #define PT_GETEVENTMSG PTRACE_GETEVENTMSG
00122 
00123   /* Get siginfo for process.  */
00124   PTRACE_GETSIGINFO = 0x4202,
00125 #define PT_GETSIGINFO PTRACE_GETSIGINFO
00126 
00127   /* Set new siginfo for process.  */
00128   PTRACE_SETSIGINFO = 0x4203
00129 #define PT_SETSIGINFO PTRACE_SETSIGINFO
00130 };
00131 
00132 
00133 /* Options set using PTRACE_SETOPTIONS.  */
00134 enum __ptrace_setoptions {
00135   PTRACE_O_TRACESYSGOOD     = 0x00000001,
00136   PTRACE_O_TRACEFORK = 0x00000002,
00137   PTRACE_O_TRACEVFORK   = 0x00000004,
00138   PTRACE_O_TRACECLONE       = 0x00000008,
00139   PTRACE_O_TRACEEXEC = 0x00000010,
00140   PTRACE_O_TRACEVFORKDONE = 0x00000020,
00141   PTRACE_O_TRACEEXIT = 0x00000040,
00142   PTRACE_O_MASK             = 0x0000007f
00143 };
00144 
00145 /* Wait extended result codes for the above trace options.  */
00146 enum __ptrace_eventcodes {
00147   PTRACE_EVENT_FORK  = 1,
00148   PTRACE_EVENT_VFORK = 2,
00149   PTRACE_EVENT_CLONE = 3,
00150   PTRACE_EVENT_EXEC  = 4,
00151   PTRACE_EVENT_VFORK_DONE = 5,
00152   PTRACE_EVENT_EXIT  = 6
00153 };
00154 
00155 /* Perform process tracing functions.  REQUEST is one of the values
00156    above, and determines the action to be taken.
00157    For all requests except PTRACE_TRACEME, PID specifies the process to be
00158    traced.
00159 
00160    PID and the other arguments described above for the various requests should
00161    appear (those that are used for the particular request) as:
00162      pid_t PID, void *ADDR, int DATA, void *ADDR2
00163    after REQUEST.  */
00164 extern long int ptrace (enum __ptrace_request __request, ...) __THROW;
00165 
00166 __END_DECLS
00167 
00168 #endif /* _SYS_PTRACE_H */