]>
Commit | Line | Data |
---|---|---|
bfff8b1b | 1 | /* Copyright (C) 1991-2017 Free Software Foundation, Inc. |
478b92f0 UD |
2 | This file is part of the GNU C Library. |
3 | ||
4 | The GNU C Library is free software; you can redistribute it and/or | |
41bdb6e2 AJ |
5 | modify it under the terms of the GNU Lesser General Public |
6 | License as published by the Free Software Foundation; either | |
7 | version 2.1 of the License, or (at your option) any later version. | |
478b92f0 UD |
8 | |
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 | |
41bdb6e2 | 12 | Lesser General Public License for more details. |
478b92f0 | 13 | |
41bdb6e2 | 14 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 PE |
15 | License along with the GNU C Library; if not, see |
16 | <http://www.gnu.org/licenses/>. */ | |
28f540f4 | 17 | |
28f540f4 RM |
18 | #include <errno.h> |
19 | #include <sys/ptrace.h> | |
20 | #include <sys/types.h> | |
21 | #include <stdarg.h> | |
4bee4cd9 | 22 | #include <libc-internal.h> |
28f540f4 RM |
23 | |
24 | /* Perform process tracing functions. REQUEST is one of the values | |
25 | in <sys/ptrace.h>, and determines the action to be taken. | |
26 | For all requests except PTRACE_TRACEME, PID specifies the process to be | |
27 | traced. | |
28 | ||
29 | PID and the other arguments described above for the various requests should | |
30 | appear (those that are used for the particular request) as: | |
31 | pid_t PID, void *ADDR, int DATA, void *ADDR2 | |
32 | after PID. */ | |
33 | int | |
4bee4cd9 | 34 | ptrace (enum __ptrace_request request, ...) |
28f540f4 RM |
35 | { |
36 | pid_t pid; | |
c4029823 UD |
37 | void *addr; |
38 | void *addr2; | |
28f540f4 RM |
39 | int data; |
40 | va_list ap; | |
41 | ||
42 | switch (request) | |
43 | { | |
44 | case PTRACE_TRACEME: | |
45 | case PTRACE_CONT: | |
46 | case PTRACE_KILL: | |
47 | case PTRACE_SINGLESTEP: | |
48 | case PTRACE_ATTACH: | |
49 | case PTRACE_DETACH: | |
50 | break; | |
51 | ||
52 | case PTRACE_PEEKTEXT: | |
53 | case PTRACE_PEEKDATA: | |
54 | case PTRACE_PEEKUSER: | |
55 | case PTRACE_GETREGS: | |
56 | case PTRACE_SETREGS: | |
57 | #ifdef PTRACE_GETFPREGS | |
58 | case PTRACE_GETFPGEGS: | |
59 | #endif | |
60 | case PTRACE_SETFPREGS: | |
61 | case PTRACE_GETFPAREGS: | |
62 | case PTRACE_SETFPAREGS: | |
4bee4cd9 RM |
63 | va_start (ap, request); |
64 | pid = va_arg (ap, pid_t); | |
65 | addr = va_arg (ap, void *); | |
66 | va_end (ap); | |
67 | ignore_value (pid); | |
68 | ignore_value (addr); | |
28f540f4 RM |
69 | break; |
70 | ||
71 | case PTRACE_POKETEXT: | |
72 | case PTRACE_POKEDATA: | |
73 | case PTRACE_POKEUSER: | |
4bee4cd9 RM |
74 | va_start (ap, request); |
75 | pid = va_arg (ap, pid_t); | |
76 | addr = va_arg (ap, void *); | |
77 | data = va_arg (ap, int); | |
78 | va_end (ap); | |
79 | ignore_value (pid); | |
80 | ignore_value (addr); | |
81 | ignore_value (data); | |
28f540f4 RM |
82 | break; |
83 | ||
84 | case PTRACE_READDATA: | |
85 | case PTRACE_WRITEDATA: | |
86 | case PTRACE_READTEXT: | |
87 | case PTRACE_WRITETEXT: | |
4bee4cd9 RM |
88 | va_start (ap, request); |
89 | pid = va_arg (ap, pid_t); | |
90 | addr = va_arg (ap, void *); | |
91 | data = va_arg (ap, int); | |
92 | addr2 = va_arg (ap, void *); | |
93 | va_end (ap); | |
94 | ignore_value (pid); | |
95 | ignore_value (addr); | |
96 | ignore_value (data); | |
97 | ignore_value (addr2); | |
28f540f4 RM |
98 | break; |
99 | ||
100 | default: | |
c4029823 | 101 | __set_errno (EINVAL); |
28f540f4 RM |
102 | return -1; |
103 | } | |
104 | ||
c4029823 | 105 | __set_errno (ENOSYS); |
28f540f4 RM |
106 | return -1; |
107 | } | |
108 | ||
3f33a4ce | 109 | stub_warning (ptrace) |