GDB (API)
|
00001 /* Portable <sys/ptrace.h> 00002 00003 Copyright (C) 2004-2013 Free Software Foundation, Inc. 00004 00005 This file is part of GDB. 00006 00007 This program is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation; either version 3 of the License, or 00010 (at your option) any later version. 00011 00012 This program is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 00019 00020 #ifndef GDB_PTRACE_H 00021 #define GDB_PTRACE_H 00022 00023 /* The <sys/ptrace.h> header was introduced with 4.4BSD, and provided 00024 the PT_* symbolic constants for the ptrace(2) request numbers. The 00025 ptrace(2) prototype was added later to the same header on BSD. 00026 SunOS and GNU/Linux have slightly different symbolic names for the 00027 constants that start with PTRACE_*. System V still doesn't have 00028 (and probably never will have) a <sys/ptrace.h> with symbolic 00029 constants; the ptrace(2) prototype can be found in <unistd.h>. 00030 Fortunately all systems use the same numerical constants for the 00031 common ptrace requests. */ 00032 00033 #ifdef HAVE_PTRACE_H 00034 # include <ptrace.h> 00035 #elif defined(HAVE_SYS_PTRACE_H) 00036 # include <sys/ptrace.h> 00037 #endif 00038 00039 /* No need to include <unistd.h> since it's already included by 00040 "defs.h". */ 00041 00042 #ifndef PT_TRACE_ME 00043 # define PT_TRACE_ME 0 00044 #endif 00045 00046 #ifndef PT_READ_I 00047 # define PT_READ_I 1 /* Read word in child's I space. */ 00048 #endif 00049 00050 #ifndef PT_READ_D 00051 # define PT_READ_D 2 /* Read word in child's D space. */ 00052 #endif 00053 00054 #ifndef PT_READ_U 00055 # define PT_READ_U 3 /* Read word in child's U space. */ 00056 #endif 00057 00058 #ifndef PT_WRITE_I 00059 # define PT_WRITE_I 4 /* Write word in child's I space. */ 00060 #endif 00061 00062 #ifndef PT_WRITE_D 00063 # define PT_WRITE_D 5 /* Write word in child's D space. */ 00064 #endif 00065 00066 #ifndef PT_WRITE_U 00067 # define PT_WRITE_U 6 /* Write word in child's U space. */ 00068 #endif 00069 00070 /* HP-UX doesn't define PT_CONTINUE and PT_STEP. Instead of those two 00071 ptrace requests, it has PT_CONTIN, PT_CONTIN1, PT_SINGLE and 00072 PT_SINGLE1. PT_CONTIN1 and PT_SINGLE1 preserve pending signals, 00073 which apparently is what is wanted by the HP-UX native code. */ 00074 00075 #ifndef PT_CONTINUE 00076 # ifdef PT_CONTIN1 00077 # define PT_CONTINUE PT_CONTIN1 00078 # else 00079 # define PT_CONTINUE 7 /* Continue the child. */ 00080 # endif 00081 #endif 00082 00083 #ifndef PT_KILL 00084 # define PT_KILL 8 /* Kill the child process. */ 00085 #endif 00086 00087 #ifndef PT_STEP 00088 # ifdef PT_SINGLE1 00089 # define PT_STEP PT_SINGLE1 00090 # else 00091 # define PT_STEP 9 /* Single step the child. */ 00092 # endif 00093 #endif 00094 00095 /* Not all systems support attaching and detaching. */ 00096 00097 #ifndef PT_ATTACH 00098 # ifdef PTRACE_ATTACH 00099 # define PT_ATTACH PTRACE_ATTACH 00100 # endif 00101 #endif 00102 00103 #ifndef PT_DETACH 00104 # ifdef PTRACE_DETACH 00105 # define PT_DETACH PTRACE_DETACH 00106 # endif 00107 #endif 00108 00109 /* For systems such as HP/UX that do not provide PT_SYSCALL, define it 00110 here as an alias for PT_CONTINUE. This is what the PT_SYSCALL 00111 request is expected to do, in addition to stopping when entering/ 00112 exiting a system call. Chances are, if the system supports system 00113 call tracing, enabling this feature is probably done separately; 00114 and there is probably no special request that we would be required 00115 to use when resuming the execution of our program. */ 00116 #ifndef PT_SYSCALL 00117 # ifdef PTRACE_SYSCALL 00118 # define PT_SYSCALL PTRACE_SYSCALL 00119 #else 00120 # define PT_SYSCALL PT_CONTINUE 00121 # endif 00122 #endif 00123 00124 /* Some systems, in particular DEC OSF/1, Digital Unix, Compaq Tru64 00125 or whatever it's called these days, don't provide a prototype for 00126 ptrace. Provide one to silence compiler warnings. */ 00127 00128 #ifndef HAVE_DECL_PTRACE 00129 extern PTRACE_TYPE_RET ptrace(); 00130 #endif 00131 00132 /* Some systems, at least AIX and HP-UX have a ptrace with five 00133 arguments. Since we never use the fifth argument, define a ptrace 00134 macro that calls the real ptrace with the last argument set to 00135 zero. */ 00136 00137 #ifdef PTRACE_TYPE_ARG5 00138 # ifdef HAVE_PTRACE64 00139 # define ptrace(request, pid, addr, data) \ 00140 ptrace64 (request, pid, addr, data, 0) 00141 # undef PTRACE_TYPE_ARG3 00142 # define PTRACE_TYPE_ARG3 long long 00143 # else 00144 # define ptrace(request, pid, addr, data) \ 00145 ptrace (request, pid, addr, data, 0) 00146 # endif 00147 #endif 00148 00149 #endif /* gdb_ptrace.h */