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) 2001, 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   /* Attach to a process that is already running. */
00074   PTRACE_ATTACH = 16,
00075 #define PT_ATTACH PTRACE_ATTACH
00076 
00077   /* Detach from a process attached to with PTRACE_ATTACH.  */
00078   PTRACE_DETACH = 17,
00079 #define PT_DETACH PTRACE_DETACH
00080 
00081   /* Continue and stop at the next (return from) syscall.  */
00082   PTRACE_SYSCALL = 24,
00083 #define PT_SYSCALL PTRACE_SYSCALL
00084 
00085   /* Set ptrace filter options.  */
00086   PTRACE_SETOPTIONS = 0x4200,
00087 #define PT_SETOPTIONS PTRACE_SETOPTIONS
00088 
00089   /* Get last ptrace message.  */
00090   PTRACE_GETEVENTMSG = 0x4201,
00091 #define PT_GETEVENTMSG PTRACE_GETEVENTMSG
00092 
00093   /* Get siginfo for process.  */
00094   PTRACE_GETSIGINFO = 0x4202,
00095 #define PT_GETSIGINFO PTRACE_GETSIGINFO
00096 
00097   /* Set new siginfo for process.  */
00098   PTRACE_SETSIGINFO = 0x4203
00099 #define PT_SETSIGINFO PTRACE_SETSIGINFO
00100 };
00101 
00102 /* Options set using PTRACE_SETOPTIONS.  */
00103 enum __ptrace_setoptions {
00104   PTRACE_O_TRACESYSGOOD     = 0x00000001,
00105   PTRACE_O_TRACEFORK = 0x00000002,
00106   PTRACE_O_TRACEVFORK   = 0x00000004,
00107   PTRACE_O_TRACECLONE       = 0x00000008,
00108   PTRACE_O_TRACEEXEC = 0x00000010,
00109   PTRACE_O_TRACEVFORKDONE = 0x00000020,
00110   PTRACE_O_TRACEEXIT = 0x00000040,
00111   PTRACE_O_MASK             = 0x0000007f
00112 };
00113 
00114 /* Wait extended result codes for the above trace options.  */
00115 enum __ptrace_eventcodes {
00116   PTRACE_EVENT_FORK  = 1,
00117   PTRACE_EVENT_VFORK = 2,
00118   PTRACE_EVENT_CLONE = 3,
00119   PTRACE_EVENT_EXEC  = 4,
00120   PTRACE_EVENT_VFORK_DONE = 5,
00121   PTRACE_EVENT_EXIT  = 6
00122 };
00123 
00124 /* Perform process tracing functions.  REQUEST is one of the values
00125    above, and determines the action to be taken.
00126    For all requests except PTRACE_TRACEME, PID specifies the process to be
00127    traced.
00128 
00129    PID and the other arguments described above for the various requests should
00130    appear (those that are used for the particular request) as:
00131      pid_t PID, void *ADDR, int DATA, void *ADDR2
00132    after REQUEST.  */
00133 extern long int ptrace (enum __ptrace_request __request, ...) __THROW;
00134 
00135 __END_DECLS
00136 
00137 #endif /* _SYS_PTRACE_H */