initial import
[glibc.git] / sysdeps / stub / ptrace.c
blob6bd5917f39a456e93305c16f0261370849b749c2
1 /* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If
16 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
17 Cambridge, MA 02139, USA. */
19 #include <ansidecl.h>
20 #include <errno.h>
21 #include <sys/ptrace.h>
22 #include <sys/types.h>
23 #include <stdarg.h>
25 /* Perform process tracing functions. REQUEST is one of the values
26 in <sys/ptrace.h>, and determines the action to be taken.
27 For all requests except PTRACE_TRACEME, PID specifies the process to be
28 traced.
30 PID and the other arguments described above for the various requests should
31 appear (those that are used for the particular request) as:
32 pid_t PID, void *ADDR, int DATA, void *ADDR2
33 after PID. */
34 int
35 DEFUN(ptrace, (request), enum __ptrace_request request DOTS)
37 pid_t pid;
38 PTR addr;
39 PTR addr2;
40 int data;
41 va_list ap;
43 switch (request)
45 case PTRACE_TRACEME:
46 case PTRACE_CONT:
47 case PTRACE_KILL:
48 case PTRACE_SINGLESTEP:
49 case PTRACE_ATTACH:
50 case PTRACE_DETACH:
51 break;
53 case PTRACE_PEEKTEXT:
54 case PTRACE_PEEKDATA:
55 case PTRACE_PEEKUSER:
56 case PTRACE_GETREGS:
57 case PTRACE_SETREGS:
58 #ifdef PTRACE_GETFPREGS
59 case PTRACE_GETFPGEGS:
60 #endif
61 case PTRACE_SETFPREGS:
62 case PTRACE_GETFPAREGS:
63 case PTRACE_SETFPAREGS:
64 va_start(ap, request);
65 pid = va_arg(ap, pid_t);
66 addr = va_arg(ap, PTR);
67 va_end(ap);
68 break;
70 case PTRACE_POKETEXT:
71 case PTRACE_POKEDATA:
72 case PTRACE_POKEUSER:
73 va_start(ap, request);
74 pid = va_arg(ap, pid_t);
75 addr = va_arg(ap, PTR);
76 data = va_arg(ap, int);
77 va_end(ap);
78 break;
80 case PTRACE_READDATA:
81 case PTRACE_WRITEDATA:
82 case PTRACE_READTEXT:
83 case PTRACE_WRITETEXT:
84 va_start(ap, request);
85 pid = va_arg(ap, pid_t);
86 addr = va_arg(ap, PTR);
87 data = va_arg(ap, int);
88 addr2 = va_arg(ap, PTR);
89 va_end(ap);
90 break;
92 default:
93 errno = EINVAL;
94 return -1;
97 errno = ENOSYS;
98 return -1;
102 #ifdef HAVE_GNU_LD
104 #include <gnu-stabs.h>
106 stub_warning(ptrace);
108 #endif /* GNU stabs. */