Commit | Line | Data |
---|---|---|
11003ae3 MK |
1 | /* Portable <sys/ptrace.h> |
2 | ||
0fb0cc75 | 3 | Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation, Inc. |
11003ae3 MK |
4 | |
5 | This file is part of GDB. | |
6 | ||
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
a9762ec7 | 9 | the Free Software Foundation; either version 3 of the License, or |
11003ae3 MK |
10 | (at your option) any later version. |
11 | ||
12 | This program is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
a9762ec7 | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
11003ae3 MK |
19 | |
20 | #ifndef GDB_PTRACE_H | |
21 | #define GDB_PTRACE_H | |
22 | ||
23 | /* The <sys/ptrace.h> header was introduced with 4.4BSD, and provided | |
24 | the PT_* symbolic constants for the ptrace(2) request numbers. The | |
25 | ptrace(2) prototype was added later to the same header on BSD. | |
277215a6 | 26 | SunOS and GNU/Linux have slightly different symbolic names for the |
11003ae3 MK |
27 | constants that start with PTRACE_*. System V still doesn't have |
28 | (and probably never will have) a <sys/ptrace.h> with symbolic | |
29 | constants; the ptrace(2) prototype can be found in <unistd.h>. | |
30 | Fortunately all systems use the same numerical constants for the | |
31 | common ptrace requests. */ | |
32 | ||
33 | #ifdef HAVE_PTRACE_H | |
34 | # include <ptrace.h> | |
35 | #elif defined(HAVE_SYS_PTRACE_H) | |
36 | # include <sys/ptrace.h> | |
37 | #endif | |
38 | ||
39 | /* No need to include <unistd.h> since it's already included by | |
40 | "defs.h". */ | |
41 | ||
4b8a1a28 MK |
42 | #ifndef PT_TRACE_ME |
43 | # define PT_TRACE_ME 0 | |
44 | #endif | |
45 | ||
11003ae3 MK |
46 | #ifndef PT_READ_I |
47 | # define PT_READ_I 1 /* Read word in child's I space. */ | |
48 | #endif | |
49 | ||
50 | #ifndef PT_READ_D | |
51 | # define PT_READ_D 2 /* Read word in child's D space. */ | |
52 | #endif | |
53 | ||
54 | #ifndef PT_READ_U | |
55 | # define PT_READ_U 3 /* Read word in child's U space. */ | |
56 | #endif | |
57 | ||
58 | #ifndef PT_WRITE_I | |
59 | # define PT_WRITE_I 4 /* Write word in child's I space. */ | |
60 | #endif | |
61 | ||
62 | #ifndef PT_WRITE_D | |
63 | # define PT_WRITE_D 5 /* Write word in child's D space. */ | |
64 | #endif | |
65 | ||
66 | #ifndef PT_WRITE_U | |
67 | # define PT_WRITE_U 6 /* Write word in child's U space. */ | |
68 | #endif | |
69 | ||
70 | /* HP-UX doesn't define PT_CONTINUE and PT_STEP. Instead of those two | |
71 | ptrace requests, it has PT_CONTIN, PT_CONTIN1, PT_SINGLE and | |
72 | PT_SINGLE1. PT_CONTIN1 and PT_SINGLE1 preserve pending signals, | |
73 | which apparently is what is wanted by the HP-UX native code. */ | |
74 | ||
75 | #ifndef PT_CONTINUE | |
76 | # ifdef PT_CONTIN1 | |
77 | # define PT_CONTINUE PT_CONTIN1 | |
78 | # else | |
79 | # define PT_CONTINUE 7 /* Continue the child. */ | |
80 | # endif | |
81 | #endif | |
82 | ||
83 | #ifndef PT_KILL | |
84 | # define PT_KILL 8 /* Kill the child process. */ | |
85 | #endif | |
86 | ||
87 | #ifndef PT_STEP | |
88 | # ifdef PT_SINGLE1 | |
89 | # define PT_STEP PT_SINGLE1 | |
90 | # else | |
91 | # define PT_STEP 9 /* Single step the child. */ | |
92 | # endif | |
93 | #endif | |
94 | ||
95 | /* Not all systems support attaching and detaching. */ | |
96 | ||
4247cafd AS |
97 | #ifndef PT_ATTACH |
98 | # ifdef PTRACE_ATTACH | |
11003ae3 MK |
99 | # define PT_ATTACH PTRACE_ATTACH |
100 | # endif | |
101 | #endif | |
102 | ||
103 | #ifndef PT_DETACH | |
104 | # ifdef PTRACE_DETACH | |
105 | # define PT_DETACH PTRACE_DETACH | |
106 | # endif | |
107 | #endif | |
108 | ||
01dedca2 JB |
109 | /* For systems such as HP/UX that do not provide PT_SYSCALL, define it |
110 | here as an alias for PT_CONTINUE. This is what the PT_SYSCALL | |
111 | request is expected to do, in addition to stopping when entering/ | |
112 | exiting a system call. Chances are, if the system supports system | |
113 | call tracing, enabling this feature is probably done separately; | |
114 | and there is probably no special request that we would be required | |
115 | to use when resuming the execution of our program. */ | |
116 | #ifndef PT_SYSCALL | |
117 | # define PT_SYSCALL PT_CONTINUE | |
118 | #endif | |
119 | ||
11003ae3 MK |
120 | /* Some systems, in particular DEC OSF/1, Digital Unix, Compaq Tru64 |
121 | or whatever it's called these days, don't provide a prototype for | |
122 | ptrace. Provide one to silence compiler warnings. */ | |
f1bc22da | 123 | |
11003ae3 MK |
124 | #ifndef HAVE_DECL_PTRACE |
125 | extern PTRACE_TYPE_RET ptrace(); | |
126 | #endif | |
127 | ||
f1bc22da MK |
128 | /* Some systems, at least AIX and HP-UX have a ptrace with five |
129 | arguments. Since we never use the fifth argument, define a ptrace | |
130 | macro that calls the real ptrace with the last argument set to | |
131 | zero. */ | |
132 | ||
133 | #ifdef PTRACE_TYPE_ARG5 | |
134 | # define ptrace(request, pid, addr, data) ptrace (request, pid, addr, data, 0) | |
135 | #endif | |
136 | ||
11003ae3 | 137 | #endif /* gdb_ptrace.h */ |