2 * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
3 * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
4 * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
5 * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
6 * Copyright (c) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
7 * Linux for s390 port by D.J. Barrow
8 * <barrow_dj@mail.yahoo.com,djbarrow@de.ibm.com>
9 * Copyright (c) 2000 PocketPenguins Inc. Linux for Hitachi SuperH
10 * port by Greg Banks <gbanks@pocketpenguins.com>
11 * Copyright (c) 1999-2018 The strace developers.
13 * All rights reserved.
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
23 * 3. The name of the author may not be used to endorse or promote products
24 * derived from this software without specific prior written permission.
26 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
27 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
28 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
29 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
30 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
31 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
47 #include "xlat/nt_descriptor_types.h"
48 #include "xlat/ptrace_cmds.h"
49 #include "xlat/ptrace_setoptions_flags.h"
50 #include "xlat/ptrace_peeksiginfo_flags.h"
52 #define uoff(member) offsetof(struct user, member)
53 #define XLAT_UOFF(member) { uoff(member), "offsetof(struct user, " #member ")" }
55 static const struct xlat struct_user_offsets[] = {
61 print_user_offset_addr(const kernel_ulong_t addr)
65 for (x = struct_user_offsets; x->str; ++x) {
72 } else if (x->val > addr) {
73 if (x == struct_user_offsets) {
77 tprintf("%s + %" PRI_klu,
78 x->str, addr - (kernel_ulong_t) x->val);
87 const kernel_ulong_t request = tcp->u_arg[0];
88 const int pid = tcp->u_arg[1];
89 const kernel_ulong_t addr = tcp->u_arg[2];
90 const kernel_ulong_t data = tcp->u_arg[3];
94 printxval64(ptrace_cmds, request, "PTRACE_???");
96 if (request == PTRACE_TRACEME) {
97 /* pid, addr, and data are ignored. */
102 tprintf(", %d", pid);
107 case PTRACE_INTERRUPT:
110 /* addr and data are ignored */
112 case PTRACE_PEEKUSER:
113 case PTRACE_POKEUSER:
115 print_user_offset_addr(addr);
117 case PTRACE_GETREGSET:
118 case PTRACE_SETREGSET:
120 printxval(nt_descriptor_types, addr, "NT_???");
122 case PTRACE_GETSIGMASK:
123 case PTRACE_SETSIGMASK:
124 case PTRACE_SECCOMP_GET_FILTER:
125 tprintf(", %" PRI_klu, addr);
127 case PTRACE_PEEKSIGINFO: {
134 if (umove_or_printaddr(tcp, addr, &psi)) {
139 tprintf("{off=%" PRIu64 ", flags=", psi.off);
140 printflags(ptrace_peeksiginfo_flags, psi.flags,
141 "PTRACE_PEEKSIGINFO_???");
142 tprintf(", nr=%u}", psi.nr);
150 # if defined IA64 || defined SPARC || defined SPARC64
153 case PTRACE_PEEKDATA:
154 case PTRACE_PEEKTEXT:
155 case PTRACE_PEEKUSER:
156 /* data is ignored */
157 return RVAL_DECODED | RVAL_HEX;
159 # if defined SPARC || defined SPARC64
162 case PTRACE_GETFPREGS:
163 case PTRACE_SETFPREGS:
164 /* data is ignored */
166 # endif /* SPARC || SPARC64 */
168 # endif /* IA64 || SPARC || SPARC64 */
177 #ifdef PTRACE_SINGLESTEP
178 case PTRACE_SINGLESTEP:
180 #ifdef PTRACE_SINGLEBLOCK
181 case PTRACE_SINGLEBLOCK:
186 #ifdef PTRACE_SYSEMU_SINGLESTEP
187 case PTRACE_SYSEMU_SINGLESTEP:
192 case PTRACE_SETOPTIONS:
193 #ifdef PTRACE_OLDSETOPTIONS
194 case PTRACE_OLDSETOPTIONS:
196 printflags64(ptrace_setoptions_flags, data, "PTRACE_O_???");
198 case PTRACE_SETSIGINFO:
199 printsiginfo_at(tcp, data);
201 case PTRACE_SETSIGMASK:
202 print_sigset_addr_len(tcp, data, addr);
204 case PTRACE_SETREGSET:
205 tprint_iov(tcp, /*len:*/ 1, data, IOV_DECODE_ADDR);
208 case PTRACE_PEEKDATA:
209 case PTRACE_PEEKTEXT:
210 case PTRACE_PEEKUSER:
212 case PTRACE_GETEVENTMSG:
213 case PTRACE_GETREGSET:
214 case PTRACE_GETSIGINFO:
215 case PTRACE_GETSIGMASK:
216 case PTRACE_PEEKSIGINFO:
217 case PTRACE_SECCOMP_GET_FILTER:
219 /* print data on exiting syscall */
232 case PTRACE_PEEKDATA:
233 case PTRACE_PEEKTEXT:
234 case PTRACE_PEEKUSER:
235 printnum_ptr(tcp, data);
238 case PTRACE_GETEVENTMSG:
239 printnum_ulong(tcp, data);
241 case PTRACE_GETREGSET:
242 tprint_iov(tcp, /*len:*/ 1, data, IOV_DECODE_ADDR);
244 case PTRACE_GETSIGINFO:
245 printsiginfo_at(tcp, data);
247 case PTRACE_GETSIGMASK:
248 print_sigset_addr_len(tcp, data, addr);
250 case PTRACE_PEEKSIGINFO:
251 print_siginfo_array(tcp, data, tcp->u_rval);
253 case PTRACE_SECCOMP_GET_FILTER:
254 print_seccomp_fprog(tcp, data, tcp->u_rval);