xref: /dflybsd-src/contrib/gdb-7/gdb/gdb_ptrace.h (revision de8e141f24382815c10a4012d209bbbf7abf1112)
15796c8dcSSimon Schubert /* Portable <sys/ptrace.h>
25796c8dcSSimon Schubert 
3*ef5ccd6cSJohn Marino    Copyright (C) 2004-2013 Free Software Foundation, Inc.
45796c8dcSSimon Schubert 
55796c8dcSSimon Schubert    This file is part of GDB.
65796c8dcSSimon Schubert 
75796c8dcSSimon Schubert    This program is free software; you can redistribute it and/or modify
85796c8dcSSimon Schubert    it under the terms of the GNU General Public License as published by
95796c8dcSSimon Schubert    the Free Software Foundation; either version 3 of the License, or
105796c8dcSSimon Schubert    (at your option) any later version.
115796c8dcSSimon Schubert 
125796c8dcSSimon Schubert    This program is distributed in the hope that it will be useful,
135796c8dcSSimon Schubert    but WITHOUT ANY WARRANTY; without even the implied warranty of
145796c8dcSSimon Schubert    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
155796c8dcSSimon Schubert    GNU General Public License for more details.
165796c8dcSSimon Schubert 
175796c8dcSSimon Schubert    You should have received a copy of the GNU General Public License
185796c8dcSSimon Schubert    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
195796c8dcSSimon Schubert 
205796c8dcSSimon Schubert #ifndef GDB_PTRACE_H
215796c8dcSSimon Schubert #define GDB_PTRACE_H
225796c8dcSSimon Schubert 
235796c8dcSSimon Schubert /* The <sys/ptrace.h> header was introduced with 4.4BSD, and provided
245796c8dcSSimon Schubert    the PT_* symbolic constants for the ptrace(2) request numbers.  The
255796c8dcSSimon Schubert    ptrace(2) prototype was added later to the same header on BSD.
265796c8dcSSimon Schubert    SunOS and GNU/Linux have slightly different symbolic names for the
275796c8dcSSimon Schubert    constants that start with PTRACE_*.  System V still doesn't have
285796c8dcSSimon Schubert    (and probably never will have) a <sys/ptrace.h> with symbolic
295796c8dcSSimon Schubert    constants; the ptrace(2) prototype can be found in <unistd.h>.
305796c8dcSSimon Schubert    Fortunately all systems use the same numerical constants for the
315796c8dcSSimon Schubert    common ptrace requests.  */
325796c8dcSSimon Schubert 
335796c8dcSSimon Schubert #ifdef HAVE_PTRACE_H
345796c8dcSSimon Schubert # include <ptrace.h>
355796c8dcSSimon Schubert #elif defined(HAVE_SYS_PTRACE_H)
365796c8dcSSimon Schubert # include <sys/ptrace.h>
375796c8dcSSimon Schubert #endif
385796c8dcSSimon Schubert 
395796c8dcSSimon Schubert /* No need to include <unistd.h> since it's already included by
405796c8dcSSimon Schubert    "defs.h".  */
415796c8dcSSimon Schubert 
425796c8dcSSimon Schubert #ifndef PT_TRACE_ME
435796c8dcSSimon Schubert # define PT_TRACE_ME	0
445796c8dcSSimon Schubert #endif
455796c8dcSSimon Schubert 
465796c8dcSSimon Schubert #ifndef PT_READ_I
475796c8dcSSimon Schubert # define PT_READ_I	1	/* Read word in child's I space.  */
485796c8dcSSimon Schubert #endif
495796c8dcSSimon Schubert 
505796c8dcSSimon Schubert #ifndef PT_READ_D
515796c8dcSSimon Schubert # define PT_READ_D	2	/* Read word in child's D space.  */
525796c8dcSSimon Schubert #endif
535796c8dcSSimon Schubert 
545796c8dcSSimon Schubert #ifndef PT_READ_U
555796c8dcSSimon Schubert # define PT_READ_U	3	/* Read word in child's U space.  */
565796c8dcSSimon Schubert #endif
575796c8dcSSimon Schubert 
585796c8dcSSimon Schubert #ifndef PT_WRITE_I
595796c8dcSSimon Schubert # define PT_WRITE_I	4	/* Write word in child's I space.  */
605796c8dcSSimon Schubert #endif
615796c8dcSSimon Schubert 
625796c8dcSSimon Schubert #ifndef PT_WRITE_D
635796c8dcSSimon Schubert # define PT_WRITE_D	5	/* Write word in child's D space.  */
645796c8dcSSimon Schubert #endif
655796c8dcSSimon Schubert 
665796c8dcSSimon Schubert #ifndef PT_WRITE_U
675796c8dcSSimon Schubert # define PT_WRITE_U	6	/* Write word in child's U space.  */
685796c8dcSSimon Schubert #endif
695796c8dcSSimon Schubert 
705796c8dcSSimon Schubert /* HP-UX doesn't define PT_CONTINUE and PT_STEP.  Instead of those two
715796c8dcSSimon Schubert    ptrace requests, it has PT_CONTIN, PT_CONTIN1, PT_SINGLE and
725796c8dcSSimon Schubert    PT_SINGLE1.  PT_CONTIN1 and PT_SINGLE1 preserve pending signals,
735796c8dcSSimon Schubert    which apparently is what is wanted by the HP-UX native code.  */
745796c8dcSSimon Schubert 
755796c8dcSSimon Schubert #ifndef PT_CONTINUE
765796c8dcSSimon Schubert # ifdef PT_CONTIN1
775796c8dcSSimon Schubert #  define PT_CONTINUE	PT_CONTIN1
785796c8dcSSimon Schubert # else
795796c8dcSSimon Schubert #  define PT_CONTINUE	7	/* Continue the child.  */
805796c8dcSSimon Schubert # endif
815796c8dcSSimon Schubert #endif
825796c8dcSSimon Schubert 
835796c8dcSSimon Schubert #ifndef PT_KILL
845796c8dcSSimon Schubert # define PT_KILL	8	/* Kill the child process.  */
855796c8dcSSimon Schubert #endif
865796c8dcSSimon Schubert 
875796c8dcSSimon Schubert #ifndef PT_STEP
885796c8dcSSimon Schubert # ifdef PT_SINGLE1
895796c8dcSSimon Schubert #  define PT_STEP	PT_SINGLE1
905796c8dcSSimon Schubert # else
915796c8dcSSimon Schubert #  define PT_STEP	9	/* Single step the child.   */
925796c8dcSSimon Schubert # endif
935796c8dcSSimon Schubert #endif
945796c8dcSSimon Schubert 
955796c8dcSSimon Schubert /* Not all systems support attaching and detaching.   */
965796c8dcSSimon Schubert 
975796c8dcSSimon Schubert #ifndef PT_ATTACH
985796c8dcSSimon Schubert # ifdef PTRACE_ATTACH
995796c8dcSSimon Schubert #  define PT_ATTACH PTRACE_ATTACH
1005796c8dcSSimon Schubert # endif
1015796c8dcSSimon Schubert #endif
1025796c8dcSSimon Schubert 
1035796c8dcSSimon Schubert #ifndef PT_DETACH
1045796c8dcSSimon Schubert # ifdef PTRACE_DETACH
1055796c8dcSSimon Schubert #  define PT_DETACH PTRACE_DETACH
1065796c8dcSSimon Schubert # endif
1075796c8dcSSimon Schubert #endif
1085796c8dcSSimon Schubert 
1095796c8dcSSimon Schubert /* For systems such as HP/UX that do not provide PT_SYSCALL, define it
1105796c8dcSSimon Schubert    here as an alias for PT_CONTINUE.  This is what the PT_SYSCALL
1115796c8dcSSimon Schubert    request is expected to do, in addition to stopping when entering/
1125796c8dcSSimon Schubert    exiting a system call.  Chances are, if the system supports system
1135796c8dcSSimon Schubert    call tracing, enabling this feature is probably done separately;
1145796c8dcSSimon Schubert    and there is probably no special request that we would be required
1155796c8dcSSimon Schubert    to use when resuming the execution of our program.  */
1165796c8dcSSimon Schubert #ifndef PT_SYSCALL
117cf7f2e2dSJohn Marino # ifdef PTRACE_SYSCALL
118cf7f2e2dSJohn Marino #  define PT_SYSCALL PTRACE_SYSCALL
119cf7f2e2dSJohn Marino #else
1205796c8dcSSimon Schubert #  define PT_SYSCALL PT_CONTINUE
1215796c8dcSSimon Schubert # endif
122cf7f2e2dSJohn Marino #endif
1235796c8dcSSimon Schubert 
1245796c8dcSSimon Schubert /* Some systems, in particular DEC OSF/1, Digital Unix, Compaq Tru64
1255796c8dcSSimon Schubert    or whatever it's called these days, don't provide a prototype for
1265796c8dcSSimon Schubert    ptrace.  Provide one to silence compiler warnings.  */
1275796c8dcSSimon Schubert 
1285796c8dcSSimon Schubert #ifndef HAVE_DECL_PTRACE
1295796c8dcSSimon Schubert extern PTRACE_TYPE_RET ptrace();
1305796c8dcSSimon Schubert #endif
1315796c8dcSSimon Schubert 
1325796c8dcSSimon Schubert /* Some systems, at least AIX and HP-UX have a ptrace with five
1335796c8dcSSimon Schubert    arguments.  Since we never use the fifth argument, define a ptrace
1345796c8dcSSimon Schubert    macro that calls the real ptrace with the last argument set to
1355796c8dcSSimon Schubert    zero.  */
1365796c8dcSSimon Schubert 
1375796c8dcSSimon Schubert #ifdef PTRACE_TYPE_ARG5
1385796c8dcSSimon Schubert # define ptrace(request, pid, addr, data) ptrace (request, pid, addr, data, 0)
1395796c8dcSSimon Schubert #endif
1405796c8dcSSimon Schubert 
1415796c8dcSSimon Schubert #endif /* gdb_ptrace.h */
142