Back to index

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