]> sourceware.org Git - systemtap.git/blame - tapset/linux/s390/aux_syscalls.stp
Deal with kernels pre-6.12 kernel that relocated unaligned.h
[systemtap.git] / tapset / linux / s390 / aux_syscalls.stp
CommitLineData
aa1d3e0a
JK
1# arch-specific requests of ptrace ___________________________
2#
eddbc9e4 3%{
115c9287
DS
4// compat_ptrace_area is defined in a private header
5// (arch/s390/kernel/compat_ptrace.h), so define our own.
6typedef struct
7{
8 __u32 len;
9 __u32 kernel_addr;
10 __u32 process_addr;
11} __stp_compat_ptrace_area;
12
13%}
14
15function _stp_ptrace_area_u:string(ptrace_area_uaddr:long)
16%{ /* pure */
f6b623f6 17 char *area_uaddr = (void *)(uintptr_t)STAP_ARG_ptrace_area_uaddr;
115c9287
DS
18 ptrace_area area;
19 if (area_uaddr == NULL)
20 strlcpy(STAP_RETVALUE, "NULL", MAXSTRINGLEN);
21 else {
22 if (_stp_copy_from_user((char*)&area, area_uaddr,
23 sizeof(area)) == 0) {
24 _stp_snprintf(STAP_RETVALUE, MAXSTRINGLEN,
25 "[{%u, %#lx, %#lx}]", area.len,
26 area.kernel_addr, area.process_addr);
27 }
28 else
29 _stp_snprintf(STAP_RETVALUE, MAXSTRINGLEN, "0x%lx",
30 (unsigned long)area_uaddr);
31 }
32%}
33
34function _stp_compat_ptrace_area_u:string(compat_ptrace_area_uaddr:long)
35%{ /* pure */
36#ifdef CONFIG_COMPAT
f6b623f6 37 char *area_uaddr = (void *)(uintptr_t)STAP_ARG_compat_ptrace_area_uaddr;
115c9287
DS
38 __stp_compat_ptrace_area area;
39 if (area_uaddr == NULL)
40 strlcpy(STAP_RETVALUE, "NULL", MAXSTRINGLEN);
41 else {
42 if (_stp_copy_from_user((char*)&area, area_uaddr,
43 sizeof(area)) == 0) {
44 _stp_snprintf(STAP_RETVALUE, MAXSTRINGLEN,
45 "[{%u, %#x, %#x}]", area.len,
46 area.kernel_addr, area.process_addr);
47 }
48 else
49 _stp_snprintf(STAP_RETVALUE, MAXSTRINGLEN, "0x%lx",
50 (unsigned long)area_uaddr);
51 }
52#endif
53%}
54
55%{
9b5f3777
DS
56// Get _stp_val_array and _stp_lookup_* definitions.
57#include "linux/syscalls-common.h"
58
ea322dcc
DS
59// PTRACE_SINGLEBLOCK was added in kernel 3.15. However, its value
60// overlaps with PTRACE_GETREGS (which userspace has defined. So,
61// we'll give PTRACE_SINGLEBLOCK a bogus value on earlier kernels.
115c9287 62#ifndef PTRACE_SINGLEBLOCK
ea322dcc 63#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)
115c9287 64#define PTRACE_SINGLEBLOCK 12
ea322dcc
DS
65#else
66#define PTRACE_SINGLEBLOCK 0xABCDEF12
67#endif
115c9287 68#endif
eddbc9e4
DS
69#ifndef PTRACE_GET_LAST_BREAK
70#define PTRACE_GET_LAST_BREAK 0x5006
71#endif
115c9287
DS
72#ifndef PTRACE_PEEK_SYSTEM_CALL
73#define PTRACE_PEEK_SYSTEM_CALL 0x5007
74#endif
75#ifndef PTRACE_POKE_SYSTEM_CALL
76#define PTRACE_POKE_SYSTEM_CALL 0x5008
77#endif
78#ifndef PTRACE_ENABLE_TE
79#define PTRACE_ENABLE_TE 0x5009
80#endif
81#ifndef PTRACE_DISABLE_TE
82#define PTRACE_DISABLE_TE 0x5010
83#endif
84#ifndef PTRACE_TE_ABORT_RAND
85#define PTRACE_TE_ABORT_RAND 0x5011
86#endif
87
1371bf9b 88static const _stp_val_array _stp_arch_ptrace_request_list[] = {
115c9287
DS
89 V(PTRACE_SINGLEBLOCK),
90 V(PTRACE_OLDSETOPTIONS),
91 V(PTRACE_PEEKUSR_AREA),
92 V(PTRACE_POKEUSR_AREA),
93 V(PTRACE_PEEKTEXT_AREA),
94 V(PTRACE_PEEKDATA_AREA),
95 V(PTRACE_POKETEXT_AREA),
96 V(PTRACE_POKEDATA_AREA),
97 V(PTRACE_GET_LAST_BREAK),
98 V(PTRACE_PEEK_SYSTEM_CALL),
99 V(PTRACE_POKE_SYSTEM_CALL),
100 V(PTRACE_ENABLE_TE),
101 V(PTRACE_DISABLE_TE),
102 V(PTRACE_TE_ABORT_RAND),
103 {0, NULL}
104};
105%}
106
107function __arch_ptrace_request_str:string(request:long)
108%{ /* pure */
109 _stp_lookup_str(_stp_arch_ptrace_request_list,
110 (unsigned long)STAP_ARG_request, STAP_RETVALUE,
111 MAXSTRINGLEN);
eddbc9e4
DS
112%}
113
aa1d3e0a
JK
114function _arch_ptrace_argstr(request, pid, addr, data)
115{
efbffd6e 116 if (request == @const("PTRACE_OLDSETOPTIONS"))
115c9287
DS
117 return sprintf("PTRACE_OLDSETOPTIONS, %d, %#x, %s", pid,
118 addr, _ptrace_options_str(data))
efbffd6e
MC
119 if (request == @const("PTRACE_PEEKUSR_AREA")
120 || request == @const("PTRACE_POKEUSR_AREA")
121 || request == @const("PTRACE_PEEKTEXT_AREA")
122 || request == @const("PTRACE_PEEKDATA_AREA")
123 || request == @const("PTRACE_POKETEXT_AREA")
124 || request == @const("PTRACE_POKEDATA_AREA"))
115c9287
DS
125 return sprintf("%s, %d, %s, %#x",
126 __arch_ptrace_request_str(request), pid,
2c3968d3 127 (@__compat_task
115c9287
DS
128 ? _stp_compat_ptrace_area_u(addr)
129 : _stp_ptrace_area_u(addr)), data)
efbffd6e
MC
130 if (request == @const("PTRACE_GET_LAST_BREAK")
131 || request == @const("PTRACE_ENABLE_TE")
132 || request == @const("PTRACE_DISABLE_TE")
133 || request == @const("PTRACE_TE_ABORT_RAND"))
115c9287
DS
134 return sprintf("%s, %d, %#x, %#x",
135 __arch_ptrace_request_str(request),
136 pid, addr, data)
137
138 // Although the following ptrace requests are defined in the
139 // ptrace header file, they aren't implemented in the kernel.
efbffd6e
MC
140 if (request == @const("PTRACE_PEEK_SYSTEM_CALL")
141 || request == @const("PTRACE_POKE_SYSTEM_CALL"))
115c9287
DS
142 return sprintf("%s, %d, %#x, %#x",
143 __arch_ptrace_request_str(request),
144 pid, addr, data)
ea322dcc
DS
145
146 if (request == @const("PTRACE_SINGLEBLOCK"))
147 return sprintf("%s, %d, %#x, %s",
148 __arch_ptrace_request_str(request), pid,
149 addr, _signal_name (data))
aa1d3e0a
JK
150}
151
31b3e2d3 152function _ptrace_return_arch_prctl_addr:long(request:long, addr:long, data:long)
aa1d3e0a 153{
208fad92 154 return 0
aa1d3e0a 155}
e4603fa5 156
c88409ef 157%( systemtap_v <= "3.0" %?
e4603fa5
DS
158function get_32mmap_args:string(args:long)
159%{ /* pure */
160 struct mmap_arg_struct_emu31 {
161 u32 addr;
162 u32 len;
163 u32 prot;
164 u32 flags;
165 u32 fd;
166 u32 offset;
167 } a;
168
f6b623f6 169 if (_stp_copy_from_user((char *)&a, (char *)(uintptr_t)STAP_ARG_args,
e4603fa5
DS
170 sizeof(a)) == 0) {
171 int len;
172 _stp_snprintf(STAP_RETVALUE, MAXSTRINGLEN, "0x%x, %u, ",
173 a.addr, a.len);
174 _stp_lookup_or_str(_stp_mprotect_list, a.prot, STAP_RETVALUE,
175 MAXSTRINGLEN);
176 strlcat (STAP_RETVALUE, ", ", MAXSTRINGLEN);
177 _stp_lookup_or_str(_stp_mmap_list, a.flags, STAP_RETVALUE,
178 MAXSTRINGLEN);
179 strlcat (STAP_RETVALUE, ", ", MAXSTRINGLEN);
180 len = strlen(STAP_RETVALUE);
181 _stp_snprintf(STAP_RETVALUE + len, MAXSTRINGLEN - len,
182 "%d, %d", a.fd, a.offset);
183 } else {
184 strlcpy (STAP_RETVALUE, "UNKNOWN", MAXSTRINGLEN);
185 }
186%}
c88409ef 187%)
This page took 0.220417 seconds and 6 git commands to generate.