Debian Codegraph @

tapset/powerpc/registers.stp

raw
1 /* Dwarfless register access for powerpc */
2
3 @__private30 global _reg_offsets[44]
4
5 probe init {
6 /* Same order as pt_regs */
7 _reg_offsets["r0"] = 0
8 _reg_offsets["r1"] = 8
9 _reg_offsets["r2"] = 16
10 _reg_offsets["r3"] = 24
11 _reg_offsets["r4"] = 32
12 _reg_offsets["r5"] = 40
13 _reg_offsets["r6"] = 48
14 _reg_offsets["r7"] = 56
15 _reg_offsets["r8"] = 64
16 _reg_offsets["r9"] = 72
17 _reg_offsets["r10"] = 80
18 _reg_offsets["r11"] = 88
19 _reg_offsets["r12"] = 96
20 _reg_offsets["r13"] = 104
21 _reg_offsets["r14"] = 112
22 _reg_offsets["r15"] = 120
23 _reg_offsets["r16"] = 128
24 _reg_offsets["r17"] = 136
25 _reg_offsets["r18"] = 144
26 _reg_offsets["r19"] = 152
27 _reg_offsets["r20"] = 160
28 _reg_offsets["r21"] = 168
29 _reg_offsets["r22"] = 176
30 _reg_offsets["r23"] = 184
31 _reg_offsets["r24"] = 192
32 _reg_offsets["r25"] = 200
33 _reg_offsets["r26"] = 208
34 _reg_offsets["r27"] = 216
35 _reg_offsets["r28"] = 224
36 _reg_offsets["r29"] = 232
37 _reg_offsets["r30"] = 240
38 _reg_offsets["r31"] = 248
39 _reg_offsets["nip"] = 256
40 _reg_offsets["msr"] = 264
41 _reg_offsets["orig_gpr3"] = 272
42 _reg_offsets["ctr"] = 280
43 _reg_offsets["link"] = 288
44 _reg_offsets["xer"] = 296
45 _reg_offsets["ccr"] = 304
46 _reg_offsets["softe"] = 312
47 _reg_offsets["trap"] = 320
48 _reg_offsets["dar"] = 328
49 _reg_offsets["dsisr"] = 336
50 _reg_offsets["result"] = 344
51
52 /*
53 * If we ever need to support 32bit powerpc, we can
54 * get to the register offsets by using just a
55 * reg32_offset = _reg_offsets["reg"]/2
56 * or somesuch
57 */
58 }
59
60 function probing_32bit_app:long() %{ /* pure */
61 STAP_RETVALUE = (CONTEXT->user_mode_p && _stp_is_compat_task());
62 %}
63
64 function arch_bytes:long() %{ /* pure */
65 STAP_RETVALUE = sizeof(long);
66 %}
67
68 function uarch_bytes:long() {
69 assert(user_mode(), "requires user mode")
70 return probing_32bit_app() ? 4 : 8
71 }
72
73 function _stp_get_register_by_offset:long (offset:long) %{ /* pure */
74 long value;
75 struct pt_regs *regs;
76 regs = (CONTEXT->user_mode_p ? CONTEXT->uregs : CONTEXT->kregs);
77 if (!regs) {
78 CONTEXT->last_error = "No registers available in this context";
79 return;
80 }
81 if (STAP_ARG_offset < 0 || STAP_ARG_offset > sizeof(struct pt_regs) - sizeof(long)) {
82 snprintf(CONTEXT->error_buffer, sizeof(CONTEXT->error_buffer),
83 "Bad register offset: %lld",
84 (long long)STAP_ARG_offset);
85 CONTEXT->last_error = CONTEXT->error_buffer;
86 return;
87 }
88 memcpy(&value, ((char *)regs) + STAP_ARG_offset, sizeof(value));
89 STAP_RETVALUE = value;
90 %}
91
92 function _stp_sign_extend32:long (value:long) {
93 if (value & 0x80000000)
94 value |= (0xffffffff << 32)
95 return value
96 }
97
98 function _stp_register:long (name:string, sign_extend:long) {
99 assert(registers_valid(), "cannot access CPU registers in this context")
100 offset = _reg_offsets[name]
101 assert(offset != 0 || (name in _reg_offsets), "Unknown register: " . name)
102 value = _stp_get_register_by_offset(offset)
103 if (probing_32bit_app()) {
104 if (sign_extend)
105 value = _stp_sign_extend32(value)
106 else
107 value &= 0xffffffff
108 }
109 return value
110 }
111
112 /* Return the named register value as a signed value. */
113 function register:long (name:string) {
114 return _stp_register(name, 1)
115 }
116
117 /*
118 * Return the named register value as an unsigned value. Specifically,
119 * don't sign-extend the register value when promoting it to 64 bits.
120 */
121 function u_register:long (name:string) {
122 return _stp_register(name, 0)
123 }
124
125 /*
126 * Return the value of function arg #argnum (1=first arg).
127 * If truncate=1, mask off the top 32 bits.
128 * If sign_extend=1 and (truncate=1 or the probepoint we've hit is in a
129 * 32-bit app), sign-extend the 32-bit value.
130 * If force64=1, return a 64-bit value even if we're in a 32-bit app.
131 */
132 function _stp_arg:long (argnum:long, sign_extend:long, truncate:long)
133 {
134 return _stp_arg2(argnum, sign_extend, truncate, 0)
135 }
136 function _stp_arg2:long (argnum:long, sign_extend:long, truncate:long,
137 force64:long)
138 {
139 val = 0
140 assert(!(argnum < 1 || argnum > 8), sprintf("Cannot access arg(%d)", argnum))
141
142 if (argnum == 1)
143 val = u_register("r3")
144 else if (argnum == 2)
145 val = u_register("r4")
146 else if (argnum == 3)
147 val = u_register("r5")
148 else if (argnum == 4)
149 val = u_register("r6")
150 else if (argnum == 5)
151 val = u_register("r7")
152 else if (argnum == 6)
153 val = u_register("r8")
154 else if (argnum == 7)
155 val = u_register("r9")
156 else if (argnum == 8)
157 val = u_register("r10")
158
159 if ((truncate || @__compat_task) && !force64) {
160 if (sign_extend)
161 val = _stp_sign_extend32(val)
162 else
163 /* High bits may be garbage. */
164 val = (val & 0xffffffff);
165 }
166 return val;
167 }
168
169 /* Return the value of function arg #argnum (1=first arg) as a signed int. */
170 function int_arg:long (argnum:long) {
171 return _stp_arg2(argnum, 1, 1, 0)
172 }
173
174 /* Return the value of function arg #argnum (1=first arg) as an unsigned int. */
175 function uint_arg:long (argnum:long) {
176 return _stp_arg2(argnum, 0, 1, 0)
177 }
178
179 function long_arg:long (argnum:long) {
180 return _stp_arg2(argnum, 1, 0, 0)
181 }
182
183 function ulong_arg:long (argnum:long) {
184 return _stp_arg2(argnum, 0, 0, 0)
185 }
186
187 function longlong_arg:long (argnum:long) {
188 if (probing_32bit_app()) {
189 highbits = _stp_arg2(argnum, 0, 1, 0)
190 lowbits = _stp_arg2(argnum+1, 0, 1, 0)
191 return ((highbits << 32) | lowbits)
192 } else
193 return _stp_arg2(argnum, 0, 0, 1)
194 }
195
196 function ulonglong_arg:long (argnum:long) {
197 return longlong_arg(argnum)
198 }
199
200 function pointer_arg:long (argnum:long) {
201 return _stp_arg2(argnum, 0, 0, 0)
202 }
203
204 function s32_arg:long (argnum:long) {
205 return int_arg(argnum)
206 }
207
208 function u32_arg:long (argnum:long) {
209 return uint_arg(argnum)
210 }
211
212 function s64_arg:long (argnum:long) {
213 return longlong_arg(argnum)
214 }
215
216 function u64_arg:long (argnum:long) {
217 return ulonglong_arg(argnum)
218 }
219
220 function asmlinkage() %{ /* pure */ %}
221
222 function fastcall() %{ /* pure */ %}
223
224 function regparm(n:long) %{
225 snprintf(CONTEXT->error_buffer, sizeof(CONTEXT->error_buffer),
226 "regparm is invalid on powerpc.");
227 CONTEXT->last_error = CONTEXT->error_buffer;
228 %}