2010-07-30 Hui Zhu <teawater@gmail.com>
[deliverable/binutils-gdb.git] / gdb / gdb_ptrace.h
CommitLineData
11003ae3
MK
1/* Portable <sys/ptrace.h>
2
4c38e0a4
JB
3 Copyright (C) 2004, 2005, 2007, 2008, 2009, 2010
4 Free Software Foundation, Inc.
11003ae3
MK
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
a9762ec7 10 the Free Software Foundation; either version 3 of the License, or
11003ae3
MK
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
a9762ec7 19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
11003ae3
MK
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.
277215a6 27 SunOS and GNU/Linux have slightly different symbolic names for the
11003ae3
MK
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
4b8a1a28
MK
43#ifndef PT_TRACE_ME
44# define PT_TRACE_ME 0
45#endif
46
11003ae3
MK
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
4247cafd
AS
98#ifndef PT_ATTACH
99# ifdef PTRACE_ATTACH
11003ae3
MK
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
01dedca2
JB
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
09de9781
DM
118# ifdef PTRACE_SYSCALL
119# define PT_SYSCALL PTRACE_SYSCALL
120#else
121# define PT_SYSCALL PT_CONTINUE
122# endif
01dedca2
JB
123#endif
124
11003ae3
MK
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. */
f1bc22da 128
11003ae3
MK
129#ifndef HAVE_DECL_PTRACE
130extern PTRACE_TYPE_RET ptrace();
131#endif
132
f1bc22da
MK
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
11003ae3 142#endif /* gdb_ptrace.h */
This page took 0.760869 seconds and 4 git commands to generate.