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