]>
Commit | Line | Data |
---|---|---|
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. | |
6 | typedef struct | |
7 | { | |
8 | __u32 len; | |
9 | __u32 kernel_addr; | |
10 | __u32 process_addr; | |
11 | } __stp_compat_ptrace_area; | |
12 | ||
13 | %} | |
14 | ||
15 | function _stp_ptrace_area_u:string(ptrace_area_uaddr:long) | |
16 | %{ /* pure */ | |
17 | char *area_uaddr = (void *)(intptr_t)STAP_ARG_ptrace_area_uaddr; | |
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 | ||
34 | function _stp_compat_ptrace_area_u:string(compat_ptrace_area_uaddr:long) | |
35 | %{ /* pure */ | |
36 | #ifdef CONFIG_COMPAT | |
37 | char *area_uaddr = (void *)(intptr_t)STAP_ARG_compat_ptrace_area_uaddr; | |
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 | ||
115c9287 DS |
59 | #ifndef PTRACE_SINGLEBLOCK |
60 | #define PTRACE_SINGLEBLOCK 12 | |
61 | #endif | |
eddbc9e4 DS |
62 | #ifndef PTRACE_GET_LAST_BREAK |
63 | #define PTRACE_GET_LAST_BREAK 0x5006 | |
64 | #endif | |
115c9287 DS |
65 | #ifndef PTRACE_PEEK_SYSTEM_CALL |
66 | #define PTRACE_PEEK_SYSTEM_CALL 0x5007 | |
67 | #endif | |
68 | #ifndef PTRACE_POKE_SYSTEM_CALL | |
69 | #define PTRACE_POKE_SYSTEM_CALL 0x5008 | |
70 | #endif | |
71 | #ifndef PTRACE_ENABLE_TE | |
72 | #define PTRACE_ENABLE_TE 0x5009 | |
73 | #endif | |
74 | #ifndef PTRACE_DISABLE_TE | |
75 | #define PTRACE_DISABLE_TE 0x5010 | |
76 | #endif | |
77 | #ifndef PTRACE_TE_ABORT_RAND | |
78 | #define PTRACE_TE_ABORT_RAND 0x5011 | |
79 | #endif | |
80 | ||
81 | static const _stp_val_array const _stp_arch_ptrace_request_list[] = { | |
82 | V(PTRACE_SINGLEBLOCK), | |
83 | V(PTRACE_OLDSETOPTIONS), | |
84 | V(PTRACE_PEEKUSR_AREA), | |
85 | V(PTRACE_POKEUSR_AREA), | |
86 | V(PTRACE_PEEKTEXT_AREA), | |
87 | V(PTRACE_PEEKDATA_AREA), | |
88 | V(PTRACE_POKETEXT_AREA), | |
89 | V(PTRACE_POKEDATA_AREA), | |
90 | V(PTRACE_GET_LAST_BREAK), | |
91 | V(PTRACE_PEEK_SYSTEM_CALL), | |
92 | V(PTRACE_POKE_SYSTEM_CALL), | |
93 | V(PTRACE_ENABLE_TE), | |
94 | V(PTRACE_DISABLE_TE), | |
95 | V(PTRACE_TE_ABORT_RAND), | |
96 | {0, NULL} | |
97 | }; | |
98 | %} | |
99 | ||
100 | function __arch_ptrace_request_str:string(request:long) | |
101 | %{ /* pure */ | |
102 | _stp_lookup_str(_stp_arch_ptrace_request_list, | |
103 | (unsigned long)STAP_ARG_request, STAP_RETVALUE, | |
104 | MAXSTRINGLEN); | |
eddbc9e4 DS |
105 | %} |
106 | ||
aa1d3e0a JK |
107 | function _arch_ptrace_argstr(request, pid, addr, data) |
108 | { | |
704c2b5d | 109 | if (request == %{ /* pure */ PTRACE_OLDSETOPTIONS %}) |
115c9287 DS |
110 | return sprintf("PTRACE_OLDSETOPTIONS, %d, %#x, %s", pid, |
111 | addr, _ptrace_options_str(data)) | |
112 | if (request == %{ /* pure */ PTRACE_PEEKUSR_AREA %} | |
113 | || request == %{ /* pure */ PTRACE_POKEUSR_AREA %} | |
114 | || request == %{ /* pure */ PTRACE_PEEKTEXT_AREA %} | |
115 | || request == %{ /* pure */ PTRACE_PEEKDATA_AREA %} | |
116 | || request == %{ /* pure */ PTRACE_POKETEXT_AREA %} | |
117 | || request == %{ /* pure */ PTRACE_POKEDATA_AREA %}) | |
118 | return sprintf("%s, %d, %s, %#x", | |
119 | __arch_ptrace_request_str(request), pid, | |
2c3968d3 | 120 | (@__compat_task |
115c9287 DS |
121 | ? _stp_compat_ptrace_area_u(addr) |
122 | : _stp_ptrace_area_u(addr)), data) | |
123 | if (request == %{ /* pure */ PTRACE_GET_LAST_BREAK %} | |
124 | || request == %{ /* pure */ PTRACE_ENABLE_TE %} | |
125 | || request == %{ /* pure */ PTRACE_DISABLE_TE %} | |
126 | || request == %{ /* pure */ PTRACE_TE_ABORT_RAND %}) | |
127 | return sprintf("%s, %d, %#x, %#x", | |
128 | __arch_ptrace_request_str(request), | |
129 | pid, addr, data) | |
130 | ||
131 | // Although the following ptrace requests are defined in the | |
132 | // ptrace header file, they aren't implemented in the kernel. | |
133 | if (request == %{ /* pure */ PTRACE_PEEK_SYSTEM_CALL %} | |
134 | || request == %{ /* pure */ PTRACE_POKE_SYSTEM_CALL %}) | |
135 | return sprintf("%s, %d, %#x, %#x", | |
136 | __arch_ptrace_request_str(request), | |
137 | pid, addr, data) | |
aa1d3e0a JK |
138 | } |
139 | ||
31b3e2d3 | 140 | function _ptrace_return_arch_prctl_addr:long(request:long, addr:long, data:long) |
aa1d3e0a | 141 | { |
208fad92 | 142 | return 0 |
aa1d3e0a | 143 | } |
e4603fa5 | 144 | |
c88409ef | 145 | %( systemtap_v <= "3.0" %? |
e4603fa5 DS |
146 | function get_32mmap_args:string(args:long) |
147 | %{ /* pure */ | |
148 | struct mmap_arg_struct_emu31 { | |
149 | u32 addr; | |
150 | u32 len; | |
151 | u32 prot; | |
152 | u32 flags; | |
153 | u32 fd; | |
154 | u32 offset; | |
155 | } a; | |
156 | ||
157 | if (_stp_copy_from_user((char *)&a, (char *)STAP_ARG_args, | |
158 | sizeof(a)) == 0) { | |
159 | int len; | |
160 | _stp_snprintf(STAP_RETVALUE, MAXSTRINGLEN, "0x%x, %u, ", | |
161 | a.addr, a.len); | |
162 | _stp_lookup_or_str(_stp_mprotect_list, a.prot, STAP_RETVALUE, | |
163 | MAXSTRINGLEN); | |
164 | strlcat (STAP_RETVALUE, ", ", MAXSTRINGLEN); | |
165 | _stp_lookup_or_str(_stp_mmap_list, a.flags, STAP_RETVALUE, | |
166 | MAXSTRINGLEN); | |
167 | strlcat (STAP_RETVALUE, ", ", MAXSTRINGLEN); | |
168 | len = strlen(STAP_RETVALUE); | |
169 | _stp_snprintf(STAP_RETVALUE + len, MAXSTRINGLEN - len, | |
170 | "%d, %d", a.fd, a.offset); | |
171 | } else { | |
172 | strlcpy (STAP_RETVALUE, "UNKNOWN", MAXSTRINGLEN); | |
173 | } | |
174 | %} | |
c88409ef | 175 | %) |