2005-01-19 Andrew Cagney <cagney@gnu.org>
[deliverable/binutils-gdb.git] / gdb / gdb_ptrace.h
1 /* Portable <sys/ptrace.h>
2
3 Copyright 2004 Free Software Foundation, Inc.
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
9 the Free Software Foundation; either version 2 of the License, or
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
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
21
22 #ifndef GDB_PTRACE_H
23 #define GDB_PTRACE_H
24
25 /* The <sys/ptrace.h> header was introduced with 4.4BSD, and provided
26 the PT_* symbolic constants for the ptrace(2) request numbers. The
27 ptrace(2) prototype was added later to the same header on BSD.
28 SunOS and GNU/Linux have slightly different symbolic names for the
29 constants that start with PTRACE_*. System V still doesn't have
30 (and probably never will have) a <sys/ptrace.h> with symbolic
31 constants; the ptrace(2) prototype can be found in <unistd.h>.
32 Fortunately all systems use the same numerical constants for the
33 common ptrace requests. */
34
35 #ifdef HAVE_PTRACE_H
36 # include <ptrace.h>
37 #elif defined(HAVE_SYS_PTRACE_H)
38 # include <sys/ptrace.h>
39 #endif
40
41 /* No need to include <unistd.h> since it's already included by
42 "defs.h". */
43
44 #ifndef PT_READ_I
45 # define PT_READ_I 1 /* Read word in child's I space. */
46 #endif
47
48 #ifndef PT_READ_D
49 # define PT_READ_D 2 /* Read word in child's D space. */
50 #endif
51
52 #ifndef PT_READ_U
53 # define PT_READ_U 3 /* Read word in child's U space. */
54 #endif
55
56 #ifndef PT_WRITE_I
57 # define PT_WRITE_I 4 /* Write word in child's I space. */
58 #endif
59
60 #ifndef PT_WRITE_D
61 # define PT_WRITE_D 5 /* Write word in child's D space. */
62 #endif
63
64 #ifndef PT_WRITE_U
65 # define PT_WRITE_U 6 /* Write word in child's U space. */
66 #endif
67
68 /* HP-UX doesn't define PT_CONTINUE and PT_STEP. Instead of those two
69 ptrace requests, it has PT_CONTIN, PT_CONTIN1, PT_SINGLE and
70 PT_SINGLE1. PT_CONTIN1 and PT_SINGLE1 preserve pending signals,
71 which apparently is what is wanted by the HP-UX native code. */
72
73 #ifndef PT_CONTINUE
74 # ifdef PT_CONTIN1
75 # define PT_CONTINUE PT_CONTIN1
76 # else
77 # define PT_CONTINUE 7 /* Continue the child. */
78 # endif
79 #endif
80
81 #ifndef PT_KILL
82 # define PT_KILL 8 /* Kill the child process. */
83 #endif
84
85 #ifndef PT_STEP
86 # ifdef PT_SINGLE1
87 # define PT_STEP PT_SINGLE1
88 # else
89 # define PT_STEP 9 /* Single step the child. */
90 # endif
91 #endif
92
93 /* Not all systems support attaching and detaching. */
94
95 #ifndef PT_ATTCH
96 # ifdef PTRACE_DETACH
97 # define PT_ATTACH PTRACE_ATTACH
98 # endif
99 #endif
100
101 #ifndef PT_DETACH
102 # ifdef PTRACE_DETACH
103 # define PT_DETACH PTRACE_DETACH
104 # endif
105 #endif
106
107 /* Some systems, in particular DEC OSF/1, Digital Unix, Compaq Tru64
108 or whatever it's called these days, don't provide a prototype for
109 ptrace. Provide one to silence compiler warnings. */
110
111 #ifndef HAVE_DECL_PTRACE
112 extern PTRACE_TYPE_RET ptrace();
113 #endif
114
115 /* Some systems, at least AIX and HP-UX have a ptrace with five
116 arguments. Since we never use the fifth argument, define a ptrace
117 macro that calls the real ptrace with the last argument set to
118 zero. */
119
120 #ifdef PTRACE_TYPE_ARG5
121 # define ptrace(request, pid, addr, data) ptrace (request, pid, addr, data, 0)
122 #endif
123
124 #endif /* gdb_ptrace.h */
This page took 0.031173 seconds and 4 git commands to generate.