Debian Codegraph @

tapset/registers.stp

raw
1 /* This is a stub tapset documenting a number of
2 * architecture-dependent functions. For actual implementation of the
3 * functions, see tapset/ARCH/registers.stp. */
4
5 /* <tapsetdescription>
6 * The functions in this tapset can be used to access information
7 * from the context at the time a probe point was hit. This includes
8 * functions to access named CPU registers, and functions that provide
9 * the values of a probed function's arguments. (The latter can be
10 * called when you have hit a probe point at the entry to a function,
11 * and are useful when the code you are probing was built without debugging
12 * information.)
13 *
14 * Function arguments are referred to by number, starting at 1.
15 * On 32-bit architectures
16 * (and when probing 32-bit applications on 64-bit architectures)
17 * a 64-bit argument occupies two "arg slots."
18 * For example, if you are probing the following function
19 *
20 * void f(int a, long long b, char *c)
21 *
22 * you would refer to a, b, and c as int_arg(1), longlong_arg(2), and
23 * pointer_arg(3), respectively, on a 64-bit architecture;
24 * but on a 32-bit architecture, you would refer to c as pointer_arg(4)
25 * (since b occupies slots 2 and 3).
26 *
27 * If the function you are probing doesn't follow the default rules
28 * for argument passing, you need to call one of the following functions
29 * in your handler before calling any *_arg function:
30 * asmlinkage(), fastcall(), or regparm().
31 * (This isn't necessary when referring to arguments only by name.)
32 *
33 * For some architectures, the *_arg functions may reject unusually
34 * high values of n.
35 * </tapsetdescription> */
36
37 %( kernel_vr == "invalidkernel" %?
38
39 /**
40 * sfunction register - Return the signed value of the named CPU register
41 *
42 * @name: Name of the register to return
43 *
44 * Description: Return the value of the named CPU register,
45 * as it was saved when the current probe point was hit.
46 * If the register is 32 bits, it is sign-extended to 64 bits.
47 *
48 * For the i386 architecture, the following names are recognized.
49 * (name1/name2 indicates that name1 and name2 are alternative names
50 * for the same register.)
51 * eax/ax, ebp/bp, ebx/bx, ecx/cx, edi/di, edx/dx, eflags/flags,
52 * eip/ip, esi/si, esp/sp, orig_eax/orig_ax,
53 * xcs/cs, xds/ds, xes/es, xfs/fs, xss/ss.
54 *
55 * For the x86_64 architecture, the following names are recognized:
56 * 64-bit registers:
57 * r8, r9, r10, r11, r12, r13, r14, r15,
58 * rax/ax, rbp/bp, rbx/bx, rcx/cx, rdi/di, rdx/dx,
59 * rip/ip, rsi/si, rsp/sp;
60 * 32-bit registers:
61 * eax, ebp, ebx, ecx, edx, edi, edx, eip, esi, esp, flags/eflags,
62 * orig_eax; segment registers: xcs/cs, xss/ss.
63 *
64 * For powerpc, the following names are recognized:
65 * r0, r1, ... r31, nip, msr, orig_gpr3, ctr, link, xer, ccr, softe, trap,
66 * dar, dsisr, result.
67 *
68 * For s390x, the following names are recognized:
69 * r0, r1, ... r15, args, psw.mask, psw.addr, orig_gpr2, ilc, trap.
70 *
71 * For AArch64, the following names are recognized:
72 * x0, x1, ... x30, fp, lr, sp, pc, and orig_x0.
73 */
74 function register:long (name:string) { }
75
76 /**
77 * sfunction u_register - Return the unsigned value of the named CPU register
78 *
79 * @name: Name of the register to return
80 *
81 * Description: Same as register(name), except that if the register
82 * is 32 bits wide, it is zero-extended to 64 bits.
83 */
84 function u_register:long (name:string) { }
85
86 /**
87 * sfunction int_arg - Return function argument as signed int
88 *
89 * @n: index of argument to return
90 *
91 * Description: Return the value of argument n as a signed int
92 * (i.e., a 32-bit integer sign-extended to 64 bits).
93 */
94 function int_arg:long (n:long) { }
95
96 /**
97 * sfunction set_int_arg - Set function argument as signed int
98 *
99 * @n: index of argument to return
100 * @v: value to set
101 *
102 * Description: Set the value of argument n as a signed int
103 * (i.e., a 32-bit integer sign-extended to 64 bits).
104 */
105 function set_int_arg (n:long, v:long) { }
106
107 /**
108 * sfunction uint_arg - Return function argument as unsigned int
109 *
110 * @n: index of argument to return
111 *
112 * Description: Return the value of argument n as an unsigned int
113 * (i.e., a 32-bit integer zero-extended to 64 bits).
114 */
115 function uint_arg:long (n:long) { }
116
117 /**
118 * sfunction set_uint_arg - Set argument as unsigned int
119 *
120 * @n: index of argument to set
121 * @v: value to set
122 *
123 * Description: Set the value of argument n as an unsigned int
124 * (i.e., a 32-bit integer zero-extended to 64 bits).
125 */
126 function set_uint_arg:long (n:long, v:long) { }
127
128 /**
129 * sfunction long_arg - Return function argument as signed long
130 *
131 * @n: index of argument to return
132 *
133 * Description: Return the value of argument n as a signed long.
134 * On architectures where a long is 32 bits, the value is sign-extended
135 * to 64 bits.
136 */
137 function long_arg:long (n:long) { }
138
139 /**
140 * sfunction set_long_arg - Set argument as signed long
141 *
142 * @n: index of argument to set
143 * @v: value to set
144 *
145 * Description: Set the value of argument n as a signed long.
146 * On architectures where a long is 32 bits, the value is sign-extended
147 * to 64 bits.
148 */
149 function set_long_arg (n:long, v:long) { }
150
151 /**
152 * sfunction ulong_arg - Return function argument as unsigned long
153 *
154 * @n: index of argument to return
155 *
156 * Description: Return the value of argument n as an unsigned long.
157 * On architectures where a long is 32 bits, the value is zero-extended
158 * to 64 bits.
159 */
160 function ulong_arg:long (n:long) { }
161
162 /**
163 * sfunction set_ulong_arg - Set function argument as unsigned long
164 *
165 * @n: index of argument to return
166 * @v: value to set
167 *
168 * Description: Set the value of argument n as an unsigned long.
169 * On architectures where a long is 32 bits, the value is zero-extended
170 * to 64 bits.
171 */
172 function set_ulong_arg (n:long, v:long) { }
173
174 /**
175 * sfunction longlong_arg - Return function argument as 64-bit value
176 *
177 * @n: index of argument to return
178 *
179 * Description: Return the value of argument n as a 64-bit value.
180 */
181 function longlong_arg:long (n:long) { }
182
183 /**
184 * sfunction set_longlong_arg - Set function argument as 64-bit value
185 *
186 * @n: index of argument to return
187 * @v: value to set
188 *
189 * Description: Set the value of argument n as a 64-bit value.
190 */
191 function set_longlong_arg:long (n:long, v:long) { }
192
193 /**
194 * sfunction ulonglong_arg - Return function argument as 64-bit value
195 *
196 * @n: index of argument to return
197 *
198 * Description: Return the value of argument n as a 64-bit value.
199 * (Same as longlong_arg.)
200 */
201 function ulonglong_arg:long (n:long) { }
202
203 /**
204 * sfunction set_ulonglong_arg - Set function argument as 64-bit value
205 *
206 * @n: index of argument to return
207 * @v: value to set
208 *
209 * Description: Set the value of argument n as a 64-bit value.
210 * (Same as longlong_arg.)
211 */
212 function set_ulonglong_arg (n:long, v:long) { }
213
214 /**
215 * sfunction pointer_arg - Return function argument as pointer value
216 *
217 * @n: index of argument to return
218 *
219 * Description: Return the unsigned value of argument n, same as ulong_arg.
220 * Can be used with any type of pointer.
221 */
222 function pointer_arg:long (n:long) { }
223
224 /**
225 * sfunction set_pointer_arg - Set function argument as pointer value
226 *
227 * @n: index of argument to return
228 * @v: value to set
229 *
230 * Description: Set the unsigned value of argument n, same as ulong_arg.
231 * Can be used with any type of pointer.
232 */
233 function set_pointer_arg (n:long, v:long) { }
234
235 /**
236 * sfunction s32_arg - Return function argument as signed 32-bit value
237 *
238 * @n: index of argument to return
239 *
240 * Description: Return the signed 32-bit value of argument n,
241 * same as int_arg.
242 */
243 function s32_arg:long (n:long) { }
244
245 /**
246 * sfunction set_s32_arg - Set function argument as signed 32-bit value
247 *
248 * @n: index of argument to return
249 * @v: value to set
250 *
251 * Description: Set the signed 32-bit value of argument n,
252 * same as int_arg.
253 */
254 function set_s32_arg (n:long, v:long) { }
255
256 /**
257 * sfunction u32_arg - Return function argument as unsigned 32-bit value
258 *
259 * @n: index of argument to return
260 *
261 * Description: Return the unsigned 32-bit value of argument n,
262 * same as uint_arg.
263 */
264 function u32_arg:long (n:long) { }
265
266 /**
267 * sfunction set_u32_arg - Set function argument as unsigned 32-bit value
268 *
269 * @n: index of argument to return
270 * @v: value to set
271 *
272 * Description: Set the unsigned 32-bit value of argument n,
273 * same as uint_arg.
274 */
275 function set_u32_arg (n:long, v:long) { }
276
277 /**
278 * sfunction s64_arg - Return function argument as signed 64-bit value
279 *
280 * @n: index of argument to return
281 *
282 * Description: Return the signed 64-bit value of argument n,
283 * same as longlong_arg.
284 */
285 function s64_arg:long (n:long) { }
286
287 /**
288 * sfunction set_s64_arg - Set function argument as signed 64-bit value
289 *
290 * @n: index of argument to return
291 * @v: value to set
292 *
293 * Description: Set the signed 64-bit value of argument n,
294 * same as longlong_arg.
295 */
296 function set_s64_arg (n:long, v:long) { }
297
298 /**
299 * sfunction u64_arg - Return function argument as unsigned 64-bit value
300 *
301 * @n: index of argument to return
302 *
303 * Description: Return the unsigned 64-bit value of argument n,
304 * same as ulonglong_arg.
305 */
306 function u64_arg:long (n:long) { }
307
308 /**
309 * sfunction set_u64_arg - Set function argument as unsigned 64-bit value
310 *
311 * @n: index of argument to return
312 * @v: value to set
313 *
314 * Description: Set the unsigned 64-bit value of argument n,
315 * same as ulonglong_arg.
316 */
317 function set_u64_arg (n:long, v:long) { }
318
319 /**
320 * sfunction asmlinkage - Mark function as declared asmlinkage
321 *
322 * Description: Call this function before accessing arguments
323 * using the *_arg functions
324 * if the probed kernel function was declared asmlinkage in the source.
325 */
326 function asmlinkage() { }
327
328 /**
329 * sfunction fastcall - Mark function as declared fastcall
330 *
331 * Description: Call this function before accessing arguments
332 * using the *_arg functions
333 * if the probed kernel function was declared fastcall in the source.
334 */
335 function fastcall() { }
336
337 /**
338 * sfunction regparm - Specify regparm value used to compile function
339 *
340 * @n: original regparm value
341 *
342 * Description: Call this function with argument n before accessing function
343 * arguments using the *_arg function is the function was build with the
344 * gcc -mregparm=n option.
345 *
346 * (The i386 kernel is built with \-mregparm=3, so systemtap considers
347 * regparm(3) the default for kernel functions on that architecture.)
348 * Only valid on i386 and x86_64 (when probing 32bit applications).
349 * Produces an error on other architectures.
350 */
351 function regparm(n:long) { }
352
353 %)
354
355 /*
356 * In nd_syscall.return probes, we sometimes need @entry() values. To
357 * ensure we get the argument in the correct mode, we need a function
358 * that calls asmlinkage() first.
359 */
360 function __asmlinkage_int_arg:long(n:long)
361 {
362 asmlinkage()
363 return int_arg(n)
364 }
365
366
367 function __get_kregs:long() %{ /* guru */ STAP_RETVALUE = (int64_t)CONTEXT->kregs; %}
368 function __get_uregs:long() %{ /* guru */ STAP_RETVALUE = (int64_t)CONTEXT->uregs; %}
369 function __set_kregs(regs:long) %{ /* guru */ CONTEXT->kregs = (struct pt_regs*)STAP_ARG_regs; %}
370 function __set_uregs(regs:long) %{ /* guru */ CONTEXT->uregs = (struct pt_regs*)STAP_ARG_regs; %}