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