Commit | Line | Data |
---|---|---|
5769d3cd | 1 | /* Target-dependent code for GDB, the GNU debugger. |
ca557f44 | 2 | |
61baf725 | 3 | Copyright (C) 2001-2017 Free Software Foundation, Inc. |
ca557f44 | 4 | |
5769d3cd AC |
5 | Contributed by D.J. Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com) |
6 | for IBM Deutschland Entwicklung GmbH, IBM Corporation. | |
7 | ||
8 | This file is part of GDB. | |
9 | ||
10 | This program is free software; you can redistribute it and/or modify | |
11 | it under the terms of the GNU General Public License as published by | |
a9762ec7 | 12 | the Free Software Foundation; either version 3 of the License, or |
5769d3cd AC |
13 | (at your option) any later version. |
14 | ||
15 | This program is distributed in the hope that it will be useful, | |
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | GNU General Public License for more details. | |
19 | ||
20 | You should have received a copy of the GNU General Public License | |
a9762ec7 | 21 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
5769d3cd | 22 | |
d0f54f9d | 23 | #include "defs.h" |
5769d3cd AC |
24 | #include "arch-utils.h" |
25 | #include "frame.h" | |
26 | #include "inferior.h" | |
45741a9c | 27 | #include "infrun.h" |
5769d3cd AC |
28 | #include "symtab.h" |
29 | #include "target.h" | |
30 | #include "gdbcore.h" | |
31 | #include "gdbcmd.h" | |
5769d3cd | 32 | #include "objfiles.h" |
5769d3cd AC |
33 | #include "floatformat.h" |
34 | #include "regcache.h" | |
a8c99f38 JB |
35 | #include "trad-frame.h" |
36 | #include "frame-base.h" | |
37 | #include "frame-unwind.h" | |
a431654a | 38 | #include "dwarf2-frame.h" |
d0f54f9d JB |
39 | #include "reggroups.h" |
40 | #include "regset.h" | |
fd0407d6 | 41 | #include "value.h" |
a89aa300 | 42 | #include "dis-asm.h" |
76a9d10f | 43 | #include "solib-svr4.h" |
3fc46200 | 44 | #include "prologue-value.h" |
70728992 | 45 | #include "linux-tdep.h" |
0e5fae36 | 46 | #include "s390-linux-tdep.h" |
566c56c9 MK |
47 | #include "linux-record.h" |
48 | #include "record-full.h" | |
4ac33720 | 49 | #include "auxv.h" |
237b092b | 50 | #include "xml-syscall.h" |
5769d3cd | 51 | |
55aa24fb SDJ |
52 | #include "stap-probe.h" |
53 | #include "ax.h" | |
54 | #include "ax-gdb.h" | |
55 | #include "user-regs.h" | |
56 | #include "cli/cli-utils.h" | |
57 | #include <ctype.h> | |
04a83fee | 58 | #include "elf/common.h" |
417c80f9 AA |
59 | #include "elf/s390.h" |
60 | #include "elf-bfd.h" | |
325fac50 | 61 | #include <algorithm> |
55aa24fb | 62 | |
7803799a | 63 | #include "features/s390-linux32.c" |
c642a434 UW |
64 | #include "features/s390-linux32v1.c" |
65 | #include "features/s390-linux32v2.c" | |
7803799a | 66 | #include "features/s390-linux64.c" |
c642a434 UW |
67 | #include "features/s390-linux64v1.c" |
68 | #include "features/s390-linux64v2.c" | |
4ac33720 | 69 | #include "features/s390-te-linux64.c" |
550bdf96 AA |
70 | #include "features/s390-vx-linux64.c" |
71 | #include "features/s390-tevx-linux64.c" | |
7803799a | 72 | #include "features/s390x-linux64.c" |
c642a434 UW |
73 | #include "features/s390x-linux64v1.c" |
74 | #include "features/s390x-linux64v2.c" | |
4ac33720 | 75 | #include "features/s390x-te-linux64.c" |
550bdf96 AA |
76 | #include "features/s390x-vx-linux64.c" |
77 | #include "features/s390x-tevx-linux64.c" | |
7803799a | 78 | |
237b092b AA |
79 | #define XML_SYSCALL_FILENAME_S390 "syscalls/s390-linux.xml" |
80 | #define XML_SYSCALL_FILENAME_S390X "syscalls/s390x-linux.xml" | |
81 | ||
65b48a81 PB |
82 | /* Holds the current set of options to be passed to the disassembler. */ |
83 | static char *s390_disassembler_options; | |
84 | ||
52059ffd TT |
85 | enum s390_abi_kind |
86 | { | |
87 | ABI_LINUX_S390, | |
88 | ABI_LINUX_ZSERIES | |
89 | }; | |
90 | ||
417c80f9 AA |
91 | enum s390_vector_abi_kind |
92 | { | |
93 | S390_VECTOR_ABI_NONE, | |
94 | S390_VECTOR_ABI_128 | |
95 | }; | |
96 | ||
d0f54f9d JB |
97 | /* The tdep structure. */ |
98 | ||
99 | struct gdbarch_tdep | |
5769d3cd | 100 | { |
b0cf273e | 101 | /* ABI version. */ |
52059ffd | 102 | enum s390_abi_kind abi; |
b0cf273e | 103 | |
417c80f9 AA |
104 | /* Vector ABI. */ |
105 | enum s390_vector_abi_kind vector_abi; | |
106 | ||
7803799a UW |
107 | /* Pseudo register numbers. */ |
108 | int gpr_full_regnum; | |
109 | int pc_regnum; | |
110 | int cc_regnum; | |
550bdf96 | 111 | int v0_full_regnum; |
7803799a | 112 | |
5aa82d05 AA |
113 | int have_linux_v1; |
114 | int have_linux_v2; | |
115 | int have_tdb; | |
d0f54f9d JB |
116 | }; |
117 | ||
118 | ||
7803799a UW |
119 | /* ABI call-saved register information. */ |
120 | ||
121 | static int | |
122 | s390_register_call_saved (struct gdbarch *gdbarch, int regnum) | |
d0f54f9d | 123 | { |
7803799a UW |
124 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); |
125 | ||
126 | switch (tdep->abi) | |
6707b003 | 127 | { |
7803799a UW |
128 | case ABI_LINUX_S390: |
129 | if ((regnum >= S390_R6_REGNUM && regnum <= S390_R15_REGNUM) | |
130 | || regnum == S390_F4_REGNUM || regnum == S390_F6_REGNUM | |
131 | || regnum == S390_A0_REGNUM) | |
132 | return 1; | |
6707b003 | 133 | |
7803799a UW |
134 | break; |
135 | ||
136 | case ABI_LINUX_ZSERIES: | |
137 | if ((regnum >= S390_R6_REGNUM && regnum <= S390_R15_REGNUM) | |
138 | || (regnum >= S390_F8_REGNUM && regnum <= S390_F15_REGNUM) | |
139 | || (regnum >= S390_A0_REGNUM && regnum <= S390_A1_REGNUM)) | |
140 | return 1; | |
141 | ||
142 | break; | |
143 | } | |
144 | ||
145 | return 0; | |
5769d3cd AC |
146 | } |
147 | ||
c642a434 UW |
148 | static int |
149 | s390_cannot_store_register (struct gdbarch *gdbarch, int regnum) | |
150 | { | |
151 | /* The last-break address is read-only. */ | |
152 | return regnum == S390_LAST_BREAK_REGNUM; | |
153 | } | |
154 | ||
155 | static void | |
156 | s390_write_pc (struct regcache *regcache, CORE_ADDR pc) | |
157 | { | |
158 | struct gdbarch *gdbarch = get_regcache_arch (regcache); | |
159 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | |
160 | ||
161 | regcache_cooked_write_unsigned (regcache, tdep->pc_regnum, pc); | |
162 | ||
163 | /* Set special SYSTEM_CALL register to 0 to prevent the kernel from | |
164 | messing with the PC we just installed, if we happen to be within | |
165 | an interrupted system call that the kernel wants to restart. | |
166 | ||
167 | Note that after we return from the dummy call, the SYSTEM_CALL and | |
168 | ORIG_R2 registers will be automatically restored, and the kernel | |
169 | continues to restart the system call at this point. */ | |
170 | if (register_size (gdbarch, S390_SYSTEM_CALL_REGNUM) > 0) | |
171 | regcache_cooked_write_unsigned (regcache, S390_SYSTEM_CALL_REGNUM, 0); | |
172 | } | |
173 | ||
f79a3bae MK |
174 | /* The "guess_tracepoint_registers" gdbarch method. */ |
175 | ||
176 | static void | |
177 | s390_guess_tracepoint_registers (struct gdbarch *gdbarch, | |
178 | struct regcache *regcache, | |
179 | CORE_ADDR addr) | |
180 | { | |
181 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | |
182 | int sz = register_size (gdbarch, S390_PSWA_REGNUM); | |
183 | gdb_byte *reg = (gdb_byte *) alloca (sz); | |
184 | ULONGEST pswm, pswa; | |
185 | ||
186 | /* Set PSWA from the location and a default PSWM (the only part we're | |
187 | unlikely to get right is the CC). */ | |
188 | if (tdep->abi == ABI_LINUX_S390) | |
189 | { | |
190 | /* 31-bit PSWA needs high bit set (it's very unlikely the target | |
191 | was in 24-bit mode). */ | |
192 | pswa = addr | 0x80000000UL; | |
193 | pswm = 0x070d0000UL; | |
194 | } | |
195 | else | |
196 | { | |
197 | pswa = addr; | |
198 | pswm = 0x0705000180000000ULL; | |
199 | } | |
200 | ||
201 | store_unsigned_integer (reg, sz, gdbarch_byte_order (gdbarch), pswa); | |
202 | regcache_raw_supply (regcache, S390_PSWA_REGNUM, reg); | |
203 | ||
204 | store_unsigned_integer (reg, sz, gdbarch_byte_order (gdbarch), pswm); | |
205 | regcache_raw_supply (regcache, S390_PSWM_REGNUM, reg); | |
206 | } | |
207 | ||
7803799a | 208 | |
d0f54f9d JB |
209 | /* DWARF Register Mapping. */ |
210 | ||
2ccd1468 | 211 | static const short s390_dwarf_regmap[] = |
d0f54f9d | 212 | { |
550bdf96 | 213 | /* 0-15: General Purpose Registers. */ |
d0f54f9d JB |
214 | S390_R0_REGNUM, S390_R1_REGNUM, S390_R2_REGNUM, S390_R3_REGNUM, |
215 | S390_R4_REGNUM, S390_R5_REGNUM, S390_R6_REGNUM, S390_R7_REGNUM, | |
216 | S390_R8_REGNUM, S390_R9_REGNUM, S390_R10_REGNUM, S390_R11_REGNUM, | |
217 | S390_R12_REGNUM, S390_R13_REGNUM, S390_R14_REGNUM, S390_R15_REGNUM, | |
218 | ||
550bdf96 | 219 | /* 16-31: Floating Point Registers / Vector Registers 0-15. */ |
d0f54f9d JB |
220 | S390_F0_REGNUM, S390_F2_REGNUM, S390_F4_REGNUM, S390_F6_REGNUM, |
221 | S390_F1_REGNUM, S390_F3_REGNUM, S390_F5_REGNUM, S390_F7_REGNUM, | |
222 | S390_F8_REGNUM, S390_F10_REGNUM, S390_F12_REGNUM, S390_F14_REGNUM, | |
223 | S390_F9_REGNUM, S390_F11_REGNUM, S390_F13_REGNUM, S390_F15_REGNUM, | |
224 | ||
550bdf96 | 225 | /* 32-47: Control Registers (not mapped). */ |
34201ae3 UW |
226 | -1, -1, -1, -1, -1, -1, -1, -1, |
227 | -1, -1, -1, -1, -1, -1, -1, -1, | |
d0f54f9d | 228 | |
550bdf96 | 229 | /* 48-63: Access Registers. */ |
d0f54f9d JB |
230 | S390_A0_REGNUM, S390_A1_REGNUM, S390_A2_REGNUM, S390_A3_REGNUM, |
231 | S390_A4_REGNUM, S390_A5_REGNUM, S390_A6_REGNUM, S390_A7_REGNUM, | |
232 | S390_A8_REGNUM, S390_A9_REGNUM, S390_A10_REGNUM, S390_A11_REGNUM, | |
233 | S390_A12_REGNUM, S390_A13_REGNUM, S390_A14_REGNUM, S390_A15_REGNUM, | |
234 | ||
550bdf96 | 235 | /* 64-65: Program Status Word. */ |
d0f54f9d | 236 | S390_PSWM_REGNUM, |
7803799a UW |
237 | S390_PSWA_REGNUM, |
238 | ||
550bdf96 AA |
239 | /* 66-67: Reserved. */ |
240 | -1, -1, | |
241 | ||
242 | /* 68-83: Vector Registers 16-31. */ | |
243 | S390_V16_REGNUM, S390_V18_REGNUM, S390_V20_REGNUM, S390_V22_REGNUM, | |
244 | S390_V17_REGNUM, S390_V19_REGNUM, S390_V21_REGNUM, S390_V23_REGNUM, | |
245 | S390_V24_REGNUM, S390_V26_REGNUM, S390_V28_REGNUM, S390_V30_REGNUM, | |
246 | S390_V25_REGNUM, S390_V27_REGNUM, S390_V29_REGNUM, S390_V31_REGNUM, | |
247 | ||
248 | /* End of "official" DWARF registers. The remainder of the map is | |
249 | for GDB internal use only. */ | |
250 | ||
7803799a UW |
251 | /* GPR Lower Half Access. */ |
252 | S390_R0_REGNUM, S390_R1_REGNUM, S390_R2_REGNUM, S390_R3_REGNUM, | |
253 | S390_R4_REGNUM, S390_R5_REGNUM, S390_R6_REGNUM, S390_R7_REGNUM, | |
254 | S390_R8_REGNUM, S390_R9_REGNUM, S390_R10_REGNUM, S390_R11_REGNUM, | |
255 | S390_R12_REGNUM, S390_R13_REGNUM, S390_R14_REGNUM, S390_R15_REGNUM, | |
d0f54f9d JB |
256 | }; |
257 | ||
550bdf96 AA |
258 | enum { s390_dwarf_reg_r0l = ARRAY_SIZE (s390_dwarf_regmap) - 16 }; |
259 | ||
d0f54f9d JB |
260 | /* Convert DWARF register number REG to the appropriate register |
261 | number used by GDB. */ | |
a78f21af | 262 | static int |
d3f73121 | 263 | s390_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int reg) |
d0f54f9d | 264 | { |
7803799a | 265 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); |
550bdf96 | 266 | int gdb_reg = -1; |
7803799a | 267 | |
550bdf96 AA |
268 | /* In a 32-on-64 debug scenario, debug info refers to the full |
269 | 64-bit GPRs. Note that call frame information still refers to | |
270 | the 32-bit lower halves, because s390_adjust_frame_regnum uses | |
271 | special register numbers to access GPRs. */ | |
7803799a UW |
272 | if (tdep->gpr_full_regnum != -1 && reg >= 0 && reg < 16) |
273 | return tdep->gpr_full_regnum + reg; | |
d0f54f9d | 274 | |
16aff9a6 | 275 | if (reg >= 0 && reg < ARRAY_SIZE (s390_dwarf_regmap)) |
550bdf96 AA |
276 | gdb_reg = s390_dwarf_regmap[reg]; |
277 | ||
278 | if (tdep->v0_full_regnum == -1) | |
279 | { | |
280 | if (gdb_reg >= S390_V16_REGNUM && gdb_reg <= S390_V31_REGNUM) | |
281 | gdb_reg = -1; | |
282 | } | |
283 | else | |
284 | { | |
285 | if (gdb_reg >= S390_F0_REGNUM && gdb_reg <= S390_F15_REGNUM) | |
286 | gdb_reg = gdb_reg - S390_F0_REGNUM + tdep->v0_full_regnum; | |
287 | } | |
d0f54f9d | 288 | |
550bdf96 | 289 | return gdb_reg; |
7803799a | 290 | } |
d0f54f9d | 291 | |
7803799a UW |
292 | /* Translate a .eh_frame register to DWARF register, or adjust a |
293 | .debug_frame register. */ | |
294 | static int | |
295 | s390_adjust_frame_regnum (struct gdbarch *gdbarch, int num, int eh_frame_p) | |
296 | { | |
297 | /* See s390_dwarf_reg_to_regnum for comments. */ | |
550bdf96 | 298 | return (num >= 0 && num < 16) ? num + s390_dwarf_reg_r0l : num; |
d0f54f9d JB |
299 | } |
300 | ||
d0f54f9d | 301 | |
7803799a UW |
302 | /* Pseudo registers. */ |
303 | ||
2ccd1468 UW |
304 | static int |
305 | regnum_is_gpr_full (struct gdbarch_tdep *tdep, int regnum) | |
306 | { | |
307 | return (tdep->gpr_full_regnum != -1 | |
308 | && regnum >= tdep->gpr_full_regnum | |
309 | && regnum <= tdep->gpr_full_regnum + 15); | |
310 | } | |
311 | ||
550bdf96 AA |
312 | /* Check whether REGNUM indicates a full vector register (v0-v15). |
313 | These pseudo-registers are composed of f0-f15 and v0l-v15l. */ | |
314 | ||
315 | static int | |
316 | regnum_is_vxr_full (struct gdbarch_tdep *tdep, int regnum) | |
317 | { | |
318 | return (tdep->v0_full_regnum != -1 | |
319 | && regnum >= tdep->v0_full_regnum | |
320 | && regnum <= tdep->v0_full_regnum + 15); | |
321 | } | |
322 | ||
87de11c0 AA |
323 | /* Return the name of register REGNO. Return the empty string for |
324 | registers that shouldn't be visible. */ | |
550bdf96 AA |
325 | |
326 | static const char * | |
327 | s390_register_name (struct gdbarch *gdbarch, int regnum) | |
328 | { | |
329 | if (regnum >= S390_V0_LOWER_REGNUM | |
330 | && regnum <= S390_V15_LOWER_REGNUM) | |
87de11c0 | 331 | return ""; |
550bdf96 AA |
332 | return tdesc_register_name (gdbarch, regnum); |
333 | } | |
334 | ||
7803799a UW |
335 | static const char * |
336 | s390_pseudo_register_name (struct gdbarch *gdbarch, int regnum) | |
d0f54f9d | 337 | { |
7803799a | 338 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); |
d0f54f9d | 339 | |
7803799a UW |
340 | if (regnum == tdep->pc_regnum) |
341 | return "pc"; | |
d0f54f9d | 342 | |
7803799a UW |
343 | if (regnum == tdep->cc_regnum) |
344 | return "cc"; | |
d0f54f9d | 345 | |
2ccd1468 | 346 | if (regnum_is_gpr_full (tdep, regnum)) |
7803799a UW |
347 | { |
348 | static const char *full_name[] = { | |
349 | "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", | |
350 | "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15" | |
351 | }; | |
352 | return full_name[regnum - tdep->gpr_full_regnum]; | |
d0f54f9d | 353 | } |
7803799a | 354 | |
550bdf96 AA |
355 | if (regnum_is_vxr_full (tdep, regnum)) |
356 | { | |
357 | static const char *full_name[] = { | |
358 | "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", | |
359 | "v8", "v9", "v10", "v11", "v12", "v13", "v14", "v15" | |
360 | }; | |
361 | return full_name[regnum - tdep->v0_full_regnum]; | |
362 | } | |
363 | ||
7803799a | 364 | internal_error (__FILE__, __LINE__, _("invalid regnum")); |
d0f54f9d JB |
365 | } |
366 | ||
7803799a UW |
367 | static struct type * |
368 | s390_pseudo_register_type (struct gdbarch *gdbarch, int regnum) | |
5769d3cd | 369 | { |
7803799a | 370 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); |
d0f54f9d | 371 | |
7803799a UW |
372 | if (regnum == tdep->pc_regnum) |
373 | return builtin_type (gdbarch)->builtin_func_ptr; | |
d0f54f9d | 374 | |
7803799a UW |
375 | if (regnum == tdep->cc_regnum) |
376 | return builtin_type (gdbarch)->builtin_int; | |
d0f54f9d | 377 | |
2ccd1468 | 378 | if (regnum_is_gpr_full (tdep, regnum)) |
7803799a UW |
379 | return builtin_type (gdbarch)->builtin_uint64; |
380 | ||
550bdf96 AA |
381 | if (regnum_is_vxr_full (tdep, regnum)) |
382 | return tdesc_find_type (gdbarch, "vec128"); | |
383 | ||
7803799a | 384 | internal_error (__FILE__, __LINE__, _("invalid regnum")); |
5769d3cd AC |
385 | } |
386 | ||
05d1431c | 387 | static enum register_status |
7803799a UW |
388 | s390_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache, |
389 | int regnum, gdb_byte *buf) | |
d0f54f9d | 390 | { |
7803799a | 391 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); |
e17a4113 | 392 | enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); |
7803799a | 393 | int regsize = register_size (gdbarch, regnum); |
d0f54f9d JB |
394 | ULONGEST val; |
395 | ||
7803799a | 396 | if (regnum == tdep->pc_regnum) |
d0f54f9d | 397 | { |
05d1431c PA |
398 | enum register_status status; |
399 | ||
400 | status = regcache_raw_read_unsigned (regcache, S390_PSWA_REGNUM, &val); | |
401 | if (status == REG_VALID) | |
402 | { | |
403 | if (register_size (gdbarch, S390_PSWA_REGNUM) == 4) | |
404 | val &= 0x7fffffff; | |
405 | store_unsigned_integer (buf, regsize, byte_order, val); | |
406 | } | |
407 | return status; | |
7803799a | 408 | } |
d0f54f9d | 409 | |
7803799a UW |
410 | if (regnum == tdep->cc_regnum) |
411 | { | |
05d1431c PA |
412 | enum register_status status; |
413 | ||
414 | status = regcache_raw_read_unsigned (regcache, S390_PSWM_REGNUM, &val); | |
415 | if (status == REG_VALID) | |
416 | { | |
417 | if (register_size (gdbarch, S390_PSWA_REGNUM) == 4) | |
418 | val = (val >> 12) & 3; | |
419 | else | |
420 | val = (val >> 44) & 3; | |
421 | store_unsigned_integer (buf, regsize, byte_order, val); | |
422 | } | |
423 | return status; | |
7803799a | 424 | } |
d0f54f9d | 425 | |
2ccd1468 | 426 | if (regnum_is_gpr_full (tdep, regnum)) |
7803799a | 427 | { |
05d1431c | 428 | enum register_status status; |
7803799a | 429 | ULONGEST val_upper; |
05d1431c | 430 | |
7803799a UW |
431 | regnum -= tdep->gpr_full_regnum; |
432 | ||
05d1431c PA |
433 | status = regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + regnum, &val); |
434 | if (status == REG_VALID) | |
435 | status = regcache_raw_read_unsigned (regcache, S390_R0_UPPER_REGNUM + regnum, | |
436 | &val_upper); | |
437 | if (status == REG_VALID) | |
438 | { | |
439 | val |= val_upper << 32; | |
440 | store_unsigned_integer (buf, regsize, byte_order, val); | |
441 | } | |
442 | return status; | |
d0f54f9d | 443 | } |
7803799a | 444 | |
550bdf96 AA |
445 | if (regnum_is_vxr_full (tdep, regnum)) |
446 | { | |
447 | enum register_status status; | |
448 | ||
449 | regnum -= tdep->v0_full_regnum; | |
450 | ||
451 | status = regcache_raw_read (regcache, S390_F0_REGNUM + regnum, buf); | |
452 | if (status == REG_VALID) | |
453 | status = regcache_raw_read (regcache, | |
454 | S390_V0_LOWER_REGNUM + regnum, buf + 8); | |
455 | return status; | |
456 | } | |
457 | ||
7803799a | 458 | internal_error (__FILE__, __LINE__, _("invalid regnum")); |
d0f54f9d JB |
459 | } |
460 | ||
461 | static void | |
7803799a UW |
462 | s390_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache, |
463 | int regnum, const gdb_byte *buf) | |
d0f54f9d | 464 | { |
7803799a | 465 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); |
e17a4113 | 466 | enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); |
7803799a | 467 | int regsize = register_size (gdbarch, regnum); |
d0f54f9d JB |
468 | ULONGEST val, psw; |
469 | ||
7803799a | 470 | if (regnum == tdep->pc_regnum) |
d0f54f9d | 471 | { |
7803799a UW |
472 | val = extract_unsigned_integer (buf, regsize, byte_order); |
473 | if (register_size (gdbarch, S390_PSWA_REGNUM) == 4) | |
474 | { | |
475 | regcache_raw_read_unsigned (regcache, S390_PSWA_REGNUM, &psw); | |
476 | val = (psw & 0x80000000) | (val & 0x7fffffff); | |
477 | } | |
478 | regcache_raw_write_unsigned (regcache, S390_PSWA_REGNUM, val); | |
479 | return; | |
480 | } | |
d0f54f9d | 481 | |
7803799a UW |
482 | if (regnum == tdep->cc_regnum) |
483 | { | |
484 | val = extract_unsigned_integer (buf, regsize, byte_order); | |
d0f54f9d | 485 | regcache_raw_read_unsigned (regcache, S390_PSWM_REGNUM, &psw); |
7803799a UW |
486 | if (register_size (gdbarch, S390_PSWA_REGNUM) == 4) |
487 | val = (psw & ~((ULONGEST)3 << 12)) | ((val & 3) << 12); | |
488 | else | |
489 | val = (psw & ~((ULONGEST)3 << 44)) | ((val & 3) << 44); | |
490 | regcache_raw_write_unsigned (regcache, S390_PSWM_REGNUM, val); | |
491 | return; | |
492 | } | |
d0f54f9d | 493 | |
2ccd1468 | 494 | if (regnum_is_gpr_full (tdep, regnum)) |
7803799a UW |
495 | { |
496 | regnum -= tdep->gpr_full_regnum; | |
497 | val = extract_unsigned_integer (buf, regsize, byte_order); | |
498 | regcache_raw_write_unsigned (regcache, S390_R0_REGNUM + regnum, | |
499 | val & 0xffffffff); | |
500 | regcache_raw_write_unsigned (regcache, S390_R0_UPPER_REGNUM + regnum, | |
501 | val >> 32); | |
502 | return; | |
d0f54f9d | 503 | } |
7803799a | 504 | |
550bdf96 AA |
505 | if (regnum_is_vxr_full (tdep, regnum)) |
506 | { | |
507 | regnum -= tdep->v0_full_regnum; | |
508 | regcache_raw_write (regcache, S390_F0_REGNUM + regnum, buf); | |
509 | regcache_raw_write (regcache, S390_V0_LOWER_REGNUM + regnum, buf + 8); | |
510 | return; | |
511 | } | |
512 | ||
7803799a | 513 | internal_error (__FILE__, __LINE__, _("invalid regnum")); |
d0f54f9d JB |
514 | } |
515 | ||
516 | /* 'float' values are stored in the upper half of floating-point | |
550bdf96 AA |
517 | registers, even though we are otherwise a big-endian platform. The |
518 | same applies to a 'float' value within a vector. */ | |
d0f54f9d | 519 | |
9acbedc0 | 520 | static struct value * |
2ed3c037 UW |
521 | s390_value_from_register (struct gdbarch *gdbarch, struct type *type, |
522 | int regnum, struct frame_id frame_id) | |
d0f54f9d | 523 | { |
550bdf96 | 524 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); |
2ed3c037 UW |
525 | struct value *value = default_value_from_register (gdbarch, type, |
526 | regnum, frame_id); | |
744a8059 SP |
527 | check_typedef (type); |
528 | ||
550bdf96 AA |
529 | if ((regnum >= S390_F0_REGNUM && regnum <= S390_F15_REGNUM |
530 | && TYPE_LENGTH (type) < 8) | |
531 | || regnum_is_vxr_full (tdep, regnum) | |
532 | || (regnum >= S390_V16_REGNUM && regnum <= S390_V31_REGNUM)) | |
9acbedc0 | 533 | set_value_offset (value, 0); |
d0f54f9d | 534 | |
9acbedc0 | 535 | return value; |
d0f54f9d JB |
536 | } |
537 | ||
538 | /* Register groups. */ | |
539 | ||
a78f21af | 540 | static int |
7803799a UW |
541 | s390_pseudo_register_reggroup_p (struct gdbarch *gdbarch, int regnum, |
542 | struct reggroup *group) | |
d0f54f9d JB |
543 | { |
544 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | |
545 | ||
d6db1fab UW |
546 | /* We usually save/restore the whole PSW, which includes PC and CC. |
547 | However, some older gdbservers may not support saving/restoring | |
548 | the whole PSW yet, and will return an XML register description | |
549 | excluding those from the save/restore register groups. In those | |
550 | cases, we still need to explicitly save/restore PC and CC in order | |
551 | to push or pop frames. Since this doesn't hurt anything if we | |
552 | already save/restore the whole PSW (it's just redundant), we add | |
553 | PC and CC at this point unconditionally. */ | |
d0f54f9d | 554 | if (group == save_reggroup || group == restore_reggroup) |
7803799a | 555 | return regnum == tdep->pc_regnum || regnum == tdep->cc_regnum; |
d0f54f9d | 556 | |
550bdf96 AA |
557 | if (group == vector_reggroup) |
558 | return regnum_is_vxr_full (tdep, regnum); | |
559 | ||
560 | if (group == general_reggroup && regnum_is_vxr_full (tdep, regnum)) | |
561 | return 0; | |
562 | ||
d0f54f9d JB |
563 | return default_register_reggroup_p (gdbarch, regnum, group); |
564 | } | |
565 | ||
c4b3e547 MK |
566 | /* The "ax_pseudo_register_collect" gdbarch method. */ |
567 | ||
568 | static int | |
569 | s390_ax_pseudo_register_collect (struct gdbarch *gdbarch, | |
570 | struct agent_expr *ax, int regnum) | |
571 | { | |
572 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | |
573 | if (regnum == tdep->pc_regnum) | |
574 | { | |
575 | ax_reg_mask (ax, S390_PSWA_REGNUM); | |
576 | } | |
577 | else if (regnum == tdep->cc_regnum) | |
578 | { | |
579 | ax_reg_mask (ax, S390_PSWM_REGNUM); | |
580 | } | |
581 | else if (regnum_is_gpr_full (tdep, regnum)) | |
582 | { | |
583 | regnum -= tdep->gpr_full_regnum; | |
584 | ax_reg_mask (ax, S390_R0_REGNUM + regnum); | |
585 | ax_reg_mask (ax, S390_R0_UPPER_REGNUM + regnum); | |
586 | } | |
587 | else if (regnum_is_vxr_full (tdep, regnum)) | |
588 | { | |
589 | regnum -= tdep->v0_full_regnum; | |
590 | ax_reg_mask (ax, S390_F0_REGNUM + regnum); | |
591 | ax_reg_mask (ax, S390_V0_LOWER_REGNUM + regnum); | |
592 | } | |
593 | else | |
594 | { | |
595 | internal_error (__FILE__, __LINE__, _("invalid regnum")); | |
596 | } | |
597 | return 0; | |
598 | } | |
599 | ||
600 | /* The "ax_pseudo_register_push_stack" gdbarch method. */ | |
601 | ||
602 | static int | |
603 | s390_ax_pseudo_register_push_stack (struct gdbarch *gdbarch, | |
604 | struct agent_expr *ax, int regnum) | |
605 | { | |
606 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | |
607 | if (regnum == tdep->pc_regnum) | |
608 | { | |
609 | ax_reg (ax, S390_PSWA_REGNUM); | |
610 | if (register_size (gdbarch, S390_PSWA_REGNUM) == 4) | |
611 | { | |
612 | ax_zero_ext (ax, 31); | |
613 | } | |
614 | } | |
615 | else if (regnum == tdep->cc_regnum) | |
616 | { | |
617 | ax_reg (ax, S390_PSWM_REGNUM); | |
618 | if (register_size (gdbarch, S390_PSWA_REGNUM) == 4) | |
619 | ax_const_l (ax, 12); | |
620 | else | |
621 | ax_const_l (ax, 44); | |
622 | ax_simple (ax, aop_rsh_unsigned); | |
623 | ax_zero_ext (ax, 2); | |
624 | } | |
625 | else if (regnum_is_gpr_full (tdep, regnum)) | |
626 | { | |
627 | regnum -= tdep->gpr_full_regnum; | |
628 | ax_reg (ax, S390_R0_REGNUM + regnum); | |
629 | ax_reg (ax, S390_R0_UPPER_REGNUM + regnum); | |
630 | ax_const_l (ax, 32); | |
631 | ax_simple (ax, aop_lsh); | |
632 | ax_simple (ax, aop_bit_or); | |
633 | } | |
634 | else if (regnum_is_vxr_full (tdep, regnum)) | |
635 | { | |
636 | /* Too large to stuff on the stack. */ | |
637 | return 1; | |
638 | } | |
639 | else | |
640 | { | |
641 | internal_error (__FILE__, __LINE__, _("invalid regnum")); | |
642 | } | |
643 | return 0; | |
644 | } | |
645 | ||
70104a90 MK |
646 | /* The "gen_return_address" gdbarch method. Since this is supposed to be |
647 | just a best-effort method, and we don't really have the means to run | |
648 | the full unwinder here, just collect the link register. */ | |
649 | ||
650 | static void | |
651 | s390_gen_return_address (struct gdbarch *gdbarch, | |
652 | struct agent_expr *ax, struct axs_value *value, | |
653 | CORE_ADDR scope) | |
654 | { | |
655 | value->type = register_type (gdbarch, S390_R14_REGNUM); | |
656 | value->kind = axs_lvalue_register; | |
657 | value->u.reg = S390_R14_REGNUM; | |
658 | } | |
659 | ||
d0f54f9d | 660 | |
6df55226 MK |
661 | /* A helper for s390_software_single_step, decides if an instruction |
662 | is a partial-execution instruction that needs to be executed until | |
663 | completion when in record mode. If it is, returns 1 and writes | |
664 | instruction length to a pointer. */ | |
665 | ||
666 | static int | |
667 | s390_is_partial_instruction (struct gdbarch *gdbarch, CORE_ADDR loc, int *len) | |
668 | { | |
669 | enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); | |
670 | uint16_t insn; | |
671 | ||
672 | insn = read_memory_integer (loc, 2, byte_order); | |
673 | ||
674 | switch (insn >> 8) | |
675 | { | |
676 | case 0xa8: /* MVCLE */ | |
677 | *len = 4; | |
678 | return 1; | |
679 | ||
680 | case 0xeb: | |
681 | { | |
682 | insn = read_memory_integer (loc + 4, 2, byte_order); | |
683 | if ((insn & 0xff) == 0x8e) | |
684 | { | |
685 | /* MVCLU */ | |
686 | *len = 6; | |
687 | return 1; | |
688 | } | |
689 | } | |
690 | break; | |
691 | } | |
692 | ||
693 | switch (insn) | |
694 | { | |
695 | case 0xb255: /* MVST */ | |
696 | case 0xb263: /* CMPSC */ | |
697 | case 0xb2a5: /* TRE */ | |
698 | case 0xb2a6: /* CU21 */ | |
699 | case 0xb2a7: /* CU12 */ | |
700 | case 0xb9b0: /* CU14 */ | |
701 | case 0xb9b1: /* CU24 */ | |
702 | case 0xb9b2: /* CU41 */ | |
703 | case 0xb9b3: /* CU42 */ | |
704 | case 0xb92a: /* KMF */ | |
705 | case 0xb92b: /* KMO */ | |
706 | case 0xb92f: /* KMC */ | |
707 | case 0xb92d: /* KMCTR */ | |
708 | case 0xb92e: /* KM */ | |
709 | case 0xb93c: /* PPNO */ | |
710 | case 0xb990: /* TRTT */ | |
711 | case 0xb991: /* TRTO */ | |
712 | case 0xb992: /* TROT */ | |
713 | case 0xb993: /* TROO */ | |
714 | *len = 4; | |
715 | return 1; | |
716 | } | |
717 | ||
718 | return 0; | |
719 | } | |
720 | ||
721 | /* Implement the "software_single_step" gdbarch method, needed to single step | |
722 | through instructions like MVCLE in record mode, to make sure they are | |
723 | executed to completion. Without that, record will save the full length | |
724 | of destination buffer on every iteration, even though the CPU will only | |
725 | process about 4kiB of it each time, leading to O(n**2) memory and time | |
726 | complexity. */ | |
727 | ||
93f9a11f | 728 | static VEC (CORE_ADDR) * |
f5ea389a | 729 | s390_software_single_step (struct regcache *regcache) |
6df55226 | 730 | { |
ad769689 YQ |
731 | struct gdbarch *gdbarch = get_regcache_arch (regcache); |
732 | CORE_ADDR loc = regcache_read_pc (regcache); | |
6df55226 MK |
733 | enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); |
734 | int len; | |
735 | uint16_t insn; | |
93f9a11f | 736 | VEC (CORE_ADDR) *next_pcs = NULL; |
6df55226 MK |
737 | |
738 | /* Special handling only if recording. */ | |
739 | if (!record_full_is_used ()) | |
93f9a11f | 740 | return NULL; |
6df55226 MK |
741 | |
742 | /* First, match a partial instruction. */ | |
743 | if (!s390_is_partial_instruction (gdbarch, loc, &len)) | |
93f9a11f | 744 | return NULL; |
6df55226 MK |
745 | |
746 | loc += len; | |
747 | ||
748 | /* Second, look for a branch back to it. */ | |
749 | insn = read_memory_integer (loc, 2, byte_order); | |
750 | if (insn != 0xa714) /* BRC with mask 1 */ | |
93f9a11f | 751 | return NULL; |
6df55226 MK |
752 | |
753 | insn = read_memory_integer (loc + 2, 2, byte_order); | |
754 | if (insn != (uint16_t) -(len / 2)) | |
93f9a11f | 755 | return NULL; |
6df55226 MK |
756 | |
757 | loc += 4; | |
758 | ||
759 | /* Found it, step past the whole thing. */ | |
93f9a11f | 760 | VEC_safe_push (CORE_ADDR, next_pcs, loc); |
6df55226 | 761 | |
93f9a11f | 762 | return next_pcs; |
6df55226 MK |
763 | } |
764 | ||
765 | static int | |
766 | s390_displaced_step_hw_singlestep (struct gdbarch *gdbarch, | |
767 | struct displaced_step_closure *closure) | |
768 | { | |
769 | return 1; | |
770 | } | |
771 | ||
772 | ||
2ccd1468 | 773 | /* Maps for register sets. */ |
d0f54f9d | 774 | |
99b7da5d | 775 | static const struct regcache_map_entry s390_gregmap[] = |
2ccd1468 | 776 | { |
99b7da5d AA |
777 | { 1, S390_PSWM_REGNUM }, |
778 | { 1, S390_PSWA_REGNUM }, | |
779 | { 16, S390_R0_REGNUM }, | |
780 | { 16, S390_A0_REGNUM }, | |
781 | { 1, S390_ORIG_R2_REGNUM }, | |
782 | { 0 } | |
2ccd1468 | 783 | }; |
d0f54f9d | 784 | |
99b7da5d | 785 | static const struct regcache_map_entry s390_fpregmap[] = |
2ccd1468 | 786 | { |
99b7da5d AA |
787 | { 1, S390_FPC_REGNUM, 8 }, |
788 | { 16, S390_F0_REGNUM, 8 }, | |
789 | { 0 } | |
2ccd1468 | 790 | }; |
d0f54f9d | 791 | |
99b7da5d | 792 | static const struct regcache_map_entry s390_regmap_upper[] = |
2ccd1468 | 793 | { |
99b7da5d AA |
794 | { 16, S390_R0_UPPER_REGNUM, 4 }, |
795 | { 0 } | |
2ccd1468 | 796 | }; |
7803799a | 797 | |
99b7da5d | 798 | static const struct regcache_map_entry s390_regmap_last_break[] = |
2ccd1468 | 799 | { |
99b7da5d AA |
800 | { 1, REGCACHE_MAP_SKIP, 4 }, |
801 | { 1, S390_LAST_BREAK_REGNUM, 4 }, | |
802 | { 0 } | |
2ccd1468 | 803 | }; |
c642a434 | 804 | |
99b7da5d | 805 | static const struct regcache_map_entry s390x_regmap_last_break[] = |
2ccd1468 | 806 | { |
99b7da5d AA |
807 | { 1, S390_LAST_BREAK_REGNUM, 8 }, |
808 | { 0 } | |
2ccd1468 UW |
809 | }; |
810 | ||
99b7da5d | 811 | static const struct regcache_map_entry s390_regmap_system_call[] = |
2ccd1468 | 812 | { |
99b7da5d AA |
813 | { 1, S390_SYSTEM_CALL_REGNUM, 4 }, |
814 | { 0 } | |
2ccd1468 UW |
815 | }; |
816 | ||
99b7da5d | 817 | static const struct regcache_map_entry s390_regmap_tdb[] = |
2ccd1468 | 818 | { |
99b7da5d AA |
819 | { 1, S390_TDB_DWORD0_REGNUM, 8 }, |
820 | { 1, S390_TDB_ABORT_CODE_REGNUM, 8 }, | |
821 | { 1, S390_TDB_CONFLICT_TOKEN_REGNUM, 8 }, | |
822 | { 1, S390_TDB_ATIA_REGNUM, 8 }, | |
823 | { 12, REGCACHE_MAP_SKIP, 8 }, | |
824 | { 16, S390_TDB_R0_REGNUM, 8 }, | |
825 | { 0 } | |
2ccd1468 | 826 | }; |
c642a434 | 827 | |
550bdf96 AA |
828 | static const struct regcache_map_entry s390_regmap_vxrs_low[] = |
829 | { | |
830 | { 16, S390_V0_LOWER_REGNUM, 8 }, | |
831 | { 0 } | |
832 | }; | |
833 | ||
834 | static const struct regcache_map_entry s390_regmap_vxrs_high[] = | |
835 | { | |
836 | { 16, S390_V16_REGNUM, 16 }, | |
837 | { 0 } | |
838 | }; | |
839 | ||
4ac33720 | 840 | |
99b7da5d AA |
841 | /* Supply the TDB regset. Like regcache_supply_regset, but invalidate |
842 | the TDB registers unless the TDB format field is valid. */ | |
4ac33720 UW |
843 | |
844 | static void | |
845 | s390_supply_tdb_regset (const struct regset *regset, struct regcache *regcache, | |
846 | int regnum, const void *regs, size_t len) | |
847 | { | |
848 | ULONGEST tdw; | |
849 | enum register_status ret; | |
4ac33720 | 850 | |
99b7da5d | 851 | regcache_supply_regset (regset, regcache, regnum, regs, len); |
4ac33720 UW |
852 | ret = regcache_cooked_read_unsigned (regcache, S390_TDB_DWORD0_REGNUM, &tdw); |
853 | if (ret != REG_VALID || (tdw >> 56) != 1) | |
99b7da5d | 854 | regcache_supply_regset (regset, regcache, regnum, NULL, len); |
d0f54f9d JB |
855 | } |
856 | ||
99b7da5d AA |
857 | const struct regset s390_gregset = { |
858 | s390_gregmap, | |
859 | regcache_supply_regset, | |
860 | regcache_collect_regset | |
d0f54f9d JB |
861 | }; |
862 | ||
99b7da5d AA |
863 | const struct regset s390_fpregset = { |
864 | s390_fpregmap, | |
865 | regcache_supply_regset, | |
866 | regcache_collect_regset | |
d0f54f9d JB |
867 | }; |
868 | ||
7803799a | 869 | static const struct regset s390_upper_regset = { |
34201ae3 | 870 | s390_regmap_upper, |
99b7da5d AA |
871 | regcache_supply_regset, |
872 | regcache_collect_regset | |
7803799a UW |
873 | }; |
874 | ||
99b7da5d | 875 | const struct regset s390_last_break_regset = { |
c642a434 | 876 | s390_regmap_last_break, |
99b7da5d AA |
877 | regcache_supply_regset, |
878 | regcache_collect_regset | |
c642a434 UW |
879 | }; |
880 | ||
99b7da5d | 881 | const struct regset s390x_last_break_regset = { |
c642a434 | 882 | s390x_regmap_last_break, |
99b7da5d AA |
883 | regcache_supply_regset, |
884 | regcache_collect_regset | |
c642a434 UW |
885 | }; |
886 | ||
99b7da5d | 887 | const struct regset s390_system_call_regset = { |
c642a434 | 888 | s390_regmap_system_call, |
99b7da5d AA |
889 | regcache_supply_regset, |
890 | regcache_collect_regset | |
c642a434 UW |
891 | }; |
892 | ||
99b7da5d | 893 | const struct regset s390_tdb_regset = { |
4ac33720 UW |
894 | s390_regmap_tdb, |
895 | s390_supply_tdb_regset, | |
99b7da5d | 896 | regcache_collect_regset |
4ac33720 UW |
897 | }; |
898 | ||
550bdf96 AA |
899 | const struct regset s390_vxrs_low_regset = { |
900 | s390_regmap_vxrs_low, | |
901 | regcache_supply_regset, | |
902 | regcache_collect_regset | |
903 | }; | |
904 | ||
905 | const struct regset s390_vxrs_high_regset = { | |
906 | s390_regmap_vxrs_high, | |
907 | regcache_supply_regset, | |
908 | regcache_collect_regset | |
909 | }; | |
910 | ||
5aa82d05 AA |
911 | /* Iterate over supported core file register note sections. */ |
912 | ||
913 | static void | |
914 | s390_iterate_over_regset_sections (struct gdbarch *gdbarch, | |
915 | iterate_over_regset_sections_cb *cb, | |
916 | void *cb_data, | |
917 | const struct regcache *regcache) | |
918 | { | |
919 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | |
8f0435f7 AA |
920 | const int gregset_size = (tdep->abi == ABI_LINUX_S390 ? |
921 | s390_sizeof_gregset : s390x_sizeof_gregset); | |
5aa82d05 | 922 | |
8f0435f7 AA |
923 | cb (".reg", gregset_size, &s390_gregset, NULL, cb_data); |
924 | cb (".reg2", s390_sizeof_fpregset, &s390_fpregset, NULL, cb_data); | |
5aa82d05 AA |
925 | |
926 | if (tdep->abi == ABI_LINUX_S390 && tdep->gpr_full_regnum != -1) | |
8f0435f7 AA |
927 | cb (".reg-s390-high-gprs", 16 * 4, &s390_upper_regset, |
928 | "s390 GPR upper halves", cb_data); | |
5aa82d05 AA |
929 | |
930 | if (tdep->have_linux_v1) | |
8f0435f7 AA |
931 | cb (".reg-s390-last-break", 8, |
932 | (gdbarch_ptr_bit (gdbarch) == 32 | |
933 | ? &s390_last_break_regset : &s390x_last_break_regset), | |
34a60ddb | 934 | "s390 last-break address", cb_data); |
5aa82d05 AA |
935 | |
936 | if (tdep->have_linux_v2) | |
8f0435f7 AA |
937 | cb (".reg-s390-system-call", 4, &s390_system_call_regset, |
938 | "s390 system-call", cb_data); | |
5aa82d05 AA |
939 | |
940 | /* If regcache is set, we are in "write" (gcore) mode. In this | |
941 | case, don't iterate over the TDB unless its registers are | |
942 | available. */ | |
943 | if (tdep->have_tdb | |
944 | && (regcache == NULL | |
945 | || REG_VALID == regcache_register_status (regcache, | |
946 | S390_TDB_DWORD0_REGNUM))) | |
8f0435f7 AA |
947 | cb (".reg-s390-tdb", s390_sizeof_tdbregset, &s390_tdb_regset, |
948 | "s390 TDB", cb_data); | |
550bdf96 AA |
949 | |
950 | if (tdep->v0_full_regnum != -1) | |
951 | { | |
952 | cb (".reg-s390-vxrs-low", 16 * 8, &s390_vxrs_low_regset, | |
953 | "s390 vector registers 0-15 lower half", cb_data); | |
954 | cb (".reg-s390-vxrs-high", 16 * 16, &s390_vxrs_high_regset, | |
955 | "s390 vector registers 16-31", cb_data); | |
956 | } | |
5aa82d05 AA |
957 | } |
958 | ||
7803799a UW |
959 | static const struct target_desc * |
960 | s390_core_read_description (struct gdbarch *gdbarch, | |
961 | struct target_ops *target, bfd *abfd) | |
962 | { | |
7803799a | 963 | asection *section = bfd_get_section_by_name (abfd, ".reg"); |
04a83fee | 964 | CORE_ADDR hwcap = 0; |
550bdf96 | 965 | int high_gprs, v1, v2, te, vx; |
4ac33720 UW |
966 | |
967 | target_auxv_search (target, AT_HWCAP, &hwcap); | |
7803799a UW |
968 | if (!section) |
969 | return NULL; | |
970 | ||
550bdf96 AA |
971 | high_gprs = (bfd_get_section_by_name (abfd, ".reg-s390-high-gprs") |
972 | != NULL); | |
973 | v1 = (bfd_get_section_by_name (abfd, ".reg-s390-last-break") != NULL); | |
974 | v2 = (bfd_get_section_by_name (abfd, ".reg-s390-system-call") != NULL); | |
975 | vx = (hwcap & HWCAP_S390_VX); | |
976 | te = (hwcap & HWCAP_S390_TE); | |
977 | ||
7803799a UW |
978 | switch (bfd_section_size (abfd, section)) |
979 | { | |
980 | case s390_sizeof_gregset: | |
c642a434 | 981 | if (high_gprs) |
550bdf96 AA |
982 | return (te && vx ? tdesc_s390_tevx_linux64 : |
983 | vx ? tdesc_s390_vx_linux64 : | |
984 | te ? tdesc_s390_te_linux64 : | |
985 | v2 ? tdesc_s390_linux64v2 : | |
986 | v1 ? tdesc_s390_linux64v1 : tdesc_s390_linux64); | |
c642a434 | 987 | else |
550bdf96 AA |
988 | return (v2 ? tdesc_s390_linux32v2 : |
989 | v1 ? tdesc_s390_linux32v1 : tdesc_s390_linux32); | |
7803799a UW |
990 | |
991 | case s390x_sizeof_gregset: | |
550bdf96 AA |
992 | return (te && vx ? tdesc_s390x_tevx_linux64 : |
993 | vx ? tdesc_s390x_vx_linux64 : | |
994 | te ? tdesc_s390x_te_linux64 : | |
995 | v2 ? tdesc_s390x_linux64v2 : | |
996 | v1 ? tdesc_s390x_linux64v1 : tdesc_s390x_linux64); | |
7803799a UW |
997 | |
998 | default: | |
999 | return NULL; | |
1000 | } | |
1001 | } | |
1002 | ||
d0f54f9d | 1003 | |
4bc8c588 JB |
1004 | /* Decoding S/390 instructions. */ |
1005 | ||
1006 | /* Named opcode values for the S/390 instructions we recognize. Some | |
1007 | instructions have their opcode split across two fields; those are the | |
1008 | op1_* and op2_* enums. */ | |
1009 | enum | |
1010 | { | |
a8c99f38 JB |
1011 | op1_lhi = 0xa7, op2_lhi = 0x08, |
1012 | op1_lghi = 0xa7, op2_lghi = 0x09, | |
00ce08ef | 1013 | op1_lgfi = 0xc0, op2_lgfi = 0x01, |
4bc8c588 | 1014 | op_lr = 0x18, |
a8c99f38 JB |
1015 | op_lgr = 0xb904, |
1016 | op_l = 0x58, | |
1017 | op1_ly = 0xe3, op2_ly = 0x58, | |
1018 | op1_lg = 0xe3, op2_lg = 0x04, | |
1019 | op_lm = 0x98, | |
1020 | op1_lmy = 0xeb, op2_lmy = 0x98, | |
1021 | op1_lmg = 0xeb, op2_lmg = 0x04, | |
4bc8c588 | 1022 | op_st = 0x50, |
a8c99f38 | 1023 | op1_sty = 0xe3, op2_sty = 0x50, |
4bc8c588 | 1024 | op1_stg = 0xe3, op2_stg = 0x24, |
a8c99f38 | 1025 | op_std = 0x60, |
4bc8c588 | 1026 | op_stm = 0x90, |
a8c99f38 | 1027 | op1_stmy = 0xeb, op2_stmy = 0x90, |
4bc8c588 | 1028 | op1_stmg = 0xeb, op2_stmg = 0x24, |
a8c99f38 JB |
1029 | op1_aghi = 0xa7, op2_aghi = 0x0b, |
1030 | op1_ahi = 0xa7, op2_ahi = 0x0a, | |
00ce08ef UW |
1031 | op1_agfi = 0xc2, op2_agfi = 0x08, |
1032 | op1_afi = 0xc2, op2_afi = 0x09, | |
1033 | op1_algfi= 0xc2, op2_algfi= 0x0a, | |
1034 | op1_alfi = 0xc2, op2_alfi = 0x0b, | |
a8c99f38 JB |
1035 | op_ar = 0x1a, |
1036 | op_agr = 0xb908, | |
1037 | op_a = 0x5a, | |
1038 | op1_ay = 0xe3, op2_ay = 0x5a, | |
1039 | op1_ag = 0xe3, op2_ag = 0x08, | |
00ce08ef UW |
1040 | op1_slgfi= 0xc2, op2_slgfi= 0x04, |
1041 | op1_slfi = 0xc2, op2_slfi = 0x05, | |
a8c99f38 JB |
1042 | op_sr = 0x1b, |
1043 | op_sgr = 0xb909, | |
1044 | op_s = 0x5b, | |
1045 | op1_sy = 0xe3, op2_sy = 0x5b, | |
1046 | op1_sg = 0xe3, op2_sg = 0x09, | |
1047 | op_nr = 0x14, | |
1048 | op_ngr = 0xb980, | |
1049 | op_la = 0x41, | |
1050 | op1_lay = 0xe3, op2_lay = 0x71, | |
1051 | op1_larl = 0xc0, op2_larl = 0x00, | |
1052 | op_basr = 0x0d, | |
1053 | op_bas = 0x4d, | |
1054 | op_bcr = 0x07, | |
1055 | op_bc = 0x0d, | |
1db4e8a0 UW |
1056 | op_bctr = 0x06, |
1057 | op_bctgr = 0xb946, | |
1058 | op_bct = 0x46, | |
1059 | op1_bctg = 0xe3, op2_bctg = 0x46, | |
1060 | op_bxh = 0x86, | |
1061 | op1_bxhg = 0xeb, op2_bxhg = 0x44, | |
1062 | op_bxle = 0x87, | |
1063 | op1_bxleg= 0xeb, op2_bxleg= 0x45, | |
a8c99f38 JB |
1064 | op1_bras = 0xa7, op2_bras = 0x05, |
1065 | op1_brasl= 0xc0, op2_brasl= 0x05, | |
1066 | op1_brc = 0xa7, op2_brc = 0x04, | |
1067 | op1_brcl = 0xc0, op2_brcl = 0x04, | |
1db4e8a0 UW |
1068 | op1_brct = 0xa7, op2_brct = 0x06, |
1069 | op1_brctg= 0xa7, op2_brctg= 0x07, | |
1070 | op_brxh = 0x84, | |
1071 | op1_brxhg= 0xec, op2_brxhg= 0x44, | |
1072 | op_brxle = 0x85, | |
1073 | op1_brxlg= 0xec, op2_brxlg= 0x45, | |
237b092b | 1074 | op_svc = 0x0a, |
4bc8c588 JB |
1075 | }; |
1076 | ||
1077 | ||
a8c99f38 JB |
1078 | /* Read a single instruction from address AT. */ |
1079 | ||
1080 | #define S390_MAX_INSTR_SIZE 6 | |
1081 | static int | |
1082 | s390_readinstruction (bfd_byte instr[], CORE_ADDR at) | |
1083 | { | |
1084 | static int s390_instrlen[] = { 2, 4, 4, 6 }; | |
1085 | int instrlen; | |
1086 | ||
8defab1a | 1087 | if (target_read_memory (at, &instr[0], 2)) |
a8c99f38 JB |
1088 | return -1; |
1089 | instrlen = s390_instrlen[instr[0] >> 6]; | |
1090 | if (instrlen > 2) | |
1091 | { | |
8defab1a | 1092 | if (target_read_memory (at + 2, &instr[2], instrlen - 2)) |
34201ae3 | 1093 | return -1; |
a8c99f38 JB |
1094 | } |
1095 | return instrlen; | |
1096 | } | |
1097 | ||
1098 | ||
4bc8c588 JB |
1099 | /* The functions below are for recognizing and decoding S/390 |
1100 | instructions of various formats. Each of them checks whether INSN | |
1101 | is an instruction of the given format, with the specified opcodes. | |
1102 | If it is, it sets the remaining arguments to the values of the | |
1103 | instruction's fields, and returns a non-zero value; otherwise, it | |
1104 | returns zero. | |
1105 | ||
1106 | These functions' arguments appear in the order they appear in the | |
1107 | instruction, not in the machine-language form. So, opcodes always | |
1108 | come first, even though they're sometimes scattered around the | |
1109 | instructions. And displacements appear before base and extension | |
1110 | registers, as they do in the assembly syntax, not at the end, as | |
1111 | they do in the machine language. */ | |
a78f21af | 1112 | static int |
4bc8c588 JB |
1113 | is_ri (bfd_byte *insn, int op1, int op2, unsigned int *r1, int *i2) |
1114 | { | |
1115 | if (insn[0] == op1 && (insn[1] & 0xf) == op2) | |
1116 | { | |
1117 | *r1 = (insn[1] >> 4) & 0xf; | |
1118 | /* i2 is a 16-bit signed quantity. */ | |
1119 | *i2 = (((insn[2] << 8) | insn[3]) ^ 0x8000) - 0x8000; | |
1120 | return 1; | |
1121 | } | |
1122 | else | |
1123 | return 0; | |
1124 | } | |
8ac0e65a | 1125 | |
5769d3cd | 1126 | |
4bc8c588 JB |
1127 | static int |
1128 | is_ril (bfd_byte *insn, int op1, int op2, | |
34201ae3 | 1129 | unsigned int *r1, int *i2) |
4bc8c588 JB |
1130 | { |
1131 | if (insn[0] == op1 && (insn[1] & 0xf) == op2) | |
1132 | { | |
1133 | *r1 = (insn[1] >> 4) & 0xf; | |
1134 | /* i2 is a signed quantity. If the host 'int' is 32 bits long, | |
34201ae3 UW |
1135 | no sign extension is necessary, but we don't want to assume |
1136 | that. */ | |
4bc8c588 | 1137 | *i2 = (((insn[2] << 24) |
34201ae3 UW |
1138 | | (insn[3] << 16) |
1139 | | (insn[4] << 8) | |
1140 | | (insn[5])) ^ 0x80000000) - 0x80000000; | |
4bc8c588 JB |
1141 | return 1; |
1142 | } | |
1143 | else | |
1144 | return 0; | |
1145 | } | |
1146 | ||
1147 | ||
1148 | static int | |
1149 | is_rr (bfd_byte *insn, int op, unsigned int *r1, unsigned int *r2) | |
1150 | { | |
1151 | if (insn[0] == op) | |
1152 | { | |
1153 | *r1 = (insn[1] >> 4) & 0xf; | |
1154 | *r2 = insn[1] & 0xf; | |
1155 | return 1; | |
1156 | } | |
1157 | else | |
1158 | return 0; | |
1159 | } | |
1160 | ||
1161 | ||
1162 | static int | |
1163 | is_rre (bfd_byte *insn, int op, unsigned int *r1, unsigned int *r2) | |
1164 | { | |
1165 | if (((insn[0] << 8) | insn[1]) == op) | |
1166 | { | |
1167 | /* Yes, insn[3]. insn[2] is unused in RRE format. */ | |
1168 | *r1 = (insn[3] >> 4) & 0xf; | |
1169 | *r2 = insn[3] & 0xf; | |
1170 | return 1; | |
1171 | } | |
1172 | else | |
1173 | return 0; | |
1174 | } | |
1175 | ||
1176 | ||
1177 | static int | |
1178 | is_rs (bfd_byte *insn, int op, | |
eb1bd1fb | 1179 | unsigned int *r1, unsigned int *r3, int *d2, unsigned int *b2) |
4bc8c588 JB |
1180 | { |
1181 | if (insn[0] == op) | |
1182 | { | |
1183 | *r1 = (insn[1] >> 4) & 0xf; | |
1184 | *r3 = insn[1] & 0xf; | |
1185 | *b2 = (insn[2] >> 4) & 0xf; | |
1186 | *d2 = ((insn[2] & 0xf) << 8) | insn[3]; | |
1187 | return 1; | |
1188 | } | |
1189 | else | |
1190 | return 0; | |
1191 | } | |
1192 | ||
1193 | ||
1194 | static int | |
a8c99f38 | 1195 | is_rsy (bfd_byte *insn, int op1, int op2, |
34201ae3 | 1196 | unsigned int *r1, unsigned int *r3, int *d2, unsigned int *b2) |
4bc8c588 JB |
1197 | { |
1198 | if (insn[0] == op1 | |
4bc8c588 JB |
1199 | && insn[5] == op2) |
1200 | { | |
1201 | *r1 = (insn[1] >> 4) & 0xf; | |
1202 | *r3 = insn[1] & 0xf; | |
1203 | *b2 = (insn[2] >> 4) & 0xf; | |
a8c99f38 | 1204 | /* The 'long displacement' is a 20-bit signed integer. */ |
34201ae3 | 1205 | *d2 = ((((insn[2] & 0xf) << 8) | insn[3] | (insn[4] << 12)) |
a8c99f38 | 1206 | ^ 0x80000) - 0x80000; |
4bc8c588 JB |
1207 | return 1; |
1208 | } | |
1209 | else | |
1210 | return 0; | |
1211 | } | |
1212 | ||
1213 | ||
1db4e8a0 UW |
1214 | static int |
1215 | is_rsi (bfd_byte *insn, int op, | |
34201ae3 | 1216 | unsigned int *r1, unsigned int *r3, int *i2) |
1db4e8a0 UW |
1217 | { |
1218 | if (insn[0] == op) | |
1219 | { | |
1220 | *r1 = (insn[1] >> 4) & 0xf; | |
1221 | *r3 = insn[1] & 0xf; | |
1222 | /* i2 is a 16-bit signed quantity. */ | |
1223 | *i2 = (((insn[2] << 8) | insn[3]) ^ 0x8000) - 0x8000; | |
1224 | return 1; | |
1225 | } | |
1226 | else | |
1227 | return 0; | |
1228 | } | |
1229 | ||
1230 | ||
1231 | static int | |
1232 | is_rie (bfd_byte *insn, int op1, int op2, | |
34201ae3 | 1233 | unsigned int *r1, unsigned int *r3, int *i2) |
1db4e8a0 UW |
1234 | { |
1235 | if (insn[0] == op1 | |
1236 | && insn[5] == op2) | |
1237 | { | |
1238 | *r1 = (insn[1] >> 4) & 0xf; | |
1239 | *r3 = insn[1] & 0xf; | |
1240 | /* i2 is a 16-bit signed quantity. */ | |
1241 | *i2 = (((insn[2] << 8) | insn[3]) ^ 0x8000) - 0x8000; | |
1242 | return 1; | |
1243 | } | |
1244 | else | |
1245 | return 0; | |
1246 | } | |
1247 | ||
1248 | ||
4bc8c588 JB |
1249 | static int |
1250 | is_rx (bfd_byte *insn, int op, | |
eb1bd1fb | 1251 | unsigned int *r1, int *d2, unsigned int *x2, unsigned int *b2) |
4bc8c588 JB |
1252 | { |
1253 | if (insn[0] == op) | |
1254 | { | |
1255 | *r1 = (insn[1] >> 4) & 0xf; | |
1256 | *x2 = insn[1] & 0xf; | |
1257 | *b2 = (insn[2] >> 4) & 0xf; | |
1258 | *d2 = ((insn[2] & 0xf) << 8) | insn[3]; | |
1259 | return 1; | |
1260 | } | |
1261 | else | |
1262 | return 0; | |
1263 | } | |
1264 | ||
1265 | ||
1266 | static int | |
a8c99f38 | 1267 | is_rxy (bfd_byte *insn, int op1, int op2, |
34201ae3 | 1268 | unsigned int *r1, int *d2, unsigned int *x2, unsigned int *b2) |
4bc8c588 JB |
1269 | { |
1270 | if (insn[0] == op1 | |
4bc8c588 JB |
1271 | && insn[5] == op2) |
1272 | { | |
1273 | *r1 = (insn[1] >> 4) & 0xf; | |
1274 | *x2 = insn[1] & 0xf; | |
1275 | *b2 = (insn[2] >> 4) & 0xf; | |
a8c99f38 | 1276 | /* The 'long displacement' is a 20-bit signed integer. */ |
34201ae3 | 1277 | *d2 = ((((insn[2] & 0xf) << 8) | insn[3] | (insn[4] << 12)) |
a8c99f38 | 1278 | ^ 0x80000) - 0x80000; |
4bc8c588 JB |
1279 | return 1; |
1280 | } | |
1281 | else | |
1282 | return 0; | |
1283 | } | |
1284 | ||
1285 | ||
3fc46200 | 1286 | /* Prologue analysis. */ |
4bc8c588 | 1287 | |
d0f54f9d JB |
1288 | #define S390_NUM_GPRS 16 |
1289 | #define S390_NUM_FPRS 16 | |
4bc8c588 | 1290 | |
a8c99f38 JB |
1291 | struct s390_prologue_data { |
1292 | ||
ee1b3323 UW |
1293 | /* The stack. */ |
1294 | struct pv_area *stack; | |
1295 | ||
e17a4113 | 1296 | /* The size and byte-order of a GPR or FPR. */ |
a8c99f38 JB |
1297 | int gpr_size; |
1298 | int fpr_size; | |
e17a4113 | 1299 | enum bfd_endian byte_order; |
a8c99f38 JB |
1300 | |
1301 | /* The general-purpose registers. */ | |
3fc46200 | 1302 | pv_t gpr[S390_NUM_GPRS]; |
a8c99f38 JB |
1303 | |
1304 | /* The floating-point registers. */ | |
3fc46200 | 1305 | pv_t fpr[S390_NUM_FPRS]; |
a8c99f38 | 1306 | |
121d8485 UW |
1307 | /* The offset relative to the CFA where the incoming GPR N was saved |
1308 | by the function prologue. 0 if not saved or unknown. */ | |
1309 | int gpr_slot[S390_NUM_GPRS]; | |
4bc8c588 | 1310 | |
121d8485 UW |
1311 | /* Likewise for FPRs. */ |
1312 | int fpr_slot[S390_NUM_FPRS]; | |
4bc8c588 | 1313 | |
121d8485 UW |
1314 | /* Nonzero if the backchain was saved. This is assumed to be the |
1315 | case when the incoming SP is saved at the current SP location. */ | |
1316 | int back_chain_saved_p; | |
1317 | }; | |
4bc8c588 | 1318 | |
3fc46200 UW |
1319 | /* Return the effective address for an X-style instruction, like: |
1320 | ||
34201ae3 | 1321 | L R1, D2(X2, B2) |
3fc46200 UW |
1322 | |
1323 | Here, X2 and B2 are registers, and D2 is a signed 20-bit | |
1324 | constant; the effective address is the sum of all three. If either | |
1325 | X2 or B2 are zero, then it doesn't contribute to the sum --- this | |
1326 | means that r0 can't be used as either X2 or B2. */ | |
1327 | static pv_t | |
1328 | s390_addr (struct s390_prologue_data *data, | |
1329 | int d2, unsigned int x2, unsigned int b2) | |
1330 | { | |
1331 | pv_t result; | |
1332 | ||
1333 | result = pv_constant (d2); | |
1334 | if (x2) | |
1335 | result = pv_add (result, data->gpr[x2]); | |
1336 | if (b2) | |
1337 | result = pv_add (result, data->gpr[b2]); | |
1338 | ||
1339 | return result; | |
1340 | } | |
1341 | ||
1342 | /* Do a SIZE-byte store of VALUE to D2(X2,B2). */ | |
a8c99f38 | 1343 | static void |
3fc46200 UW |
1344 | s390_store (struct s390_prologue_data *data, |
1345 | int d2, unsigned int x2, unsigned int b2, CORE_ADDR size, | |
1346 | pv_t value) | |
4bc8c588 | 1347 | { |
3fc46200 | 1348 | pv_t addr = s390_addr (data, d2, x2, b2); |
ee1b3323 | 1349 | pv_t offset; |
121d8485 UW |
1350 | |
1351 | /* Check whether we are storing the backchain. */ | |
3fc46200 | 1352 | offset = pv_subtract (data->gpr[S390_SP_REGNUM - S390_R0_REGNUM], addr); |
121d8485 | 1353 | |
3fc46200 | 1354 | if (pv_is_constant (offset) && offset.k == 0) |
121d8485 | 1355 | if (size == data->gpr_size |
3fc46200 | 1356 | && pv_is_register_k (value, S390_SP_REGNUM, 0)) |
121d8485 UW |
1357 | { |
1358 | data->back_chain_saved_p = 1; | |
1359 | return; | |
1360 | } | |
1361 | ||
1362 | ||
1363 | /* Check whether we are storing a register into the stack. */ | |
ee1b3323 UW |
1364 | if (!pv_area_store_would_trash (data->stack, addr)) |
1365 | pv_area_store (data->stack, addr, size, value); | |
4bc8c588 | 1366 | |
a8c99f38 | 1367 | |
121d8485 UW |
1368 | /* Note: If this is some store we cannot identify, you might think we |
1369 | should forget our cached values, as any of those might have been hit. | |
1370 | ||
1371 | However, we make the assumption that the register save areas are only | |
1372 | ever stored to once in any given function, and we do recognize these | |
1373 | stores. Thus every store we cannot recognize does not hit our data. */ | |
4bc8c588 | 1374 | } |
4bc8c588 | 1375 | |
3fc46200 UW |
1376 | /* Do a SIZE-byte load from D2(X2,B2). */ |
1377 | static pv_t | |
1378 | s390_load (struct s390_prologue_data *data, | |
1379 | int d2, unsigned int x2, unsigned int b2, CORE_ADDR size) | |
34201ae3 | 1380 | |
4bc8c588 | 1381 | { |
3fc46200 | 1382 | pv_t addr = s390_addr (data, d2, x2, b2); |
4bc8c588 | 1383 | |
a8c99f38 JB |
1384 | /* If it's a load from an in-line constant pool, then we can |
1385 | simulate that, under the assumption that the code isn't | |
1386 | going to change between the time the processor actually | |
1387 | executed it creating the current frame, and the time when | |
1388 | we're analyzing the code to unwind past that frame. */ | |
3fc46200 | 1389 | if (pv_is_constant (addr)) |
4bc8c588 | 1390 | { |
0542c86d | 1391 | struct target_section *secp; |
3fc46200 | 1392 | secp = target_section_by_addr (¤t_target, addr.k); |
a8c99f38 | 1393 | if (secp != NULL |
34201ae3 | 1394 | && (bfd_get_section_flags (secp->the_bfd_section->owner, |
57e6060e | 1395 | secp->the_bfd_section) |
34201ae3 UW |
1396 | & SEC_READONLY)) |
1397 | return pv_constant (read_memory_integer (addr.k, size, | |
e17a4113 | 1398 | data->byte_order)); |
a8c99f38 | 1399 | } |
7666f43c | 1400 | |
121d8485 | 1401 | /* Check whether we are accessing one of our save slots. */ |
ee1b3323 UW |
1402 | return pv_area_fetch (data->stack, addr, size); |
1403 | } | |
121d8485 | 1404 | |
ee1b3323 UW |
1405 | /* Function for finding saved registers in a 'struct pv_area'; we pass |
1406 | this to pv_area_scan. | |
121d8485 | 1407 | |
ee1b3323 UW |
1408 | If VALUE is a saved register, ADDR says it was saved at a constant |
1409 | offset from the frame base, and SIZE indicates that the whole | |
1410 | register was saved, record its offset in the reg_offset table in | |
1411 | PROLOGUE_UNTYPED. */ | |
1412 | static void | |
c378eb4e MS |
1413 | s390_check_for_saved (void *data_untyped, pv_t addr, |
1414 | CORE_ADDR size, pv_t value) | |
ee1b3323 | 1415 | { |
19ba03f4 | 1416 | struct s390_prologue_data *data = (struct s390_prologue_data *) data_untyped; |
ee1b3323 UW |
1417 | int i, offset; |
1418 | ||
1419 | if (!pv_is_register (addr, S390_SP_REGNUM)) | |
1420 | return; | |
1421 | ||
1422 | offset = 16 * data->gpr_size + 32 - addr.k; | |
4bc8c588 | 1423 | |
ee1b3323 UW |
1424 | /* If we are storing the original value of a register, we want to |
1425 | record the CFA offset. If the same register is stored multiple | |
1426 | times, the stack slot with the highest address counts. */ | |
34201ae3 | 1427 | |
ee1b3323 UW |
1428 | for (i = 0; i < S390_NUM_GPRS; i++) |
1429 | if (size == data->gpr_size | |
1430 | && pv_is_register_k (value, S390_R0_REGNUM + i, 0)) | |
1431 | if (data->gpr_slot[i] == 0 | |
1432 | || data->gpr_slot[i] > offset) | |
1433 | { | |
1434 | data->gpr_slot[i] = offset; | |
1435 | return; | |
1436 | } | |
1437 | ||
1438 | for (i = 0; i < S390_NUM_FPRS; i++) | |
1439 | if (size == data->fpr_size | |
1440 | && pv_is_register_k (value, S390_F0_REGNUM + i, 0)) | |
1441 | if (data->fpr_slot[i] == 0 | |
1442 | || data->fpr_slot[i] > offset) | |
1443 | { | |
1444 | data->fpr_slot[i] = offset; | |
1445 | return; | |
1446 | } | |
a8c99f38 | 1447 | } |
4bc8c588 | 1448 | |
a8c99f38 JB |
1449 | /* Analyze the prologue of the function starting at START_PC, |
1450 | continuing at most until CURRENT_PC. Initialize DATA to | |
1451 | hold all information we find out about the state of the registers | |
1452 | and stack slots. Return the address of the instruction after | |
1453 | the last one that changed the SP, FP, or back chain; or zero | |
1454 | on error. */ | |
1455 | static CORE_ADDR | |
1456 | s390_analyze_prologue (struct gdbarch *gdbarch, | |
1457 | CORE_ADDR start_pc, | |
1458 | CORE_ADDR current_pc, | |
1459 | struct s390_prologue_data *data) | |
4bc8c588 | 1460 | { |
a8c99f38 JB |
1461 | int word_size = gdbarch_ptr_bit (gdbarch) / 8; |
1462 | ||
4bc8c588 | 1463 | /* Our return value: |
a8c99f38 | 1464 | The address of the instruction after the last one that changed |
34201ae3 | 1465 | the SP, FP, or back chain; zero if we got an error trying to |
a8c99f38 JB |
1466 | read memory. */ |
1467 | CORE_ADDR result = start_pc; | |
4bc8c588 | 1468 | |
4bc8c588 JB |
1469 | /* The current PC for our abstract interpretation. */ |
1470 | CORE_ADDR pc; | |
1471 | ||
1472 | /* The address of the next instruction after that. */ | |
1473 | CORE_ADDR next_pc; | |
34201ae3 | 1474 | |
4bc8c588 JB |
1475 | /* Set up everything's initial value. */ |
1476 | { | |
1477 | int i; | |
1478 | ||
55f960e1 | 1479 | data->stack = make_pv_area (S390_SP_REGNUM, gdbarch_addr_bit (gdbarch)); |
ee1b3323 | 1480 | |
a8c99f38 JB |
1481 | /* For the purpose of prologue tracking, we consider the GPR size to |
1482 | be equal to the ABI word size, even if it is actually larger | |
1483 | (i.e. when running a 32-bit binary under a 64-bit kernel). */ | |
1484 | data->gpr_size = word_size; | |
1485 | data->fpr_size = 8; | |
e17a4113 | 1486 | data->byte_order = gdbarch_byte_order (gdbarch); |
a8c99f38 | 1487 | |
4bc8c588 | 1488 | for (i = 0; i < S390_NUM_GPRS; i++) |
3fc46200 | 1489 | data->gpr[i] = pv_register (S390_R0_REGNUM + i, 0); |
4bc8c588 JB |
1490 | |
1491 | for (i = 0; i < S390_NUM_FPRS; i++) | |
3fc46200 | 1492 | data->fpr[i] = pv_register (S390_F0_REGNUM + i, 0); |
4bc8c588 | 1493 | |
121d8485 UW |
1494 | for (i = 0; i < S390_NUM_GPRS; i++) |
1495 | data->gpr_slot[i] = 0; | |
1496 | ||
1497 | for (i = 0; i < S390_NUM_FPRS; i++) | |
1498 | data->fpr_slot[i] = 0; | |
4bc8c588 | 1499 | |
121d8485 | 1500 | data->back_chain_saved_p = 0; |
4bc8c588 JB |
1501 | } |
1502 | ||
a8c99f38 JB |
1503 | /* Start interpreting instructions, until we hit the frame's |
1504 | current PC or the first branch instruction. */ | |
1505 | for (pc = start_pc; pc > 0 && pc < current_pc; pc = next_pc) | |
5769d3cd | 1506 | { |
4bc8c588 | 1507 | bfd_byte insn[S390_MAX_INSTR_SIZE]; |
a788de9b | 1508 | int insn_len = s390_readinstruction (insn, pc); |
4bc8c588 | 1509 | |
3fc46200 UW |
1510 | bfd_byte dummy[S390_MAX_INSTR_SIZE] = { 0 }; |
1511 | bfd_byte *insn32 = word_size == 4 ? insn : dummy; | |
1512 | bfd_byte *insn64 = word_size == 8 ? insn : dummy; | |
1513 | ||
4bc8c588 | 1514 | /* Fields for various kinds of instructions. */ |
a8c99f38 JB |
1515 | unsigned int b2, r1, r2, x2, r3; |
1516 | int i2, d2; | |
4bc8c588 | 1517 | |
121d8485 | 1518 | /* The values of SP and FP before this instruction, |
34201ae3 | 1519 | for detecting instructions that change them. */ |
3fc46200 | 1520 | pv_t pre_insn_sp, pre_insn_fp; |
121d8485 UW |
1521 | /* Likewise for the flag whether the back chain was saved. */ |
1522 | int pre_insn_back_chain_saved_p; | |
4bc8c588 JB |
1523 | |
1524 | /* If we got an error trying to read the instruction, report it. */ | |
1525 | if (insn_len < 0) | |
34201ae3 UW |
1526 | { |
1527 | result = 0; | |
1528 | break; | |
1529 | } | |
4bc8c588 JB |
1530 | |
1531 | next_pc = pc + insn_len; | |
1532 | ||
a8c99f38 JB |
1533 | pre_insn_sp = data->gpr[S390_SP_REGNUM - S390_R0_REGNUM]; |
1534 | pre_insn_fp = data->gpr[S390_FRAME_REGNUM - S390_R0_REGNUM]; | |
121d8485 | 1535 | pre_insn_back_chain_saved_p = data->back_chain_saved_p; |
4bc8c588 | 1536 | |
4bc8c588 | 1537 | |
3fc46200 UW |
1538 | /* LHI r1, i2 --- load halfword immediate. */ |
1539 | /* LGHI r1, i2 --- load halfword immediate (64-bit version). */ | |
1540 | /* LGFI r1, i2 --- load fullword immediate. */ | |
1541 | if (is_ri (insn32, op1_lhi, op2_lhi, &r1, &i2) | |
34201ae3 UW |
1542 | || is_ri (insn64, op1_lghi, op2_lghi, &r1, &i2) |
1543 | || is_ril (insn, op1_lgfi, op2_lgfi, &r1, &i2)) | |
3fc46200 UW |
1544 | data->gpr[r1] = pv_constant (i2); |
1545 | ||
1546 | /* LR r1, r2 --- load from register. */ | |
1547 | /* LGR r1, r2 --- load from register (64-bit version). */ | |
1548 | else if (is_rr (insn32, op_lr, &r1, &r2) | |
1549 | || is_rre (insn64, op_lgr, &r1, &r2)) | |
1550 | data->gpr[r1] = data->gpr[r2]; | |
1551 | ||
1552 | /* L r1, d2(x2, b2) --- load. */ | |
1553 | /* LY r1, d2(x2, b2) --- load (long-displacement version). */ | |
1554 | /* LG r1, d2(x2, b2) --- load (64-bit version). */ | |
1555 | else if (is_rx (insn32, op_l, &r1, &d2, &x2, &b2) | |
1556 | || is_rxy (insn32, op1_ly, op2_ly, &r1, &d2, &x2, &b2) | |
1557 | || is_rxy (insn64, op1_lg, op2_lg, &r1, &d2, &x2, &b2)) | |
1558 | data->gpr[r1] = s390_load (data, d2, x2, b2, data->gpr_size); | |
1559 | ||
1560 | /* ST r1, d2(x2, b2) --- store. */ | |
1561 | /* STY r1, d2(x2, b2) --- store (long-displacement version). */ | |
1562 | /* STG r1, d2(x2, b2) --- store (64-bit version). */ | |
1563 | else if (is_rx (insn32, op_st, &r1, &d2, &x2, &b2) | |
1564 | || is_rxy (insn32, op1_sty, op2_sty, &r1, &d2, &x2, &b2) | |
1565 | || is_rxy (insn64, op1_stg, op2_stg, &r1, &d2, &x2, &b2)) | |
1566 | s390_store (data, d2, x2, b2, data->gpr_size, data->gpr[r1]); | |
1567 | ||
1568 | /* STD r1, d2(x2,b2) --- store floating-point register. */ | |
4bc8c588 | 1569 | else if (is_rx (insn, op_std, &r1, &d2, &x2, &b2)) |
3fc46200 UW |
1570 | s390_store (data, d2, x2, b2, data->fpr_size, data->fpr[r1]); |
1571 | ||
1572 | /* STM r1, r3, d2(b2) --- store multiple. */ | |
c378eb4e MS |
1573 | /* STMY r1, r3, d2(b2) --- store multiple (long-displacement |
1574 | version). */ | |
3fc46200 UW |
1575 | /* STMG r1, r3, d2(b2) --- store multiple (64-bit version). */ |
1576 | else if (is_rs (insn32, op_stm, &r1, &r3, &d2, &b2) | |
1577 | || is_rsy (insn32, op1_stmy, op2_stmy, &r1, &r3, &d2, &b2) | |
1578 | || is_rsy (insn64, op1_stmg, op2_stmg, &r1, &r3, &d2, &b2)) | |
34201ae3 UW |
1579 | { |
1580 | for (; r1 <= r3; r1++, d2 += data->gpr_size) | |
3fc46200 | 1581 | s390_store (data, d2, 0, b2, data->gpr_size, data->gpr[r1]); |
34201ae3 | 1582 | } |
4bc8c588 | 1583 | |
3fc46200 UW |
1584 | /* AHI r1, i2 --- add halfword immediate. */ |
1585 | /* AGHI r1, i2 --- add halfword immediate (64-bit version). */ | |
1586 | /* AFI r1, i2 --- add fullword immediate. */ | |
1587 | /* AGFI r1, i2 --- add fullword immediate (64-bit version). */ | |
1588 | else if (is_ri (insn32, op1_ahi, op2_ahi, &r1, &i2) | |
1589 | || is_ri (insn64, op1_aghi, op2_aghi, &r1, &i2) | |
1590 | || is_ril (insn32, op1_afi, op2_afi, &r1, &i2) | |
1591 | || is_ril (insn64, op1_agfi, op2_agfi, &r1, &i2)) | |
1592 | data->gpr[r1] = pv_add_constant (data->gpr[r1], i2); | |
1593 | ||
1594 | /* ALFI r1, i2 --- add logical immediate. */ | |
1595 | /* ALGFI r1, i2 --- add logical immediate (64-bit version). */ | |
1596 | else if (is_ril (insn32, op1_alfi, op2_alfi, &r1, &i2) | |
1597 | || is_ril (insn64, op1_algfi, op2_algfi, &r1, &i2)) | |
1598 | data->gpr[r1] = pv_add_constant (data->gpr[r1], | |
1599 | (CORE_ADDR)i2 & 0xffffffff); | |
1600 | ||
1601 | /* AR r1, r2 -- add register. */ | |
1602 | /* AGR r1, r2 -- add register (64-bit version). */ | |
1603 | else if (is_rr (insn32, op_ar, &r1, &r2) | |
1604 | || is_rre (insn64, op_agr, &r1, &r2)) | |
1605 | data->gpr[r1] = pv_add (data->gpr[r1], data->gpr[r2]); | |
1606 | ||
1607 | /* A r1, d2(x2, b2) -- add. */ | |
1608 | /* AY r1, d2(x2, b2) -- add (long-displacement version). */ | |
1609 | /* AG r1, d2(x2, b2) -- add (64-bit version). */ | |
1610 | else if (is_rx (insn32, op_a, &r1, &d2, &x2, &b2) | |
1611 | || is_rxy (insn32, op1_ay, op2_ay, &r1, &d2, &x2, &b2) | |
1612 | || is_rxy (insn64, op1_ag, op2_ag, &r1, &d2, &x2, &b2)) | |
1613 | data->gpr[r1] = pv_add (data->gpr[r1], | |
1614 | s390_load (data, d2, x2, b2, data->gpr_size)); | |
1615 | ||
1616 | /* SLFI r1, i2 --- subtract logical immediate. */ | |
1617 | /* SLGFI r1, i2 --- subtract logical immediate (64-bit version). */ | |
1618 | else if (is_ril (insn32, op1_slfi, op2_slfi, &r1, &i2) | |
1619 | || is_ril (insn64, op1_slgfi, op2_slgfi, &r1, &i2)) | |
1620 | data->gpr[r1] = pv_add_constant (data->gpr[r1], | |
1621 | -((CORE_ADDR)i2 & 0xffffffff)); | |
1622 | ||
1623 | /* SR r1, r2 -- subtract register. */ | |
1624 | /* SGR r1, r2 -- subtract register (64-bit version). */ | |
1625 | else if (is_rr (insn32, op_sr, &r1, &r2) | |
1626 | || is_rre (insn64, op_sgr, &r1, &r2)) | |
1627 | data->gpr[r1] = pv_subtract (data->gpr[r1], data->gpr[r2]); | |
1628 | ||
1629 | /* S r1, d2(x2, b2) -- subtract. */ | |
1630 | /* SY r1, d2(x2, b2) -- subtract (long-displacement version). */ | |
1631 | /* SG r1, d2(x2, b2) -- subtract (64-bit version). */ | |
1632 | else if (is_rx (insn32, op_s, &r1, &d2, &x2, &b2) | |
1633 | || is_rxy (insn32, op1_sy, op2_sy, &r1, &d2, &x2, &b2) | |
1634 | || is_rxy (insn64, op1_sg, op2_sg, &r1, &d2, &x2, &b2)) | |
1635 | data->gpr[r1] = pv_subtract (data->gpr[r1], | |
1636 | s390_load (data, d2, x2, b2, data->gpr_size)); | |
1637 | ||
1638 | /* LA r1, d2(x2, b2) --- load address. */ | |
1639 | /* LAY r1, d2(x2, b2) --- load address (long-displacement version). */ | |
1640 | else if (is_rx (insn, op_la, &r1, &d2, &x2, &b2) | |
34201ae3 | 1641 | || is_rxy (insn, op1_lay, op2_lay, &r1, &d2, &x2, &b2)) |
3fc46200 UW |
1642 | data->gpr[r1] = s390_addr (data, d2, x2, b2); |
1643 | ||
1644 | /* LARL r1, i2 --- load address relative long. */ | |
a8c99f38 | 1645 | else if (is_ril (insn, op1_larl, op2_larl, &r1, &i2)) |
3fc46200 | 1646 | data->gpr[r1] = pv_constant (pc + i2 * 2); |
a8c99f38 | 1647 | |
3fc46200 | 1648 | /* BASR r1, 0 --- branch and save. |
34201ae3 | 1649 | Since r2 is zero, this saves the PC in r1, but doesn't branch. */ |
a8c99f38 | 1650 | else if (is_rr (insn, op_basr, &r1, &r2) |
34201ae3 | 1651 | && r2 == 0) |
3fc46200 | 1652 | data->gpr[r1] = pv_constant (next_pc); |
a8c99f38 | 1653 | |
3fc46200 | 1654 | /* BRAS r1, i2 --- branch relative and save. */ |
a8c99f38 | 1655 | else if (is_ri (insn, op1_bras, op2_bras, &r1, &i2)) |
34201ae3 UW |
1656 | { |
1657 | data->gpr[r1] = pv_constant (next_pc); | |
1658 | next_pc = pc + i2 * 2; | |
4bc8c588 | 1659 | |
34201ae3 UW |
1660 | /* We'd better not interpret any backward branches. We'll |
1661 | never terminate. */ | |
1662 | if (next_pc <= pc) | |
1663 | break; | |
1664 | } | |
4bc8c588 | 1665 | |
bc0e3f49 AA |
1666 | /* BRC/BRCL -- branch relative on condition. Ignore "branch |
1667 | never", branch to following instruction, and "conditional | |
1668 | trap" (BRC +2). Otherwise terminate search. */ | |
1669 | else if (is_ri (insn, op1_brc, op2_brc, &r1, &i2)) | |
1670 | { | |
1671 | if (r1 != 0 && i2 != 1 && i2 != 2) | |
1672 | break; | |
1673 | } | |
1674 | else if (is_ril (insn, op1_brcl, op2_brcl, &r1, &i2)) | |
1675 | { | |
1676 | if (r1 != 0 && i2 != 3) | |
1677 | break; | |
1678 | } | |
1679 | ||
a8c99f38 JB |
1680 | /* Terminate search when hitting any other branch instruction. */ |
1681 | else if (is_rr (insn, op_basr, &r1, &r2) | |
1682 | || is_rx (insn, op_bas, &r1, &d2, &x2, &b2) | |
1683 | || is_rr (insn, op_bcr, &r1, &r2) | |
1684 | || is_rx (insn, op_bc, &r1, &d2, &x2, &b2) | |
a8c99f38 JB |
1685 | || is_ril (insn, op1_brasl, op2_brasl, &r2, &i2)) |
1686 | break; | |
1687 | ||
4bc8c588 | 1688 | else |
d4fb63e1 TT |
1689 | { |
1690 | /* An instruction we don't know how to simulate. The only | |
1691 | safe thing to do would be to set every value we're tracking | |
1692 | to 'unknown'. Instead, we'll be optimistic: we assume that | |
1693 | we *can* interpret every instruction that the compiler uses | |
1694 | to manipulate any of the data we're interested in here -- | |
1695 | then we can just ignore anything else. */ | |
1696 | } | |
4bc8c588 JB |
1697 | |
1698 | /* Record the address after the last instruction that changed | |
34201ae3 UW |
1699 | the FP, SP, or backlink. Ignore instructions that changed |
1700 | them back to their original values --- those are probably | |
1701 | restore instructions. (The back chain is never restored, | |
1702 | just popped.) */ | |
4bc8c588 | 1703 | { |
34201ae3 UW |
1704 | pv_t sp = data->gpr[S390_SP_REGNUM - S390_R0_REGNUM]; |
1705 | pv_t fp = data->gpr[S390_FRAME_REGNUM - S390_R0_REGNUM]; | |
1706 | ||
1707 | if ((! pv_is_identical (pre_insn_sp, sp) | |
1708 | && ! pv_is_register_k (sp, S390_SP_REGNUM, 0) | |
3fc46200 | 1709 | && sp.kind != pvk_unknown) |
34201ae3 UW |
1710 | || (! pv_is_identical (pre_insn_fp, fp) |
1711 | && ! pv_is_register_k (fp, S390_FRAME_REGNUM, 0) | |
3fc46200 | 1712 | && fp.kind != pvk_unknown) |
34201ae3 UW |
1713 | || pre_insn_back_chain_saved_p != data->back_chain_saved_p) |
1714 | result = next_pc; | |
4bc8c588 | 1715 | } |
5769d3cd | 1716 | } |
4bc8c588 | 1717 | |
ee1b3323 UW |
1718 | /* Record where all the registers were saved. */ |
1719 | pv_area_scan (data->stack, s390_check_for_saved, data); | |
1720 | ||
1721 | free_pv_area (data->stack); | |
1722 | data->stack = NULL; | |
1723 | ||
4bc8c588 | 1724 | return result; |
5769d3cd AC |
1725 | } |
1726 | ||
34201ae3 | 1727 | /* Advance PC across any function entry prologue instructions to reach |
a8c99f38 JB |
1728 | some "real" code. */ |
1729 | static CORE_ADDR | |
6093d2eb | 1730 | s390_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) |
a8c99f38 JB |
1731 | { |
1732 | struct s390_prologue_data data; | |
f054145e AA |
1733 | CORE_ADDR skip_pc, func_addr; |
1734 | ||
1735 | if (find_pc_partial_function (pc, NULL, &func_addr, NULL)) | |
1736 | { | |
1737 | CORE_ADDR post_prologue_pc | |
1738 | = skip_prologue_using_sal (gdbarch, func_addr); | |
1739 | if (post_prologue_pc != 0) | |
325fac50 | 1740 | return std::max (pc, post_prologue_pc); |
f054145e AA |
1741 | } |
1742 | ||
6093d2eb | 1743 | skip_pc = s390_analyze_prologue (gdbarch, pc, (CORE_ADDR)-1, &data); |
a8c99f38 JB |
1744 | return skip_pc ? skip_pc : pc; |
1745 | } | |
1746 | ||
c9cf6e20 | 1747 | /* Implmement the stack_frame_destroyed_p gdbarch method. */ |
d0f54f9d | 1748 | static int |
c9cf6e20 | 1749 | s390_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc) |
d0f54f9d JB |
1750 | { |
1751 | int word_size = gdbarch_ptr_bit (gdbarch) / 8; | |
1752 | ||
1753 | /* In frameless functions, there's not frame to destroy and thus | |
1754 | we don't care about the epilogue. | |
1755 | ||
1756 | In functions with frame, the epilogue sequence is a pair of | |
1757 | a LM-type instruction that restores (amongst others) the | |
1758 | return register %r14 and the stack pointer %r15, followed | |
1759 | by a branch 'br %r14' --or equivalent-- that effects the | |
1760 | actual return. | |
1761 | ||
1762 | In that situation, this function needs to return 'true' in | |
1763 | exactly one case: when pc points to that branch instruction. | |
1764 | ||
1765 | Thus we try to disassemble the one instructions immediately | |
177b42fe | 1766 | preceding pc and check whether it is an LM-type instruction |
d0f54f9d JB |
1767 | modifying the stack pointer. |
1768 | ||
1769 | Note that disassembling backwards is not reliable, so there | |
1770 | is a slight chance of false positives here ... */ | |
1771 | ||
1772 | bfd_byte insn[6]; | |
1773 | unsigned int r1, r3, b2; | |
1774 | int d2; | |
1775 | ||
1776 | if (word_size == 4 | |
8defab1a | 1777 | && !target_read_memory (pc - 4, insn, 4) |
d0f54f9d JB |
1778 | && is_rs (insn, op_lm, &r1, &r3, &d2, &b2) |
1779 | && r3 == S390_SP_REGNUM - S390_R0_REGNUM) | |
1780 | return 1; | |
1781 | ||
a8c99f38 | 1782 | if (word_size == 4 |
8defab1a | 1783 | && !target_read_memory (pc - 6, insn, 6) |
a8c99f38 JB |
1784 | && is_rsy (insn, op1_lmy, op2_lmy, &r1, &r3, &d2, &b2) |
1785 | && r3 == S390_SP_REGNUM - S390_R0_REGNUM) | |
1786 | return 1; | |
1787 | ||
d0f54f9d | 1788 | if (word_size == 8 |
8defab1a | 1789 | && !target_read_memory (pc - 6, insn, 6) |
a8c99f38 | 1790 | && is_rsy (insn, op1_lmg, op2_lmg, &r1, &r3, &d2, &b2) |
d0f54f9d JB |
1791 | && r3 == S390_SP_REGNUM - S390_R0_REGNUM) |
1792 | return 1; | |
1793 | ||
1794 | return 0; | |
1795 | } | |
5769d3cd | 1796 | |
1db4e8a0 UW |
1797 | /* Displaced stepping. */ |
1798 | ||
5ac21343 PA |
1799 | /* Return true if INSN is a non-branch RIL-b or RIL-c format |
1800 | instruction. */ | |
1801 | ||
1802 | static int | |
1803 | is_non_branch_ril (gdb_byte *insn) | |
1804 | { | |
1805 | gdb_byte op1 = insn[0]; | |
1806 | ||
1807 | if (op1 == 0xc4) | |
1808 | { | |
1809 | gdb_byte op2 = insn[1] & 0x0f; | |
1810 | ||
1811 | switch (op2) | |
1812 | { | |
1813 | case 0x02: /* llhrl */ | |
1814 | case 0x04: /* lghrl */ | |
1815 | case 0x05: /* lhrl */ | |
1816 | case 0x06: /* llghrl */ | |
1817 | case 0x07: /* sthrl */ | |
1818 | case 0x08: /* lgrl */ | |
1819 | case 0x0b: /* stgrl */ | |
1820 | case 0x0c: /* lgfrl */ | |
1821 | case 0x0d: /* lrl */ | |
1822 | case 0x0e: /* llgfrl */ | |
1823 | case 0x0f: /* strl */ | |
1824 | return 1; | |
1825 | } | |
1826 | } | |
1827 | else if (op1 == 0xc6) | |
1828 | { | |
1829 | gdb_byte op2 = insn[1] & 0x0f; | |
1830 | ||
1831 | switch (op2) | |
1832 | { | |
1833 | case 0x00: /* exrl */ | |
1834 | case 0x02: /* pfdrl */ | |
1835 | case 0x04: /* cghrl */ | |
1836 | case 0x05: /* chrl */ | |
1837 | case 0x06: /* clghrl */ | |
1838 | case 0x07: /* clhrl */ | |
1839 | case 0x08: /* cgrl */ | |
1840 | case 0x0a: /* clgrl */ | |
1841 | case 0x0c: /* cgfrl */ | |
1842 | case 0x0d: /* crl */ | |
1843 | case 0x0e: /* clgfrl */ | |
1844 | case 0x0f: /* clrl */ | |
1845 | return 1; | |
1846 | } | |
1847 | } | |
1848 | ||
1849 | return 0; | |
1850 | } | |
1851 | ||
1852 | /* Implementation of gdbarch_displaced_step_copy_insn. */ | |
1853 | ||
1854 | static struct displaced_step_closure * | |
1855 | s390_displaced_step_copy_insn (struct gdbarch *gdbarch, | |
1856 | CORE_ADDR from, CORE_ADDR to, | |
1857 | struct regcache *regs) | |
1858 | { | |
1859 | size_t len = gdbarch_max_insn_length (gdbarch); | |
224c3ddb | 1860 | gdb_byte *buf = (gdb_byte *) xmalloc (len); |
5ac21343 PA |
1861 | struct cleanup *old_chain = make_cleanup (xfree, buf); |
1862 | ||
1863 | read_memory (from, buf, len); | |
1864 | ||
1865 | /* Adjust the displacement field of PC-relative RIL instructions, | |
1866 | except branches. The latter are handled in the fixup hook. */ | |
1867 | if (is_non_branch_ril (buf)) | |
1868 | { | |
1869 | LONGEST offset; | |
1870 | ||
1871 | offset = extract_signed_integer (buf + 2, 4, BFD_ENDIAN_BIG); | |
1872 | offset = (from - to + offset * 2) / 2; | |
1873 | ||
1874 | /* If the instruction is too far from the jump pad, punt. This | |
1875 | will usually happen with instructions in shared libraries. | |
1876 | We could probably support these by rewriting them to be | |
1877 | absolute or fully emulating them. */ | |
1878 | if (offset < INT32_MIN || offset > INT32_MAX) | |
1879 | { | |
1880 | /* Let the core fall back to stepping over the breakpoint | |
1881 | in-line. */ | |
1882 | if (debug_displaced) | |
1883 | { | |
1884 | fprintf_unfiltered (gdb_stdlog, | |
1885 | "displaced: can't displaced step " | |
1886 | "RIL instruction: offset %s out of range\n", | |
1887 | plongest (offset)); | |
1888 | } | |
1889 | do_cleanups (old_chain); | |
1890 | return NULL; | |
1891 | } | |
1892 | ||
1893 | store_signed_integer (buf + 2, 4, BFD_ENDIAN_BIG, offset); | |
1894 | } | |
1895 | ||
1896 | write_memory (to, buf, len); | |
1897 | ||
1898 | if (debug_displaced) | |
1899 | { | |
1900 | fprintf_unfiltered (gdb_stdlog, "displaced: copy %s->%s: ", | |
1901 | paddress (gdbarch, from), paddress (gdbarch, to)); | |
1902 | displaced_step_dump_bytes (gdb_stdlog, buf, len); | |
1903 | } | |
1904 | ||
1905 | discard_cleanups (old_chain); | |
1906 | return (struct displaced_step_closure *) buf; | |
1907 | } | |
1908 | ||
1db4e8a0 UW |
1909 | /* Fix up the state of registers and memory after having single-stepped |
1910 | a displaced instruction. */ | |
1911 | static void | |
1912 | s390_displaced_step_fixup (struct gdbarch *gdbarch, | |
1913 | struct displaced_step_closure *closure, | |
1914 | CORE_ADDR from, CORE_ADDR to, | |
1915 | struct regcache *regs) | |
1916 | { | |
5ac21343 | 1917 | /* Our closure is a copy of the instruction. */ |
1db4e8a0 UW |
1918 | gdb_byte *insn = (gdb_byte *) closure; |
1919 | static int s390_instrlen[] = { 2, 4, 4, 6 }; | |
1920 | int insnlen = s390_instrlen[insn[0] >> 6]; | |
1921 | ||
1922 | /* Fields for various kinds of instructions. */ | |
1923 | unsigned int b2, r1, r2, x2, r3; | |
1924 | int i2, d2; | |
1925 | ||
1926 | /* Get current PC and addressing mode bit. */ | |
1927 | CORE_ADDR pc = regcache_read_pc (regs); | |
beaabab2 | 1928 | ULONGEST amode = 0; |
1db4e8a0 UW |
1929 | |
1930 | if (register_size (gdbarch, S390_PSWA_REGNUM) == 4) | |
1931 | { | |
1932 | regcache_cooked_read_unsigned (regs, S390_PSWA_REGNUM, &amode); | |
1933 | amode &= 0x80000000; | |
1934 | } | |
1935 | ||
1936 | if (debug_displaced) | |
1937 | fprintf_unfiltered (gdb_stdlog, | |
0161e4b9 | 1938 | "displaced: (s390) fixup (%s, %s) pc %s len %d amode 0x%x\n", |
1db4e8a0 | 1939 | paddress (gdbarch, from), paddress (gdbarch, to), |
0161e4b9 | 1940 | paddress (gdbarch, pc), insnlen, (int) amode); |
1db4e8a0 UW |
1941 | |
1942 | /* Handle absolute branch and save instructions. */ | |
1943 | if (is_rr (insn, op_basr, &r1, &r2) | |
1944 | || is_rx (insn, op_bas, &r1, &d2, &x2, &b2)) | |
1945 | { | |
1946 | /* Recompute saved return address in R1. */ | |
1947 | regcache_cooked_write_unsigned (regs, S390_R0_REGNUM + r1, | |
1948 | amode | (from + insnlen)); | |
1949 | } | |
1950 | ||
1951 | /* Handle absolute branch instructions. */ | |
1952 | else if (is_rr (insn, op_bcr, &r1, &r2) | |
1953 | || is_rx (insn, op_bc, &r1, &d2, &x2, &b2) | |
1954 | || is_rr (insn, op_bctr, &r1, &r2) | |
1955 | || is_rre (insn, op_bctgr, &r1, &r2) | |
1956 | || is_rx (insn, op_bct, &r1, &d2, &x2, &b2) | |
1957 | || is_rxy (insn, op1_bctg, op2_brctg, &r1, &d2, &x2, &b2) | |
1958 | || is_rs (insn, op_bxh, &r1, &r3, &d2, &b2) | |
1959 | || is_rsy (insn, op1_bxhg, op2_bxhg, &r1, &r3, &d2, &b2) | |
1960 | || is_rs (insn, op_bxle, &r1, &r3, &d2, &b2) | |
1961 | || is_rsy (insn, op1_bxleg, op2_bxleg, &r1, &r3, &d2, &b2)) | |
1962 | { | |
1963 | /* Update PC iff branch was *not* taken. */ | |
1964 | if (pc == to + insnlen) | |
1965 | regcache_write_pc (regs, from + insnlen); | |
1966 | } | |
1967 | ||
1968 | /* Handle PC-relative branch and save instructions. */ | |
1969 | else if (is_ri (insn, op1_bras, op2_bras, &r1, &i2) | |
34201ae3 | 1970 | || is_ril (insn, op1_brasl, op2_brasl, &r1, &i2)) |
1db4e8a0 UW |
1971 | { |
1972 | /* Update PC. */ | |
1973 | regcache_write_pc (regs, pc - to + from); | |
1974 | /* Recompute saved return address in R1. */ | |
1975 | regcache_cooked_write_unsigned (regs, S390_R0_REGNUM + r1, | |
1976 | amode | (from + insnlen)); | |
1977 | } | |
1978 | ||
1979 | /* Handle PC-relative branch instructions. */ | |
1980 | else if (is_ri (insn, op1_brc, op2_brc, &r1, &i2) | |
1981 | || is_ril (insn, op1_brcl, op2_brcl, &r1, &i2) | |
1982 | || is_ri (insn, op1_brct, op2_brct, &r1, &i2) | |
1983 | || is_ri (insn, op1_brctg, op2_brctg, &r1, &i2) | |
1984 | || is_rsi (insn, op_brxh, &r1, &r3, &i2) | |
1985 | || is_rie (insn, op1_brxhg, op2_brxhg, &r1, &r3, &i2) | |
1986 | || is_rsi (insn, op_brxle, &r1, &r3, &i2) | |
1987 | || is_rie (insn, op1_brxlg, op2_brxlg, &r1, &r3, &i2)) | |
1988 | { | |
1989 | /* Update PC. */ | |
1990 | regcache_write_pc (regs, pc - to + from); | |
1991 | } | |
1992 | ||
1993 | /* Handle LOAD ADDRESS RELATIVE LONG. */ | |
1994 | else if (is_ril (insn, op1_larl, op2_larl, &r1, &i2)) | |
1995 | { | |
0161e4b9 UW |
1996 | /* Update PC. */ |
1997 | regcache_write_pc (regs, from + insnlen); | |
34201ae3 | 1998 | /* Recompute output address in R1. */ |
1db4e8a0 | 1999 | regcache_cooked_write_unsigned (regs, S390_R0_REGNUM + r1, |
0161e4b9 | 2000 | amode | (from + i2 * 2)); |
1db4e8a0 UW |
2001 | } |
2002 | ||
2003 | /* If we executed a breakpoint instruction, point PC right back at it. */ | |
2004 | else if (insn[0] == 0x0 && insn[1] == 0x1) | |
2005 | regcache_write_pc (regs, from); | |
2006 | ||
2007 | /* For any other insn, PC points right after the original instruction. */ | |
2008 | else | |
2009 | regcache_write_pc (regs, from + insnlen); | |
0161e4b9 UW |
2010 | |
2011 | if (debug_displaced) | |
2012 | fprintf_unfiltered (gdb_stdlog, | |
2013 | "displaced: (s390) pc is now %s\n", | |
2014 | paddress (gdbarch, regcache_read_pc (regs))); | |
1db4e8a0 | 2015 | } |
a8c99f38 | 2016 | |
d6db1fab UW |
2017 | |
2018 | /* Helper routine to unwind pseudo registers. */ | |
2019 | ||
2020 | static struct value * | |
2021 | s390_unwind_pseudo_register (struct frame_info *this_frame, int regnum) | |
2022 | { | |
2023 | struct gdbarch *gdbarch = get_frame_arch (this_frame); | |
2024 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | |
2025 | struct type *type = register_type (gdbarch, regnum); | |
2026 | ||
2027 | /* Unwind PC via PSW address. */ | |
2028 | if (regnum == tdep->pc_regnum) | |
2029 | { | |
2030 | struct value *val; | |
2031 | ||
2032 | val = frame_unwind_register_value (this_frame, S390_PSWA_REGNUM); | |
2033 | if (!value_optimized_out (val)) | |
2034 | { | |
2035 | LONGEST pswa = value_as_long (val); | |
2036 | ||
2037 | if (TYPE_LENGTH (type) == 4) | |
2038 | return value_from_pointer (type, pswa & 0x7fffffff); | |
2039 | else | |
2040 | return value_from_pointer (type, pswa); | |
2041 | } | |
2042 | } | |
2043 | ||
2044 | /* Unwind CC via PSW mask. */ | |
2045 | if (regnum == tdep->cc_regnum) | |
2046 | { | |
2047 | struct value *val; | |
2048 | ||
2049 | val = frame_unwind_register_value (this_frame, S390_PSWM_REGNUM); | |
2050 | if (!value_optimized_out (val)) | |
2051 | { | |
2052 | LONGEST pswm = value_as_long (val); | |
2053 | ||
2054 | if (TYPE_LENGTH (type) == 4) | |
2055 | return value_from_longest (type, (pswm >> 12) & 3); | |
2056 | else | |
2057 | return value_from_longest (type, (pswm >> 44) & 3); | |
2058 | } | |
2059 | } | |
2060 | ||
2061 | /* Unwind full GPRs to show at least the lower halves (as the | |
2062 | upper halves are undefined). */ | |
2ccd1468 | 2063 | if (regnum_is_gpr_full (tdep, regnum)) |
d6db1fab UW |
2064 | { |
2065 | int reg = regnum - tdep->gpr_full_regnum; | |
2066 | struct value *val; | |
2067 | ||
2068 | val = frame_unwind_register_value (this_frame, S390_R0_REGNUM + reg); | |
2069 | if (!value_optimized_out (val)) | |
2070 | return value_cast (type, val); | |
2071 | } | |
2072 | ||
2073 | return allocate_optimized_out_value (type); | |
2074 | } | |
2075 | ||
2076 | static struct value * | |
2077 | s390_trad_frame_prev_register (struct frame_info *this_frame, | |
2078 | struct trad_frame_saved_reg saved_regs[], | |
2079 | int regnum) | |
2080 | { | |
2081 | if (regnum < S390_NUM_REGS) | |
2082 | return trad_frame_get_prev_register (this_frame, saved_regs, regnum); | |
2083 | else | |
2084 | return s390_unwind_pseudo_register (this_frame, regnum); | |
2085 | } | |
2086 | ||
2087 | ||
a8c99f38 JB |
2088 | /* Normal stack frames. */ |
2089 | ||
2090 | struct s390_unwind_cache { | |
2091 | ||
2092 | CORE_ADDR func; | |
2093 | CORE_ADDR frame_base; | |
2094 | CORE_ADDR local_base; | |
2095 | ||
2096 | struct trad_frame_saved_reg *saved_regs; | |
2097 | }; | |
2098 | ||
a78f21af | 2099 | static int |
f089c433 | 2100 | s390_prologue_frame_unwind_cache (struct frame_info *this_frame, |
a8c99f38 | 2101 | struct s390_unwind_cache *info) |
5769d3cd | 2102 | { |
f089c433 | 2103 | struct gdbarch *gdbarch = get_frame_arch (this_frame); |
a8c99f38 JB |
2104 | int word_size = gdbarch_ptr_bit (gdbarch) / 8; |
2105 | struct s390_prologue_data data; | |
3fc46200 UW |
2106 | pv_t *fp = &data.gpr[S390_FRAME_REGNUM - S390_R0_REGNUM]; |
2107 | pv_t *sp = &data.gpr[S390_SP_REGNUM - S390_R0_REGNUM]; | |
121d8485 UW |
2108 | int i; |
2109 | CORE_ADDR cfa; | |
a8c99f38 JB |
2110 | CORE_ADDR func; |
2111 | CORE_ADDR result; | |
2112 | ULONGEST reg; | |
2113 | CORE_ADDR prev_sp; | |
2114 | int frame_pointer; | |
2115 | int size; | |
edb3359d | 2116 | struct frame_info *next_frame; |
a8c99f38 JB |
2117 | |
2118 | /* Try to find the function start address. If we can't find it, we don't | |
2119 | bother searching for it -- with modern compilers this would be mostly | |
2120 | pointless anyway. Trust that we'll either have valid DWARF-2 CFI data | |
2121 | or else a valid backchain ... */ | |
6d53bec8 AA |
2122 | if (!get_frame_func_if_available (this_frame, &info->func)) |
2123 | { | |
2124 | info->func = -1; | |
2125 | return 0; | |
2126 | } | |
2127 | func = info->func; | |
5769d3cd | 2128 | |
a8c99f38 JB |
2129 | /* Try to analyze the prologue. */ |
2130 | result = s390_analyze_prologue (gdbarch, func, | |
f089c433 | 2131 | get_frame_pc (this_frame), &data); |
a8c99f38 | 2132 | if (!result) |
5769d3cd | 2133 | return 0; |
5769d3cd | 2134 | |
a8c99f38 | 2135 | /* If this was successful, we should have found the instruction that |
34201ae3 | 2136 | sets the stack pointer register to the previous value of the stack |
a8c99f38 | 2137 | pointer minus the frame size. */ |
3fc46200 | 2138 | if (!pv_is_register (*sp, S390_SP_REGNUM)) |
5769d3cd | 2139 | return 0; |
a8c99f38 | 2140 | |
34201ae3 | 2141 | /* A frame size of zero at this point can mean either a real |
a8c99f38 | 2142 | frameless function, or else a failure to find the prologue. |
34201ae3 | 2143 | Perform some sanity checks to verify we really have a |
a8c99f38 JB |
2144 | frameless function. */ |
2145 | if (sp->k == 0) | |
5769d3cd | 2146 | { |
34201ae3 UW |
2147 | /* If the next frame is a NORMAL_FRAME, this frame *cannot* have frame |
2148 | size zero. This is only possible if the next frame is a sentinel | |
a8c99f38 | 2149 | frame, a dummy frame, or a signal trampoline frame. */ |
0e100dab AC |
2150 | /* FIXME: cagney/2004-05-01: This sanity check shouldn't be |
2151 | needed, instead the code should simpliy rely on its | |
2152 | analysis. */ | |
edb3359d DJ |
2153 | next_frame = get_next_frame (this_frame); |
2154 | while (next_frame && get_frame_type (next_frame) == INLINE_FRAME) | |
2155 | next_frame = get_next_frame (next_frame); | |
2156 | if (next_frame | |
f089c433 | 2157 | && get_frame_type (get_next_frame (this_frame)) == NORMAL_FRAME) |
5769d3cd | 2158 | return 0; |
5769d3cd | 2159 | |
a8c99f38 JB |
2160 | /* If we really have a frameless function, %r14 must be valid |
2161 | -- in particular, it must point to a different function. */ | |
f089c433 | 2162 | reg = get_frame_register_unsigned (this_frame, S390_RETADDR_REGNUM); |
a8c99f38 JB |
2163 | reg = gdbarch_addr_bits_remove (gdbarch, reg) - 1; |
2164 | if (get_pc_function_start (reg) == func) | |
5769d3cd | 2165 | { |
a8c99f38 JB |
2166 | /* However, there is one case where it *is* valid for %r14 |
2167 | to point to the same function -- if this is a recursive | |
2168 | call, and we have stopped in the prologue *before* the | |
2169 | stack frame was allocated. | |
2170 | ||
2171 | Recognize this case by looking ahead a bit ... */ | |
5769d3cd | 2172 | |
a8c99f38 | 2173 | struct s390_prologue_data data2; |
3fc46200 | 2174 | pv_t *sp = &data2.gpr[S390_SP_REGNUM - S390_R0_REGNUM]; |
a8c99f38 JB |
2175 | |
2176 | if (!(s390_analyze_prologue (gdbarch, func, (CORE_ADDR)-1, &data2) | |
34201ae3 UW |
2177 | && pv_is_register (*sp, S390_SP_REGNUM) |
2178 | && sp->k != 0)) | |
a8c99f38 | 2179 | return 0; |
5769d3cd | 2180 | } |
5769d3cd | 2181 | } |
5769d3cd AC |
2182 | |
2183 | ||
a8c99f38 JB |
2184 | /* OK, we've found valid prologue data. */ |
2185 | size = -sp->k; | |
5769d3cd | 2186 | |
a8c99f38 JB |
2187 | /* If the frame pointer originally also holds the same value |
2188 | as the stack pointer, we're probably using it. If it holds | |
2189 | some other value -- even a constant offset -- it is most | |
2190 | likely used as temp register. */ | |
3fc46200 | 2191 | if (pv_is_identical (*sp, *fp)) |
a8c99f38 JB |
2192 | frame_pointer = S390_FRAME_REGNUM; |
2193 | else | |
2194 | frame_pointer = S390_SP_REGNUM; | |
2195 | ||
34201ae3 UW |
2196 | /* If we've detected a function with stack frame, we'll still have to |
2197 | treat it as frameless if we're currently within the function epilog | |
c378eb4e | 2198 | code at a point where the frame pointer has already been restored. |
a8c99f38 | 2199 | This can only happen in an innermost frame. */ |
0e100dab AC |
2200 | /* FIXME: cagney/2004-05-01: This sanity check shouldn't be needed, |
2201 | instead the code should simpliy rely on its analysis. */ | |
edb3359d DJ |
2202 | next_frame = get_next_frame (this_frame); |
2203 | while (next_frame && get_frame_type (next_frame) == INLINE_FRAME) | |
2204 | next_frame = get_next_frame (next_frame); | |
f089c433 | 2205 | if (size > 0 |
edb3359d | 2206 | && (next_frame == NULL |
f089c433 | 2207 | || get_frame_type (get_next_frame (this_frame)) != NORMAL_FRAME)) |
5769d3cd | 2208 | { |
c9cf6e20 | 2209 | /* See the comment in s390_stack_frame_destroyed_p on why this is |
a8c99f38 | 2210 | not completely reliable ... */ |
c9cf6e20 | 2211 | if (s390_stack_frame_destroyed_p (gdbarch, get_frame_pc (this_frame))) |
5769d3cd | 2212 | { |
a8c99f38 JB |
2213 | memset (&data, 0, sizeof (data)); |
2214 | size = 0; | |
2215 | frame_pointer = S390_SP_REGNUM; | |
5769d3cd | 2216 | } |
5769d3cd | 2217 | } |
5769d3cd | 2218 | |
a8c99f38 JB |
2219 | /* Once we know the frame register and the frame size, we can unwind |
2220 | the current value of the frame register from the next frame, and | |
34201ae3 | 2221 | add back the frame size to arrive that the previous frame's |
a8c99f38 | 2222 | stack pointer value. */ |
f089c433 | 2223 | prev_sp = get_frame_register_unsigned (this_frame, frame_pointer) + size; |
121d8485 | 2224 | cfa = prev_sp + 16*word_size + 32; |
5769d3cd | 2225 | |
7803799a UW |
2226 | /* Set up ABI call-saved/call-clobbered registers. */ |
2227 | for (i = 0; i < S390_NUM_REGS; i++) | |
2228 | if (!s390_register_call_saved (gdbarch, i)) | |
2229 | trad_frame_set_unknown (info->saved_regs, i); | |
2230 | ||
2231 | /* CC is always call-clobbered. */ | |
d6db1fab | 2232 | trad_frame_set_unknown (info->saved_regs, S390_PSWM_REGNUM); |
7803799a | 2233 | |
121d8485 UW |
2234 | /* Record the addresses of all register spill slots the prologue parser |
2235 | has recognized. Consider only registers defined as call-saved by the | |
2236 | ABI; for call-clobbered registers the parser may have recognized | |
2237 | spurious stores. */ | |
5769d3cd | 2238 | |
7803799a UW |
2239 | for (i = 0; i < 16; i++) |
2240 | if (s390_register_call_saved (gdbarch, S390_R0_REGNUM + i) | |
2241 | && data.gpr_slot[i] != 0) | |
121d8485 | 2242 | info->saved_regs[S390_R0_REGNUM + i].addr = cfa - data.gpr_slot[i]; |
a8c99f38 | 2243 | |
7803799a UW |
2244 | for (i = 0; i < 16; i++) |
2245 | if (s390_register_call_saved (gdbarch, S390_F0_REGNUM + i) | |
2246 | && data.fpr_slot[i] != 0) | |
2247 | info->saved_regs[S390_F0_REGNUM + i].addr = cfa - data.fpr_slot[i]; | |
a8c99f38 JB |
2248 | |
2249 | /* Function return will set PC to %r14. */ | |
d6db1fab | 2250 | info->saved_regs[S390_PSWA_REGNUM] = info->saved_regs[S390_RETADDR_REGNUM]; |
a8c99f38 JB |
2251 | |
2252 | /* In frameless functions, we unwind simply by moving the return | |
2253 | address to the PC. However, if we actually stored to the | |
2254 | save area, use that -- we might only think the function frameless | |
2255 | because we're in the middle of the prologue ... */ | |
2256 | if (size == 0 | |
d6db1fab | 2257 | && !trad_frame_addr_p (info->saved_regs, S390_PSWA_REGNUM)) |
a8c99f38 | 2258 | { |
d6db1fab | 2259 | info->saved_regs[S390_PSWA_REGNUM].realreg = S390_RETADDR_REGNUM; |
5769d3cd | 2260 | } |
a8c99f38 JB |
2261 | |
2262 | /* Another sanity check: unless this is a frameless function, | |
2263 | we should have found spill slots for SP and PC. | |
2264 | If not, we cannot unwind further -- this happens e.g. in | |
2265 | libc's thread_start routine. */ | |
2266 | if (size > 0) | |
5769d3cd | 2267 | { |
a8c99f38 | 2268 | if (!trad_frame_addr_p (info->saved_regs, S390_SP_REGNUM) |
d6db1fab | 2269 | || !trad_frame_addr_p (info->saved_regs, S390_PSWA_REGNUM)) |
a8c99f38 | 2270 | prev_sp = -1; |
5769d3cd | 2271 | } |
a8c99f38 JB |
2272 | |
2273 | /* We use the current value of the frame register as local_base, | |
2274 | and the top of the register save area as frame_base. */ | |
2275 | if (prev_sp != -1) | |
2276 | { | |
2277 | info->frame_base = prev_sp + 16*word_size + 32; | |
2278 | info->local_base = prev_sp - size; | |
2279 | } | |
2280 | ||
a8c99f38 | 2281 | return 1; |
5769d3cd AC |
2282 | } |
2283 | ||
a78f21af | 2284 | static void |
f089c433 | 2285 | s390_backchain_frame_unwind_cache (struct frame_info *this_frame, |
a8c99f38 | 2286 | struct s390_unwind_cache *info) |
5769d3cd | 2287 | { |
f089c433 | 2288 | struct gdbarch *gdbarch = get_frame_arch (this_frame); |
a8c99f38 | 2289 | int word_size = gdbarch_ptr_bit (gdbarch) / 8; |
e17a4113 | 2290 | enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); |
a8c99f38 JB |
2291 | CORE_ADDR backchain; |
2292 | ULONGEST reg; | |
f2489477 | 2293 | LONGEST sp, tmp; |
7803799a UW |
2294 | int i; |
2295 | ||
2296 | /* Set up ABI call-saved/call-clobbered registers. */ | |
2297 | for (i = 0; i < S390_NUM_REGS; i++) | |
2298 | if (!s390_register_call_saved (gdbarch, i)) | |
2299 | trad_frame_set_unknown (info->saved_regs, i); | |
2300 | ||
2301 | /* CC is always call-clobbered. */ | |
d6db1fab | 2302 | trad_frame_set_unknown (info->saved_regs, S390_PSWM_REGNUM); |
a8c99f38 JB |
2303 | |
2304 | /* Get the backchain. */ | |
f089c433 | 2305 | reg = get_frame_register_unsigned (this_frame, S390_SP_REGNUM); |
f2489477 AA |
2306 | if (!safe_read_memory_integer (reg, word_size, byte_order, &tmp)) |
2307 | tmp = 0; | |
2308 | backchain = (CORE_ADDR) tmp; | |
a8c99f38 JB |
2309 | |
2310 | /* A zero backchain terminates the frame chain. As additional | |
2311 | sanity check, let's verify that the spill slot for SP in the | |
2312 | save area pointed to by the backchain in fact links back to | |
2313 | the save area. */ | |
2314 | if (backchain != 0 | |
e17a4113 UW |
2315 | && safe_read_memory_integer (backchain + 15*word_size, |
2316 | word_size, byte_order, &sp) | |
a8c99f38 JB |
2317 | && (CORE_ADDR)sp == backchain) |
2318 | { | |
2319 | /* We don't know which registers were saved, but it will have | |
34201ae3 UW |
2320 | to be at least %r14 and %r15. This will allow us to continue |
2321 | unwinding, but other prev-frame registers may be incorrect ... */ | |
a8c99f38 JB |
2322 | info->saved_regs[S390_SP_REGNUM].addr = backchain + 15*word_size; |
2323 | info->saved_regs[S390_RETADDR_REGNUM].addr = backchain + 14*word_size; | |
2324 | ||
2325 | /* Function return will set PC to %r14. */ | |
d6db1fab | 2326 | info->saved_regs[S390_PSWA_REGNUM] |
7803799a | 2327 | = info->saved_regs[S390_RETADDR_REGNUM]; |
a8c99f38 JB |
2328 | |
2329 | /* We use the current value of the frame register as local_base, | |
34201ae3 | 2330 | and the top of the register save area as frame_base. */ |
a8c99f38 JB |
2331 | info->frame_base = backchain + 16*word_size + 32; |
2332 | info->local_base = reg; | |
2333 | } | |
2334 | ||
f089c433 | 2335 | info->func = get_frame_pc (this_frame); |
5769d3cd AC |
2336 | } |
2337 | ||
a8c99f38 | 2338 | static struct s390_unwind_cache * |
f089c433 | 2339 | s390_frame_unwind_cache (struct frame_info *this_frame, |
a8c99f38 JB |
2340 | void **this_prologue_cache) |
2341 | { | |
2342 | struct s390_unwind_cache *info; | |
62261490 | 2343 | |
a8c99f38 | 2344 | if (*this_prologue_cache) |
19ba03f4 | 2345 | return (struct s390_unwind_cache *) *this_prologue_cache; |
a8c99f38 JB |
2346 | |
2347 | info = FRAME_OBSTACK_ZALLOC (struct s390_unwind_cache); | |
2348 | *this_prologue_cache = info; | |
f089c433 | 2349 | info->saved_regs = trad_frame_alloc_saved_regs (this_frame); |
a8c99f38 JB |
2350 | info->func = -1; |
2351 | info->frame_base = -1; | |
2352 | info->local_base = -1; | |
2353 | ||
492d29ea | 2354 | TRY |
62261490 PA |
2355 | { |
2356 | /* Try to use prologue analysis to fill the unwind cache. | |
2357 | If this fails, fall back to reading the stack backchain. */ | |
2358 | if (!s390_prologue_frame_unwind_cache (this_frame, info)) | |
2359 | s390_backchain_frame_unwind_cache (this_frame, info); | |
2360 | } | |
492d29ea | 2361 | CATCH (ex, RETURN_MASK_ERROR) |
7556d4a4 PA |
2362 | { |
2363 | if (ex.error != NOT_AVAILABLE_ERROR) | |
2364 | throw_exception (ex); | |
2365 | } | |
492d29ea | 2366 | END_CATCH |
a8c99f38 JB |
2367 | |
2368 | return info; | |
2369 | } | |
5769d3cd | 2370 | |
a78f21af | 2371 | static void |
f089c433 | 2372 | s390_frame_this_id (struct frame_info *this_frame, |
a8c99f38 JB |
2373 | void **this_prologue_cache, |
2374 | struct frame_id *this_id) | |
5769d3cd | 2375 | { |
a8c99f38 | 2376 | struct s390_unwind_cache *info |
f089c433 | 2377 | = s390_frame_unwind_cache (this_frame, this_prologue_cache); |
5769d3cd | 2378 | |
a8c99f38 | 2379 | if (info->frame_base == -1) |
6d53bec8 AA |
2380 | { |
2381 | if (info->func != -1) | |
2382 | *this_id = frame_id_build_unavailable_stack (info->func); | |
2383 | return; | |
2384 | } | |
5769d3cd | 2385 | |
a8c99f38 | 2386 | *this_id = frame_id_build (info->frame_base, info->func); |
5769d3cd AC |
2387 | } |
2388 | ||
f089c433 UW |
2389 | static struct value * |
2390 | s390_frame_prev_register (struct frame_info *this_frame, | |
2391 | void **this_prologue_cache, int regnum) | |
a8c99f38 JB |
2392 | { |
2393 | struct s390_unwind_cache *info | |
f089c433 | 2394 | = s390_frame_unwind_cache (this_frame, this_prologue_cache); |
7803799a | 2395 | |
d6db1fab | 2396 | return s390_trad_frame_prev_register (this_frame, info->saved_regs, regnum); |
a8c99f38 JB |
2397 | } |
2398 | ||
2399 | static const struct frame_unwind s390_frame_unwind = { | |
2400 | NORMAL_FRAME, | |
8fbca658 | 2401 | default_frame_unwind_stop_reason, |
a8c99f38 | 2402 | s390_frame_this_id, |
f089c433 UW |
2403 | s390_frame_prev_register, |
2404 | NULL, | |
2405 | default_frame_sniffer | |
a8c99f38 JB |
2406 | }; |
2407 | ||
5769d3cd | 2408 | |
8e645ae7 AC |
2409 | /* Code stubs and their stack frames. For things like PLTs and NULL |
2410 | function calls (where there is no true frame and the return address | |
2411 | is in the RETADDR register). */ | |
a8c99f38 | 2412 | |
8e645ae7 AC |
2413 | struct s390_stub_unwind_cache |
2414 | { | |
a8c99f38 JB |
2415 | CORE_ADDR frame_base; |
2416 | struct trad_frame_saved_reg *saved_regs; | |
2417 | }; | |
2418 | ||
8e645ae7 | 2419 | static struct s390_stub_unwind_cache * |
f089c433 | 2420 | s390_stub_frame_unwind_cache (struct frame_info *this_frame, |
8e645ae7 | 2421 | void **this_prologue_cache) |
5769d3cd | 2422 | { |
f089c433 | 2423 | struct gdbarch *gdbarch = get_frame_arch (this_frame); |
a8c99f38 | 2424 | int word_size = gdbarch_ptr_bit (gdbarch) / 8; |
8e645ae7 | 2425 | struct s390_stub_unwind_cache *info; |
a8c99f38 | 2426 | ULONGEST reg; |
5c3cf190 | 2427 | |
a8c99f38 | 2428 | if (*this_prologue_cache) |
19ba03f4 | 2429 | return (struct s390_stub_unwind_cache *) *this_prologue_cache; |
5c3cf190 | 2430 | |
8e645ae7 | 2431 | info = FRAME_OBSTACK_ZALLOC (struct s390_stub_unwind_cache); |
a8c99f38 | 2432 | *this_prologue_cache = info; |
f089c433 | 2433 | info->saved_regs = trad_frame_alloc_saved_regs (this_frame); |
a8c99f38 JB |
2434 | |
2435 | /* The return address is in register %r14. */ | |
d6db1fab | 2436 | info->saved_regs[S390_PSWA_REGNUM].realreg = S390_RETADDR_REGNUM; |
a8c99f38 JB |
2437 | |
2438 | /* Retrieve stack pointer and determine our frame base. */ | |
f089c433 | 2439 | reg = get_frame_register_unsigned (this_frame, S390_SP_REGNUM); |
a8c99f38 JB |
2440 | info->frame_base = reg + 16*word_size + 32; |
2441 | ||
2442 | return info; | |
5769d3cd AC |
2443 | } |
2444 | ||
a8c99f38 | 2445 | static void |
f089c433 | 2446 | s390_stub_frame_this_id (struct frame_info *this_frame, |
8e645ae7 AC |
2447 | void **this_prologue_cache, |
2448 | struct frame_id *this_id) | |
5769d3cd | 2449 | { |
8e645ae7 | 2450 | struct s390_stub_unwind_cache *info |
f089c433 UW |
2451 | = s390_stub_frame_unwind_cache (this_frame, this_prologue_cache); |
2452 | *this_id = frame_id_build (info->frame_base, get_frame_pc (this_frame)); | |
a8c99f38 | 2453 | } |
5769d3cd | 2454 | |
f089c433 UW |
2455 | static struct value * |
2456 | s390_stub_frame_prev_register (struct frame_info *this_frame, | |
2457 | void **this_prologue_cache, int regnum) | |
8e645ae7 AC |
2458 | { |
2459 | struct s390_stub_unwind_cache *info | |
f089c433 | 2460 | = s390_stub_frame_unwind_cache (this_frame, this_prologue_cache); |
d6db1fab | 2461 | return s390_trad_frame_prev_register (this_frame, info->saved_regs, regnum); |
a8c99f38 JB |
2462 | } |
2463 | ||
f089c433 UW |
2464 | static int |
2465 | s390_stub_frame_sniffer (const struct frame_unwind *self, | |
2466 | struct frame_info *this_frame, | |
2467 | void **this_prologue_cache) | |
a8c99f38 | 2468 | { |
93d42b30 | 2469 | CORE_ADDR addr_in_block; |
8e645ae7 AC |
2470 | bfd_byte insn[S390_MAX_INSTR_SIZE]; |
2471 | ||
2472 | /* If the current PC points to non-readable memory, we assume we | |
2473 | have trapped due to an invalid function pointer call. We handle | |
2474 | the non-existing current function like a PLT stub. */ | |
f089c433 | 2475 | addr_in_block = get_frame_address_in_block (this_frame); |
3e5d3a5a | 2476 | if (in_plt_section (addr_in_block) |
f089c433 UW |
2477 | || s390_readinstruction (insn, get_frame_pc (this_frame)) < 0) |
2478 | return 1; | |
2479 | return 0; | |
a8c99f38 | 2480 | } |
5769d3cd | 2481 | |
f089c433 UW |
2482 | static const struct frame_unwind s390_stub_frame_unwind = { |
2483 | NORMAL_FRAME, | |
8fbca658 | 2484 | default_frame_unwind_stop_reason, |
f089c433 UW |
2485 | s390_stub_frame_this_id, |
2486 | s390_stub_frame_prev_register, | |
2487 | NULL, | |
2488 | s390_stub_frame_sniffer | |
2489 | }; | |
2490 | ||
5769d3cd | 2491 | |
a8c99f38 | 2492 | /* Signal trampoline stack frames. */ |
5769d3cd | 2493 | |
a8c99f38 JB |
2494 | struct s390_sigtramp_unwind_cache { |
2495 | CORE_ADDR frame_base; | |
2496 | struct trad_frame_saved_reg *saved_regs; | |
2497 | }; | |
5769d3cd | 2498 | |
a8c99f38 | 2499 | static struct s390_sigtramp_unwind_cache * |
f089c433 | 2500 | s390_sigtramp_frame_unwind_cache (struct frame_info *this_frame, |
a8c99f38 | 2501 | void **this_prologue_cache) |
5769d3cd | 2502 | { |
f089c433 | 2503 | struct gdbarch *gdbarch = get_frame_arch (this_frame); |
7803799a | 2504 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); |
a8c99f38 | 2505 | int word_size = gdbarch_ptr_bit (gdbarch) / 8; |
e17a4113 | 2506 | enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); |
a8c99f38 JB |
2507 | struct s390_sigtramp_unwind_cache *info; |
2508 | ULONGEST this_sp, prev_sp; | |
7803799a | 2509 | CORE_ADDR next_ra, next_cfa, sigreg_ptr, sigreg_high_off; |
a8c99f38 JB |
2510 | int i; |
2511 | ||
2512 | if (*this_prologue_cache) | |
19ba03f4 | 2513 | return (struct s390_sigtramp_unwind_cache *) *this_prologue_cache; |
5769d3cd | 2514 | |
a8c99f38 JB |
2515 | info = FRAME_OBSTACK_ZALLOC (struct s390_sigtramp_unwind_cache); |
2516 | *this_prologue_cache = info; | |
f089c433 | 2517 | info->saved_regs = trad_frame_alloc_saved_regs (this_frame); |
a8c99f38 | 2518 | |
f089c433 UW |
2519 | this_sp = get_frame_register_unsigned (this_frame, S390_SP_REGNUM); |
2520 | next_ra = get_frame_pc (this_frame); | |
a8c99f38 JB |
2521 | next_cfa = this_sp + 16*word_size + 32; |
2522 | ||
2523 | /* New-style RT frame: | |
2524 | retcode + alignment (8 bytes) | |
2525 | siginfo (128 bytes) | |
c378eb4e | 2526 | ucontext (contains sigregs at offset 5 words). */ |
a8c99f38 JB |
2527 | if (next_ra == next_cfa) |
2528 | { | |
f0f63663 | 2529 | sigreg_ptr = next_cfa + 8 + 128 + align_up (5*word_size, 8); |
7803799a UW |
2530 | /* sigregs are followed by uc_sigmask (8 bytes), then by the |
2531 | upper GPR halves if present. */ | |
2532 | sigreg_high_off = 8; | |
a8c99f38 JB |
2533 | } |
2534 | ||
2535 | /* Old-style RT frame and all non-RT frames: | |
2536 | old signal mask (8 bytes) | |
c378eb4e | 2537 | pointer to sigregs. */ |
5769d3cd AC |
2538 | else |
2539 | { | |
e17a4113 UW |
2540 | sigreg_ptr = read_memory_unsigned_integer (next_cfa + 8, |
2541 | word_size, byte_order); | |
7803799a UW |
2542 | /* sigregs are followed by signo (4 bytes), then by the |
2543 | upper GPR halves if present. */ | |
2544 | sigreg_high_off = 4; | |
a8c99f38 | 2545 | } |
5769d3cd | 2546 | |
a8c99f38 | 2547 | /* The sigregs structure looks like this: |
34201ae3 UW |
2548 | long psw_mask; |
2549 | long psw_addr; | |
2550 | long gprs[16]; | |
2551 | int acrs[16]; | |
2552 | int fpc; | |
2553 | int __pad; | |
2554 | double fprs[16]; */ | |
5769d3cd | 2555 | |
7803799a UW |
2556 | /* PSW mask and address. */ |
2557 | info->saved_regs[S390_PSWM_REGNUM].addr = sigreg_ptr; | |
a8c99f38 | 2558 | sigreg_ptr += word_size; |
7803799a | 2559 | info->saved_regs[S390_PSWA_REGNUM].addr = sigreg_ptr; |
a8c99f38 JB |
2560 | sigreg_ptr += word_size; |
2561 | ||
2562 | /* Then the GPRs. */ | |
2563 | for (i = 0; i < 16; i++) | |
2564 | { | |
2565 | info->saved_regs[S390_R0_REGNUM + i].addr = sigreg_ptr; | |
2566 | sigreg_ptr += word_size; | |
2567 | } | |
2568 | ||
2569 | /* Then the ACRs. */ | |
2570 | for (i = 0; i < 16; i++) | |
2571 | { | |
2572 | info->saved_regs[S390_A0_REGNUM + i].addr = sigreg_ptr; | |
2573 | sigreg_ptr += 4; | |
5769d3cd | 2574 | } |
5769d3cd | 2575 | |
a8c99f38 JB |
2576 | /* The floating-point control word. */ |
2577 | info->saved_regs[S390_FPC_REGNUM].addr = sigreg_ptr; | |
2578 | sigreg_ptr += 8; | |
5769d3cd | 2579 | |
a8c99f38 JB |
2580 | /* And finally the FPRs. */ |
2581 | for (i = 0; i < 16; i++) | |
2582 | { | |
2583 | info->saved_regs[S390_F0_REGNUM + i].addr = sigreg_ptr; | |
2584 | sigreg_ptr += 8; | |
2585 | } | |
2586 | ||
7803799a UW |
2587 | /* If we have them, the GPR upper halves are appended at the end. */ |
2588 | sigreg_ptr += sigreg_high_off; | |
2589 | if (tdep->gpr_full_regnum != -1) | |
2590 | for (i = 0; i < 16; i++) | |
2591 | { | |
34201ae3 | 2592 | info->saved_regs[S390_R0_UPPER_REGNUM + i].addr = sigreg_ptr; |
7803799a UW |
2593 | sigreg_ptr += 4; |
2594 | } | |
2595 | ||
a8c99f38 JB |
2596 | /* Restore the previous frame's SP. */ |
2597 | prev_sp = read_memory_unsigned_integer ( | |
2598 | info->saved_regs[S390_SP_REGNUM].addr, | |
e17a4113 | 2599 | word_size, byte_order); |
5769d3cd | 2600 | |
a8c99f38 JB |
2601 | /* Determine our frame base. */ |
2602 | info->frame_base = prev_sp + 16*word_size + 32; | |
5769d3cd | 2603 | |
a8c99f38 | 2604 | return info; |
5769d3cd AC |
2605 | } |
2606 | ||
a8c99f38 | 2607 | static void |
f089c433 | 2608 | s390_sigtramp_frame_this_id (struct frame_info *this_frame, |
a8c99f38 JB |
2609 | void **this_prologue_cache, |
2610 | struct frame_id *this_id) | |
5769d3cd | 2611 | { |
a8c99f38 | 2612 | struct s390_sigtramp_unwind_cache *info |
f089c433 UW |
2613 | = s390_sigtramp_frame_unwind_cache (this_frame, this_prologue_cache); |
2614 | *this_id = frame_id_build (info->frame_base, get_frame_pc (this_frame)); | |
5769d3cd AC |
2615 | } |
2616 | ||
f089c433 UW |
2617 | static struct value * |
2618 | s390_sigtramp_frame_prev_register (struct frame_info *this_frame, | |
2619 | void **this_prologue_cache, int regnum) | |
a8c99f38 JB |
2620 | { |
2621 | struct s390_sigtramp_unwind_cache *info | |
f089c433 | 2622 | = s390_sigtramp_frame_unwind_cache (this_frame, this_prologue_cache); |
d6db1fab | 2623 | return s390_trad_frame_prev_register (this_frame, info->saved_regs, regnum); |
a8c99f38 JB |
2624 | } |
2625 | ||
f089c433 UW |
2626 | static int |
2627 | s390_sigtramp_frame_sniffer (const struct frame_unwind *self, | |
2628 | struct frame_info *this_frame, | |
2629 | void **this_prologue_cache) | |
5769d3cd | 2630 | { |
f089c433 | 2631 | CORE_ADDR pc = get_frame_pc (this_frame); |
a8c99f38 | 2632 | bfd_byte sigreturn[2]; |
4c8287ac | 2633 | |
8defab1a | 2634 | if (target_read_memory (pc, sigreturn, 2)) |
f089c433 | 2635 | return 0; |
4c8287ac | 2636 | |
237b092b | 2637 | if (sigreturn[0] != op_svc) |
f089c433 | 2638 | return 0; |
5769d3cd | 2639 | |
a8c99f38 JB |
2640 | if (sigreturn[1] != 119 /* sigreturn */ |
2641 | && sigreturn[1] != 173 /* rt_sigreturn */) | |
f089c433 | 2642 | return 0; |
34201ae3 | 2643 | |
f089c433 | 2644 | return 1; |
5769d3cd AC |
2645 | } |
2646 | ||
f089c433 UW |
2647 | static const struct frame_unwind s390_sigtramp_frame_unwind = { |
2648 | SIGTRAMP_FRAME, | |
8fbca658 | 2649 | default_frame_unwind_stop_reason, |
f089c433 UW |
2650 | s390_sigtramp_frame_this_id, |
2651 | s390_sigtramp_frame_prev_register, | |
2652 | NULL, | |
2653 | s390_sigtramp_frame_sniffer | |
2654 | }; | |
2655 | ||
237b092b AA |
2656 | /* Retrieve the syscall number at a ptrace syscall-stop. Return -1 |
2657 | upon error. */ | |
2658 | ||
2659 | static LONGEST | |
2660 | s390_linux_get_syscall_number (struct gdbarch *gdbarch, | |
2661 | ptid_t ptid) | |
2662 | { | |
2663 | struct regcache *regs = get_thread_regcache (ptid); | |
2664 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | |
2665 | enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); | |
2666 | ULONGEST pc; | |
2667 | ULONGEST svc_number = -1; | |
2668 | unsigned opcode; | |
2669 | ||
2670 | /* Assume that the PC points after the 2-byte SVC instruction. We | |
2671 | don't currently support SVC via EXECUTE. */ | |
2672 | regcache_cooked_read_unsigned (regs, tdep->pc_regnum, &pc); | |
2673 | pc -= 2; | |
2674 | opcode = read_memory_unsigned_integer ((CORE_ADDR) pc, 1, byte_order); | |
2675 | if (opcode != op_svc) | |
2676 | return -1; | |
2677 | ||
2678 | svc_number = read_memory_unsigned_integer ((CORE_ADDR) pc + 1, 1, | |
2679 | byte_order); | |
2680 | if (svc_number == 0) | |
2681 | regcache_cooked_read_unsigned (regs, S390_R1_REGNUM, &svc_number); | |
2682 | ||
2683 | return svc_number; | |
2684 | } | |
2685 | ||
566c56c9 MK |
2686 | /* Process record-replay */ |
2687 | ||
2688 | static struct linux_record_tdep s390_linux_record_tdep; | |
2689 | static struct linux_record_tdep s390x_linux_record_tdep; | |
2690 | ||
2691 | /* Record all registers but PC register for process-record. */ | |
2692 | ||
2693 | static int | |
2694 | s390_all_but_pc_registers_record (struct regcache *regcache) | |
2695 | { | |
2696 | struct gdbarch *gdbarch = get_regcache_arch (regcache); | |
2697 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | |
2698 | int i; | |
2699 | ||
2700 | for (i = 0; i < 16; i++) | |
2701 | { | |
2702 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + i)) | |
2703 | return -1; | |
2704 | if (record_full_arch_list_add_reg (regcache, S390_A0_REGNUM + i)) | |
2705 | return -1; | |
2706 | if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + i)) | |
2707 | return -1; | |
2708 | if (tdep->gpr_full_regnum != -1) | |
2709 | if (record_full_arch_list_add_reg (regcache, S390_R0_UPPER_REGNUM + i)) | |
2710 | return -1; | |
2711 | if (tdep->v0_full_regnum != -1) | |
2712 | { | |
2713 | if (record_full_arch_list_add_reg (regcache, S390_V0_LOWER_REGNUM + i)) | |
2714 | return -1; | |
2715 | if (record_full_arch_list_add_reg (regcache, S390_V16_REGNUM + i)) | |
2716 | return -1; | |
2717 | } | |
2718 | } | |
2719 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
2720 | return -1; | |
2721 | if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM)) | |
2722 | return -1; | |
2723 | ||
2724 | return 0; | |
2725 | } | |
2726 | ||
2727 | static enum gdb_syscall | |
2728 | s390_canonicalize_syscall (int syscall, enum s390_abi_kind abi) | |
2729 | { | |
2730 | switch (syscall) | |
2731 | { | |
2732 | /* s390 syscall numbers < 222 are mostly the same as x86, so just list | |
2733 | the exceptions. */ | |
2734 | case 0: | |
2735 | return gdb_sys_no_syscall; | |
2736 | case 7: | |
2737 | return gdb_sys_restart_syscall; | |
2738 | /* These syscalls work only on 31-bit. */ | |
2739 | case 13: /* time */ | |
2740 | case 16: /* lchown[16] */ | |
2741 | case 23: /* setuid[16] */ | |
2742 | case 24: /* getuid[16] */ | |
2743 | case 25: /* stime */ | |
2744 | case 46: /* setgid[16] */ | |
2745 | case 47: /* getgid[16] */ | |
2746 | case 49: /* seteuid[16] */ | |
2747 | case 50: /* getegid[16] */ | |
2748 | case 70: /* setreuid[16] */ | |
2749 | case 71: /* setregid[16] */ | |
2750 | case 76: /* [old_]getrlimit */ | |
2751 | case 80: /* getgroups[16] */ | |
2752 | case 81: /* setgroups[16] */ | |
2753 | case 95: /* fchown[16] */ | |
2754 | case 101: /* ioperm */ | |
2755 | case 138: /* setfsuid[16] */ | |
2756 | case 139: /* setfsgid[16] */ | |
2757 | case 140: /* _llseek */ | |
2758 | case 164: /* setresuid[16] */ | |
2759 | case 165: /* getresuid[16] */ | |
2760 | case 170: /* setresgid[16] */ | |
2761 | case 171: /* getresgid[16] */ | |
2762 | case 182: /* chown[16] */ | |
2763 | case 192: /* mmap2 */ | |
2764 | case 193: /* truncate64 */ | |
2765 | case 194: /* ftruncate64 */ | |
2766 | case 195: /* stat64 */ | |
2767 | case 196: /* lstat64 */ | |
2768 | case 197: /* fstat64 */ | |
2769 | case 221: /* fcntl64 */ | |
2770 | if (abi == ABI_LINUX_S390) | |
4d193179 | 2771 | return (enum gdb_syscall) syscall; |
566c56c9 MK |
2772 | return gdb_sys_no_syscall; |
2773 | /* These syscalls don't exist on s390. */ | |
2774 | case 17: /* break */ | |
2775 | case 18: /* oldstat */ | |
2776 | case 28: /* oldfstat */ | |
2777 | case 31: /* stty */ | |
2778 | case 32: /* gtty */ | |
2779 | case 35: /* ftime */ | |
2780 | case 44: /* prof */ | |
2781 | case 53: /* lock */ | |
2782 | case 56: /* mpx */ | |
2783 | case 58: /* ulimit */ | |
2784 | case 59: /* oldolduname */ | |
2785 | case 68: /* sgetmask */ | |
2786 | case 69: /* ssetmask */ | |
2787 | case 82: /* [old_]select */ | |
2788 | case 84: /* oldlstat */ | |
2789 | case 98: /* profil */ | |
2790 | case 109: /* olduname */ | |
2791 | case 113: /* vm86old */ | |
2792 | case 123: /* modify_ldt */ | |
2793 | case 166: /* vm86 */ | |
2794 | return gdb_sys_no_syscall; | |
2795 | case 110: | |
2796 | return gdb_sys_lookup_dcookie; | |
2797 | /* Here come the differences. */ | |
2798 | case 222: | |
2799 | return gdb_sys_readahead; | |
2800 | case 223: | |
2801 | if (abi == ABI_LINUX_S390) | |
2802 | return gdb_sys_sendfile64; | |
2803 | return gdb_sys_no_syscall; | |
2804 | /* 224-235 handled below */ | |
2805 | case 236: | |
2806 | return gdb_sys_gettid; | |
2807 | case 237: | |
2808 | return gdb_sys_tkill; | |
2809 | case 238: | |
2810 | return gdb_sys_futex; | |
2811 | case 239: | |
2812 | return gdb_sys_sched_setaffinity; | |
2813 | case 240: | |
2814 | return gdb_sys_sched_getaffinity; | |
2815 | case 241: | |
2816 | return gdb_sys_tgkill; | |
2817 | /* 242 reserved */ | |
2818 | case 243: | |
2819 | return gdb_sys_io_setup; | |
2820 | case 244: | |
2821 | return gdb_sys_io_destroy; | |
2822 | case 245: | |
2823 | return gdb_sys_io_getevents; | |
2824 | case 246: | |
2825 | return gdb_sys_io_submit; | |
2826 | case 247: | |
2827 | return gdb_sys_io_cancel; | |
2828 | case 248: | |
2829 | return gdb_sys_exit_group; | |
2830 | case 249: | |
2831 | return gdb_sys_epoll_create; | |
2832 | case 250: | |
2833 | return gdb_sys_epoll_ctl; | |
2834 | case 251: | |
2835 | return gdb_sys_epoll_wait; | |
2836 | case 252: | |
2837 | return gdb_sys_set_tid_address; | |
2838 | case 253: | |
2839 | return gdb_sys_fadvise64; | |
2840 | /* 254-262 handled below */ | |
2841 | /* 263 reserved */ | |
2842 | case 264: | |
2843 | if (abi == ABI_LINUX_S390) | |
2844 | return gdb_sys_fadvise64_64; | |
2845 | return gdb_sys_no_syscall; | |
2846 | case 265: | |
2847 | return gdb_sys_statfs64; | |
2848 | case 266: | |
2849 | return gdb_sys_fstatfs64; | |
2850 | case 267: | |
2851 | return gdb_sys_remap_file_pages; | |
2852 | /* 268-270 reserved */ | |
2853 | /* 271-277 handled below */ | |
2854 | case 278: | |
2855 | return gdb_sys_add_key; | |
2856 | case 279: | |
2857 | return gdb_sys_request_key; | |
2858 | case 280: | |
2859 | return gdb_sys_keyctl; | |
2860 | case 281: | |
2861 | return gdb_sys_waitid; | |
2862 | /* 282-312 handled below */ | |
2863 | case 293: | |
2864 | if (abi == ABI_LINUX_S390) | |
2865 | return gdb_sys_fstatat64; | |
2866 | return gdb_sys_newfstatat; | |
2867 | /* 313+ not yet supported */ | |
2868 | default: | |
4d193179 SM |
2869 | { |
2870 | int ret; | |
2871 | ||
2872 | /* Most "old" syscalls copied from i386. */ | |
2873 | if (syscall <= 221) | |
2874 | ret = syscall; | |
2875 | /* xattr syscalls. */ | |
2876 | else if (syscall >= 224 && syscall <= 235) | |
2877 | ret = syscall + 2; | |
2878 | /* timer syscalls. */ | |
2879 | else if (syscall >= 254 && syscall <= 262) | |
2880 | ret = syscall + 5; | |
2881 | /* mq_* and kexec_load */ | |
2882 | else if (syscall >= 271 && syscall <= 277) | |
2883 | ret = syscall + 6; | |
2884 | /* ioprio_set .. epoll_pwait */ | |
2885 | else if (syscall >= 282 && syscall <= 312) | |
2886 | ret = syscall + 7; | |
2887 | else | |
2888 | ret = gdb_sys_no_syscall; | |
2889 | ||
2890 | return (enum gdb_syscall) ret; | |
2891 | } | |
566c56c9 MK |
2892 | } |
2893 | } | |
2894 | ||
2895 | static int | |
2896 | s390_linux_syscall_record (struct regcache *regcache, LONGEST syscall_native) | |
2897 | { | |
2898 | struct gdbarch *gdbarch = get_regcache_arch (regcache); | |
2899 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | |
2900 | int ret; | |
2901 | enum gdb_syscall syscall_gdb; | |
2902 | ||
2903 | /* On s390, syscall number can be passed either as immediate field of svc | |
2904 | instruction, or in %r1 (with svc 0). */ | |
2905 | if (syscall_native == 0) | |
2906 | regcache_raw_read_signed (regcache, S390_R1_REGNUM, &syscall_native); | |
2907 | ||
2908 | syscall_gdb = s390_canonicalize_syscall (syscall_native, tdep->abi); | |
2909 | ||
2910 | if (syscall_gdb < 0) | |
2911 | { | |
2912 | printf_unfiltered (_("Process record and replay target doesn't " | |
2913 | "support syscall number %s\n"), | |
2914 | plongest (syscall_native)); | |
2915 | return -1; | |
2916 | } | |
2917 | ||
2918 | if (syscall_gdb == gdb_sys_sigreturn | |
2919 | || syscall_gdb == gdb_sys_rt_sigreturn) | |
2920 | { | |
2921 | if (s390_all_but_pc_registers_record (regcache)) | |
2922 | return -1; | |
2923 | return 0; | |
2924 | } | |
2925 | ||
2926 | if (tdep->abi == ABI_LINUX_ZSERIES) | |
2927 | ret = record_linux_system_call (syscall_gdb, regcache, | |
2928 | &s390x_linux_record_tdep); | |
2929 | else | |
2930 | ret = record_linux_system_call (syscall_gdb, regcache, | |
2931 | &s390_linux_record_tdep); | |
2932 | ||
2933 | if (ret) | |
2934 | return ret; | |
2935 | ||
2936 | /* Record the return value of the system call. */ | |
2937 | if (record_full_arch_list_add_reg (regcache, S390_R2_REGNUM)) | |
2938 | return -1; | |
2939 | ||
2940 | return 0; | |
2941 | } | |
2942 | ||
2943 | static int | |
2944 | s390_linux_record_signal (struct gdbarch *gdbarch, struct regcache *regcache, | |
2945 | enum gdb_signal signal) | |
2946 | { | |
2947 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | |
2948 | /* There are two kinds of signal frames on s390. rt_sigframe is always | |
2949 | the larger one, so don't even bother with sigframe. */ | |
2950 | const int sizeof_rt_sigframe = (tdep->abi == ABI_LINUX_ZSERIES ? | |
2951 | 160 + 8 + 128 + 1024 : 96 + 8 + 128 + 1000); | |
2952 | ULONGEST sp; | |
2953 | int i; | |
2954 | ||
2955 | for (i = 0; i < 16; i++) | |
2956 | { | |
2957 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + i)) | |
2958 | return -1; | |
2959 | if (tdep->gpr_full_regnum != -1) | |
2960 | if (record_full_arch_list_add_reg (regcache, S390_R0_UPPER_REGNUM + i)) | |
2961 | return -1; | |
2962 | } | |
2963 | if (record_full_arch_list_add_reg (regcache, S390_PSWA_REGNUM)) | |
2964 | return -1; | |
2965 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
2966 | return -1; | |
2967 | ||
2968 | /* Record the change in the stack. | |
2969 | frame-size = sizeof (struct rt_sigframe) + SIGNAL_FRAMESIZE */ | |
2970 | regcache_raw_read_unsigned (regcache, S390_SP_REGNUM, &sp); | |
2971 | sp -= sizeof_rt_sigframe; | |
2972 | ||
2973 | if (record_full_arch_list_add_mem (sp, sizeof_rt_sigframe)) | |
2974 | return -1; | |
2975 | ||
2976 | if (record_full_arch_list_add_end ()) | |
2977 | return -1; | |
2978 | ||
2979 | return 0; | |
2980 | } | |
4c8287ac | 2981 | |
a8c99f38 JB |
2982 | /* Frame base handling. */ |
2983 | ||
2984 | static CORE_ADDR | |
f089c433 | 2985 | s390_frame_base_address (struct frame_info *this_frame, void **this_cache) |
4c8287ac | 2986 | { |
a8c99f38 | 2987 | struct s390_unwind_cache *info |
f089c433 | 2988 | = s390_frame_unwind_cache (this_frame, this_cache); |
a8c99f38 JB |
2989 | return info->frame_base; |
2990 | } | |
2991 | ||
2992 | static CORE_ADDR | |
f089c433 | 2993 | s390_local_base_address (struct frame_info *this_frame, void **this_cache) |
a8c99f38 JB |
2994 | { |
2995 | struct s390_unwind_cache *info | |
f089c433 | 2996 | = s390_frame_unwind_cache (this_frame, this_cache); |
a8c99f38 JB |
2997 | return info->local_base; |
2998 | } | |
2999 | ||
3000 | static const struct frame_base s390_frame_base = { | |
3001 | &s390_frame_unwind, | |
3002 | s390_frame_base_address, | |
3003 | s390_local_base_address, | |
3004 | s390_local_base_address | |
3005 | }; | |
3006 | ||
3007 | static CORE_ADDR | |
3008 | s390_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame) | |
3009 | { | |
7803799a | 3010 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); |
a8c99f38 | 3011 | ULONGEST pc; |
7803799a | 3012 | pc = frame_unwind_register_unsigned (next_frame, tdep->pc_regnum); |
a8c99f38 JB |
3013 | return gdbarch_addr_bits_remove (gdbarch, pc); |
3014 | } | |
3015 | ||
3016 | static CORE_ADDR | |
3017 | s390_unwind_sp (struct gdbarch *gdbarch, struct frame_info *next_frame) | |
3018 | { | |
3019 | ULONGEST sp; | |
3020 | sp = frame_unwind_register_unsigned (next_frame, S390_SP_REGNUM); | |
3021 | return gdbarch_addr_bits_remove (gdbarch, sp); | |
4c8287ac JB |
3022 | } |
3023 | ||
3024 | ||
a431654a AC |
3025 | /* DWARF-2 frame support. */ |
3026 | ||
7803799a UW |
3027 | static struct value * |
3028 | s390_dwarf2_prev_register (struct frame_info *this_frame, void **this_cache, | |
3029 | int regnum) | |
3030 | { | |
d6db1fab | 3031 | return s390_unwind_pseudo_register (this_frame, regnum); |
7803799a UW |
3032 | } |
3033 | ||
a431654a AC |
3034 | static void |
3035 | s390_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum, | |
34201ae3 | 3036 | struct dwarf2_frame_state_reg *reg, |
4a4e5149 | 3037 | struct frame_info *this_frame) |
a431654a | 3038 | { |
d6db1fab UW |
3039 | /* The condition code (and thus PSW mask) is call-clobbered. */ |
3040 | if (regnum == S390_PSWM_REGNUM) | |
3041 | reg->how = DWARF2_FRAME_REG_UNDEFINED; | |
3042 | ||
3043 | /* The PSW address unwinds to the return address. */ | |
3044 | else if (regnum == S390_PSWA_REGNUM) | |
3045 | reg->how = DWARF2_FRAME_REG_RA; | |
3046 | ||
7803799a UW |
3047 | /* Fixed registers are call-saved or call-clobbered |
3048 | depending on the ABI in use. */ | |
d6db1fab | 3049 | else if (regnum < S390_NUM_REGS) |
a431654a | 3050 | { |
7803799a | 3051 | if (s390_register_call_saved (gdbarch, regnum)) |
a431654a | 3052 | reg->how = DWARF2_FRAME_REG_SAME_VALUE; |
7803799a | 3053 | else |
a431654a | 3054 | reg->how = DWARF2_FRAME_REG_UNDEFINED; |
7803799a | 3055 | } |
a431654a | 3056 | |
d6db1fab UW |
3057 | /* We install a special function to unwind pseudos. */ |
3058 | else | |
7803799a UW |
3059 | { |
3060 | reg->how = DWARF2_FRAME_REG_FN; | |
3061 | reg->loc.fn = s390_dwarf2_prev_register; | |
a431654a AC |
3062 | } |
3063 | } | |
3064 | ||
3065 | ||
b0cf273e JB |
3066 | /* Dummy function calls. */ |
3067 | ||
80f75320 AA |
3068 | /* Unwrap any single-field structs in TYPE and return the effective |
3069 | "inner" type. E.g., yield "float" for all these cases: | |
20a940cc | 3070 | |
80f75320 AA |
3071 | float x; |
3072 | struct { float x }; | |
3073 | struct { struct { float x; } x; }; | |
417c80f9 AA |
3074 | struct { struct { struct { float x; } x; } x; }; |
3075 | ||
3076 | However, if an inner type is smaller than MIN_SIZE, abort the | |
3077 | unwrapping. */ | |
20a940cc | 3078 | |
80f75320 | 3079 | static struct type * |
417c80f9 | 3080 | s390_effective_inner_type (struct type *type, unsigned int min_size) |
20a940cc | 3081 | { |
80f75320 AA |
3082 | while (TYPE_CODE (type) == TYPE_CODE_STRUCT |
3083 | && TYPE_NFIELDS (type) == 1) | |
417c80f9 AA |
3084 | { |
3085 | struct type *inner = check_typedef (TYPE_FIELD_TYPE (type, 0)); | |
3086 | ||
3087 | if (TYPE_LENGTH (inner) < min_size) | |
3088 | break; | |
3089 | type = inner; | |
3090 | } | |
3091 | ||
80f75320 | 3092 | return type; |
20a940cc JB |
3093 | } |
3094 | ||
80f75320 AA |
3095 | /* Return non-zero if TYPE should be passed like "float" or |
3096 | "double". */ | |
20a940cc | 3097 | |
20a940cc | 3098 | static int |
80f75320 | 3099 | s390_function_arg_float (struct type *type) |
20a940cc | 3100 | { |
80f75320 AA |
3101 | /* Note that long double as well as complex types are intentionally |
3102 | excluded. */ | |
3103 | if (TYPE_LENGTH (type) > 8) | |
3104 | return 0; | |
20a940cc | 3105 | |
80f75320 AA |
3106 | /* A struct containing just a float or double is passed like a float |
3107 | or double. */ | |
417c80f9 | 3108 | type = s390_effective_inner_type (type, 0); |
20a940cc | 3109 | |
20a940cc | 3110 | return (TYPE_CODE (type) == TYPE_CODE_FLT |
80f75320 | 3111 | || TYPE_CODE (type) == TYPE_CODE_DECFLOAT); |
20a940cc JB |
3112 | } |
3113 | ||
417c80f9 AA |
3114 | /* Return non-zero if TYPE should be passed like a vector. */ |
3115 | ||
3116 | static int | |
3117 | s390_function_arg_vector (struct type *type) | |
3118 | { | |
3119 | if (TYPE_LENGTH (type) > 16) | |
3120 | return 0; | |
3121 | ||
3122 | /* Structs containing just a vector are passed like a vector. */ | |
3123 | type = s390_effective_inner_type (type, TYPE_LENGTH (type)); | |
3124 | ||
3125 | return TYPE_CODE (type) == TYPE_CODE_ARRAY && TYPE_VECTOR (type); | |
3126 | } | |
3127 | ||
6dbc9c04 | 3128 | /* Determine whether N is a power of two. */ |
20a940cc | 3129 | |
78f8b424 | 3130 | static int |
b0cf273e | 3131 | is_power_of_two (unsigned int n) |
78f8b424 | 3132 | { |
6dbc9c04 | 3133 | return n && ((n & (n - 1)) == 0); |
78f8b424 JB |
3134 | } |
3135 | ||
80f75320 | 3136 | /* For an argument whose type is TYPE and which is not passed like a |
417c80f9 AA |
3137 | float or vector, return non-zero if it should be passed like "int" |
3138 | or "long long". */ | |
4d819d0e | 3139 | |
78f8b424 | 3140 | static int |
b0cf273e | 3141 | s390_function_arg_integer (struct type *type) |
78f8b424 | 3142 | { |
80f75320 AA |
3143 | enum type_code code = TYPE_CODE (type); |
3144 | ||
354ecfd5 | 3145 | if (TYPE_LENGTH (type) > 8) |
b0cf273e | 3146 | return 0; |
78f8b424 | 3147 | |
80f75320 AA |
3148 | if (code == TYPE_CODE_INT |
3149 | || code == TYPE_CODE_ENUM | |
3150 | || code == TYPE_CODE_RANGE | |
3151 | || code == TYPE_CODE_CHAR | |
3152 | || code == TYPE_CODE_BOOL | |
3153 | || code == TYPE_CODE_PTR | |
3154 | || code == TYPE_CODE_REF) | |
3155 | return 1; | |
3156 | ||
3157 | return ((code == TYPE_CODE_UNION || code == TYPE_CODE_STRUCT) | |
3158 | && is_power_of_two (TYPE_LENGTH (type))); | |
78f8b424 JB |
3159 | } |
3160 | ||
80f75320 AA |
3161 | /* Argument passing state: Internal data structure passed to helper |
3162 | routines of s390_push_dummy_call. */ | |
78f8b424 | 3163 | |
80f75320 AA |
3164 | struct s390_arg_state |
3165 | { | |
3166 | /* Register cache, or NULL, if we are in "preparation mode". */ | |
3167 | struct regcache *regcache; | |
417c80f9 AA |
3168 | /* Next available general/floating-point/vector register for |
3169 | argument passing. */ | |
3170 | int gr, fr, vr; | |
80f75320 AA |
3171 | /* Current pointer to copy area (grows downwards). */ |
3172 | CORE_ADDR copy; | |
3173 | /* Current pointer to parameter area (grows upwards). */ | |
3174 | CORE_ADDR argp; | |
3175 | }; | |
78f8b424 | 3176 | |
80f75320 AA |
3177 | /* Prepare one argument ARG for a dummy call and update the argument |
3178 | passing state AS accordingly. If the regcache field in AS is set, | |
3179 | operate in "write mode" and write ARG into the inferior. Otherwise | |
3180 | run "preparation mode" and skip all updates to the inferior. */ | |
78f8b424 | 3181 | |
80f75320 AA |
3182 | static void |
3183 | s390_handle_arg (struct s390_arg_state *as, struct value *arg, | |
3184 | struct gdbarch_tdep *tdep, int word_size, | |
417c80f9 | 3185 | enum bfd_endian byte_order, int is_unnamed) |
78f8b424 | 3186 | { |
80f75320 AA |
3187 | struct type *type = check_typedef (value_type (arg)); |
3188 | unsigned int length = TYPE_LENGTH (type); | |
3189 | int write_mode = as->regcache != NULL; | |
78f8b424 | 3190 | |
80f75320 AA |
3191 | if (s390_function_arg_float (type)) |
3192 | { | |
3193 | /* The GNU/Linux for S/390 ABI uses FPRs 0 and 2 to pass | |
3194 | arguments. The GNU/Linux for zSeries ABI uses 0, 2, 4, and | |
3195 | 6. */ | |
3196 | if (as->fr <= (tdep->abi == ABI_LINUX_S390 ? 2 : 6)) | |
3197 | { | |
3198 | /* When we store a single-precision value in an FP register, | |
3199 | it occupies the leftmost bits. */ | |
3200 | if (write_mode) | |
3201 | regcache_cooked_write_part (as->regcache, | |
3202 | S390_F0_REGNUM + as->fr, | |
3203 | 0, length, | |
3204 | value_contents (arg)); | |
3205 | as->fr += 2; | |
3206 | } | |
3207 | else | |
3208 | { | |
3209 | /* When we store a single-precision value in a stack slot, | |
3210 | it occupies the rightmost bits. */ | |
3211 | as->argp = align_up (as->argp + length, word_size); | |
3212 | if (write_mode) | |
3213 | write_memory (as->argp - length, value_contents (arg), | |
3214 | length); | |
3215 | } | |
3216 | } | |
417c80f9 AA |
3217 | else if (tdep->vector_abi == S390_VECTOR_ABI_128 |
3218 | && s390_function_arg_vector (type)) | |
3219 | { | |
3220 | static const char use_vr[] = {24, 26, 28, 30, 25, 27, 29, 31}; | |
3221 | ||
3222 | if (!is_unnamed && as->vr < ARRAY_SIZE (use_vr)) | |
3223 | { | |
3224 | int regnum = S390_V24_REGNUM + use_vr[as->vr] - 24; | |
3225 | ||
3226 | if (write_mode) | |
3227 | regcache_cooked_write_part (as->regcache, regnum, | |
3228 | 0, length, | |
3229 | value_contents (arg)); | |
3230 | as->vr++; | |
3231 | } | |
3232 | else | |
3233 | { | |
3234 | if (write_mode) | |
3235 | write_memory (as->argp, value_contents (arg), length); | |
3236 | as->argp = align_up (as->argp + length, word_size); | |
3237 | } | |
3238 | } | |
80f75320 | 3239 | else if (s390_function_arg_integer (type) && length <= word_size) |
78f8b424 | 3240 | { |
decf8d9a JK |
3241 | /* Initialize it just to avoid a GCC false warning. */ |
3242 | ULONGEST val = 0; | |
78f8b424 | 3243 | |
80f75320 | 3244 | if (write_mode) |
34201ae3 | 3245 | { |
80f75320 AA |
3246 | /* Place value in least significant bits of the register or |
3247 | memory word and sign- or zero-extend to full word size. | |
3248 | This also applies to a struct or union. */ | |
3249 | val = TYPE_UNSIGNED (type) | |
3250 | ? extract_unsigned_integer (value_contents (arg), | |
3251 | length, byte_order) | |
3252 | : extract_signed_integer (value_contents (arg), | |
3253 | length, byte_order); | |
3254 | } | |
78f8b424 | 3255 | |
80f75320 AA |
3256 | if (as->gr <= 6) |
3257 | { | |
3258 | if (write_mode) | |
3259 | regcache_cooked_write_unsigned (as->regcache, | |
3260 | S390_R0_REGNUM + as->gr, | |
3261 | val); | |
3262 | as->gr++; | |
3263 | } | |
3264 | else | |
3265 | { | |
3266 | if (write_mode) | |
3267 | write_memory_unsigned_integer (as->argp, word_size, | |
3268 | byte_order, val); | |
3269 | as->argp += word_size; | |
34201ae3 | 3270 | } |
78f8b424 | 3271 | } |
80f75320 AA |
3272 | else if (s390_function_arg_integer (type) && length == 8) |
3273 | { | |
3274 | if (as->gr <= 5) | |
3275 | { | |
3276 | if (write_mode) | |
3277 | { | |
3278 | regcache_cooked_write (as->regcache, | |
3279 | S390_R0_REGNUM + as->gr, | |
3280 | value_contents (arg)); | |
3281 | regcache_cooked_write (as->regcache, | |
3282 | S390_R0_REGNUM + as->gr + 1, | |
3283 | value_contents (arg) + word_size); | |
3284 | } | |
3285 | as->gr += 2; | |
3286 | } | |
3287 | else | |
3288 | { | |
3289 | /* If we skipped r6 because we couldn't fit a DOUBLE_ARG | |
3290 | in it, then don't go back and use it again later. */ | |
3291 | as->gr = 7; | |
78f8b424 | 3292 | |
80f75320 AA |
3293 | if (write_mode) |
3294 | write_memory (as->argp, value_contents (arg), length); | |
3295 | as->argp += length; | |
3296 | } | |
3297 | } | |
3298 | else | |
3299 | { | |
3300 | /* This argument type is never passed in registers. Place the | |
3301 | value in the copy area and pass a pointer to it. Use 8-byte | |
3302 | alignment as a conservative assumption. */ | |
3303 | as->copy = align_down (as->copy - length, 8); | |
3304 | if (write_mode) | |
3305 | write_memory (as->copy, value_contents (arg), length); | |
3306 | ||
3307 | if (as->gr <= 6) | |
3308 | { | |
3309 | if (write_mode) | |
3310 | regcache_cooked_write_unsigned (as->regcache, | |
3311 | S390_R0_REGNUM + as->gr, | |
3312 | as->copy); | |
3313 | as->gr++; | |
3314 | } | |
3315 | else | |
3316 | { | |
3317 | if (write_mode) | |
3318 | write_memory_unsigned_integer (as->argp, word_size, | |
3319 | byte_order, as->copy); | |
3320 | as->argp += word_size; | |
3321 | } | |
3322 | } | |
78f8b424 JB |
3323 | } |
3324 | ||
78f8b424 | 3325 | /* Put the actual parameter values pointed to by ARGS[0..NARGS-1] in |
ca557f44 AC |
3326 | place to be passed to a function, as specified by the "GNU/Linux |
3327 | for S/390 ELF Application Binary Interface Supplement". | |
78f8b424 JB |
3328 | |
3329 | SP is the current stack pointer. We must put arguments, links, | |
3330 | padding, etc. whereever they belong, and return the new stack | |
3331 | pointer value. | |
34201ae3 | 3332 | |
78f8b424 JB |
3333 | If STRUCT_RETURN is non-zero, then the function we're calling is |
3334 | going to return a structure by value; STRUCT_ADDR is the address of | |
3335 | a block we've allocated for it on the stack. | |
3336 | ||
3337 | Our caller has taken care of any type promotions needed to satisfy | |
3338 | prototypes or the old K&R argument-passing rules. */ | |
80f75320 | 3339 | |
a78f21af | 3340 | static CORE_ADDR |
7d9b040b | 3341 | s390_push_dummy_call (struct gdbarch *gdbarch, struct value *function, |
b0cf273e JB |
3342 | struct regcache *regcache, CORE_ADDR bp_addr, |
3343 | int nargs, struct value **args, CORE_ADDR sp, | |
3344 | int struct_return, CORE_ADDR struct_addr) | |
5769d3cd | 3345 | { |
b0cf273e JB |
3346 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); |
3347 | int word_size = gdbarch_ptr_bit (gdbarch) / 8; | |
e17a4113 | 3348 | enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); |
78f8b424 | 3349 | int i; |
80f75320 AA |
3350 | struct s390_arg_state arg_state, arg_prep; |
3351 | CORE_ADDR param_area_start, new_sp; | |
417c80f9 AA |
3352 | struct type *ftype = check_typedef (value_type (function)); |
3353 | ||
3354 | if (TYPE_CODE (ftype) == TYPE_CODE_PTR) | |
3355 | ftype = check_typedef (TYPE_TARGET_TYPE (ftype)); | |
5769d3cd | 3356 | |
80f75320 AA |
3357 | arg_prep.copy = sp; |
3358 | arg_prep.gr = struct_return ? 3 : 2; | |
3359 | arg_prep.fr = 0; | |
417c80f9 | 3360 | arg_prep.vr = 0; |
80f75320 AA |
3361 | arg_prep.argp = 0; |
3362 | arg_prep.regcache = NULL; | |
5769d3cd | 3363 | |
80f75320 AA |
3364 | /* Initialize arg_state for "preparation mode". */ |
3365 | arg_state = arg_prep; | |
5769d3cd | 3366 | |
80f75320 AA |
3367 | /* Update arg_state.copy with the start of the reference-to-copy area |
3368 | and arg_state.argp with the size of the parameter area. */ | |
3369 | for (i = 0; i < nargs; i++) | |
417c80f9 AA |
3370 | s390_handle_arg (&arg_state, args[i], tdep, word_size, byte_order, |
3371 | TYPE_VARARGS (ftype) && i >= TYPE_NFIELDS (ftype)); | |
78f8b424 | 3372 | |
80f75320 | 3373 | param_area_start = align_down (arg_state.copy - arg_state.argp, 8); |
78f8b424 | 3374 | |
c0cc4c83 | 3375 | /* Allocate the standard frame areas: the register save area, the |
80f75320 AA |
3376 | word reserved for the compiler, and the back chain pointer. */ |
3377 | new_sp = param_area_start - (16 * word_size + 32); | |
3378 | ||
3379 | /* Now we have the final stack pointer. Make sure we didn't | |
3380 | underflow; on 31-bit, this would result in addresses with the | |
3381 | high bit set, which causes confusion elsewhere. Note that if we | |
3382 | error out here, stack and registers remain untouched. */ | |
3383 | if (gdbarch_addr_bits_remove (gdbarch, new_sp) != new_sp) | |
c0cc4c83 UW |
3384 | error (_("Stack overflow")); |
3385 | ||
80f75320 AA |
3386 | /* Pass the structure return address in general register 2. */ |
3387 | if (struct_return) | |
3388 | regcache_cooked_write_unsigned (regcache, S390_R2_REGNUM, struct_addr); | |
c0cc4c83 | 3389 | |
80f75320 AA |
3390 | /* Initialize arg_state for "write mode". */ |
3391 | arg_state = arg_prep; | |
3392 | arg_state.argp = param_area_start; | |
3393 | arg_state.regcache = regcache; | |
78f8b424 | 3394 | |
80f75320 AA |
3395 | /* Write all parameters. */ |
3396 | for (i = 0; i < nargs; i++) | |
417c80f9 AA |
3397 | s390_handle_arg (&arg_state, args[i], tdep, word_size, byte_order, |
3398 | TYPE_VARARGS (ftype) && i >= TYPE_NFIELDS (ftype)); | |
78f8b424 | 3399 | |
8de7d199 UW |
3400 | /* Store return PSWA. In 31-bit mode, keep addressing mode bit. */ |
3401 | if (word_size == 4) | |
3402 | { | |
3403 | ULONGEST pswa; | |
3404 | regcache_cooked_read_unsigned (regcache, S390_PSWA_REGNUM, &pswa); | |
3405 | bp_addr = (bp_addr & 0x7fffffff) | (pswa & 0x80000000); | |
3406 | } | |
b0cf273e | 3407 | regcache_cooked_write_unsigned (regcache, S390_RETADDR_REGNUM, bp_addr); |
8de7d199 | 3408 | |
b0cf273e | 3409 | /* Store updated stack pointer. */ |
80f75320 | 3410 | regcache_cooked_write_unsigned (regcache, S390_SP_REGNUM, new_sp); |
78f8b424 | 3411 | |
a8c99f38 | 3412 | /* We need to return the 'stack part' of the frame ID, |
121d8485 | 3413 | which is actually the top of the register save area. */ |
80f75320 | 3414 | return param_area_start; |
5769d3cd AC |
3415 | } |
3416 | ||
f089c433 | 3417 | /* Assuming THIS_FRAME is a dummy, return the frame ID of that |
b0cf273e JB |
3418 | dummy frame. The frame ID's base needs to match the TOS value |
3419 | returned by push_dummy_call, and the PC match the dummy frame's | |
3420 | breakpoint. */ | |
3421 | static struct frame_id | |
f089c433 | 3422 | s390_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame) |
b0cf273e | 3423 | { |
a8c99f38 | 3424 | int word_size = gdbarch_ptr_bit (gdbarch) / 8; |
f089c433 UW |
3425 | CORE_ADDR sp = get_frame_register_unsigned (this_frame, S390_SP_REGNUM); |
3426 | sp = gdbarch_addr_bits_remove (gdbarch, sp); | |
a8c99f38 | 3427 | |
121d8485 | 3428 | return frame_id_build (sp + 16*word_size + 32, |
34201ae3 | 3429 | get_frame_pc (this_frame)); |
b0cf273e | 3430 | } |
c8f9d51c | 3431 | |
4074e13c JB |
3432 | static CORE_ADDR |
3433 | s390_frame_align (struct gdbarch *gdbarch, CORE_ADDR addr) | |
3434 | { | |
3435 | /* Both the 32- and 64-bit ABI's say that the stack pointer should | |
3436 | always be aligned on an eight-byte boundary. */ | |
3437 | return (addr & -8); | |
3438 | } | |
3439 | ||
3440 | ||
4e65a17e AA |
3441 | /* Helper for s390_return_value: Set or retrieve a function return |
3442 | value if it resides in a register. */ | |
b0cf273e | 3443 | |
4e65a17e AA |
3444 | static void |
3445 | s390_register_return_value (struct gdbarch *gdbarch, struct type *type, | |
3446 | struct regcache *regcache, | |
3447 | gdb_byte *out, const gdb_byte *in) | |
c8f9d51c | 3448 | { |
4e65a17e AA |
3449 | enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); |
3450 | int word_size = gdbarch_ptr_bit (gdbarch) / 8; | |
3451 | int length = TYPE_LENGTH (type); | |
3452 | int code = TYPE_CODE (type); | |
b0cf273e | 3453 | |
4e65a17e | 3454 | if (code == TYPE_CODE_FLT || code == TYPE_CODE_DECFLOAT) |
b0cf273e | 3455 | { |
4e65a17e AA |
3456 | /* Float-like value: left-aligned in f0. */ |
3457 | if (in != NULL) | |
3458 | regcache_cooked_write_part (regcache, S390_F0_REGNUM, | |
3459 | 0, length, in); | |
3460 | else | |
3461 | regcache_cooked_read_part (regcache, S390_F0_REGNUM, | |
3462 | 0, length, out); | |
3463 | } | |
417c80f9 AA |
3464 | else if (code == TYPE_CODE_ARRAY) |
3465 | { | |
3466 | /* Vector: left-aligned in v24. */ | |
3467 | if (in != NULL) | |
3468 | regcache_cooked_write_part (regcache, S390_V24_REGNUM, | |
3469 | 0, length, in); | |
3470 | else | |
3471 | regcache_cooked_read_part (regcache, S390_V24_REGNUM, | |
3472 | 0, length, out); | |
3473 | } | |
4e65a17e AA |
3474 | else if (length <= word_size) |
3475 | { | |
3476 | /* Integer: zero- or sign-extended in r2. */ | |
3477 | if (out != NULL) | |
3478 | regcache_cooked_read_part (regcache, S390_R2_REGNUM, | |
3479 | word_size - length, length, out); | |
3480 | else if (TYPE_UNSIGNED (type)) | |
3481 | regcache_cooked_write_unsigned | |
3482 | (regcache, S390_R2_REGNUM, | |
3483 | extract_unsigned_integer (in, length, byte_order)); | |
3484 | else | |
3485 | regcache_cooked_write_signed | |
3486 | (regcache, S390_R2_REGNUM, | |
3487 | extract_signed_integer (in, length, byte_order)); | |
b0cf273e | 3488 | } |
4e65a17e AA |
3489 | else if (length == 2 * word_size) |
3490 | { | |
3491 | /* Double word: in r2 and r3. */ | |
3492 | if (in != NULL) | |
3493 | { | |
3494 | regcache_cooked_write (regcache, S390_R2_REGNUM, in); | |
3495 | regcache_cooked_write (regcache, S390_R3_REGNUM, | |
3496 | in + word_size); | |
3497 | } | |
3498 | else | |
3499 | { | |
3500 | regcache_cooked_read (regcache, S390_R2_REGNUM, out); | |
3501 | regcache_cooked_read (regcache, S390_R3_REGNUM, | |
3502 | out + word_size); | |
3503 | } | |
3504 | } | |
3505 | else | |
3506 | internal_error (__FILE__, __LINE__, _("invalid return type")); | |
c8f9d51c JB |
3507 | } |
3508 | ||
4e65a17e AA |
3509 | |
3510 | /* Implement the 'return_value' gdbarch method. */ | |
3511 | ||
b0cf273e | 3512 | static enum return_value_convention |
6a3a010b | 3513 | s390_return_value (struct gdbarch *gdbarch, struct value *function, |
c055b101 CV |
3514 | struct type *type, struct regcache *regcache, |
3515 | gdb_byte *out, const gdb_byte *in) | |
5769d3cd | 3516 | { |
56b9d9ac | 3517 | enum return_value_convention rvc; |
56b9d9ac UW |
3518 | |
3519 | type = check_typedef (type); | |
56b9d9ac | 3520 | |
4e65a17e | 3521 | switch (TYPE_CODE (type)) |
b0cf273e | 3522 | { |
4e65a17e AA |
3523 | case TYPE_CODE_STRUCT: |
3524 | case TYPE_CODE_UNION: | |
4e65a17e AA |
3525 | case TYPE_CODE_COMPLEX: |
3526 | rvc = RETURN_VALUE_STRUCT_CONVENTION; | |
3527 | break; | |
417c80f9 AA |
3528 | case TYPE_CODE_ARRAY: |
3529 | rvc = (gdbarch_tdep (gdbarch)->vector_abi == S390_VECTOR_ABI_128 | |
3530 | && TYPE_LENGTH (type) <= 16 && TYPE_VECTOR (type)) | |
3531 | ? RETURN_VALUE_REGISTER_CONVENTION | |
3532 | : RETURN_VALUE_STRUCT_CONVENTION; | |
3533 | break; | |
4e65a17e AA |
3534 | default: |
3535 | rvc = TYPE_LENGTH (type) <= 8 | |
3536 | ? RETURN_VALUE_REGISTER_CONVENTION | |
3537 | : RETURN_VALUE_STRUCT_CONVENTION; | |
b0cf273e | 3538 | } |
5769d3cd | 3539 | |
4e65a17e AA |
3540 | if (in != NULL || out != NULL) |
3541 | { | |
3542 | if (rvc == RETURN_VALUE_REGISTER_CONVENTION) | |
3543 | s390_register_return_value (gdbarch, type, regcache, out, in); | |
3544 | else if (in != NULL) | |
3545 | error (_("Cannot set function return value.")); | |
3546 | else | |
3547 | error (_("Function return value unknown.")); | |
b0cf273e JB |
3548 | } |
3549 | ||
3550 | return rvc; | |
3551 | } | |
5769d3cd AC |
3552 | |
3553 | ||
a8c99f38 | 3554 | /* Breakpoints. */ |
04180708 | 3555 | constexpr gdb_byte s390_break_insn[] = { 0x0, 0x1 }; |
a8c99f38 | 3556 | |
04180708 | 3557 | typedef BP_MANIPULATION (s390_break_insn) s390_breakpoint; |
5769d3cd | 3558 | |
a8c99f38 | 3559 | /* Address handling. */ |
5769d3cd AC |
3560 | |
3561 | static CORE_ADDR | |
24568a2c | 3562 | s390_addr_bits_remove (struct gdbarch *gdbarch, CORE_ADDR addr) |
5769d3cd | 3563 | { |
a8c99f38 | 3564 | return addr & 0x7fffffff; |
5769d3cd AC |
3565 | } |
3566 | ||
ffc65945 KB |
3567 | static int |
3568 | s390_address_class_type_flags (int byte_size, int dwarf2_addr_class) | |
3569 | { | |
3570 | if (byte_size == 4) | |
119ac181 | 3571 | return TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1; |
ffc65945 KB |
3572 | else |
3573 | return 0; | |
3574 | } | |
3575 | ||
3576 | static const char * | |
3577 | s390_address_class_type_flags_to_name (struct gdbarch *gdbarch, int type_flags) | |
3578 | { | |
119ac181 | 3579 | if (type_flags & TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1) |
ffc65945 KB |
3580 | return "mode32"; |
3581 | else | |
3582 | return NULL; | |
3583 | } | |
3584 | ||
a78f21af | 3585 | static int |
c378eb4e MS |
3586 | s390_address_class_name_to_type_flags (struct gdbarch *gdbarch, |
3587 | const char *name, | |
ffc65945 KB |
3588 | int *type_flags_ptr) |
3589 | { | |
3590 | if (strcmp (name, "mode32") == 0) | |
3591 | { | |
119ac181 | 3592 | *type_flags_ptr = TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1; |
ffc65945 KB |
3593 | return 1; |
3594 | } | |
3595 | else | |
3596 | return 0; | |
3597 | } | |
3598 | ||
60abeae4 AA |
3599 | /* Implement gdbarch_gcc_target_options. GCC does not know "-m32" or |
3600 | "-mcmodel=large". */ | |
a2658feb JK |
3601 | |
3602 | static char * | |
3603 | s390_gcc_target_options (struct gdbarch *gdbarch) | |
3604 | { | |
60abeae4 AA |
3605 | return xstrdup (gdbarch_ptr_bit (gdbarch) == 64 ? "-m64" : "-m31"); |
3606 | } | |
3607 | ||
3608 | /* Implement gdbarch_gnu_triplet_regexp. Target triplets are "s390-*" | |
3609 | for 31-bit and "s390x-*" for 64-bit, while the BFD arch name is | |
3610 | always "s390". Note that an s390x compiler supports "-m31" as | |
3611 | well. */ | |
3612 | ||
3613 | static const char * | |
3614 | s390_gnu_triplet_regexp (struct gdbarch *gdbarch) | |
3615 | { | |
3616 | return "s390x?"; | |
a2658feb JK |
3617 | } |
3618 | ||
55aa24fb SDJ |
3619 | /* Implementation of `gdbarch_stap_is_single_operand', as defined in |
3620 | gdbarch.h. */ | |
3621 | ||
3622 | static int | |
3623 | s390_stap_is_single_operand (struct gdbarch *gdbarch, const char *s) | |
3624 | { | |
3625 | return ((isdigit (*s) && s[1] == '(' && s[2] == '%') /* Displacement | |
3626 | or indirection. */ | |
3627 | || *s == '%' /* Register access. */ | |
3628 | || isdigit (*s)); /* Literal number. */ | |
3629 | } | |
3630 | ||
566c56c9 MK |
3631 | /* Process record and replay helpers. */ |
3632 | ||
3633 | /* Takes the intermediate sum of address calculations and masks off upper | |
3634 | bits according to current addressing mode. */ | |
3635 | ||
3636 | static CORE_ADDR | |
3637 | s390_record_address_mask (struct gdbarch *gdbarch, struct regcache *regcache, | |
3638 | CORE_ADDR val) { | |
3639 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | |
3640 | ULONGEST pswm, pswa; | |
3641 | int am; | |
3642 | if (tdep->abi == ABI_LINUX_S390) | |
3643 | { | |
3644 | regcache_raw_read_unsigned (regcache, S390_PSWA_REGNUM, &pswa); | |
3645 | am = pswa >> 31 & 1; | |
3646 | } | |
3647 | else | |
3648 | { | |
3649 | regcache_raw_read_unsigned (regcache, S390_PSWM_REGNUM, &pswm); | |
3650 | am = pswm >> 31 & 3; | |
3651 | } | |
3652 | switch (am) | |
3653 | { | |
3654 | case 0: | |
3655 | return val & 0xffffff; | |
3656 | case 1: | |
3657 | return val & 0x7fffffff; | |
3658 | case 3: | |
3659 | return val; | |
3660 | default: | |
3661 | fprintf_unfiltered (gdb_stdlog, "Warning: Addressing mode %d used.", am); | |
3662 | return 0; | |
3663 | } | |
3664 | } | |
3665 | ||
3666 | /* Calculates memory address using pre-calculated index, raw instruction word | |
3667 | with b and d/dl fields, and raw instruction byte with dh field. Index and | |
3668 | dh should be set to 0 if unused. */ | |
3669 | ||
3670 | static CORE_ADDR | |
3671 | s390_record_calc_disp_common (struct gdbarch *gdbarch, struct regcache *regcache, | |
3672 | ULONGEST x, uint16_t bd, int8_t dh) | |
3673 | { | |
3674 | uint8_t rb = bd >> 12 & 0xf; | |
3675 | int32_t d = (bd & 0xfff) | ((int32_t)dh << 12); | |
3676 | ULONGEST b; | |
3677 | CORE_ADDR res = d + x; | |
3678 | if (rb) | |
3679 | { | |
3680 | regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + rb, &b); | |
3681 | res += b; | |
3682 | } | |
3683 | return s390_record_address_mask (gdbarch, regcache, res); | |
3684 | } | |
3685 | ||
3686 | /* Calculates memory address using raw x, b + d/dl, dh fields from | |
3687 | instruction. rx and dh should be set to 0 if unused. */ | |
3688 | ||
3689 | static CORE_ADDR | |
3690 | s390_record_calc_disp (struct gdbarch *gdbarch, struct regcache *regcache, | |
3691 | uint8_t rx, uint16_t bd, int8_t dh) | |
3692 | { | |
3693 | ULONGEST x = 0; | |
3694 | if (rx) | |
3695 | regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + rx, &x); | |
3696 | return s390_record_calc_disp_common (gdbarch, regcache, x, bd, dh); | |
3697 | } | |
3698 | ||
3699 | /* Calculates memory address for VSCE[GF] instructions. */ | |
3700 | ||
3701 | static int | |
3702 | s390_record_calc_disp_vsce (struct gdbarch *gdbarch, struct regcache *regcache, | |
3703 | uint8_t vx, uint8_t el, uint8_t es, uint16_t bd, | |
3704 | int8_t dh, CORE_ADDR *res) | |
3705 | { | |
3706 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | |
3707 | enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); | |
3708 | ULONGEST x; | |
3709 | gdb_byte buf[16]; | |
3710 | if (tdep->v0_full_regnum == -1 || el * es >= 16) | |
3711 | return -1; | |
3712 | if (vx < 16) | |
3713 | regcache_cooked_read (regcache, tdep->v0_full_regnum + vx, buf); | |
3714 | else | |
3715 | regcache_raw_read (regcache, S390_V16_REGNUM + vx - 16, buf); | |
3716 | x = extract_unsigned_integer (buf + el * es, es, byte_order); | |
3717 | *res = s390_record_calc_disp_common (gdbarch, regcache, x, bd, dh); | |
3718 | return 0; | |
3719 | } | |
3720 | ||
3721 | /* Calculates memory address for instructions with relative long addressing. */ | |
3722 | ||
3723 | static CORE_ADDR | |
3724 | s390_record_calc_rl (struct gdbarch *gdbarch, struct regcache *regcache, | |
3725 | CORE_ADDR addr, uint16_t i1, uint16_t i2) | |
3726 | { | |
3727 | int32_t ri = i1 << 16 | i2; | |
3728 | return s390_record_address_mask (gdbarch, regcache, addr + (LONGEST)ri * 2); | |
3729 | } | |
3730 | ||
3731 | /* Population count helper. */ | |
3732 | ||
3733 | static int s390_popcnt (unsigned int x) { | |
3734 | int res = 0; | |
3735 | while (x) | |
3736 | { | |
3737 | if (x & 1) | |
3738 | res++; | |
3739 | x >>= 1; | |
3740 | } | |
3741 | return res; | |
3742 | } | |
3743 | ||
3744 | /* Record 64-bit register. */ | |
3745 | ||
3746 | static int | |
3747 | s390_record_gpr_g (struct gdbarch *gdbarch, struct regcache *regcache, int i) | |
3748 | { | |
3749 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | |
3750 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + i)) | |
3751 | return -1; | |
3752 | if (tdep->abi == ABI_LINUX_S390) | |
3753 | if (record_full_arch_list_add_reg (regcache, S390_R0_UPPER_REGNUM + i)) | |
3754 | return -1; | |
3755 | return 0; | |
3756 | } | |
3757 | ||
3758 | /* Record high 32 bits of a register. */ | |
3759 | ||
3760 | static int | |
3761 | s390_record_gpr_h (struct gdbarch *gdbarch, struct regcache *regcache, int i) | |
3762 | { | |
3763 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | |
3764 | if (tdep->abi == ABI_LINUX_S390) | |
3765 | { | |
3766 | if (record_full_arch_list_add_reg (regcache, S390_R0_UPPER_REGNUM + i)) | |
3767 | return -1; | |
3768 | } | |
3769 | else | |
3770 | { | |
3771 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + i)) | |
3772 | return -1; | |
3773 | } | |
3774 | return 0; | |
3775 | } | |
3776 | ||
3777 | /* Record vector register. */ | |
3778 | ||
3779 | static int | |
3780 | s390_record_vr (struct gdbarch *gdbarch, struct regcache *regcache, int i) | |
3781 | { | |
566c56c9 MK |
3782 | if (i < 16) |
3783 | { | |
3784 | if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + i)) | |
3785 | return -1; | |
3786 | if (record_full_arch_list_add_reg (regcache, S390_V0_LOWER_REGNUM + i)) | |
3787 | return -1; | |
3788 | } | |
3789 | else | |
3790 | { | |
3791 | if (record_full_arch_list_add_reg (regcache, S390_V16_REGNUM + i - 16)) | |
3792 | return -1; | |
3793 | } | |
3794 | return 0; | |
3795 | } | |
3796 | ||
3797 | static int | |
3798 | s390_process_record (struct gdbarch *gdbarch, struct regcache *regcache, | |
3799 | CORE_ADDR addr) | |
3800 | { | |
566c56c9 MK |
3801 | uint16_t insn[3] = {0}; |
3802 | /* Instruction as bytes. */ | |
3803 | uint8_t ibyte[6]; | |
3804 | /* Instruction as nibbles. */ | |
3805 | uint8_t inib[12]; | |
3806 | /* Instruction vector registers. */ | |
3807 | uint8_t ivec[4]; | |
3808 | CORE_ADDR oaddr, oaddr2, oaddr3; | |
3809 | ULONGEST tmp; | |
3810 | int i, n; | |
3811 | /* if EX/EXRL instruction used, here's the reg parameter */ | |
3812 | int ex = -1; | |
3813 | enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); | |
3814 | ||
3815 | /* Attempting to use EX or EXRL jumps back here */ | |
3816 | ex: | |
3817 | ||
3818 | /* Read instruction. */ | |
3819 | insn[0] = read_memory_unsigned_integer (addr, 2, byte_order); | |
3820 | /* If execute was involved, do the adjustment. */ | |
3821 | if (ex != -1) | |
3822 | insn[0] |= ex & 0xff; | |
3823 | /* Two highest bits determine instruction size. */ | |
3824 | if (insn[0] >= 0x4000) | |
3825 | insn[1] = read_memory_unsigned_integer (addr+2, 2, byte_order); | |
3826 | else | |
3827 | /* Not necessary, but avoids uninitialized variable warnings. */ | |
3828 | insn[1] = 0; | |
3829 | if (insn[0] >= 0xc000) | |
3830 | insn[2] = read_memory_unsigned_integer (addr+4, 2, byte_order); | |
3831 | else | |
3832 | insn[2] = 0; | |
3833 | /* Split instruction into bytes and nibbles. */ | |
3834 | for (i = 0; i < 3; i++) | |
3835 | { | |
3836 | ibyte[i*2] = insn[i] >> 8 & 0xff; | |
3837 | ibyte[i*2+1] = insn[i] & 0xff; | |
3838 | } | |
3839 | for (i = 0; i < 6; i++) | |
3840 | { | |
3841 | inib[i*2] = ibyte[i] >> 4 & 0xf; | |
3842 | inib[i*2+1] = ibyte[i] & 0xf; | |
3843 | } | |
3844 | /* Compute vector registers, if applicable. */ | |
3845 | ivec[0] = (inib[9] >> 3 & 1) << 4 | inib[2]; | |
3846 | ivec[1] = (inib[9] >> 2 & 1) << 4 | inib[3]; | |
3847 | ivec[2] = (inib[9] >> 1 & 1) << 4 | inib[4]; | |
3848 | ivec[3] = (inib[9] >> 0 & 1) << 4 | inib[8]; | |
3849 | ||
3850 | switch (ibyte[0]) | |
3851 | { | |
3852 | /* 0x00 undefined */ | |
3853 | ||
3854 | case 0x01: | |
3855 | /* E-format instruction */ | |
3856 | switch (ibyte[1]) | |
3857 | { | |
3858 | /* 0x00 undefined */ | |
3859 | /* 0x01 unsupported: PR - program return */ | |
3860 | /* 0x02 unsupported: UPT */ | |
3861 | /* 0x03 undefined */ | |
3862 | /* 0x04 privileged: PTFF - perform timing facility function */ | |
3863 | /* 0x05-0x06 undefined */ | |
3864 | /* 0x07 privileged: SCKPF - set clock programmable field */ | |
3865 | /* 0x08-0x09 undefined */ | |
3866 | ||
3867 | case 0x0a: /* PFPO - perform floating point operation */ | |
3868 | regcache_raw_read_unsigned (regcache, S390_R0_REGNUM, &tmp); | |
3869 | if (!(tmp & 0x80000000u)) | |
3870 | { | |
3871 | uint8_t ofc = tmp >> 16 & 0xff; | |
3872 | switch (ofc) | |
3873 | { | |
3874 | case 0x00: /* HFP32 */ | |
3875 | case 0x01: /* HFP64 */ | |
3876 | case 0x05: /* BFP32 */ | |
3877 | case 0x06: /* BFP64 */ | |
3878 | case 0x08: /* DFP32 */ | |
3879 | case 0x09: /* DFP64 */ | |
3880 | if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM)) | |
3881 | return -1; | |
3882 | break; | |
3883 | case 0x02: /* HFP128 */ | |
3884 | case 0x07: /* BFP128 */ | |
3885 | case 0x0a: /* DFP128 */ | |
3886 | if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM)) | |
3887 | return -1; | |
3888 | if (record_full_arch_list_add_reg (regcache, S390_F2_REGNUM)) | |
3889 | return -1; | |
3890 | break; | |
3891 | default: | |
3892 | fprintf_unfiltered (gdb_stdlog, "Warning: Unknown PFPO OFC %02x at %s.\n", | |
3893 | ofc, paddress (gdbarch, addr)); | |
3894 | return -1; | |
3895 | } | |
3896 | ||
3897 | if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM)) | |
3898 | return -1; | |
3899 | } | |
3900 | if (record_full_arch_list_add_reg (regcache, S390_R1_REGNUM)) | |
3901 | return -1; | |
3902 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
3903 | return -1; | |
3904 | break; | |
3905 | ||
3906 | case 0x0b: /* TAM - test address mode */ | |
3907 | case 0x0c: /* SAM24 - set address mode 24 */ | |
3908 | case 0x0d: /* SAM31 - set address mode 31 */ | |
3909 | case 0x0e: /* SAM64 - set address mode 64 */ | |
3910 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
3911 | return -1; | |
3912 | break; | |
3913 | ||
3914 | /* 0x0f-0xfe undefined */ | |
3915 | ||
3916 | /* 0xff unsupported: TRAP */ | |
3917 | ||
3918 | default: | |
3919 | goto UNKNOWN_OP; | |
3920 | } | |
3921 | break; | |
3922 | ||
3923 | /* 0x02 undefined */ | |
3924 | /* 0x03 undefined */ | |
3925 | ||
3926 | case 0x04: /* SPM - set program mask */ | |
3927 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
3928 | return -1; | |
3929 | break; | |
3930 | ||
3931 | case 0x05: /* BALR - branch and link */ | |
3932 | case 0x45: /* BAL - branch and link */ | |
3933 | case 0x06: /* BCTR - branch on count */ | |
3934 | case 0x46: /* BCT - branch on count */ | |
3935 | case 0x0d: /* BASR - branch and save */ | |
3936 | case 0x4d: /* BAS - branch and save */ | |
3937 | case 0x84: /* BRXH - branch relative on index high */ | |
3938 | case 0x85: /* BRXLE - branch relative on index low or equal */ | |
3939 | case 0x86: /* BXH - branch on index high */ | |
3940 | case 0x87: /* BXLE - branch on index low or equal */ | |
3941 | /* BA[SL]* use native-size destination for linkage info, BCT*, BRX*, BX* | |
3942 | use 32-bit destination as counter. */ | |
3943 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2])) | |
3944 | return -1; | |
3945 | break; | |
3946 | ||
3947 | case 0x07: /* BCR - branch on condition */ | |
3948 | case 0x47: /* BC - branch on condition */ | |
3949 | /* No effect other than PC transfer. */ | |
3950 | break; | |
3951 | ||
3952 | /* 0x08 undefined */ | |
3953 | /* 0x09 undefined */ | |
3954 | ||
3955 | case 0x0a: | |
3956 | /* SVC - supervisor call */ | |
3957 | if (s390_linux_syscall_record (regcache, ibyte[1])) | |
3958 | return -1; | |
3959 | break; | |
3960 | ||
3961 | case 0x0b: /* BSM - branch and set mode */ | |
3962 | if (inib[2]) | |
3963 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2])) | |
3964 | return -1; | |
3965 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
3966 | return -1; | |
3967 | break; | |
3968 | ||
3969 | case 0x0c: /* BASSM - branch and save and set mode */ | |
3970 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2])) | |
3971 | return -1; | |
3972 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
3973 | return -1; | |
3974 | break; | |
3975 | ||
3976 | case 0x0e: /* MVCL - move long [interruptible] */ | |
3977 | regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[2], &tmp); | |
3978 | oaddr = s390_record_address_mask (gdbarch, regcache, tmp); | |
3979 | regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + (inib[2] | 1), &tmp); | |
3980 | tmp &= 0xffffff; | |
3981 | if (record_full_arch_list_add_mem (oaddr, tmp)) | |
3982 | return -1; | |
3983 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2])) | |
3984 | return -1; | |
3985 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[2] | 1))) | |
3986 | return -1; | |
3987 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[3])) | |
3988 | return -1; | |
3989 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[3] | 1))) | |
3990 | return -1; | |
3991 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
3992 | return -1; | |
3993 | break; | |
3994 | ||
3995 | case 0x0f: /* CLCL - compare logical long [interruptible] */ | |
3996 | case 0xa9: /* CLCLE - compare logical long extended [partial] */ | |
3997 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2])) | |
3998 | return -1; | |
3999 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[2] | 1))) | |
4000 | return -1; | |
4001 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[3])) | |
4002 | return -1; | |
4003 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[3] | 1))) | |
4004 | return -1; | |
4005 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
4006 | return -1; | |
4007 | break; | |
4008 | ||
4009 | case 0x10: /* LPR - load positive */ | |
4010 | case 0x11: /* LNR - load negative */ | |
4011 | case 0x12: /* LTR - load and test */ | |
4012 | case 0x13: /* LCR - load complement */ | |
4013 | case 0x14: /* NR - and */ | |
4014 | case 0x16: /* OR - or */ | |
4015 | case 0x17: /* XR - xor */ | |
4016 | case 0x1a: /* AR - add */ | |
4017 | case 0x1b: /* SR - subtract */ | |
4018 | case 0x1e: /* ALR - add logical */ | |
4019 | case 0x1f: /* SLR - subtract logical */ | |
4020 | case 0x54: /* N - and */ | |
4021 | case 0x56: /* O - or */ | |
4022 | case 0x57: /* X - xor */ | |
4023 | case 0x5a: /* A - add */ | |
4024 | case 0x5b: /* S - subtract */ | |
4025 | case 0x5e: /* AL - add logical */ | |
4026 | case 0x5f: /* SL - subtract logical */ | |
4027 | case 0x4a: /* AH - add halfword */ | |
4028 | case 0x4b: /* SH - subtract halfword */ | |
4029 | case 0x8a: /* SRA - shift right single */ | |
4030 | case 0x8b: /* SLA - shift left single */ | |
4031 | case 0xbf: /* ICM - insert characters under mask */ | |
4032 | /* 32-bit destination + flags */ | |
4033 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2])) | |
4034 | return -1; | |
4035 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
4036 | return -1; | |
4037 | break; | |
4038 | ||
4039 | case 0x15: /* CLR - compare logical */ | |
4040 | case 0x55: /* CL - compare logical */ | |
4041 | case 0x19: /* CR - compare */ | |
4042 | case 0x29: /* CDR - compare */ | |
4043 | case 0x39: /* CER - compare */ | |
4044 | case 0x49: /* CH - compare halfword */ | |
4045 | case 0x59: /* C - compare */ | |
4046 | case 0x69: /* CD - compare */ | |
4047 | case 0x79: /* CE - compare */ | |
4048 | case 0x91: /* TM - test under mask */ | |
4049 | case 0x95: /* CLI - compare logical */ | |
4050 | case 0xbd: /* CLM - compare logical under mask */ | |
4051 | case 0xd5: /* CLC - compare logical */ | |
4052 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
4053 | return -1; | |
4054 | break; | |
4055 | ||
4056 | case 0x18: /* LR - load */ | |
4057 | case 0x48: /* LH - load halfword */ | |
4058 | case 0x58: /* L - load */ | |
4059 | case 0x41: /* LA - load address */ | |
4060 | case 0x43: /* IC - insert character */ | |
4061 | case 0x4c: /* MH - multiply halfword */ | |
4062 | case 0x71: /* MS - multiply single */ | |
4063 | case 0x88: /* SRL - shift right single logical */ | |
4064 | case 0x89: /* SLL - shift left single logical */ | |
4065 | /* 32-bit, 8-bit (IC), or native width (LA) destination, no flags */ | |
4066 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2])) | |
4067 | return -1; | |
4068 | break; | |
4069 | ||
4070 | case 0x1c: /* MR - multiply */ | |
4071 | case 0x5c: /* M - multiply */ | |
4072 | case 0x1d: /* DR - divide */ | |
4073 | case 0x5d: /* D - divide */ | |
4074 | case 0x8c: /* SRDL - shift right double logical */ | |
4075 | case 0x8d: /* SLDL - shift left double logical */ | |
4076 | /* 32-bit pair destination, no flags */ | |
4077 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2])) | |
4078 | return -1; | |
4079 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[2] | 1))) | |
4080 | return -1; | |
4081 | break; | |
4082 | ||
4083 | case 0x20: /* LPDR - load positive */ | |
4084 | case 0x30: /* LPER - load positive */ | |
4085 | case 0x21: /* LNDR - load negative */ | |
4086 | case 0x31: /* LNER - load negative */ | |
4087 | case 0x22: /* LTDR - load and test */ | |
4088 | case 0x32: /* LTER - load and test */ | |
4089 | case 0x23: /* LCDR - load complement */ | |
4090 | case 0x33: /* LCER - load complement */ | |
4091 | case 0x2a: /* ADR - add */ | |
4092 | case 0x3a: /* AER - add */ | |
4093 | case 0x6a: /* AD - add */ | |
4094 | case 0x7a: /* AE - add */ | |
4095 | case 0x2b: /* SDR - subtract */ | |
4096 | case 0x3b: /* SER - subtract */ | |
4097 | case 0x6b: /* SD - subtract */ | |
4098 | case 0x7b: /* SE - subtract */ | |
4099 | case 0x2e: /* AWR - add unnormalized */ | |
4100 | case 0x3e: /* AUR - add unnormalized */ | |
4101 | case 0x6e: /* AW - add unnormalized */ | |
4102 | case 0x7e: /* AU - add unnormalized */ | |
4103 | case 0x2f: /* SWR - subtract unnormalized */ | |
4104 | case 0x3f: /* SUR - subtract unnormalized */ | |
4105 | case 0x6f: /* SW - subtract unnormalized */ | |
4106 | case 0x7f: /* SU - subtract unnormalized */ | |
4107 | /* float destination + flags */ | |
4108 | if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[2])) | |
4109 | return -1; | |
4110 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
4111 | return -1; | |
4112 | break; | |
4113 | ||
4114 | case 0x24: /* HDR - halve */ | |
4115 | case 0x34: /* HER - halve */ | |
4116 | case 0x25: /* LDXR - load rounded */ | |
4117 | case 0x35: /* LEDR - load rounded */ | |
4118 | case 0x28: /* LDR - load */ | |
4119 | case 0x38: /* LER - load */ | |
4120 | case 0x68: /* LD - load */ | |
4121 | case 0x78: /* LE - load */ | |
4122 | case 0x2c: /* MDR - multiply */ | |
4123 | case 0x3c: /* MDER - multiply */ | |
4124 | case 0x6c: /* MD - multiply */ | |
4125 | case 0x7c: /* MDE - multiply */ | |
4126 | case 0x2d: /* DDR - divide */ | |
4127 | case 0x3d: /* DER - divide */ | |
4128 | case 0x6d: /* DD - divide */ | |
4129 | case 0x7d: /* DE - divide */ | |
4130 | /* float destination, no flags */ | |
4131 | if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[2])) | |
4132 | return -1; | |
4133 | break; | |
4134 | ||
4135 | case 0x26: /* MXR - multiply */ | |
4136 | case 0x27: /* MXDR - multiply */ | |
4137 | case 0x67: /* MXD - multiply */ | |
4138 | /* float pair destination, no flags */ | |
4139 | if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[2])) | |
4140 | return -1; | |
4141 | if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + (inib[2] | 2))) | |
4142 | return -1; | |
4143 | break; | |
4144 | ||
4145 | case 0x36: /* AXR - add */ | |
4146 | case 0x37: /* SXR - subtract */ | |
4147 | /* float pair destination + flags */ | |
4148 | if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[2])) | |
4149 | return -1; | |
4150 | if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + (inib[2] | 2))) | |
4151 | return -1; | |
4152 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
4153 | return -1; | |
4154 | break; | |
4155 | ||
4156 | case 0x40: /* STH - store halfword */ | |
4157 | oaddr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], 0); | |
4158 | if (record_full_arch_list_add_mem (oaddr, 2)) | |
4159 | return -1; | |
4160 | break; | |
4161 | ||
4162 | case 0x42: /* STC - store character */ | |
4163 | oaddr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], 0); | |
4164 | if (record_full_arch_list_add_mem (oaddr, 1)) | |
4165 | return -1; | |
4166 | break; | |
4167 | ||
4168 | case 0x44: /* EX - execute */ | |
4169 | if (ex != -1) | |
4170 | { | |
4171 | fprintf_unfiltered (gdb_stdlog, "Warning: Double execute at %s.\n", | |
4172 | paddress (gdbarch, addr)); | |
4173 | return -1; | |
4174 | } | |
4175 | addr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], 0); | |
4176 | if (inib[2]) | |
4177 | { | |
4178 | regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[2], &tmp); | |
4179 | ex = tmp & 0xff; | |
4180 | } | |
4181 | else | |
4182 | { | |
4183 | ex = 0; | |
4184 | } | |
4185 | goto ex; | |
4186 | ||
4187 | case 0x4e: /* CVD - convert to decimal */ | |
4188 | case 0x60: /* STD - store */ | |
4189 | oaddr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], 0); | |
4190 | if (record_full_arch_list_add_mem (oaddr, 8)) | |
4191 | return -1; | |
4192 | break; | |
4193 | ||
4194 | case 0x4f: /* CVB - convert to binary */ | |
4195 | /* 32-bit gpr destination + FPC (DXC write) */ | |
4196 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2])) | |
4197 | return -1; | |
4198 | if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM)) | |
4199 | return -1; | |
4200 | break; | |
4201 | ||
4202 | case 0x50: /* ST - store */ | |
4203 | case 0x70: /* STE - store */ | |
4204 | oaddr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], 0); | |
4205 | if (record_full_arch_list_add_mem (oaddr, 4)) | |
4206 | return -1; | |
4207 | break; | |
4208 | ||
4209 | case 0x51: /* LAE - load address extended */ | |
4210 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2])) | |
4211 | return -1; | |
4212 | if (record_full_arch_list_add_reg (regcache, S390_A0_REGNUM + inib[2])) | |
4213 | return -1; | |
4214 | break; | |
4215 | ||
4216 | /* 0x52 undefined */ | |
4217 | /* 0x53 undefined */ | |
4218 | ||
4219 | /* 0x61-0x66 undefined */ | |
4220 | ||
4221 | /* 0x72-0x77 undefined */ | |
4222 | ||
4223 | /* 0x80 privileged: SSM - set system mask */ | |
4224 | /* 0x81 undefined */ | |
4225 | /* 0x82 privileged: LPSW - load PSW */ | |
4226 | /* 0x83 privileged: diagnose */ | |
4227 | ||
4228 | case 0x8e: /* SRDA - shift right double */ | |
4229 | case 0x8f: /* SLDA - shift left double */ | |
4230 | /* 32-bit pair destination + flags */ | |
4231 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2])) | |
4232 | return -1; | |
4233 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[2] | 1))) | |
4234 | return -1; | |
4235 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
4236 | return -1; | |
4237 | break; | |
4238 | ||
4239 | case 0x90: /* STM - store multiple */ | |
4240 | case 0x9b: /* STAM - store access multiple */ | |
4241 | oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0); | |
4242 | if (inib[2] <= inib[3]) | |
4243 | n = inib[3] - inib[2] + 1; | |
4244 | else | |
4245 | n = inib[3] + 0x10 - inib[2] + 1; | |
4246 | if (record_full_arch_list_add_mem (oaddr, n * 4)) | |
4247 | return -1; | |
4248 | break; | |
4249 | ||
4250 | case 0x92: /* MVI - move */ | |
4251 | oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0); | |
4252 | if (record_full_arch_list_add_mem (oaddr, 1)) | |
4253 | return -1; | |
4254 | break; | |
4255 | ||
4256 | case 0x93: /* TS - test and set */ | |
4257 | case 0x94: /* NI - and */ | |
4258 | case 0x96: /* OI - or */ | |
4259 | case 0x97: /* XI - xor */ | |
4260 | oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0); | |
4261 | if (record_full_arch_list_add_mem (oaddr, 1)) | |
4262 | return -1; | |
4263 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
4264 | return -1; | |
4265 | break; | |
4266 | ||
4267 | case 0x98: /* LM - load multiple */ | |
4268 | for (i = inib[2]; i != inib[3]; i++, i &= 0xf) | |
4269 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + i)) | |
4270 | return -1; | |
4271 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[3])) | |
4272 | return -1; | |
4273 | break; | |
4274 | ||
4275 | /* 0x99 privileged: TRACE */ | |
4276 | ||
4277 | case 0x9a: /* LAM - load access multiple */ | |
4278 | for (i = inib[2]; i != inib[3]; i++, i &= 0xf) | |
4279 | if (record_full_arch_list_add_reg (regcache, S390_A0_REGNUM + i)) | |
4280 | return -1; | |
4281 | if (record_full_arch_list_add_reg (regcache, S390_A0_REGNUM + inib[3])) | |
4282 | return -1; | |
4283 | break; | |
4284 | ||
4285 | /* 0x9c-0x9f privileged and obsolete (old I/O) */ | |
4286 | /* 0xa0-0xa4 undefined */ | |
4287 | ||
4288 | case 0xa5: | |
4289 | case 0xa7: | |
4290 | /* RI-format instruction */ | |
4291 | switch (ibyte[0] << 4 | inib[3]) | |
4292 | { | |
4293 | case 0xa50: /* IIHH - insert immediate */ | |
4294 | case 0xa51: /* IIHL - insert immediate */ | |
4295 | /* high 32-bit destination */ | |
4296 | if (s390_record_gpr_h (gdbarch, regcache, inib[2])) | |
4297 | return -1; | |
4298 | break; | |
4299 | ||
4300 | case 0xa52: /* IILH - insert immediate */ | |
4301 | case 0xa53: /* IILL - insert immediate */ | |
4302 | case 0xa75: /* BRAS - branch relative and save */ | |
4303 | case 0xa76: /* BRCT - branch relative on count */ | |
4304 | case 0xa78: /* LHI - load halfword immediate */ | |
4305 | case 0xa7c: /* MHI - multiply halfword immediate */ | |
4306 | /* 32-bit or native destination */ | |
4307 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2])) | |
4308 | return -1; | |
4309 | break; | |
4310 | ||
4311 | case 0xa54: /* NIHH - and immediate */ | |
4312 | case 0xa55: /* NIHL - and immediate */ | |
4313 | case 0xa58: /* OIHH - or immediate */ | |
4314 | case 0xa59: /* OIHL - or immediate */ | |
4315 | /* high 32-bit destination + flags */ | |
4316 | if (s390_record_gpr_h (gdbarch, regcache, inib[2])) | |
4317 | return -1; | |
4318 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
4319 | return -1; | |
4320 | break; | |
4321 | ||
4322 | case 0xa56: /* NILH - and immediate */ | |
4323 | case 0xa57: /* NILL - and immediate */ | |
4324 | case 0xa5a: /* OILH - or immediate */ | |
4325 | case 0xa5b: /* OILL - or immediate */ | |
4326 | case 0xa7a: /* AHI - add halfword immediate */ | |
4327 | /* 32-bit destination + flags */ | |
4328 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2])) | |
4329 | return -1; | |
4330 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
4331 | return -1; | |
4332 | break; | |
4333 | ||
4334 | case 0xa5c: /* LLIHH - load logical immediate */ | |
4335 | case 0xa5d: /* LLIHL - load logical immediate */ | |
4336 | case 0xa5e: /* LLILH - load logical immediate */ | |
4337 | case 0xa5f: /* LLILL - load logical immediate */ | |
4338 | case 0xa77: /* BRCTG - branch relative on count */ | |
4339 | case 0xa79: /* LGHI - load halfword immediate */ | |
4340 | case 0xa7d: /* MGHI - multiply halfword immediate */ | |
4341 | /* 64-bit destination */ | |
4342 | if (s390_record_gpr_g (gdbarch, regcache, inib[2])) | |
4343 | return -1; | |
4344 | break; | |
4345 | ||
4346 | case 0xa70: /* TMLH - test under mask */ | |
4347 | case 0xa71: /* TMLL - test under mask */ | |
4348 | case 0xa72: /* TMHH - test under mask */ | |
4349 | case 0xa73: /* TMHL - test under mask */ | |
4350 | case 0xa7e: /* CHI - compare halfword immediate */ | |
4351 | case 0xa7f: /* CGHI - compare halfword immediate */ | |
4352 | /* flags only */ | |
4353 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
4354 | return -1; | |
4355 | break; | |
4356 | ||
4357 | case 0xa74: /* BRC - branch relative on condition */ | |
4358 | /* no register change */ | |
4359 | break; | |
4360 | ||
4361 | case 0xa7b: /* AGHI - add halfword immediate */ | |
4362 | /* 64-bit destination + flags */ | |
4363 | if (s390_record_gpr_g (gdbarch, regcache, inib[2])) | |
4364 | return -1; | |
4365 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
4366 | return -1; | |
4367 | break; | |
4368 | ||
4369 | default: | |
4370 | goto UNKNOWN_OP; | |
4371 | } | |
4372 | break; | |
4373 | ||
4374 | /* 0xa6 undefined */ | |
4375 | ||
4376 | case 0xa8: /* MVCLE - move long extended [partial] */ | |
4377 | regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[2], &tmp); | |
4378 | oaddr = s390_record_address_mask (gdbarch, regcache, tmp); | |
4379 | regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + (inib[2] | 1), &tmp); | |
4380 | if (record_full_arch_list_add_mem (oaddr, tmp)) | |
4381 | return -1; | |
4382 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2])) | |
4383 | return -1; | |
4384 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[2] | 1))) | |
4385 | return -1; | |
4386 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[3])) | |
4387 | return -1; | |
4388 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[3] | 1))) | |
4389 | return -1; | |
4390 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
4391 | return -1; | |
4392 | break; | |
4393 | ||
4394 | /* 0xaa-0xab undefined */ | |
4395 | /* 0xac privileged: STNSM - store then and system mask */ | |
4396 | /* 0xad privileged: STOSM - store then or system mask */ | |
4397 | /* 0xae privileged: SIGP - signal processor */ | |
4398 | /* 0xaf unsupported: MC - monitor call */ | |
4399 | /* 0xb0 undefined */ | |
4400 | /* 0xb1 privileged: LRA - load real address */ | |
4401 | ||
4402 | case 0xb2: | |
4403 | case 0xb3: | |
4404 | case 0xb9: | |
4405 | /* S/RRD/RRE/RRF/IE-format instruction */ | |
4406 | switch (insn[0]) | |
4407 | { | |
4408 | /* 0xb200-0xb204 undefined or privileged */ | |
4409 | ||
4410 | case 0xb205: /* STCK - store clock */ | |
4411 | case 0xb27c: /* STCKF - store clock fast */ | |
4412 | oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0); | |
4413 | if (record_full_arch_list_add_mem (oaddr, 8)) | |
4414 | return -1; | |
4415 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
4416 | return -1; | |
4417 | break; | |
4418 | ||
4419 | /* 0xb206-0xb219 undefined, privileged, or unsupported */ | |
4420 | /* 0xb21a unsupported: CFC */ | |
4421 | /* 0xb21b-0xb221 undefined or privileged */ | |
4422 | ||
4423 | case 0xb222: /* IPM - insert program mask */ | |
4424 | case 0xb24f: /* EAR - extract access */ | |
4425 | case 0xb252: /* MSR - multiply single */ | |
4426 | case 0xb2ec: /* ETND - extract transaction nesting depth */ | |
4427 | case 0xb38c: /* EFPC - extract fpc */ | |
4428 | case 0xb91f: /* LRVR - load reversed */ | |
4429 | case 0xb926: /* LBR - load byte */ | |
4430 | case 0xb927: /* LHR - load halfword */ | |
4431 | case 0xb994: /* LLCR - load logical character */ | |
4432 | case 0xb995: /* LLHR - load logical halfword */ | |
4433 | case 0xb9f2: /* LOCR - load on condition */ | |
4434 | /* 32-bit gpr destination */ | |
4435 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6])) | |
4436 | return -1; | |
4437 | break; | |
4438 | ||
4439 | /* 0xb223-0xb22c privileged or unsupported */ | |
4440 | ||
4441 | case 0xb22d: /* DXR - divide */ | |
4442 | case 0xb325: /* LXDR - load lengthened */ | |
4443 | case 0xb326: /* LXER - load lengthened */ | |
4444 | case 0xb336: /* SQXR - square root */ | |
4445 | case 0xb365: /* LXR - load */ | |
4446 | case 0xb367: /* FIXR - load fp integer */ | |
4447 | case 0xb376: /* LZXR - load zero */ | |
4448 | case 0xb3b6: /* CXFR - convert from fixed */ | |
4449 | case 0xb3c6: /* CXGR - convert from fixed */ | |
4450 | case 0xb3fe: /* IEXTR - insert biased exponent */ | |
4451 | /* float pair destination */ | |
4452 | if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[6])) | |
4453 | return -1; | |
4454 | if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + (inib[6] | 2))) | |
4455 | return -1; | |
4456 | break; | |
4457 | ||
4458 | /* 0xb22e-0xb240 undefined, privileged, or unsupported */ | |
4459 | ||
4460 | case 0xb241: /* CKSM - checksum [partial] */ | |
4461 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6])) | |
4462 | return -1; | |
4463 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[7])) | |
4464 | return -1; | |
4465 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[7] | 1))) | |
4466 | return -1; | |
4467 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
4468 | return -1; | |
4469 | break; | |
4470 | ||
4471 | /* 0xb242-0xb243 undefined */ | |
4472 | ||
4473 | case 0xb244: /* SQDR - square root */ | |
4474 | case 0xb245: /* SQER - square root */ | |
4475 | case 0xb324: /* LDER - load lengthened */ | |
4476 | case 0xb337: /* MEER - multiply */ | |
4477 | case 0xb366: /* LEXR - load rounded */ | |
4478 | case 0xb370: /* LPDFR - load positive */ | |
4479 | case 0xb371: /* LNDFR - load negative */ | |
4480 | case 0xb372: /* CSDFR - copy sign */ | |
4481 | case 0xb373: /* LCDFR - load complement */ | |
4482 | case 0xb374: /* LZER - load zero */ | |
4483 | case 0xb375: /* LZDR - load zero */ | |
4484 | case 0xb377: /* FIER - load fp integer */ | |
4485 | case 0xb37f: /* FIDR - load fp integer */ | |
4486 | case 0xb3b4: /* CEFR - convert from fixed */ | |
4487 | case 0xb3b5: /* CDFR - convert from fixed */ | |
4488 | case 0xb3c1: /* LDGR - load fpr from gr */ | |
4489 | case 0xb3c4: /* CEGR - convert from fixed */ | |
4490 | case 0xb3c5: /* CDGR - convert from fixed */ | |
4491 | case 0xb3f6: /* IEDTR - insert biased exponent */ | |
4492 | /* float destination */ | |
4493 | if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[6])) | |
4494 | return -1; | |
4495 | break; | |
4496 | ||
4497 | /* 0xb246-0xb24c: privileged or unsupported */ | |
4498 | ||
4499 | case 0xb24d: /* CPYA - copy access */ | |
4500 | case 0xb24e: /* SAR - set access */ | |
4501 | if (record_full_arch_list_add_reg (regcache, S390_A0_REGNUM + inib[6])) | |
4502 | return -1; | |
4503 | break; | |
4504 | ||
4505 | /* 0xb250-0xb251 undefined or privileged */ | |
4506 | /* 0xb253-0xb254 undefined or privileged */ | |
4507 | ||
4508 | case 0xb255: /* MVST - move string [partial] */ | |
4509 | { | |
4510 | uint8_t end; | |
4511 | gdb_byte cur; | |
4512 | ULONGEST num = 0; | |
4513 | /* Read ending byte. */ | |
4514 | regcache_raw_read_unsigned (regcache, S390_R0_REGNUM, &tmp); | |
4515 | end = tmp & 0xff; | |
4516 | /* Get address of second operand. */ | |
4517 | regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[7], &tmp); | |
4518 | oaddr = s390_record_address_mask (gdbarch, regcache, tmp); | |
4519 | /* Search for ending byte and compute length. */ | |
4520 | do { | |
4521 | num++; | |
4522 | if (target_read_memory (oaddr, &cur, 1)) | |
4523 | return -1; | |
4524 | oaddr++; | |
4525 | } while (cur != end); | |
4526 | /* Get address of first operand and record it. */ | |
4527 | regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[6], &tmp); | |
4528 | oaddr = s390_record_address_mask (gdbarch, regcache, tmp); | |
4529 | if (record_full_arch_list_add_mem (oaddr, num)) | |
4530 | return -1; | |
4531 | /* Record the registers. */ | |
4532 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6])) | |
4533 | return -1; | |
4534 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[7])) | |
4535 | return -1; | |
4536 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
4537 | return -1; | |
4538 | } | |
4539 | break; | |
4540 | ||
4541 | /* 0xb256 undefined */ | |
4542 | ||
4543 | case 0xb257: /* CUSE - compare until substring equal [interruptible] */ | |
4544 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6])) | |
4545 | return -1; | |
4546 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[6] | 1))) | |
4547 | return -1; | |
4548 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[7])) | |
4549 | return -1; | |
4550 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[7] | 1))) | |
4551 | return -1; | |
4552 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
4553 | return -1; | |
4554 | break; | |
4555 | ||
4556 | /* 0xb258-0xb25c undefined, privileged, or unsupported */ | |
4557 | ||
4558 | case 0xb25d: /* CLST - compare logical string [partial] */ | |
4559 | case 0xb25e: /* SRST - search string [partial] */ | |
4560 | case 0xb9be: /* SRSTU - search string unicode [partial] */ | |
4561 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6])) | |
4562 | return -1; | |
4563 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[7])) | |
4564 | return -1; | |
4565 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
4566 | return -1; | |
4567 | break; | |
4568 | ||
4569 | /* 0xb25f-0xb262 undefined */ | |
4570 | ||
4571 | case 0xb263: /* CMPSC - compression call [interruptible] */ | |
4572 | regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[6], &tmp); | |
4573 | oaddr = s390_record_address_mask (gdbarch, regcache, tmp); | |
4574 | regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + (inib[6] | 1), &tmp); | |
4575 | if (record_full_arch_list_add_mem (oaddr, tmp)) | |
4576 | return -1; | |
4577 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6])) | |
4578 | return -1; | |
4579 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[6] | 1))) | |
4580 | return -1; | |
4581 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[7])) | |
4582 | return -1; | |
4583 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[7] | 1))) | |
4584 | return -1; | |
4585 | if (record_full_arch_list_add_reg (regcache, S390_R1_REGNUM)) | |
4586 | return -1; | |
4587 | /* DXC may be written */ | |
4588 | if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM)) | |
4589 | return -1; | |
4590 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
4591 | return -1; | |
4592 | break; | |
4593 | ||
4594 | /* 0xb264-0xb277 undefined, privileged, or unsupported */ | |
4595 | ||
4596 | case 0xb278: /* STCKE - store clock extended */ | |
4597 | oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0); | |
4598 | if (record_full_arch_list_add_mem (oaddr, 16)) | |
4599 | return -1; | |
4600 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
4601 | return -1; | |
4602 | break; | |
4603 | ||
4604 | /* 0xb279-0xb27b undefined or unsupported */ | |
4605 | /* 0xb27d-0xb298 undefined or privileged */ | |
4606 | ||
4607 | case 0xb299: /* SRNM - set rounding mode */ | |
4608 | case 0xb2b8: /* SRNMB - set bfp rounding mode */ | |
4609 | case 0xb2b9: /* SRNMT - set dfp rounding mode */ | |
4610 | case 0xb29d: /* LFPC - load fpc */ | |
4611 | case 0xb2bd: /* LFAS - load fpc and signal */ | |
4612 | case 0xb384: /* SFPC - set fpc */ | |
4613 | case 0xb385: /* SFASR - set fpc and signal */ | |
4614 | case 0xb960: /* CGRT - compare and trap */ | |
4615 | case 0xb961: /* CLGRT - compare logical and trap */ | |
4616 | case 0xb972: /* CRT - compare and trap */ | |
4617 | case 0xb973: /* CLRT - compare logical and trap */ | |
4618 | /* fpc only - including possible DXC write for trapping insns */ | |
4619 | if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM)) | |
4620 | return -1; | |
4621 | break; | |
4622 | ||
4623 | /* 0xb29a-0xb29b undefined */ | |
4624 | ||
4625 | case 0xb29c: /* STFPC - store fpc */ | |
4626 | oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0); | |
4627 | if (record_full_arch_list_add_mem (oaddr, 4)) | |
4628 | return -1; | |
4629 | break; | |
4630 | ||
4631 | /* 0xb29e-0xb2a4 undefined */ | |
4632 | ||
4633 | case 0xb2a5: /* TRE - translate extended [partial] */ | |
4634 | regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[6], &tmp); | |
4635 | oaddr = s390_record_address_mask (gdbarch, regcache, tmp); | |
4636 | regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + (inib[6] | 1), &tmp); | |
4637 | if (record_full_arch_list_add_mem (oaddr, tmp)) | |
4638 | return -1; | |
4639 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6])) | |
4640 | return -1; | |
4641 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[6] | 1))) | |
4642 | return -1; | |
4643 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
4644 | return -1; | |
4645 | break; | |
4646 | ||
4647 | case 0xb2a6: /* CU21 - convert UTF-16 to UTF-8 [partial] */ | |
4648 | case 0xb2a7: /* CU12 - convert UTF-8 to UTF-16 [partial] */ | |
4649 | case 0xb9b0: /* CU14 - convert UTF-8 to UTF-32 [partial] */ | |
4650 | case 0xb9b1: /* CU24 - convert UTF-16 to UTF-32 [partial] */ | |
4651 | case 0xb9b2: /* CU41 - convert UTF-32 to UTF-8 [partial] */ | |
4652 | case 0xb9b3: /* CU42 - convert UTF-32 to UTF-16 [partial] */ | |
4653 | regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[6], &tmp); | |
4654 | oaddr = s390_record_address_mask (gdbarch, regcache, tmp); | |
4655 | regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + (inib[6] | 1), &tmp); | |
4656 | if (record_full_arch_list_add_mem (oaddr, tmp)) | |
4657 | return -1; | |
4658 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6])) | |
4659 | return -1; | |
4660 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[6] | 1))) | |
4661 | return -1; | |
4662 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[7])) | |
4663 | return -1; | |
4664 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[7] | 1))) | |
4665 | return -1; | |
4666 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
4667 | return -1; | |
4668 | break; | |
4669 | ||
4670 | /* 0xb2a8-0xb2af undefined */ | |
4671 | ||
4672 | case 0xb2b0: /* STFLE - store facility list extended */ | |
4673 | oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0); | |
4674 | regcache_raw_read_unsigned (regcache, S390_R0_REGNUM, &tmp); | |
4675 | tmp &= 0xff; | |
4676 | if (record_full_arch_list_add_mem (oaddr, 8 * (tmp + 1))) | |
4677 | return -1; | |
4678 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM)) | |
4679 | return -1; | |
4680 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
4681 | return -1; | |
4682 | break; | |
4683 | ||
4684 | /* 0xb2b1-0xb2b7 undefined or privileged */ | |
4685 | /* 0xb2ba-0xb2bc undefined */ | |
4686 | /* 0xb2be-0xb2e7 undefined */ | |
4687 | /* 0xb2e9-0xb2eb undefined */ | |
4688 | /* 0xb2ed-0xb2f7 undefined */ | |
4689 | /* 0xb2f8 unsupported: TEND */ | |
4690 | /* 0xb2f9 undefined */ | |
4691 | ||
4692 | case 0xb2e8: /* PPA - perform processor assist */ | |
4693 | case 0xb2fa: /* NIAI - next instruction access intent */ | |
4694 | /* no visible effects */ | |
4695 | break; | |
4696 | ||
4697 | /* 0xb2fb undefined */ | |
4698 | /* 0xb2fc unsupported: TABORT */ | |
4699 | /* 0xb2fd-0xb2fe undefined */ | |
4700 | /* 0xb2ff unsupported: TRAP */ | |
4701 | ||
4702 | case 0xb300: /* LPEBR - load positive */ | |
4703 | case 0xb301: /* LNEBR - load negative */ | |
4704 | case 0xb303: /* LCEBR - load complement */ | |
4705 | case 0xb310: /* LPDBR - load positive */ | |
4706 | case 0xb311: /* LNDBR - load negative */ | |
4707 | case 0xb313: /* LCDBR - load complement */ | |
4708 | case 0xb350: /* TBEDR - convert hfp to bfp */ | |
4709 | case 0xb351: /* TBDR - convert hfp to bfp */ | |
4710 | case 0xb358: /* THDER - convert bfp to hfp */ | |
4711 | case 0xb359: /* THDR - convert bfp to hfp */ | |
4712 | /* float destination + flags */ | |
4713 | if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[6])) | |
4714 | return -1; | |
4715 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
4716 | return -1; | |
4717 | break; | |
4718 | ||
4719 | case 0xb304: /* LDEBR - load lengthened */ | |
4720 | case 0xb30c: /* MDEBR - multiply */ | |
4721 | case 0xb30d: /* DEBR - divide */ | |
4722 | case 0xb314: /* SQEBR - square root */ | |
4723 | case 0xb315: /* SQDBR - square root */ | |
4724 | case 0xb317: /* MEEBR - multiply */ | |
4725 | case 0xb31c: /* MDBR - multiply */ | |
4726 | case 0xb31d: /* DDBR - divide */ | |
4727 | case 0xb344: /* LEDBRA - load rounded */ | |
4728 | case 0xb345: /* LDXBRA - load rounded */ | |
4729 | case 0xb346: /* LEXBRA - load rounded */ | |
4730 | case 0xb357: /* FIEBRA - load fp integer */ | |
4731 | case 0xb35f: /* FIDBRA - load fp integer */ | |
4732 | case 0xb390: /* CELFBR - convert from logical */ | |
4733 | case 0xb391: /* CDLFBR - convert from logical */ | |
4734 | case 0xb394: /* CEFBR - convert from fixed */ | |
4735 | case 0xb395: /* CDFBR - convert from fixed */ | |
4736 | case 0xb3a0: /* CELGBR - convert from logical */ | |
4737 | case 0xb3a1: /* CDLGBR - convert from logical */ | |
4738 | case 0xb3a4: /* CEGBR - convert from fixed */ | |
4739 | case 0xb3a5: /* CDGBR - convert from fixed */ | |
4740 | case 0xb3d0: /* MDTR - multiply */ | |
4741 | case 0xb3d1: /* DDTR - divide */ | |
4742 | case 0xb3d4: /* LDETR - load lengthened */ | |
4743 | case 0xb3d5: /* LEDTR - load lengthened */ | |
4744 | case 0xb3d7: /* FIDTR - load fp integer */ | |
4745 | case 0xb3dd: /* LDXTR - load lengthened */ | |
4746 | case 0xb3f1: /* CDGTR - convert from fixed */ | |
4747 | case 0xb3f2: /* CDUTR - convert from unsigned packed */ | |
4748 | case 0xb3f3: /* CDSTR - convert from signed packed */ | |
4749 | case 0xb3f5: /* QADTR - quantize */ | |
4750 | case 0xb3f7: /* RRDTR - reround */ | |
4751 | case 0xb951: /* CDFTR - convert from fixed */ | |
4752 | case 0xb952: /* CDLGTR - convert from logical */ | |
4753 | case 0xb953: /* CDLFTR - convert from logical */ | |
4754 | /* float destination + fpc */ | |
4755 | if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[6])) | |
4756 | return -1; | |
4757 | if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM)) | |
4758 | return -1; | |
4759 | break; | |
4760 | ||
4761 | case 0xb305: /* LXDBR - load lengthened */ | |
4762 | case 0xb306: /* LXEBR - load lengthened */ | |
4763 | case 0xb307: /* MXDBR - multiply */ | |
4764 | case 0xb316: /* SQXBR - square root */ | |
4765 | case 0xb34c: /* MXBR - multiply */ | |
4766 | case 0xb34d: /* DXBR - divide */ | |
4767 | case 0xb347: /* FIXBRA - load fp integer */ | |
4768 | case 0xb392: /* CXLFBR - convert from logical */ | |
4769 | case 0xb396: /* CXFBR - convert from fixed */ | |
4770 | case 0xb3a2: /* CXLGBR - convert from logical */ | |
4771 | case 0xb3a6: /* CXGBR - convert from fixed */ | |
4772 | case 0xb3d8: /* MXTR - multiply */ | |
4773 | case 0xb3d9: /* DXTR - divide */ | |
4774 | case 0xb3dc: /* LXDTR - load lengthened */ | |
4775 | case 0xb3df: /* FIXTR - load fp integer */ | |
4776 | case 0xb3f9: /* CXGTR - convert from fixed */ | |
4777 | case 0xb3fa: /* CXUTR - convert from unsigned packed */ | |
4778 | case 0xb3fb: /* CXSTR - convert from signed packed */ | |
4779 | case 0xb3fd: /* QAXTR - quantize */ | |
4780 | case 0xb3ff: /* RRXTR - reround */ | |
4781 | case 0xb959: /* CXFTR - convert from fixed */ | |
4782 | case 0xb95a: /* CXLGTR - convert from logical */ | |
4783 | case 0xb95b: /* CXLFTR - convert from logical */ | |
4784 | /* float pair destination + fpc */ | |
4785 | if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[6])) | |
4786 | return -1; | |
4787 | if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + (inib[6] | 2))) | |
4788 | return -1; | |
4789 | if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM)) | |
4790 | return -1; | |
4791 | break; | |
4792 | ||
4793 | case 0xb308: /* KEBR - compare and signal */ | |
4794 | case 0xb309: /* CEBR - compare */ | |
4795 | case 0xb318: /* KDBR - compare and signal */ | |
4796 | case 0xb319: /* CDBR - compare */ | |
4797 | case 0xb348: /* KXBR - compare and signal */ | |
4798 | case 0xb349: /* CXBR - compare */ | |
4799 | case 0xb3e0: /* KDTR - compare and signal */ | |
4800 | case 0xb3e4: /* CDTR - compare */ | |
4801 | case 0xb3e8: /* KXTR - compare and signal */ | |
4802 | case 0xb3ec: /* CXTR - compare */ | |
4803 | /* flags + fpc only */ | |
4804 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
4805 | return -1; | |
4806 | if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM)) | |
4807 | return -1; | |
4808 | break; | |
4809 | ||
4810 | case 0xb302: /* LTEBR - load and test */ | |
4811 | case 0xb312: /* LTDBR - load and test */ | |
4812 | case 0xb30a: /* AEBR - add */ | |
4813 | case 0xb30b: /* SEBR - subtract */ | |
4814 | case 0xb31a: /* ADBR - add */ | |
4815 | case 0xb31b: /* SDBR - subtract */ | |
4816 | case 0xb3d2: /* ADTR - add */ | |
4817 | case 0xb3d3: /* SDTR - subtract */ | |
4818 | case 0xb3d6: /* LTDTR - load and test */ | |
4819 | /* float destination + flags + fpc */ | |
4820 | if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[6])) | |
4821 | return -1; | |
4822 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
4823 | return -1; | |
4824 | if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM)) | |
4825 | return -1; | |
4826 | break; | |
4827 | ||
4828 | case 0xb30e: /* MAEBR - multiply and add */ | |
4829 | case 0xb30f: /* MSEBR - multiply and subtract */ | |
4830 | case 0xb31e: /* MADBR - multiply and add */ | |
4831 | case 0xb31f: /* MSDBR - multiply and subtract */ | |
4832 | /* float destination [RRD] + fpc */ | |
4833 | if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[4])) | |
4834 | return -1; | |
4835 | if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM)) | |
4836 | return -1; | |
4837 | break; | |
4838 | ||
4839 | /* 0xb320-0xb323 undefined */ | |
4840 | /* 0xb327-0xb32d undefined */ | |
4841 | ||
4842 | case 0xb32e: /* MAER - multiply and add */ | |
4843 | case 0xb32f: /* MSER - multiply and subtract */ | |
4844 | case 0xb338: /* MAYLR - multiply and add unnormalized */ | |
4845 | case 0xb339: /* MYLR - multiply unnormalized */ | |
4846 | case 0xb33c: /* MAYHR - multiply and add unnormalized */ | |
4847 | case 0xb33d: /* MYHR - multiply unnormalized */ | |
4848 | case 0xb33e: /* MADR - multiply and add */ | |
4849 | case 0xb33f: /* MSDR - multiply and subtract */ | |
4850 | /* float destination [RRD] */ | |
4851 | if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[4])) | |
4852 | return -1; | |
4853 | break; | |
4854 | ||
4855 | /* 0xb330-0xb335 undefined */ | |
4856 | ||
4857 | case 0xb33a: /* MAYR - multiply and add unnormalized */ | |
4858 | case 0xb33b: /* MYR - multiply unnormalized */ | |
4859 | /* float pair destination [RRD] */ | |
4860 | if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[4])) | |
4861 | return -1; | |
4862 | if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + (inib[4] | 2))) | |
4863 | return -1; | |
4864 | break; | |
4865 | ||
4866 | case 0xb340: /* LPXBR - load positive */ | |
4867 | case 0xb341: /* LNXBR - load negative */ | |
4868 | case 0xb343: /* LCXBR - load complement */ | |
4869 | case 0xb360: /* LPXR - load positive */ | |
4870 | case 0xb361: /* LNXR - load negative */ | |
4871 | case 0xb362: /* LTXR - load and test */ | |
4872 | case 0xb363: /* LCXR - load complement */ | |
4873 | /* float pair destination + flags */ | |
4874 | if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[6])) | |
4875 | return -1; | |
4876 | if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + (inib[6] | 2))) | |
4877 | return -1; | |
4878 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
4879 | return -1; | |
4880 | break; | |
4881 | ||
4882 | case 0xb342: /* LTXBR - load and test */ | |
4883 | case 0xb34a: /* AXBR - add */ | |
4884 | case 0xb34b: /* SXBR - subtract */ | |
4885 | case 0xb3da: /* AXTR - add */ | |
4886 | case 0xb3db: /* SXTR - subtract */ | |
4887 | case 0xb3de: /* LTXTR - load and test */ | |
4888 | /* float pair destination + flags + fpc */ | |
4889 | if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[6])) | |
4890 | return -1; | |
4891 | if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + (inib[6] | 2))) | |
4892 | return -1; | |
4893 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
4894 | return -1; | |
4895 | if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM)) | |
4896 | return -1; | |
4897 | break; | |
4898 | ||
4899 | /* 0xb34e-0xb34f undefined */ | |
4900 | /* 0xb352 undefined */ | |
4901 | ||
4902 | case 0xb353: /* DIEBR - divide to integer */ | |
4903 | case 0xb35b: /* DIDBR - divide to integer */ | |
4904 | /* two float destinations + flags + fpc */ | |
4905 | if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[4])) | |
4906 | return -1; | |
4907 | if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[6])) | |
4908 | return -1; | |
4909 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
4910 | return -1; | |
4911 | if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM)) | |
4912 | return -1; | |
4913 | break; | |
4914 | ||
4915 | /* 0xb354-0xb356 undefined */ | |
4916 | /* 0xb35a undefined */ | |
4917 | ||
4918 | /* 0xb35c-0xb35e undefined */ | |
4919 | /* 0xb364 undefined */ | |
4920 | /* 0xb368 undefined */ | |
4921 | ||
4922 | case 0xb369: /* CXR - compare */ | |
4923 | case 0xb3f4: /* CEDTR - compare biased exponent */ | |
4924 | case 0xb3fc: /* CEXTR - compare biased exponent */ | |
4925 | case 0xb920: /* CGR - compare */ | |
4926 | case 0xb921: /* CLGR - compare logical */ | |
4927 | case 0xb930: /* CGFR - compare */ | |
4928 | case 0xb931: /* CLGFR - compare logical */ | |
4929 | case 0xb9cd: /* CHHR - compare high */ | |
4930 | case 0xb9cf: /* CLHHR - compare logical high */ | |
4931 | case 0xb9dd: /* CHLR - compare high */ | |
4932 | case 0xb9df: /* CLHLR - compare logical high */ | |
4933 | /* flags only */ | |
4934 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
4935 | return -1; | |
4936 | break; | |
4937 | ||
4938 | /* 0xb36a-0xb36f undefined */ | |
4939 | /* 0xb377-0xb37e undefined */ | |
4940 | /* 0xb380-0xb383 undefined */ | |
4941 | /* 0xb386-0xb38b undefined */ | |
4942 | /* 0xb38d-0xb38f undefined */ | |
4943 | /* 0xb393 undefined */ | |
4944 | /* 0xb397 undefined */ | |
4945 | ||
4946 | case 0xb398: /* CFEBR - convert to fixed */ | |
4947 | case 0xb399: /* CFDBR - convert to fixed */ | |
4948 | case 0xb39a: /* CFXBR - convert to fixed */ | |
4949 | case 0xb39c: /* CLFEBR - convert to logical */ | |
4950 | case 0xb39d: /* CLFDBR - convert to logical */ | |
4951 | case 0xb39e: /* CLFXBR - convert to logical */ | |
4952 | case 0xb941: /* CFDTR - convert to fixed */ | |
4953 | case 0xb949: /* CFXTR - convert to fixed */ | |
4954 | case 0xb943: /* CLFDTR - convert to logical */ | |
4955 | case 0xb94b: /* CLFXTR - convert to logical */ | |
4956 | /* 32-bit gpr destination + flags + fpc */ | |
4957 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6])) | |
4958 | return -1; | |
4959 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
4960 | return -1; | |
4961 | if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM)) | |
4962 | return -1; | |
4963 | break; | |
4964 | ||
4965 | /* 0xb39b undefined */ | |
4966 | /* 0xb39f undefined */ | |
4967 | ||
4968 | /* 0xb3a3 undefined */ | |
4969 | /* 0xb3a7 undefined */ | |
4970 | ||
4971 | case 0xb3a8: /* CGEBR - convert to fixed */ | |
4972 | case 0xb3a9: /* CGDBR - convert to fixed */ | |
4973 | case 0xb3aa: /* CGXBR - convert to fixed */ | |
4974 | case 0xb3ac: /* CLGEBR - convert to logical */ | |
4975 | case 0xb3ad: /* CLGDBR - convert to logical */ | |
4976 | case 0xb3ae: /* CLGXBR - convert to logical */ | |
4977 | case 0xb3e1: /* CGDTR - convert to fixed */ | |
4978 | case 0xb3e9: /* CGXTR - convert to fixed */ | |
4979 | case 0xb942: /* CLGDTR - convert to logical */ | |
4980 | case 0xb94a: /* CLGXTR - convert to logical */ | |
4981 | /* 64-bit gpr destination + flags + fpc */ | |
4982 | if (s390_record_gpr_g (gdbarch, regcache, inib[6])) | |
4983 | return -1; | |
4984 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
4985 | return -1; | |
4986 | if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM)) | |
4987 | return -1; | |
4988 | break; | |
4989 | ||
4990 | /* 0xb3ab undefined */ | |
4991 | /* 0xb3af-0xb3b3 undefined */ | |
4992 | /* 0xb3b7 undefined */ | |
4993 | ||
4994 | case 0xb3b8: /* CFER - convert to fixed */ | |
4995 | case 0xb3b9: /* CFDR - convert to fixed */ | |
4996 | case 0xb3ba: /* CFXR - convert to fixed */ | |
4997 | case 0xb998: /* ALCR - add logical with carry */ | |
4998 | case 0xb999: /* SLBR - subtract logical with borrow */ | |
4999 | case 0xb9f4: /* NRK - and */ | |
5000 | case 0xb9f6: /* ORK - or */ | |
5001 | case 0xb9f7: /* XRK - xor */ | |
5002 | case 0xb9f8: /* ARK - add */ | |
5003 | case 0xb9f9: /* SRK - subtract */ | |
5004 | case 0xb9fa: /* ALRK - add logical */ | |
5005 | case 0xb9fb: /* SLRK - subtract logical */ | |
5006 | /* 32-bit gpr destination + flags */ | |
5007 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6])) | |
5008 | return -1; | |
5009 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
5010 | return -1; | |
5011 | break; | |
5012 | ||
5013 | case 0xb3c8: /* CGER - convert to fixed */ | |
5014 | case 0xb3c9: /* CGDR - convert to fixed */ | |
5015 | case 0xb3ca: /* CGXR - convert to fixed */ | |
5016 | case 0xb900: /* LPGR - load positive */ | |
5017 | case 0xb901: /* LNGR - load negative */ | |
5018 | case 0xb902: /* LTGR - load and test */ | |
5019 | case 0xb903: /* LCGR - load complement */ | |
5020 | case 0xb908: /* AGR - add */ | |
5021 | case 0xb909: /* SGR - subtract */ | |
5022 | case 0xb90a: /* ALGR - add logical */ | |
5023 | case 0xb90b: /* SLGR - subtract logical */ | |
5024 | case 0xb910: /* LPGFR - load positive */ | |
5025 | case 0xb911: /* LNGFR - load negative */ | |
5026 | case 0xb912: /* LTGFR - load and test */ | |
5027 | case 0xb913: /* LCGFR - load complement */ | |
5028 | case 0xb918: /* AGFR - add */ | |
5029 | case 0xb919: /* SGFR - subtract */ | |
5030 | case 0xb91a: /* ALGFR - add logical */ | |
5031 | case 0xb91b: /* SLGFR - subtract logical */ | |
5032 | case 0xb980: /* NGR - and */ | |
5033 | case 0xb981: /* OGR - or */ | |
5034 | case 0xb982: /* XGR - xor */ | |
5035 | case 0xb988: /* ALCGR - add logical with carry */ | |
5036 | case 0xb989: /* SLBGR - subtract logical with borrow */ | |
5037 | case 0xb9e1: /* POPCNT - population count */ | |
5038 | case 0xb9e4: /* NGRK - and */ | |
5039 | case 0xb9e6: /* OGRK - or */ | |
5040 | case 0xb9e7: /* XGRK - xor */ | |
5041 | case 0xb9e8: /* AGRK - add */ | |
5042 | case 0xb9e9: /* SGRK - subtract */ | |
5043 | case 0xb9ea: /* ALGRK - add logical */ | |
5044 | case 0xb9eb: /* SLGRK - subtract logical */ | |
5045 | /* 64-bit gpr destination + flags */ | |
5046 | if (s390_record_gpr_g (gdbarch, regcache, inib[6])) | |
5047 | return -1; | |
5048 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
5049 | return -1; | |
5050 | break; | |
5051 | ||
5052 | /* 0xb3bb-0xb3c0 undefined */ | |
5053 | /* 0xb3c2-0xb3c3 undefined */ | |
5054 | /* 0xb3c7 undefined */ | |
5055 | /* 0xb3cb-0xb3cc undefined */ | |
5056 | ||
5057 | case 0xb3cd: /* LGDR - load gr from fpr */ | |
5058 | case 0xb3e2: /* CUDTR - convert to unsigned packed */ | |
5059 | case 0xb3e3: /* CSDTR - convert to signed packed */ | |
5060 | case 0xb3e5: /* EEDTR - extract biased exponent */ | |
5061 | case 0xb3e7: /* ESDTR - extract significance */ | |
5062 | case 0xb3ed: /* EEXTR - extract biased exponent */ | |
5063 | case 0xb3ef: /* ESXTR - extract significance */ | |
5064 | case 0xb904: /* LGR - load */ | |
5065 | case 0xb906: /* LGBR - load byte */ | |
5066 | case 0xb907: /* LGHR - load halfword */ | |
5067 | case 0xb90c: /* MSGR - multiply single */ | |
5068 | case 0xb90f: /* LRVGR - load reversed */ | |
5069 | case 0xb914: /* LGFR - load */ | |
5070 | case 0xb916: /* LLGFR - load logical */ | |
5071 | case 0xb917: /* LLGTR - load logical thirty one bits */ | |
5072 | case 0xb91c: /* MSGFR - load */ | |
5073 | case 0xb946: /* BCTGR - branch on count */ | |
5074 | case 0xb984: /* LLGCR - load logical character */ | |
5075 | case 0xb985: /* LLGHR - load logical halfword */ | |
5076 | case 0xb9e2: /* LOCGR - load on condition */ | |
5077 | /* 64-bit gpr destination */ | |
5078 | if (s390_record_gpr_g (gdbarch, regcache, inib[6])) | |
5079 | return -1; | |
5080 | break; | |
5081 | ||
5082 | /* 0xb3ce-0xb3cf undefined */ | |
5083 | /* 0xb3e6 undefined */ | |
5084 | ||
5085 | case 0xb3ea: /* CUXTR - convert to unsigned packed */ | |
5086 | case 0xb3eb: /* CSXTR - convert to signed packed */ | |
5087 | case 0xb90d: /* DSGR - divide single */ | |
5088 | case 0xb91d: /* DSGFR - divide single */ | |
5089 | case 0xb986: /* MLGR - multiply logical */ | |
5090 | case 0xb987: /* DLGR - divide logical */ | |
5091 | /* 64-bit gpr pair destination */ | |
5092 | if (s390_record_gpr_g (gdbarch, regcache, inib[6])) | |
5093 | return -1; | |
5094 | if (s390_record_gpr_g (gdbarch, regcache, inib[6] | 1)) | |
5095 | return -1; | |
5096 | break; | |
5097 | ||
5098 | /* 0xb3ee undefined */ | |
5099 | /* 0xb3f0 undefined */ | |
5100 | /* 0xb3f8 undefined */ | |
5101 | ||
5102 | /* 0xb905 privileged */ | |
5103 | ||
5104 | /* 0xb90e unsupported: EREGG */ | |
5105 | ||
5106 | /* 0xb915 undefined */ | |
5107 | ||
5108 | case 0xb91e: /* KMAC - compute message authentication code [partial] */ | |
5109 | regcache_raw_read_unsigned (regcache, S390_R1_REGNUM, &tmp); | |
5110 | oaddr = s390_record_address_mask (gdbarch, regcache, tmp); | |
5111 | regcache_raw_read_unsigned (regcache, S390_R0_REGNUM, &tmp); | |
5112 | tmp &= 0xff; | |
5113 | switch (tmp) | |
5114 | { | |
5115 | case 0x00: /* KMAC-Query */ | |
5116 | if (record_full_arch_list_add_mem (oaddr, 16)) | |
5117 | return -1; | |
5118 | break; | |
5119 | ||
5120 | case 0x01: /* KMAC-DEA */ | |
5121 | case 0x02: /* KMAC-TDEA-128 */ | |
5122 | case 0x03: /* KMAC-TDEA-192 */ | |
5123 | case 0x09: /* KMAC-Encrypted-DEA */ | |
5124 | case 0x0a: /* KMAC-Encrypted-TDEA-128 */ | |
5125 | case 0x0b: /* KMAC-Encrypted-TDEA-192 */ | |
5126 | if (record_full_arch_list_add_mem (oaddr, 8)) | |
5127 | return -1; | |
5128 | break; | |
5129 | ||
5130 | case 0x12: /* KMAC-AES-128 */ | |
5131 | case 0x13: /* KMAC-AES-192 */ | |
5132 | case 0x14: /* KMAC-AES-256 */ | |
5133 | case 0x1a: /* KMAC-Encrypted-AES-128 */ | |
5134 | case 0x1b: /* KMAC-Encrypted-AES-192 */ | |
5135 | case 0x1c: /* KMAC-Encrypted-AES-256 */ | |
5136 | if (record_full_arch_list_add_mem (oaddr, 16)) | |
5137 | return -1; | |
5138 | break; | |
5139 | ||
5140 | default: | |
5141 | fprintf_unfiltered (gdb_stdlog, "Warning: Unknown KMAC function %02x at %s.\n", | |
5142 | (int)tmp, paddress (gdbarch, addr)); | |
5143 | return -1; | |
5144 | } | |
5145 | if (tmp != 0) | |
5146 | { | |
5147 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[7])) | |
5148 | return -1; | |
5149 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[7] | 1))) | |
5150 | return -1; | |
5151 | } | |
5152 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
5153 | return -1; | |
5154 | break; | |
5155 | ||
5156 | /* 0xb922-0xb924 undefined */ | |
5157 | /* 0xb925 privileged */ | |
5158 | /* 0xb928 privileged */ | |
5159 | /* 0xb929 undefined */ | |
5160 | ||
5161 | case 0xb92a: /* KMF - cipher message with cipher feedback [partial] */ | |
5162 | case 0xb92b: /* KMO - cipher message with output feedback [partial] */ | |
5163 | case 0xb92f: /* KMC - cipher message with chaining [partial] */ | |
5164 | regcache_raw_read_unsigned (regcache, S390_R1_REGNUM, &tmp); | |
5165 | oaddr = s390_record_address_mask (gdbarch, regcache, tmp); | |
5166 | regcache_raw_read_unsigned (regcache, S390_R0_REGNUM, &tmp); | |
5167 | tmp &= 0x7f; | |
5168 | switch (tmp) | |
5169 | { | |
5170 | case 0x00: /* KM*-Query */ | |
5171 | if (record_full_arch_list_add_mem (oaddr, 16)) | |
5172 | return -1; | |
5173 | break; | |
5174 | ||
5175 | case 0x01: /* KM*-DEA */ | |
5176 | case 0x02: /* KM*-TDEA-128 */ | |
5177 | case 0x03: /* KM*-TDEA-192 */ | |
5178 | case 0x09: /* KM*-Encrypted-DEA */ | |
5179 | case 0x0a: /* KM*-Encrypted-TDEA-128 */ | |
5180 | case 0x0b: /* KM*-Encrypted-TDEA-192 */ | |
5181 | if (record_full_arch_list_add_mem (oaddr, 8)) | |
5182 | return -1; | |
5183 | break; | |
5184 | ||
5185 | case 0x12: /* KM*-AES-128 */ | |
5186 | case 0x13: /* KM*-AES-192 */ | |
5187 | case 0x14: /* KM*-AES-256 */ | |
5188 | case 0x1a: /* KM*-Encrypted-AES-128 */ | |
5189 | case 0x1b: /* KM*-Encrypted-AES-192 */ | |
5190 | case 0x1c: /* KM*-Encrypted-AES-256 */ | |
5191 | if (record_full_arch_list_add_mem (oaddr, 16)) | |
5192 | return -1; | |
5193 | break; | |
5194 | ||
5195 | case 0x43: /* KMC-PRNG */ | |
5196 | /* Only valid for KMC. */ | |
5197 | if (insn[0] == 0xb92f) | |
5198 | { | |
5199 | if (record_full_arch_list_add_mem (oaddr, 8)) | |
5200 | return -1; | |
5201 | break; | |
5202 | } | |
5203 | /* For other instructions, fallthru. */ | |
5204 | default: | |
5205 | fprintf_unfiltered (gdb_stdlog, "Warning: Unknown KM* function %02x at %s.\n", | |
5206 | (int)tmp, paddress (gdbarch, addr)); | |
5207 | return -1; | |
5208 | } | |
5209 | if (tmp != 0) | |
5210 | { | |
5211 | regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[6], &tmp); | |
5212 | oaddr2 = s390_record_address_mask (gdbarch, regcache, tmp); | |
5213 | regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + (inib[7] | 1), &tmp); | |
5214 | if (record_full_arch_list_add_mem (oaddr2, tmp)) | |
5215 | return -1; | |
5216 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6])) | |
5217 | return -1; | |
5218 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[7])) | |
5219 | return -1; | |
5220 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[7] | 1))) | |
5221 | return -1; | |
5222 | } | |
5223 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
5224 | return -1; | |
5225 | break; | |
5226 | ||
5227 | case 0xb92c: /* PCC - perform cryptographic computation [partial] */ | |
5228 | regcache_raw_read_unsigned (regcache, S390_R1_REGNUM, &tmp); | |
5229 | oaddr = s390_record_address_mask (gdbarch, regcache, tmp); | |
5230 | regcache_raw_read_unsigned (regcache, S390_R0_REGNUM, &tmp); | |
5231 | tmp &= 0x7f; | |
5232 | switch (tmp) | |
5233 | { | |
5234 | case 0x00: /* PCC-Query */ | |
5235 | if (record_full_arch_list_add_mem (oaddr, 16)) | |
5236 | return -1; | |
5237 | break; | |
5238 | ||
5239 | case 0x01: /* PCC-Compute-Last-Block-CMAC-Using-DEA */ | |
5240 | case 0x02: /* PCC-Compute-Last-Block-CMAC-Using-TDEA-128 */ | |
5241 | case 0x03: /* PCC-Compute-Last-Block-CMAC-Using-TDEA-192 */ | |
5242 | case 0x09: /* PCC-Compute-Last-Block-CMAC-Using-Encrypted-DEA */ | |
5243 | case 0x0a: /* PCC-Compute-Last-Block-CMAC-Using-Encrypted-TDEA-128 */ | |
5244 | case 0x0b: /* PCC-Compute-Last-Block-CMAC-Using-Encrypted-TDEA-192 */ | |
5245 | if (record_full_arch_list_add_mem (oaddr + 0x10, 8)) | |
5246 | return -1; | |
5247 | break; | |
5248 | ||
5249 | case 0x12: /* PCC-Compute-Last-Block-CMAC-Using-AES-128 */ | |
5250 | case 0x13: /* PCC-Compute-Last-Block-CMAC-Using-AES-192 */ | |
5251 | case 0x14: /* PCC-Compute-Last-Block-CMAC-Using-AES-256 */ | |
5252 | case 0x1a: /* PCC-Compute-Last-Block-CMAC-Using-Encrypted-AES-128 */ | |
5253 | case 0x1b: /* PCC-Compute-Last-Block-CMAC-Using-Encrypted-AES-192 */ | |
5254 | case 0x1c: /* PCC-Compute-Last-Block-CMAC-Using-Encrypted-AES-256 */ | |
5255 | if (record_full_arch_list_add_mem (oaddr + 0x18, 16)) | |
5256 | return -1; | |
5257 | break; | |
5258 | ||
5259 | case 0x32: /* PCC-Compute-XTS-Parameter-Using-AES-128 */ | |
5260 | if (record_full_arch_list_add_mem (oaddr + 0x30, 32)) | |
5261 | return -1; | |
5262 | break; | |
5263 | ||
5264 | case 0x34: /* PCC-Compute-XTS-Parameter-Using-AES-256 */ | |
5265 | if (record_full_arch_list_add_mem (oaddr + 0x40, 32)) | |
5266 | return -1; | |
5267 | break; | |
5268 | ||
5269 | case 0x3a: /* PCC-Compute-XTS-Parameter-Using-Encrypted-AES-128 */ | |
5270 | if (record_full_arch_list_add_mem (oaddr + 0x50, 32)) | |
5271 | return -1; | |
5272 | break; | |
5273 | ||
5274 | case 0x3c: /* PCC-Compute-XTS-Parameter-Using-Encrypted-AES-256 */ | |
5275 | if (record_full_arch_list_add_mem (oaddr + 0x60, 32)) | |
5276 | return -1; | |
5277 | break; | |
5278 | ||
5279 | default: | |
5280 | fprintf_unfiltered (gdb_stdlog, "Warning: Unknown PCC function %02x at %s.\n", | |
5281 | (int)tmp, paddress (gdbarch, addr)); | |
5282 | return -1; | |
5283 | } | |
5284 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
5285 | return -1; | |
5286 | break; | |
5287 | ||
5288 | case 0xb92d: /* KMCTR - cipher message with counter [partial] */ | |
5289 | regcache_raw_read_unsigned (regcache, S390_R1_REGNUM, &tmp); | |
5290 | oaddr = s390_record_address_mask (gdbarch, regcache, tmp); | |
5291 | regcache_raw_read_unsigned (regcache, S390_R0_REGNUM, &tmp); | |
5292 | tmp &= 0x7f; | |
5293 | switch (tmp) | |
5294 | { | |
5295 | case 0x00: /* KMCTR-Query */ | |
5296 | if (record_full_arch_list_add_mem (oaddr, 16)) | |
5297 | return -1; | |
5298 | break; | |
5299 | ||
5300 | case 0x01: /* KMCTR-DEA */ | |
5301 | case 0x02: /* KMCTR-TDEA-128 */ | |
5302 | case 0x03: /* KMCTR-TDEA-192 */ | |
5303 | case 0x09: /* KMCTR-Encrypted-DEA */ | |
5304 | case 0x0a: /* KMCTR-Encrypted-TDEA-128 */ | |
5305 | case 0x0b: /* KMCTR-Encrypted-TDEA-192 */ | |
5306 | case 0x12: /* KMCTR-AES-128 */ | |
5307 | case 0x13: /* KMCTR-AES-192 */ | |
5308 | case 0x14: /* KMCTR-AES-256 */ | |
5309 | case 0x1a: /* KMCTR-Encrypted-AES-128 */ | |
5310 | case 0x1b: /* KMCTR-Encrypted-AES-192 */ | |
5311 | case 0x1c: /* KMCTR-Encrypted-AES-256 */ | |
5312 | break; | |
5313 | ||
5314 | default: | |
5315 | fprintf_unfiltered (gdb_stdlog, "Warning: Unknown KMCTR function %02x at %s.\n", | |
5316 | (int)tmp, paddress (gdbarch, addr)); | |
5317 | return -1; | |
5318 | } | |
5319 | if (tmp != 0) | |
5320 | { | |
5321 | regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[6], &tmp); | |
5322 | oaddr2 = s390_record_address_mask (gdbarch, regcache, tmp); | |
5323 | regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + (inib[7] | 1), &tmp); | |
5324 | if (record_full_arch_list_add_mem (oaddr2, tmp)) | |
5325 | return -1; | |
5326 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6])) | |
5327 | return -1; | |
5328 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[7])) | |
5329 | return -1; | |
5330 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[7] | 1))) | |
5331 | return -1; | |
5332 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[4])) | |
5333 | return -1; | |
5334 | } | |
5335 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
5336 | return -1; | |
5337 | break; | |
5338 | ||
5339 | case 0xb92e: /* KM - cipher message [partial] */ | |
5340 | regcache_raw_read_unsigned (regcache, S390_R1_REGNUM, &tmp); | |
5341 | oaddr = s390_record_address_mask (gdbarch, regcache, tmp); | |
5342 | regcache_raw_read_unsigned (regcache, S390_R0_REGNUM, &tmp); | |
5343 | tmp &= 0x7f; | |
5344 | switch (tmp) | |
5345 | { | |
5346 | case 0x00: /* KM-Query */ | |
5347 | if (record_full_arch_list_add_mem (oaddr, 16)) | |
5348 | return -1; | |
5349 | break; | |
5350 | ||
5351 | case 0x01: /* KM-DEA */ | |
5352 | case 0x02: /* KM-TDEA-128 */ | |
5353 | case 0x03: /* KM-TDEA-192 */ | |
5354 | case 0x09: /* KM-Encrypted-DEA */ | |
5355 | case 0x0a: /* KM-Encrypted-TDEA-128 */ | |
5356 | case 0x0b: /* KM-Encrypted-TDEA-192 */ | |
5357 | case 0x12: /* KM-AES-128 */ | |
5358 | case 0x13: /* KM-AES-192 */ | |
5359 | case 0x14: /* KM-AES-256 */ | |
5360 | case 0x1a: /* KM-Encrypted-AES-128 */ | |
5361 | case 0x1b: /* KM-Encrypted-AES-192 */ | |
5362 | case 0x1c: /* KM-Encrypted-AES-256 */ | |
5363 | break; | |
5364 | ||
5365 | case 0x32: /* KM-XTS-AES-128 */ | |
5366 | if (record_full_arch_list_add_mem (oaddr + 0x10, 16)) | |
5367 | return -1; | |
5368 | break; | |
5369 | ||
5370 | case 0x34: /* KM-XTS-AES-256 */ | |
5371 | if (record_full_arch_list_add_mem (oaddr + 0x20, 16)) | |
5372 | return -1; | |
5373 | break; | |
5374 | ||
5375 | case 0x3a: /* KM-XTS-Encrypted-AES-128 */ | |
5376 | if (record_full_arch_list_add_mem (oaddr + 0x30, 16)) | |
5377 | return -1; | |
5378 | break; | |
5379 | ||
5380 | case 0x3c: /* KM-XTS-Encrypted-AES-256 */ | |
5381 | if (record_full_arch_list_add_mem (oaddr + 0x40, 16)) | |
5382 | return -1; | |
5383 | break; | |
5384 | ||
5385 | default: | |
5386 | fprintf_unfiltered (gdb_stdlog, "Warning: Unknown KM function %02x at %s.\n", | |
5387 | (int)tmp, paddress (gdbarch, addr)); | |
5388 | return -1; | |
5389 | } | |
5390 | if (tmp != 0) | |
5391 | { | |
5392 | regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[6], &tmp); | |
5393 | oaddr2 = s390_record_address_mask (gdbarch, regcache, tmp); | |
5394 | regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + (inib[7] | 1), &tmp); | |
5395 | if (record_full_arch_list_add_mem (oaddr2, tmp)) | |
5396 | return -1; | |
5397 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6])) | |
5398 | return -1; | |
5399 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[7])) | |
5400 | return -1; | |
5401 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[7] | 1))) | |
5402 | return -1; | |
5403 | } | |
5404 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
5405 | return -1; | |
5406 | break; | |
5407 | ||
5408 | /* 0xb932-0xb93b undefined */ | |
5409 | ||
5410 | case 0xb93c: /* PPNO - perform pseudorandom number operation [partial] */ | |
5411 | regcache_raw_read_unsigned (regcache, S390_R1_REGNUM, &tmp); | |
5412 | oaddr = s390_record_address_mask (gdbarch, regcache, tmp); | |
5413 | regcache_raw_read_unsigned (regcache, S390_R0_REGNUM, &tmp); | |
5414 | tmp &= 0xff; | |
5415 | switch (tmp) | |
5416 | { | |
5417 | case 0x00: /* PPNO-Query */ | |
5418 | case 0x80: /* PPNO-Query */ | |
5419 | if (record_full_arch_list_add_mem (oaddr, 16)) | |
5420 | return -1; | |
5421 | break; | |
5422 | ||
5423 | case 0x03: /* PPNO-SHA-512-DRNG - generate */ | |
5424 | if (record_full_arch_list_add_mem (oaddr, 240)) | |
5425 | return -1; | |
5426 | regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[6], &tmp); | |
5427 | oaddr2 = s390_record_address_mask (gdbarch, regcache, tmp); | |
5428 | regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + (inib[6] | 1), &tmp); | |
5429 | if (record_full_arch_list_add_mem (oaddr2, tmp)) | |
5430 | return -1; | |
5431 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6])) | |
5432 | return -1; | |
5433 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[6] | 1))) | |
5434 | return -1; | |
5435 | break; | |
5436 | ||
5437 | case 0x83: /* PPNO-SHA-512-DRNG - seed */ | |
5438 | if (record_full_arch_list_add_mem (oaddr, 240)) | |
5439 | return -1; | |
5440 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[7])) | |
5441 | return -1; | |
5442 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[7] | 1))) | |
5443 | return -1; | |
5444 | break; | |
5445 | ||
5446 | default: | |
5447 | fprintf_unfiltered (gdb_stdlog, "Warning: Unknown PPNO function %02x at %s.\n", | |
5448 | (int)tmp, paddress (gdbarch, addr)); | |
5449 | return -1; | |
5450 | } | |
5451 | /* DXC may be written */ | |
5452 | if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM)) | |
5453 | return -1; | |
5454 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
5455 | return -1; | |
5456 | break; | |
5457 | ||
5458 | /* 0xb93d undefined */ | |
5459 | ||
5460 | case 0xb93e: /* KIMD - compute intermediate message digest [partial] */ | |
5461 | case 0xb93f: /* KLMD - compute last message digest [partial] */ | |
5462 | regcache_raw_read_unsigned (regcache, S390_R1_REGNUM, &tmp); | |
5463 | oaddr = s390_record_address_mask (gdbarch, regcache, tmp); | |
5464 | regcache_raw_read_unsigned (regcache, S390_R0_REGNUM, &tmp); | |
5465 | tmp &= 0xff; | |
5466 | switch (tmp) | |
5467 | { | |
5468 | case 0x00: /* K*MD-Query */ | |
5469 | if (record_full_arch_list_add_mem (oaddr, 16)) | |
5470 | return -1; | |
5471 | break; | |
5472 | ||
5473 | case 0x01: /* K*MD-SHA-1 */ | |
5474 | if (record_full_arch_list_add_mem (oaddr, 20)) | |
5475 | return -1; | |
5476 | break; | |
5477 | ||
5478 | case 0x02: /* K*MD-SHA-256 */ | |
5479 | if (record_full_arch_list_add_mem (oaddr, 32)) | |
5480 | return -1; | |
5481 | break; | |
5482 | ||
5483 | case 0x03: /* K*MD-SHA-512 */ | |
5484 | if (record_full_arch_list_add_mem (oaddr, 64)) | |
5485 | return -1; | |
5486 | break; | |
5487 | ||
5488 | case 0x41: /* KIMD-GHASH */ | |
5489 | /* Only valid for KIMD. */ | |
5490 | if (insn[0] == 0xb93e) | |
5491 | { | |
5492 | if (record_full_arch_list_add_mem (oaddr, 16)) | |
5493 | return -1; | |
5494 | break; | |
5495 | } | |
5496 | /* For KLMD, fallthru. */ | |
5497 | default: | |
5498 | fprintf_unfiltered (gdb_stdlog, "Warning: Unknown KMAC function %02x at %s.\n", | |
5499 | (int)tmp, paddress (gdbarch, addr)); | |
5500 | return -1; | |
5501 | } | |
5502 | if (tmp != 0) | |
5503 | { | |
5504 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[7])) | |
5505 | return -1; | |
5506 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[7] | 1))) | |
5507 | return -1; | |
5508 | } | |
5509 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
5510 | return -1; | |
5511 | break; | |
5512 | ||
5513 | /* 0xb940 undefined */ | |
5514 | /* 0xb944-0xb945 undefined */ | |
5515 | /* 0xb947-0xb948 undefined */ | |
5516 | /* 0xb94c-0xb950 undefined */ | |
5517 | /* 0xb954-0xb958 undefined */ | |
5518 | /* 0xb95c-0xb95f undefined */ | |
5519 | /* 0xb962-0xb971 undefined */ | |
5520 | /* 0xb974-0xb97f undefined */ | |
5521 | ||
5522 | case 0xb983: /* FLOGR - find leftmost one */ | |
5523 | /* 64-bit gpr pair destination + flags */ | |
5524 | if (s390_record_gpr_g (gdbarch, regcache, inib[6])) | |
5525 | return -1; | |
5526 | if (s390_record_gpr_g (gdbarch, regcache, inib[6] | 1)) | |
5527 | return -1; | |
5528 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
5529 | return -1; | |
5530 | break; | |
5531 | ||
5532 | /* 0xb98a privileged */ | |
5533 | /* 0xb98b-0xb98c undefined */ | |
5534 | ||
5535 | case 0xb98d: /* EPSW - extract psw */ | |
5536 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6])) | |
5537 | return -1; | |
5538 | if (inib[7]) | |
5539 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[7])) | |
5540 | return -1; | |
5541 | break; | |
5542 | ||
5543 | /* 0xb98e-0xb98f privileged */ | |
5544 | ||
5545 | case 0xb990: /* TRTT - translate two to two [partial] */ | |
5546 | case 0xb991: /* TRTO - translate two to one [partial] */ | |
5547 | case 0xb992: /* TROT - translate one to two [partial] */ | |
5548 | case 0xb993: /* TROO - translate one to one [partial] */ | |
5549 | regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[6], &tmp); | |
5550 | oaddr = s390_record_address_mask (gdbarch, regcache, tmp); | |
5551 | regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + (inib[6] | 1), &tmp); | |
5552 | /* tmp is source length, we want destination length. Adjust. */ | |
5553 | if (insn[0] == 0xb991) | |
5554 | tmp >>= 1; | |
5555 | if (insn[0] == 0xb992) | |
5556 | tmp <<= 1; | |
5557 | if (record_full_arch_list_add_mem (oaddr, tmp)) | |
5558 | return -1; | |
5559 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6])) | |
5560 | return -1; | |
5561 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[6] | 1))) | |
5562 | return -1; | |
5563 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[7])) | |
5564 | return -1; | |
5565 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
5566 | return -1; | |
5567 | break; | |
5568 | ||
5569 | case 0xb996: /* MLR - multiply logical */ | |
5570 | case 0xb997: /* DLR - divide logical */ | |
5571 | /* 32-bit gpr pair destination */ | |
5572 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6])) | |
5573 | return -1; | |
5574 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[6] | 1))) | |
5575 | return -1; | |
5576 | break; | |
5577 | ||
5578 | /* 0xb99a-0xb9af unsupported, privileged, or undefined */ | |
5579 | /* 0xb9b4-0xb9bc undefined */ | |
5580 | ||
5581 | case 0xb9bd: /* TRTRE - translate and test reverse extended [partial] */ | |
5582 | case 0xb9bf: /* TRTE - translate and test extended [partial] */ | |
5583 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6])) | |
5584 | return -1; | |
5585 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[6] | 1))) | |
5586 | return -1; | |
5587 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[7])) | |
5588 | return -1; | |
5589 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
5590 | return -1; | |
5591 | break; | |
5592 | ||
5593 | /* 0xb9c0-0xb9c7 undefined */ | |
5594 | ||
5595 | case 0xb9c8: /* AHHHR - add high */ | |
5596 | case 0xb9c9: /* SHHHR - subtract high */ | |
5597 | case 0xb9ca: /* ALHHHR - add logical high */ | |
5598 | case 0xb9cb: /* SLHHHR - subtract logical high */ | |
5599 | case 0xb9d8: /* AHHLR - add high */ | |
5600 | case 0xb9d9: /* SHHLR - subtract high */ | |
5601 | case 0xb9da: /* ALHHLR - add logical high */ | |
5602 | case 0xb9db: /* SLHHLR - subtract logical high */ | |
5603 | /* 32-bit high gpr destination + flags */ | |
5604 | if (s390_record_gpr_h (gdbarch, regcache, inib[6])) | |
5605 | return -1; | |
5606 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
5607 | return -1; | |
5608 | break; | |
5609 | ||
5610 | /* 0xb9cc undefined */ | |
5611 | /* 0xb9ce undefined */ | |
5612 | /* 0xb9d0-0xb9d7 undefined */ | |
5613 | /* 0xb9dc undefined */ | |
5614 | /* 0xb9de undefined */ | |
5615 | ||
5616 | case 0xb9e0: /* LOCFHR - load high on condition */ | |
5617 | /* 32-bit high gpr destination */ | |
5618 | if (s390_record_gpr_h (gdbarch, regcache, inib[6])) | |
5619 | return -1; | |
5620 | break; | |
5621 | ||
5622 | /* 0xb9e3 undefined */ | |
5623 | /* 0xb9e5 undefined */ | |
5624 | /* 0xb9ec-0xb9f1 undefined */ | |
5625 | /* 0xb9f3 undefined */ | |
5626 | /* 0xb9f5 undefined */ | |
5627 | /* 0xb9fc-0xb9ff undefined */ | |
5628 | ||
5629 | default: | |
5630 | goto UNKNOWN_OP; | |
5631 | } | |
5632 | break; | |
5633 | ||
5634 | /* 0xb4-0xb5 undefined */ | |
5635 | /* 0xb6 privileged: STCTL - store control */ | |
5636 | /* 0xb7 privileged: LCTL - load control */ | |
5637 | /* 0xb8 undefined */ | |
5638 | ||
5639 | case 0xba: /* CS - compare and swap */ | |
5640 | oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0); | |
5641 | if (record_full_arch_list_add_mem (oaddr, 4)) | |
5642 | return -1; | |
5643 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2])) | |
5644 | return -1; | |
5645 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
5646 | return -1; | |
5647 | break; | |
5648 | ||
5649 | case 0xbb: /* CDS - compare double and swap */ | |
5650 | oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0); | |
5651 | if (record_full_arch_list_add_mem (oaddr, 8)) | |
5652 | return -1; | |
5653 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2])) | |
5654 | return -1; | |
5655 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[2] | 1))) | |
5656 | return -1; | |
5657 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
5658 | return -1; | |
5659 | break; | |
5660 | ||
5661 | /* 0xbc undefined */ | |
5662 | ||
5663 | case 0xbe: /* STCM - store characters under mask */ | |
5664 | oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0); | |
5665 | if (record_full_arch_list_add_mem (oaddr, s390_popcnt (inib[3]))) | |
5666 | return -1; | |
5667 | break; | |
5668 | ||
5669 | case 0xc0: | |
5670 | case 0xc2: | |
5671 | case 0xc4: | |
5672 | case 0xc6: | |
5673 | case 0xcc: | |
5674 | /* RIL-format instruction */ | |
5675 | switch (ibyte[0] << 4 | inib[3]) | |
5676 | { | |
5677 | case 0xc00: /* LARL - load address relative long */ | |
5678 | case 0xc05: /* BRASL - branch relative and save long */ | |
5679 | case 0xc09: /* IILF - insert immediate */ | |
5680 | case 0xc21: /* MSFI - multiply single immediate */ | |
5681 | case 0xc42: /* LLHRL - load logical halfword relative long */ | |
5682 | case 0xc45: /* LHRL - load halfword relative long */ | |
5683 | case 0xc4d: /* LRL - load relative long */ | |
5684 | /* 32-bit or native gpr destination */ | |
5685 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2])) | |
5686 | return -1; | |
5687 | break; | |
5688 | ||
5689 | case 0xc01: /* LGFI - load immediate */ | |
5690 | case 0xc0e: /* LLIHF - load logical immediate */ | |
5691 | case 0xc0f: /* LLILF - load logical immediate */ | |
5692 | case 0xc20: /* MSGFI - multiply single immediate */ | |
5693 | case 0xc44: /* LGHRL - load halfword relative long */ | |
5694 | case 0xc46: /* LLGHRL - load logical halfword relative long */ | |
5695 | case 0xc48: /* LGRL - load relative long */ | |
5696 | case 0xc4c: /* LGFRL - load relative long */ | |
5697 | case 0xc4e: /* LLGFRL - load logical relative long */ | |
5698 | /* 64-bit gpr destination */ | |
5699 | if (s390_record_gpr_g (gdbarch, regcache, inib[2])) | |
5700 | return -1; | |
5701 | break; | |
5702 | ||
5703 | /* 0xc02-0xc03 undefined */ | |
5704 | ||
5705 | case 0xc04: /* BRCL - branch relative on condition long */ | |
5706 | case 0xc62: /* PFDRL - prefetch data relative long */ | |
5707 | break; | |
5708 | ||
5709 | case 0xc06: /* XIHF - xor immediate */ | |
5710 | case 0xc0a: /* NIHF - and immediate */ | |
5711 | case 0xc0c: /* OIHF - or immediate */ | |
5712 | case 0xcc8: /* AIH - add immediate high */ | |
5713 | case 0xcca: /* ALSIH - add logical with signed immediate high */ | |
5714 | /* 32-bit high gpr destination + flags */ | |
5715 | if (s390_record_gpr_h (gdbarch, regcache, inib[2])) | |
5716 | return -1; | |
5717 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
5718 | return -1; | |
5719 | break; | |
5720 | ||
5721 | case 0xc07: /* XILF - xor immediate */ | |
5722 | case 0xc0b: /* NILF - and immediate */ | |
5723 | case 0xc0d: /* OILF - or immediate */ | |
5724 | case 0xc25: /* SLFI - subtract logical immediate */ | |
5725 | case 0xc29: /* AFI - add immediate */ | |
5726 | case 0xc2b: /* ALFI - add logical immediate */ | |
5727 | /* 32-bit gpr destination + flags */ | |
5728 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2])) | |
5729 | return -1; | |
5730 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
5731 | return -1; | |
5732 | break; | |
5733 | ||
5734 | case 0xc08: /* IIHF - insert immediate */ | |
5735 | case 0xcc6: /* BRCTH - branch relative on count high */ | |
5736 | case 0xccb: /* ALSIHN - add logical with signed immediate high */ | |
5737 | /* 32-bit high gpr destination */ | |
5738 | if (s390_record_gpr_h (gdbarch, regcache, inib[2])) | |
5739 | return -1; | |
5740 | break; | |
5741 | ||
5742 | /* 0xc22-0xc23 undefined */ | |
5743 | ||
5744 | case 0xc24: /* SLGFI - subtract logical immediate */ | |
5745 | case 0xc28: /* AGFI - add immediate */ | |
5746 | case 0xc2a: /* ALGFI - add logical immediate */ | |
5747 | /* 64-bit gpr destination + flags */ | |
5748 | if (s390_record_gpr_g (gdbarch, regcache, inib[2])) | |
5749 | return -1; | |
5750 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
5751 | return -1; | |
5752 | break; | |
5753 | ||
5754 | /* 0xc26-0xc27 undefined */ | |
5755 | ||
5756 | case 0xc2c: /* CGFI - compare immediate */ | |
5757 | case 0xc2d: /* CFI - compare immediate */ | |
5758 | case 0xc2e: /* CLGFI - compare logical immediate */ | |
5759 | case 0xc2f: /* CLFI - compare logical immediate */ | |
5760 | case 0xc64: /* CGHRL - compare halfword relative long */ | |
5761 | case 0xc65: /* CHRL - compare halfword relative long */ | |
5762 | case 0xc66: /* CLGHRL - compare logical halfword relative long */ | |
5763 | case 0xc67: /* CLHRL - compare logical halfword relative long */ | |
5764 | case 0xc68: /* CGRL - compare relative long */ | |
5765 | case 0xc6a: /* CLGRL - compare logical relative long */ | |
5766 | case 0xc6c: /* CGFRL - compare relative long */ | |
5767 | case 0xc6d: /* CRL - compare relative long */ | |
5768 | case 0xc6e: /* CLGFRL - compare logical relative long */ | |
5769 | case 0xc6f: /* CLRL - compare logical relative long */ | |
5770 | case 0xccd: /* CIH - compare immediate high */ | |
5771 | case 0xccf: /* CLIH - compare logical immediate high */ | |
5772 | /* flags only */ | |
5773 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
5774 | return -1; | |
5775 | break; | |
5776 | ||
5777 | /* 0xc40-0xc41 undefined */ | |
5778 | /* 0xc43 undefined */ | |
5779 | ||
5780 | case 0xc47: /* STHRL - store halfword relative long */ | |
5781 | oaddr = s390_record_calc_rl (gdbarch, regcache, addr, insn[1], insn[2]); | |
5782 | if (record_full_arch_list_add_mem (oaddr, 2)) | |
5783 | return -1; | |
5784 | break; | |
5785 | ||
5786 | /* 0xc49-0xc4a undefined */ | |
5787 | ||
5788 | case 0xc4b: /* STGRL - store relative long */ | |
5789 | oaddr = s390_record_calc_rl (gdbarch, regcache, addr, insn[1], insn[2]); | |
5790 | if (record_full_arch_list_add_mem (oaddr, 8)) | |
5791 | return -1; | |
5792 | break; | |
5793 | ||
5794 | case 0xc4f: /* STRL - store relative long */ | |
5795 | oaddr = s390_record_calc_rl (gdbarch, regcache, addr, insn[1], insn[2]); | |
5796 | if (record_full_arch_list_add_mem (oaddr, 4)) | |
5797 | return -1; | |
5798 | break; | |
5799 | ||
5800 | case 0xc60: /* EXRL - execute relative long */ | |
5801 | if (ex != -1) | |
5802 | { | |
5803 | fprintf_unfiltered (gdb_stdlog, "Warning: Double execute at %s.\n", | |
5804 | paddress (gdbarch, addr)); | |
5805 | return -1; | |
5806 | } | |
5807 | addr = s390_record_calc_rl (gdbarch, regcache, addr, insn[1], insn[2]); | |
5808 | if (inib[2]) | |
5809 | { | |
5810 | regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[2], &tmp); | |
5811 | ex = tmp & 0xff; | |
5812 | } | |
5813 | else | |
5814 | { | |
5815 | ex = 0; | |
5816 | } | |
5817 | goto ex; | |
5818 | ||
5819 | /* 0xc61 undefined */ | |
5820 | /* 0xc63 undefined */ | |
5821 | /* 0xc69 undefined */ | |
5822 | /* 0xc6b undefined */ | |
5823 | /* 0xcc0-0xcc5 undefined */ | |
5824 | /* 0xcc7 undefined */ | |
5825 | /* 0xcc9 undefined */ | |
5826 | /* 0xccc undefined */ | |
5827 | /* 0xcce undefined */ | |
5828 | ||
5829 | default: | |
5830 | goto UNKNOWN_OP; | |
5831 | } | |
5832 | break; | |
5833 | ||
5834 | /* 0xc1 undefined */ | |
5835 | /* 0xc3 undefined */ | |
5836 | ||
5837 | case 0xc5: /* BPRP - branch prediction relative preload */ | |
5838 | case 0xc7: /* BPP - branch prediction preload */ | |
5839 | /* no visible effect */ | |
5840 | break; | |
5841 | ||
5842 | case 0xc8: | |
5843 | /* SSF-format instruction */ | |
5844 | switch (ibyte[0] << 4 | inib[3]) | |
5845 | { | |
5846 | /* 0xc80 unsupported */ | |
5847 | ||
5848 | case 0xc81: /* ECTG - extract cpu time */ | |
5849 | if (s390_record_gpr_g (gdbarch, regcache, inib[2])) | |
5850 | return -1; | |
5851 | if (s390_record_gpr_g (gdbarch, regcache, 0)) | |
5852 | return -1; | |
5853 | if (s390_record_gpr_g (gdbarch, regcache, 1)) | |
5854 | return -1; | |
5855 | break; | |
5856 | ||
5857 | case 0xc82: /* CSST - compare and swap and store */ | |
5858 | { | |
5859 | uint8_t fc, sc; | |
5860 | regcache_raw_read_unsigned (regcache, S390_R0_REGNUM, &tmp); | |
5861 | fc = tmp & 0xff; | |
5862 | sc = tmp >> 8 & 0xff; | |
5863 | ||
5864 | /* First and third operands. */ | |
5865 | oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0); | |
5866 | switch (fc) | |
5867 | { | |
5868 | case 0x00: /* 32-bit */ | |
5869 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2])) | |
5870 | return -1; | |
5871 | if (record_full_arch_list_add_mem (oaddr, 4)) | |
5872 | return -1; | |
5873 | break; | |
5874 | ||
5875 | case 0x01: /* 64-bit */ | |
5876 | if (s390_record_gpr_g (gdbarch, regcache, inib[2])) | |
5877 | return -1; | |
5878 | if (record_full_arch_list_add_mem (oaddr, 8)) | |
5879 | return -1; | |
5880 | break; | |
5881 | ||
5882 | case 0x02: /* 128-bit */ | |
5883 | if (s390_record_gpr_g (gdbarch, regcache, inib[2])) | |
5884 | return -1; | |
5885 | if (s390_record_gpr_g (gdbarch, regcache, inib[2] | 1)) | |
5886 | return -1; | |
5887 | if (record_full_arch_list_add_mem (oaddr, 16)) | |
5888 | return -1; | |
5889 | break; | |
5890 | ||
5891 | default: | |
5892 | fprintf_unfiltered (gdb_stdlog, "Warning: Unknown CSST FC %02x at %s.\n", | |
5893 | fc, paddress (gdbarch, addr)); | |
5894 | return -1; | |
5895 | } | |
5896 | ||
5897 | /* Second operand. */ | |
5898 | oaddr2 = s390_record_calc_disp (gdbarch, regcache, 0, insn[2], 0); | |
5899 | if (sc > 4) | |
5900 | { | |
5901 | fprintf_unfiltered (gdb_stdlog, "Warning: Unknown CSST FC %02x at %s.\n", | |
5902 | sc, paddress (gdbarch, addr)); | |
5903 | return -1; | |
5904 | } | |
5905 | ||
5906 | if (record_full_arch_list_add_mem (oaddr2, 1 << sc)) | |
5907 | return -1; | |
5908 | ||
5909 | /* Flags. */ | |
5910 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
5911 | return -1; | |
5912 | } | |
5913 | break; | |
5914 | ||
5915 | /* 0xc83 undefined */ | |
5916 | ||
5917 | case 0xc84: /* LPD - load pair disjoint */ | |
5918 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2])) | |
5919 | return -1; | |
5920 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[2] | 1))) | |
5921 | return -1; | |
5922 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
5923 | return -1; | |
5924 | break; | |
5925 | ||
5926 | case 0xc85: /* LPDG - load pair disjoint */ | |
5927 | if (s390_record_gpr_g (gdbarch, regcache, inib[2])) | |
5928 | return -1; | |
5929 | if (s390_record_gpr_g (gdbarch, regcache, inib[2] | 1)) | |
5930 | return -1; | |
5931 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
5932 | return -1; | |
5933 | break; | |
5934 | ||
5935 | /* 0xc86-0xc8f undefined */ | |
5936 | ||
5937 | default: | |
5938 | goto UNKNOWN_OP; | |
5939 | } | |
5940 | break; | |
5941 | ||
5942 | /* 0xc9-0xcb undefined */ | |
5943 | /* 0xcd-0xcf undefined */ | |
5944 | ||
5945 | case 0xd0: /* TRTR - translate and test reversed */ | |
5946 | case 0xdd: /* TRT - translate and test */ | |
5947 | if (record_full_arch_list_add_reg (regcache, S390_R1_REGNUM)) | |
5948 | return -1; | |
5949 | if (record_full_arch_list_add_reg (regcache, S390_R2_REGNUM)) | |
5950 | return -1; | |
5951 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
5952 | return -1; | |
5953 | break; | |
5954 | ||
5955 | case 0xd1: /* MVN - move numbers */ | |
5956 | case 0xd2: /* MVC - move */ | |
5957 | case 0xd3: /* MVZ - move zones */ | |
5958 | case 0xdc: /* TR - translate */ | |
5959 | case 0xe8: /* MVCIN - move inverse */ | |
5960 | oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0); | |
5961 | if (record_full_arch_list_add_mem (oaddr, ibyte[1] + 1)) | |
5962 | return -1; | |
5963 | break; | |
5964 | ||
5965 | case 0xd4: /* NC - and */ | |
5966 | case 0xd6: /* OC - or*/ | |
5967 | case 0xd7: /* XC - xor */ | |
5968 | case 0xe2: /* UNPKU - unpack unicode */ | |
5969 | case 0xea: /* UNPKA - unpack ASCII */ | |
5970 | oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0); | |
5971 | if (record_full_arch_list_add_mem (oaddr, ibyte[1] + 1)) | |
5972 | return -1; | |
5973 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
5974 | return -1; | |
5975 | break; | |
5976 | ||
5977 | case 0xde: /* ED - edit */ | |
5978 | oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0); | |
5979 | if (record_full_arch_list_add_mem (oaddr, ibyte[1] + 1)) | |
5980 | return -1; | |
5981 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
5982 | return -1; | |
5983 | /* DXC may be written */ | |
5984 | if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM)) | |
5985 | return -1; | |
5986 | break; | |
5987 | ||
5988 | case 0xdf: /* EDMK - edit and mark */ | |
5989 | oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0); | |
5990 | if (record_full_arch_list_add_mem (oaddr, ibyte[1] + 1)) | |
5991 | return -1; | |
5992 | if (record_full_arch_list_add_reg (regcache, S390_R1_REGNUM)) | |
5993 | return -1; | |
5994 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
5995 | return -1; | |
5996 | /* DXC may be written */ | |
5997 | if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM)) | |
5998 | return -1; | |
5999 | break; | |
6000 | ||
6001 | /* 0xd8 undefined */ | |
6002 | /* 0xd9 unsupported: MVCK - move with key */ | |
6003 | /* 0xda unsupported: MVCP - move to primary */ | |
6004 | /* 0xdb unsupported: MVCS - move to secondary */ | |
6005 | /* 0xe0 undefined */ | |
6006 | ||
6007 | case 0xe1: /* PKU - pack unicode */ | |
6008 | case 0xe9: /* PKA - pack ASCII */ | |
6009 | oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0); | |
6010 | if (record_full_arch_list_add_mem (oaddr, 16)) | |
6011 | return -1; | |
6012 | break; | |
6013 | ||
6014 | case 0xe3: | |
6015 | case 0xe7: | |
6016 | case 0xeb: | |
6017 | case 0xed: | |
6018 | /* RXY/RXE/RXF/RSL/RSY/SIY/V*-format instruction */ | |
6019 | switch (ibyte[0] << 8 | ibyte[5]) | |
6020 | { | |
6021 | /* 0xe300-0xe301 undefined */ | |
6022 | ||
6023 | case 0xe302: /* LTG - load and test */ | |
6024 | case 0xe308: /* AG - add */ | |
6025 | case 0xe309: /* SG - subtract */ | |
6026 | case 0xe30a: /* ALG - add logical */ | |
6027 | case 0xe30b: /* SLG - subtract logical */ | |
6028 | case 0xe318: /* AGF - add */ | |
6029 | case 0xe319: /* SGF - subtract */ | |
6030 | case 0xe31a: /* ALGF - add logical */ | |
6031 | case 0xe31b: /* SLGF - subtract logical */ | |
6032 | case 0xe332: /* LTGF - load and test */ | |
6033 | case 0xe380: /* NG - and */ | |
6034 | case 0xe381: /* OG - or */ | |
6035 | case 0xe382: /* XG - xor */ | |
6036 | case 0xe388: /* ALCG - add logical with carry */ | |
6037 | case 0xe389: /* SLBG - subtract logical with borrow */ | |
6038 | case 0xeb0a: /* SRAG - shift right single */ | |
6039 | case 0xeb0b: /* SLAG - shift left single */ | |
6040 | /* 64-bit gpr destination + flags */ | |
6041 | if (s390_record_gpr_g (gdbarch, regcache, inib[2])) | |
6042 | return -1; | |
6043 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
6044 | return -1; | |
6045 | break; | |
6046 | ||
6047 | /* 0xe303 privileged */ | |
6048 | ||
6049 | case 0xe304: /* LG - load */ | |
6050 | case 0xe30c: /* MSG - multiply single */ | |
6051 | case 0xe30f: /* LRVG - load reversed */ | |
6052 | case 0xe314: /* LGF - load */ | |
6053 | case 0xe315: /* LGH - load halfword */ | |
6054 | case 0xe316: /* LLGF - load logical */ | |
6055 | case 0xe317: /* LLGT - load logical thirty one bits */ | |
6056 | case 0xe31c: /* MSGF - multiply single */ | |
6057 | case 0xe32a: /* LZRG - load and zero rightmost byte */ | |
6058 | case 0xe33a: /* LLZRGF - load logical and zero rightmost byte */ | |
6059 | case 0xe346: /* BCTG - branch on count */ | |
6060 | case 0xe377: /* LGB - load byte */ | |
6061 | case 0xe390: /* LLGC - load logical character */ | |
6062 | case 0xe391: /* LLGH - load logical halfword */ | |
6063 | case 0xeb0c: /* SRLG - shift right single logical */ | |
6064 | case 0xeb0d: /* SLLG - shift left single logical */ | |
6065 | case 0xeb1c: /* RLLG - rotate left single logical */ | |
6066 | case 0xeb44: /* BXHG - branch on index high */ | |
6067 | case 0xeb45: /* BXLEG - branch on index low or equal */ | |
6068 | case 0xeb4c: /* ECAG - extract cpu attribute */ | |
6069 | case 0xebe2: /* LOCG - load on condition */ | |
6070 | /* 64-bit gpr destination */ | |
6071 | if (s390_record_gpr_g (gdbarch, regcache, inib[2])) | |
6072 | return -1; | |
6073 | break; | |
6074 | ||
6075 | /* 0xe305 undefined */ | |
6076 | ||
6077 | case 0xe306: /* CVBY - convert to binary */ | |
6078 | /* 32-bit or native gpr destination + FPC (DXC write) */ | |
6079 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2])) | |
6080 | return -1; | |
6081 | if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM)) | |
6082 | return -1; | |
6083 | break; | |
6084 | ||
6085 | /* 0xe307 undefined */ | |
6086 | ||
6087 | case 0xe30d: /* DSG - divide single */ | |
6088 | case 0xe31d: /* DSGF - divide single */ | |
6089 | case 0xe386: /* MLG - multiply logical */ | |
6090 | case 0xe387: /* DLG - divide logical */ | |
6091 | case 0xe38f: /* LPQ - load pair from quadword */ | |
6092 | /* 64-bit gpr pair destination */ | |
6093 | if (s390_record_gpr_g (gdbarch, regcache, inib[2])) | |
6094 | return -1; | |
6095 | if (s390_record_gpr_g (gdbarch, regcache, inib[2] | 1)) | |
6096 | return -1; | |
6097 | break; | |
6098 | ||
6099 | case 0xe30e: /* CVBG - convert to binary */ | |
6100 | /* 64-bit gpr destination + FPC (DXC write) */ | |
6101 | if (s390_record_gpr_g (gdbarch, regcache, inib[2])) | |
6102 | return -1; | |
6103 | if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM)) | |
6104 | return -1; | |
6105 | break; | |
6106 | ||
6107 | /* 0xe310-0xe311 undefined */ | |
6108 | ||
6109 | case 0xe312: /* LT - load and test */ | |
6110 | case 0xe354: /* NY - and */ | |
6111 | case 0xe356: /* OY - or */ | |
6112 | case 0xe357: /* XY - xor */ | |
6113 | case 0xe35a: /* AY - add */ | |
6114 | case 0xe35b: /* SY - subtract */ | |
6115 | case 0xe35e: /* ALY - add logical */ | |
6116 | case 0xe35f: /* SLY - subtract logical */ | |
6117 | case 0xe37a: /* AHY - add halfword */ | |
6118 | case 0xe37b: /* SHY - subtract halfword */ | |
6119 | case 0xe398: /* ALC - add logical with carry */ | |
6120 | case 0xe399: /* SLB - subtract logical with borrow */ | |
6121 | case 0xe727: /* LCBB - load count to block bounduary */ | |
6122 | case 0xeb81: /* ICMY - insert characters under mask */ | |
6123 | case 0xebdc: /* SRAK - shift left single */ | |
6124 | case 0xebdd: /* SLAK - shift left single */ | |
6125 | /* 32-bit gpr destination + flags */ | |
6126 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2])) | |
6127 | return -1; | |
6128 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
6129 | return -1; | |
6130 | break; | |
6131 | ||
6132 | /* 0xe313 privileged */ | |
6133 | ||
6134 | case 0xe31e: /* LRV - load reversed */ | |
6135 | case 0xe31f: /* LRVH - load reversed */ | |
6136 | case 0xe33b: /* LZRF - load and zero rightmost byte */ | |
6137 | case 0xe351: /* MSY - multiply single */ | |
6138 | case 0xe358: /* LY - load */ | |
6139 | case 0xe371: /* LAY - load address */ | |
6140 | case 0xe373: /* ICY - insert character */ | |
6141 | case 0xe376: /* LB - load byte */ | |
6142 | case 0xe378: /* LHY - load */ | |
6143 | case 0xe37c: /* MHY - multiply halfword */ | |
6144 | case 0xe394: /* LLC - load logical character */ | |
6145 | case 0xe395: /* LLH - load logical halfword */ | |
6146 | case 0xeb1d: /* RLL - rotate left single logical */ | |
6147 | case 0xebde: /* SRLK - shift left single logical */ | |
6148 | case 0xebdf: /* SLLK - shift left single logical */ | |
6149 | case 0xebf2: /* LOC - load on condition */ | |
6150 | /* 32-bit or native gpr destination */ | |
6151 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2])) | |
6152 | return -1; | |
6153 | break; | |
6154 | ||
6155 | case 0xe320: /* CG - compare */ | |
6156 | case 0xe321: /* CLG - compare logical */ | |
6157 | case 0xe330: /* CGF - compare */ | |
6158 | case 0xe331: /* CLGF - compare logical */ | |
6159 | case 0xe334: /* CGH - compare halfword */ | |
6160 | case 0xe355: /* CLY - compare logical */ | |
6161 | case 0xe359: /* CY - compare */ | |
6162 | case 0xe379: /* CHY - compare halfword */ | |
6163 | case 0xe3cd: /* CHF - compare high */ | |
6164 | case 0xe3cf: /* CLHF - compare logical high */ | |
6165 | case 0xeb20: /* CLMH - compare logical under mask high */ | |
6166 | case 0xeb21: /* CLMY - compare logical under mask */ | |
6167 | case 0xeb51: /* TMY - test under mask */ | |
6168 | case 0xeb55: /* CLIY - compare logical */ | |
6169 | case 0xebc0: /* TP - test decimal */ | |
6170 | case 0xed10: /* TCEB - test data class */ | |
6171 | case 0xed11: /* TCDB - test data class */ | |
6172 | case 0xed12: /* TCXB - test data class */ | |
6173 | case 0xed50: /* TDCET - test data class */ | |
6174 | case 0xed51: /* TDGET - test data group */ | |
6175 | case 0xed54: /* TDCDT - test data class */ | |
6176 | case 0xed55: /* TDGDT - test data group */ | |
6177 | case 0xed58: /* TDCXT - test data class */ | |
6178 | case 0xed59: /* TDGXT - test data group */ | |
6179 | /* flags only */ | |
6180 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
6181 | return -1; | |
6182 | break; | |
6183 | ||
6184 | /* 0xe322-0xe323 undefined */ | |
6185 | ||
6186 | case 0xe324: /* STG - store */ | |
6187 | case 0xe325: /* NTSTG - nontransactional store */ | |
6188 | case 0xe326: /* CVDY - convert to decimal */ | |
6189 | case 0xe32f: /* STRVG - store reversed */ | |
6190 | case 0xebe3: /* STOCG - store on condition */ | |
6191 | case 0xed67: /* STDY - store */ | |
6192 | oaddr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], ibyte[4]); | |
6193 | if (record_full_arch_list_add_mem (oaddr, 8)) | |
6194 | return -1; | |
6195 | break; | |
6196 | ||
6197 | /* 0xe327-0xe329 undefined */ | |
6198 | /* 0xe32b-0xe32d undefined */ | |
6199 | ||
6200 | case 0xe32e: /* CVDG - convert to decimal */ | |
6201 | case 0xe38e: /* STPQ - store pair to quadword */ | |
6202 | oaddr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], ibyte[4]); | |
6203 | if (record_full_arch_list_add_mem (oaddr, 16)) | |
6204 | return -1; | |
6205 | break; | |
6206 | ||
6207 | /* 0xe333 undefined */ | |
6208 | /* 0xe335 undefined */ | |
6209 | ||
6210 | case 0xe336: /* PFD - prefetch data */ | |
6211 | break; | |
6212 | ||
6213 | /* 0xe337-0xe339 undefined */ | |
6214 | /* 0xe33c-0xe33d undefined */ | |
6215 | ||
6216 | case 0xe33e: /* STRV - store reversed */ | |
6217 | case 0xe350: /* STY - store */ | |
6218 | case 0xe3cb: /* STFH - store high */ | |
6219 | case 0xebe1: /* STOCFH - store high on condition */ | |
6220 | case 0xebf3: /* STOC - store on condition */ | |
6221 | case 0xed66: /* STEY - store */ | |
6222 | oaddr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], ibyte[4]); | |
6223 | if (record_full_arch_list_add_mem (oaddr, 4)) | |
6224 | return -1; | |
6225 | break; | |
6226 | ||
6227 | case 0xe33f: /* STRVH - store reversed */ | |
6228 | case 0xe370: /* STHY - store halfword */ | |
6229 | case 0xe3c7: /* STHH - store halfword high */ | |
6230 | oaddr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], ibyte[4]); | |
6231 | if (record_full_arch_list_add_mem (oaddr, 2)) | |
6232 | return -1; | |
6233 | break; | |
6234 | ||
6235 | /* 0xe340-0xe345 undefined */ | |
6236 | /* 0xe347-0xe34f undefined */ | |
6237 | /* 0xe352-0xe353 undefined */ | |
6238 | ||
6239 | case 0xe35c: /* MFY - multiply */ | |
6240 | case 0xe396: /* ML - multiply logical */ | |
6241 | case 0xe397: /* DL - divide logical */ | |
6242 | /* 32-bit gpr pair destination */ | |
6243 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2])) | |
6244 | return -1; | |
6245 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[2] | 1))) | |
6246 | return -1; | |
6247 | break; | |
6248 | ||
6249 | /* 0xe35d undefined */ | |
6250 | /* 0xe360-0xe36f undefined */ | |
6251 | ||
6252 | case 0xe372: /* STCY - store character */ | |
6253 | case 0xe3c3: /* STCH - store character high */ | |
6254 | oaddr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], ibyte[4]); | |
6255 | if (record_full_arch_list_add_mem (oaddr, 1)) | |
6256 | return -1; | |
6257 | break; | |
6258 | ||
6259 | /* 0xe374 undefined */ | |
6260 | ||
6261 | case 0xe375: /* LAEY - load address extended */ | |
6262 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2])) | |
6263 | return -1; | |
6264 | if (record_full_arch_list_add_reg (regcache, S390_A0_REGNUM + inib[2])) | |
6265 | return -1; | |
6266 | break; | |
6267 | ||
6268 | /* 0xe37d-0xe37f undefined */ | |
6269 | /* 0xe383-0xe384 undefined */ | |
6270 | ||
6271 | case 0xe385: /* LGAT - load and trap */ | |
6272 | case 0xe39c: /* LLGTAT - load logical thirty one bits and trap */ | |
6273 | case 0xe39d: /* LLGFAT - load logical and trap */ | |
6274 | case 0xe721: /* VLGV - vector load gr from vr element */ | |
6275 | /* 64-bit gpr destination + fpc for possible DXC write */ | |
6276 | if (s390_record_gpr_g (gdbarch, regcache, inib[2])) | |
6277 | return -1; | |
6278 | if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM)) | |
6279 | return -1; | |
6280 | break; | |
6281 | ||
6282 | /* 0xe38a-0xe38d undefined */ | |
6283 | /* 0xe392-0xe393 undefined */ | |
6284 | /* 0xe39a-0xe39b undefined */ | |
6285 | /* 0xe39e undefined */ | |
6286 | ||
6287 | case 0xe39f: /* LAT - load and trap */ | |
6288 | /* 32-bit gpr destination + fpc for possible DXC write */ | |
6289 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2])) | |
6290 | return -1; | |
6291 | if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM)) | |
6292 | return -1; | |
6293 | break; | |
6294 | ||
6295 | /* 0xe3a0-0xe3bf undefined */ | |
6296 | ||
6297 | case 0xe3c0: /* LBH - load byte high */ | |
6298 | case 0xe3c2: /* LLCH - load logical character high */ | |
6299 | case 0xe3c4: /* LHH - load halfword high */ | |
6300 | case 0xe3c6: /* LLHH - load logical halfword high */ | |
6301 | case 0xe3ca: /* LFH - load high */ | |
6302 | case 0xebe0: /* LOCFH - load high on condition */ | |
6303 | /* 32-bit high gpr destination */ | |
6304 | if (s390_record_gpr_h (gdbarch, regcache, inib[2])) | |
6305 | return -1; | |
6306 | break; | |
6307 | ||
6308 | /* 0xe3c1 undefined */ | |
6309 | /* 0xe3c5 undefined */ | |
6310 | ||
6311 | case 0xe3c8: /* LFHAT - load high and trap */ | |
6312 | /* 32-bit high gpr destination + fpc for possible DXC write */ | |
6313 | if (s390_record_gpr_h (gdbarch, regcache, inib[2])) | |
6314 | return -1; | |
6315 | if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM)) | |
6316 | return -1; | |
6317 | break; | |
6318 | ||
6319 | /* 0xe3c9 undefined */ | |
6320 | /* 0xe3cc undefined */ | |
6321 | /* 0xe3ce undefined */ | |
6322 | /* 0xe3d0-0xe3ff undefined */ | |
6323 | ||
6324 | case 0xe700: /* VLEB - vector load element */ | |
6325 | case 0xe701: /* VLEH - vector load element */ | |
6326 | case 0xe702: /* VLEG - vector load element */ | |
6327 | case 0xe703: /* VLEF - vector load element */ | |
6328 | case 0xe704: /* VLLEZ - vector load logical element and zero */ | |
6329 | case 0xe705: /* VLREP - vector load and replicate */ | |
6330 | case 0xe706: /* VL - vector load */ | |
6331 | case 0xe707: /* VLBB - vector load to block bounduary */ | |
6332 | case 0xe712: /* VGEG - vector gather element */ | |
6333 | case 0xe713: /* VGEF - vector gather element */ | |
6334 | case 0xe722: /* VLVG - vector load vr element from gr */ | |
6335 | case 0xe730: /* VESL - vector element shift left */ | |
6336 | case 0xe733: /* VERLL - vector element rotate left logical */ | |
6337 | case 0xe737: /* VLL - vector load with length */ | |
6338 | case 0xe738: /* VESRL - vector element shift right logical */ | |
6339 | case 0xe73a: /* VESRA - vector element shift right arithmetic */ | |
6340 | case 0xe740: /* VLEIB - vector load element immediate */ | |
6341 | case 0xe741: /* VLEIH - vector load element immediate */ | |
6342 | case 0xe742: /* VLEIG - vector load element immediate */ | |
6343 | case 0xe743: /* VLEIF - vector load element immediate */ | |
6344 | case 0xe744: /* VGBM - vector generate byte mask */ | |
6345 | case 0xe745: /* VREPI - vector replicate immediate */ | |
6346 | case 0xe746: /* VGM - vector generate mask */ | |
6347 | case 0xe74d: /* VREP - vector replicate */ | |
6348 | case 0xe750: /* VPOPCT - vector population count */ | |
6349 | case 0xe752: /* VCTZ - vector count trailing zeros */ | |
6350 | case 0xe753: /* VCLZ - vector count leading zeros */ | |
6351 | case 0xe756: /* VLR - vector load */ | |
6352 | case 0xe75f: /* VSEG -vector sign extend to doubleword */ | |
6353 | case 0xe760: /* VMRL - vector merge low */ | |
6354 | case 0xe761: /* VMRH - vector merge high */ | |
6355 | case 0xe762: /* VLVGP - vector load vr from grs disjoint */ | |
6356 | case 0xe764: /* VSUM - vector sum across word */ | |
6357 | case 0xe765: /* VSUMG - vector sum across doubleword */ | |
6358 | case 0xe766: /* VCKSM - vector checksum */ | |
6359 | case 0xe767: /* VSUMQ - vector sum across quadword */ | |
6360 | case 0xe768: /* VN - vector and */ | |
6361 | case 0xe769: /* VNC - vector and with complement */ | |
6362 | case 0xe76a: /* VO - vector or */ | |
6363 | case 0xe76b: /* VNO - vector nor */ | |
6364 | case 0xe76d: /* VX - vector xor */ | |
6365 | case 0xe770: /* VESLV - vector element shift left */ | |
6366 | case 0xe772: /* VERIM - vector element rotate and insert under mask */ | |
6367 | case 0xe773: /* VERLLV - vector element rotate left logical */ | |
6368 | case 0xe774: /* VSL - vector shift left */ | |
6369 | case 0xe775: /* VSLB - vector shift left by byte */ | |
6370 | case 0xe777: /* VSLDB - vector shift left double by byte */ | |
6371 | case 0xe778: /* VESRLV - vector element shift right logical */ | |
6372 | case 0xe77a: /* VESRAV - vector element shift right arithmetic */ | |
6373 | case 0xe77c: /* VSRL - vector shift right logical */ | |
6374 | case 0xe77d: /* VSRLB - vector shift right logical by byte */ | |
6375 | case 0xe77e: /* VSRA - vector shift right arithmetic */ | |
6376 | case 0xe77f: /* VSRAB - vector shift right arithmetic by byte */ | |
6377 | case 0xe784: /* VPDI - vector permute doubleword immediate */ | |
6378 | case 0xe78c: /* VPERM - vector permute */ | |
6379 | case 0xe78d: /* VSEL - vector select */ | |
6380 | case 0xe78e: /* VFMS - vector fp multiply and subtract */ | |
6381 | case 0xe78f: /* VFMA - vector fp multiply and add */ | |
6382 | case 0xe794: /* VPK - vector pack */ | |
6383 | case 0xe7a1: /* VMLH - vector multiply logical high */ | |
6384 | case 0xe7a2: /* VML - vector multiply low */ | |
6385 | case 0xe7a3: /* VMH - vector multiply high */ | |
6386 | case 0xe7a4: /* VMLE - vector multiply logical even */ | |
6387 | case 0xe7a5: /* VMLO - vector multiply logical odd */ | |
6388 | case 0xe7a6: /* VME - vector multiply even */ | |
6389 | case 0xe7a7: /* VMO - vector multiply odd */ | |
6390 | case 0xe7a9: /* VMALH - vector multiply and add logical high */ | |
6391 | case 0xe7aa: /* VMAL - vector multiply and add low */ | |
6392 | case 0xe7ab: /* VMAH - vector multiply and add high */ | |
6393 | case 0xe7ac: /* VMALE - vector multiply and add logical even */ | |
6394 | case 0xe7ad: /* VMALO - vector multiply and add logical odd */ | |
6395 | case 0xe7ae: /* VMAE - vector multiply and add even */ | |
6396 | case 0xe7af: /* VMAO - vector multiply and add odd */ | |
6397 | case 0xe7b4: /* VGFM - vector Galois field multiply sum */ | |
6398 | case 0xe7b9: /* VACCC - vector add with carry compute carry */ | |
6399 | case 0xe7bb: /* VAC - vector add with carry */ | |
6400 | case 0xe7bc: /* VGFMA - vector Galois field multiply sum and accumulate */ | |
6401 | case 0xe7bd: /* VSBCBI - vector subtract with borrow compute borrow indication */ | |
6402 | case 0xe7bf: /* VSBI - vector subtract with borrow indication */ | |
6403 | case 0xe7c0: /* VCLGD - vector convert to logical 64-bit */ | |
6404 | case 0xe7c1: /* VCDLG - vector convert from logical 64-bit */ | |
6405 | case 0xe7c2: /* VCGD - vector convert to fixed 64-bit */ | |
6406 | case 0xe7c3: /* VCDG - vector convert from fixed 64-bit */ | |
6407 | case 0xe7c4: /* VLDE - vector fp load lengthened */ | |
6408 | case 0xe7c5: /* VLED - vector fp load rounded */ | |
6409 | case 0xe7c7: /* VFI - vector load fp integer */ | |
6410 | case 0xe7cc: /* VFPSO - vector fp perform sign operation */ | |
6411 | case 0xe7ce: /* VFSQ - vector fp square root */ | |
6412 | case 0xe7d4: /* VUPLL - vector unpack logical low */ | |
6413 | case 0xe7d6: /* VUPL - vector unpack low */ | |
6414 | case 0xe7d5: /* VUPLH - vector unpack logical high */ | |
6415 | case 0xe7d7: /* VUPH - vector unpack high */ | |
6416 | case 0xe7de: /* VLC - vector load complement */ | |
6417 | case 0xe7df: /* VLP - vector load positive */ | |
6418 | case 0xe7e2: /* VFA - vector fp subtract */ | |
6419 | case 0xe7e3: /* VFA - vector fp add */ | |
6420 | case 0xe7e5: /* VFD - vector fp divide */ | |
6421 | case 0xe7e7: /* VFM - vector fp multiply */ | |
6422 | case 0xe7f0: /* VAVGL - vector average logical */ | |
6423 | case 0xe7f1: /* VACC - vector add and compute carry */ | |
6424 | case 0xe7f2: /* VAVG - vector average */ | |
6425 | case 0xe7f3: /* VA - vector add */ | |
6426 | case 0xe7f5: /* VSCBI - vector subtract compute borrow indication */ | |
6427 | case 0xe7f7: /* VS - vector subtract */ | |
6428 | case 0xe7fc: /* VMNL - vector minimum logical */ | |
6429 | case 0xe7fd: /* VMXL - vector maximum logical */ | |
6430 | case 0xe7fe: /* VMN - vector minimum */ | |
6431 | case 0xe7ff: /* VMX - vector maximum */ | |
6432 | /* vector destination + FPC */ | |
6433 | if (s390_record_vr (gdbarch, regcache, ivec[0])) | |
6434 | return -1; | |
6435 | if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM)) | |
6436 | return -1; | |
6437 | break; | |
6438 | ||
6439 | case 0xe708: /* VSTEB - vector store element */ | |
6440 | oaddr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], 0); | |
6441 | if (record_full_arch_list_add_mem (oaddr, 1)) | |
6442 | return -1; | |
6443 | if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM)) | |
6444 | return -1; | |
6445 | break; | |
6446 | ||
6447 | case 0xe709: /* VSTEH - vector store element */ | |
6448 | oaddr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], 0); | |
6449 | if (record_full_arch_list_add_mem (oaddr, 2)) | |
6450 | return -1; | |
6451 | if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM)) | |
6452 | return -1; | |
6453 | break; | |
6454 | ||
6455 | case 0xe70a: /* VSTEG - vector store element */ | |
6456 | oaddr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], 0); | |
6457 | if (record_full_arch_list_add_mem (oaddr, 8)) | |
6458 | return -1; | |
6459 | if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM)) | |
6460 | return -1; | |
6461 | break; | |
6462 | ||
6463 | case 0xe70b: /* VSTEF - vector store element */ | |
6464 | oaddr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], 0); | |
6465 | if (record_full_arch_list_add_mem (oaddr, 4)) | |
6466 | return -1; | |
6467 | if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM)) | |
6468 | return -1; | |
6469 | break; | |
6470 | ||
6471 | /* 0xe70c-0xe70d undefined */ | |
6472 | ||
6473 | case 0xe70e: /* VST - vector store */ | |
6474 | oaddr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], 0); | |
6475 | if (record_full_arch_list_add_mem (oaddr, 16)) | |
6476 | return -1; | |
6477 | if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM)) | |
6478 | return -1; | |
6479 | break; | |
6480 | ||
6481 | /* 0xe70f-0xe711 undefined */ | |
6482 | /* 0xe714-0xe719 undefined */ | |
6483 | ||
6484 | case 0xe71a: /* VSCEG - vector scatter element */ | |
6485 | if (s390_record_calc_disp_vsce (gdbarch, regcache, ivec[1], inib[8], 8, insn[1], 0, &oaddr)) | |
6486 | return -1; | |
6487 | if (record_full_arch_list_add_mem (oaddr, 8)) | |
6488 | return -1; | |
6489 | if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM)) | |
6490 | return -1; | |
6491 | break; | |
6492 | ||
6493 | case 0xe71b: /* VSCEF - vector scatter element */ | |
6494 | if (s390_record_calc_disp_vsce (gdbarch, regcache, ivec[1], inib[8], 4, insn[1], 0, &oaddr)) | |
6495 | return -1; | |
6496 | if (record_full_arch_list_add_mem (oaddr, 4)) | |
6497 | return -1; | |
6498 | if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM)) | |
6499 | return -1; | |
6500 | break; | |
6501 | ||
6502 | /* 0xe71c-0xe720 undefined */ | |
6503 | /* 0xe723-0xe726 undefined */ | |
6504 | /* 0xe728-0xe72f undefined */ | |
6505 | /* 0xe731-0xe732 undefined */ | |
6506 | /* 0xe734-0xe735 undefined */ | |
6507 | ||
6508 | case 0xe736: /* VLM - vector load multiple */ | |
6509 | for (i = ivec[0]; i != ivec[1]; i++, i &= 0x1f) | |
6510 | if (s390_record_vr (gdbarch, regcache, i)) | |
6511 | return -1; | |
6512 | if (s390_record_vr (gdbarch, regcache, ivec[1])) | |
6513 | return -1; | |
6514 | if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM)) | |
6515 | return -1; | |
6516 | break; | |
6517 | ||
6518 | /* 0xe739 undefined */ | |
6519 | /* 0xe73b-0xe73d undefined */ | |
6520 | ||
6521 | case 0xe73e: /* VSTM - vector store multiple */ | |
6522 | oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0); | |
6523 | if (ivec[0] <= ivec[1]) | |
6524 | n = ivec[1] - ivec[0] + 1; | |
6525 | else | |
6526 | n = ivec[1] + 0x20 - ivec[0] + 1; | |
6527 | if (record_full_arch_list_add_mem (oaddr, n * 16)) | |
6528 | return -1; | |
6529 | if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM)) | |
6530 | return -1; | |
6531 | break; | |
6532 | ||
6533 | case 0xe73f: /* VSTL - vector store with length */ | |
6534 | oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0); | |
6535 | regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[3], &tmp); | |
6536 | tmp &= 0xffffffffu; | |
6537 | if (tmp > 16) | |
6538 | tmp = 16; | |
6539 | if (record_full_arch_list_add_mem (oaddr, tmp)) | |
6540 | return -1; | |
6541 | if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM)) | |
6542 | return -1; | |
6543 | break; | |
6544 | ||
6545 | /* 0xe747-0xe749 undefined */ | |
6546 | ||
6547 | case 0xe74a: /* VFTCI - vector fp test data class immediate */ | |
6548 | case 0xe75c: /* VISTR - vector isolate string */ | |
6549 | case 0xe780: /* VFEE - vector find element equal */ | |
6550 | case 0xe781: /* VFENE - vector find element not equal */ | |
6551 | case 0xe782: /* VFA - vector find any element equal */ | |
6552 | case 0xe78a: /* VSTRC - vector string range compare */ | |
6553 | case 0xe795: /* VPKLS - vector pack logical saturate */ | |
6554 | case 0xe797: /* VPKS - vector pack saturate */ | |
6555 | case 0xe7e8: /* VFCE - vector fp compare equal */ | |
6556 | case 0xe7ea: /* VFCHE - vector fp compare high or equal */ | |
6557 | case 0xe7eb: /* VFCE - vector fp compare high */ | |
6558 | case 0xe7f8: /* VCEQ - vector compare equal */ | |
6559 | case 0xe7f9: /* VCHL - vector compare high logical */ | |
6560 | case 0xe7fb: /* VCH - vector compare high */ | |
6561 | /* vector destination + flags + FPC */ | |
6562 | if (s390_record_vr (gdbarch, regcache, ivec[0])) | |
6563 | return -1; | |
6564 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
6565 | return -1; | |
6566 | if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM)) | |
6567 | return -1; | |
6568 | break; | |
6569 | ||
6570 | /* 0xe74b-0xe74c undefined */ | |
6571 | /* 0xe74e-0xe74f undefined */ | |
6572 | /* 0xe751 undefined */ | |
6573 | /* 0xe754-0xe755 undefined */ | |
6574 | /* 0xe757-0xe75b undefined */ | |
6575 | /* 0xe75d-0xe75e undefined */ | |
6576 | /* 0xe763 undefined */ | |
6577 | /* 0xe76c undefined */ | |
6578 | /* 0xe76e-0xe76f undefined */ | |
6579 | /* 0xe771 undefined */ | |
6580 | /* 0xe776 undefined */ | |
6581 | /* 0xe779 undefined */ | |
6582 | /* 0xe77b undefined */ | |
6583 | /* 0xe783 undefined */ | |
6584 | /* 0xe785-0xe789 undefined */ | |
6585 | /* 0xe78b undefined */ | |
6586 | /* 0xe790-0xe793 undefined */ | |
6587 | /* 0xe796 undefined */ | |
6588 | /* 0xe798-0xe7a0 undefined */ | |
6589 | /* 0xe7a8 undefined */ | |
6590 | /* 0xe7b0-0xe7b3 undefined */ | |
6591 | /* 0xe7b5-0xe7b8 undefined */ | |
6592 | /* 0xe7ba undefined */ | |
6593 | /* 0xe7be undefined */ | |
6594 | /* 0xe7c6 undefined */ | |
6595 | /* 0xe7c8-0xe7c9 undefined */ | |
6596 | ||
6597 | case 0xe7ca: /* WFK - vector fp compare and signal scalar */ | |
6598 | case 0xe7cb: /* WFC - vector fp compare scalar */ | |
6599 | case 0xe7d8: /* VTM - vector test under mask */ | |
6600 | case 0xe7d9: /* VECL - vector element compare logical */ | |
6601 | case 0xe7db: /* VEC - vector element compare */ | |
6602 | case 0xed08: /* KEB - compare and signal */ | |
6603 | case 0xed09: /* CEB - compare */ | |
6604 | case 0xed18: /* KDB - compare and signal */ | |
6605 | case 0xed19: /* CDB - compare */ | |
6606 | /* flags + fpc only */ | |
6607 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
6608 | return -1; | |
6609 | if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM)) | |
6610 | return -1; | |
6611 | break; | |
6612 | ||
6613 | /* 0xe7cd undefined */ | |
6614 | /* 0xe7cf-0xe7d3 undefined */ | |
6615 | /* 0xe7da undefined */ | |
6616 | /* 0xe7dc-0xe7dd undefined */ | |
6617 | /* 0xe7e0-0xe7e1 undefined */ | |
6618 | /* 0xe7e4 undefined */ | |
6619 | /* 0xe7e6 undefined */ | |
6620 | /* 0xe7e9 undefined */ | |
6621 | /* 0xe7ec-0xe7ef undefined */ | |
6622 | /* 0xe7f4 undefined */ | |
6623 | /* 0xe7f6 undefined */ | |
6624 | /* 0xe7fa undefined */ | |
6625 | ||
6626 | /* 0xeb00-0xeb03 undefined */ | |
6627 | ||
6628 | case 0xeb04: /* LMG - load multiple */ | |
6629 | for (i = inib[2]; i != inib[3]; i++, i &= 0xf) | |
6630 | if (s390_record_gpr_g (gdbarch, regcache, i)) | |
6631 | return -1; | |
6632 | if (s390_record_gpr_g (gdbarch, regcache, inib[3])) | |
6633 | return -1; | |
6634 | break; | |
6635 | ||
6636 | /* 0xeb05-0xeb09 undefined */ | |
6637 | /* 0xeb0e undefined */ | |
6638 | /* 0xeb0f privileged: TRACG */ | |
6639 | /* 0xeb10-0xeb13 undefined */ | |
6640 | ||
6641 | case 0xeb14: /* CSY - compare and swap */ | |
6642 | case 0xebf4: /* LAN - load and and */ | |
6643 | case 0xebf6: /* LAO - load and or */ | |
6644 | case 0xebf7: /* LAX - load and xor */ | |
6645 | case 0xebf8: /* LAA - load and add */ | |
6646 | case 0xebfa: /* LAAL - load and add logical */ | |
6647 | oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], ibyte[4]); | |
6648 | if (record_full_arch_list_add_mem (oaddr, 4)) | |
6649 | return -1; | |
6650 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2])) | |
6651 | return -1; | |
6652 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
6653 | return -1; | |
6654 | break; | |
6655 | ||
6656 | /* 0xeb15-0xeb1b undefined */ | |
6657 | /* 0xeb1e-0xeb1f undefined */ | |
6658 | /* 0xeb22 undefined */ | |
6659 | ||
6660 | case 0xeb23: /* CLT - compare logical and trap */ | |
6661 | case 0xeb2b: /* CLGT - compare logical and trap */ | |
6662 | /* fpc only - including possible DXC write for trapping insns */ | |
6663 | if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM)) | |
6664 | return -1; | |
6665 | break; | |
6666 | ||
6667 | case 0xeb24: /* STMG - store multiple */ | |
6668 | oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], ibyte[4]); | |
6669 | if (inib[2] <= inib[3]) | |
6670 | n = inib[3] - inib[2] + 1; | |
6671 | else | |
6672 | n = inib[3] + 0x10 - inib[2] + 1; | |
6673 | if (record_full_arch_list_add_mem (oaddr, n * 8)) | |
6674 | return -1; | |
6675 | break; | |
6676 | ||
6677 | /* 0xeb25 privileged */ | |
6678 | ||
6679 | case 0xeb26: /* STMH - store multiple high */ | |
6680 | case 0xeb90: /* STMY - store multiple */ | |
6681 | case 0xeb9b: /* STAMY - store access multiple */ | |
6682 | oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], ibyte[4]); | |
6683 | if (inib[2] <= inib[3]) | |
6684 | n = inib[3] - inib[2] + 1; | |
6685 | else | |
6686 | n = inib[3] + 0x10 - inib[2] + 1; | |
6687 | if (record_full_arch_list_add_mem (oaddr, n * 4)) | |
6688 | return -1; | |
6689 | break; | |
6690 | ||
6691 | /* 0xeb27-0xeb2a undefined */ | |
6692 | ||
6693 | case 0xeb2c: /* STCMH - store characters under mask */ | |
6694 | case 0xeb2d: /* STCMY - store characters under mask */ | |
6695 | oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], ibyte[4]); | |
6696 | if (record_full_arch_list_add_mem (oaddr, s390_popcnt (inib[3]))) | |
6697 | return -1; | |
6698 | break; | |
6699 | ||
6700 | /* 0xeb2e undefined */ | |
6701 | /* 0xeb2f privileged */ | |
6702 | ||
6703 | case 0xeb30: /* CSG - compare and swap */ | |
6704 | case 0xebe4: /* LANG - load and and */ | |
6705 | case 0xebe6: /* LAOG - load and or */ | |
6706 | case 0xebe7: /* LAXG - load and xor */ | |
6707 | case 0xebe8: /* LAAG - load and add */ | |
6708 | case 0xebea: /* LAALG - load and add logical */ | |
6709 | oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], ibyte[4]); | |
6710 | if (record_full_arch_list_add_mem (oaddr, 8)) | |
6711 | return -1; | |
6712 | if (s390_record_gpr_g (gdbarch, regcache, inib[2])) | |
6713 | return -1; | |
6714 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
6715 | return -1; | |
6716 | break; | |
6717 | ||
6718 | case 0xeb31: /* CDSY - compare double and swap */ | |
6719 | oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], ibyte[4]); | |
6720 | if (record_full_arch_list_add_mem (oaddr, 8)) | |
6721 | return -1; | |
6722 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2])) | |
6723 | return -1; | |
6724 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[2] | 1))) | |
6725 | return -1; | |
6726 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
6727 | return -1; | |
6728 | break; | |
6729 | ||
6730 | /* 0xeb32-0xeb3d undefined */ | |
6731 | ||
6732 | case 0xeb3e: /* CDSG - compare double and swap */ | |
6733 | oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], ibyte[4]); | |
6734 | if (record_full_arch_list_add_mem (oaddr, 16)) | |
6735 | return -1; | |
6736 | if (s390_record_gpr_g (gdbarch, regcache, inib[2])) | |
6737 | return -1; | |
6738 | if (s390_record_gpr_g (gdbarch, regcache, inib[2] | 1)) | |
6739 | return -1; | |
6740 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
6741 | return -1; | |
6742 | break; | |
6743 | ||
6744 | /* 0xeb3f-0xeb43 undefined */ | |
6745 | /* 0xeb46-0xeb4b undefined */ | |
6746 | /* 0xeb4d-0xeb50 undefined */ | |
6747 | ||
6748 | case 0xeb52: /* MVIY - move */ | |
6749 | oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], ibyte[4]); | |
6750 | if (record_full_arch_list_add_mem (oaddr, 1)) | |
6751 | return -1; | |
6752 | break; | |
6753 | ||
6754 | case 0xeb54: /* NIY - and */ | |
6755 | case 0xeb56: /* OIY - or */ | |
6756 | case 0xeb57: /* XIY - xor */ | |
6757 | oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], ibyte[4]); | |
6758 | if (record_full_arch_list_add_mem (oaddr, 1)) | |
6759 | return -1; | |
6760 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
6761 | return -1; | |
6762 | break; | |
6763 | ||
6764 | /* 0xeb53 undefined */ | |
6765 | /* 0xeb58-0xeb69 undefined */ | |
6766 | ||
6767 | case 0xeb6a: /* ASI - add immediate */ | |
6768 | case 0xeb6e: /* ALSI - add immediate */ | |
6769 | oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], ibyte[4]); | |
6770 | if (record_full_arch_list_add_mem (oaddr, 4)) | |
6771 | return -1; | |
6772 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
6773 | return -1; | |
6774 | break; | |
6775 | ||
6776 | /* 0xeb6b-0xeb6d undefined */ | |
6777 | /* 0xeb6f-0xeb79 undefined */ | |
6778 | ||
6779 | case 0xeb7a: /* AGSI - add immediate */ | |
6780 | case 0xeb7e: /* ALGSI - add immediate */ | |
6781 | oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], ibyte[4]); | |
6782 | if (record_full_arch_list_add_mem (oaddr, 8)) | |
6783 | return -1; | |
6784 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
6785 | return -1; | |
6786 | break; | |
6787 | ||
6788 | /* 0xeb7b-0xeb7d undefined */ | |
6789 | /* 0xeb7f undefined */ | |
6790 | ||
6791 | case 0xeb80: /* ICMH - insert characters under mask */ | |
6792 | /* 32-bit high gpr destination + flags */ | |
6793 | if (s390_record_gpr_h (gdbarch, regcache, inib[2])) | |
6794 | return -1; | |
6795 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
6796 | return -1; | |
6797 | break; | |
6798 | ||
6799 | /* 0xeb82-0xeb8d undefined */ | |
6800 | ||
6801 | case 0xeb8e: /* MVCLU - move long unicode [partial] */ | |
6802 | regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[2], &tmp); | |
6803 | oaddr = s390_record_address_mask (gdbarch, regcache, tmp); | |
6804 | regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + (inib[2] | 1), &tmp); | |
6805 | if (record_full_arch_list_add_mem (oaddr, tmp)) | |
6806 | return -1; | |
6807 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2])) | |
6808 | return -1; | |
6809 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[2] | 1))) | |
6810 | return -1; | |
6811 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[3])) | |
6812 | return -1; | |
6813 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[3] | 1))) | |
6814 | return -1; | |
6815 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
6816 | return -1; | |
6817 | break; | |
6818 | ||
6819 | case 0xeb8f: /* CLCLU - compare logical long unicode [partial] */ | |
6820 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2])) | |
6821 | return -1; | |
6822 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[2] | 1))) | |
6823 | return -1; | |
6824 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[3])) | |
6825 | return -1; | |
6826 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[3] | 1))) | |
6827 | return -1; | |
6828 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
6829 | return -1; | |
6830 | break; | |
6831 | ||
6832 | /* 0xeb91-0xeb95 undefined */ | |
6833 | ||
6834 | case 0xeb96: /* LMH - load multiple high */ | |
6835 | for (i = inib[2]; i != inib[3]; i++, i &= 0xf) | |
6836 | if (s390_record_gpr_h (gdbarch, regcache, i)) | |
6837 | return -1; | |
6838 | if (s390_record_gpr_h (gdbarch, regcache, inib[3])) | |
6839 | return -1; | |
6840 | break; | |
6841 | ||
6842 | /* 0xeb97 undefined */ | |
6843 | ||
6844 | case 0xeb98: /* LMY - load multiple */ | |
6845 | for (i = inib[2]; i != inib[3]; i++, i &= 0xf) | |
6846 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + i)) | |
6847 | return -1; | |
6848 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[3])) | |
6849 | return -1; | |
6850 | break; | |
6851 | ||
6852 | /* 0xeb99 undefined */ | |
6853 | ||
6854 | case 0xeb9a: /* LAMY - load access multiple */ | |
6855 | for (i = inib[2]; i != inib[3]; i++, i &= 0xf) | |
6856 | if (record_full_arch_list_add_reg (regcache, S390_A0_REGNUM + i)) | |
6857 | return -1; | |
6858 | if (record_full_arch_list_add_reg (regcache, S390_A0_REGNUM + inib[3])) | |
6859 | return -1; | |
6860 | break; | |
6861 | ||
6862 | /* 0xeb9c-0xebbf undefined */ | |
6863 | /* 0xebc1-0xebdb undefined */ | |
6864 | /* 0xebe5 undefined */ | |
6865 | /* 0xebe9 undefined */ | |
6866 | /* 0xebeb-0xebf1 undefined */ | |
6867 | /* 0xebf5 undefined */ | |
6868 | /* 0xebf9 undefined */ | |
6869 | /* 0xebfb-0xebff undefined */ | |
6870 | ||
6871 | /* 0xed00-0xed03 undefined */ | |
6872 | ||
6873 | case 0xed04: /* LDEB - load lengthened */ | |
6874 | case 0xed0c: /* MDEB - multiply */ | |
6875 | case 0xed0d: /* DEB - divide */ | |
6876 | case 0xed14: /* SQEB - square root */ | |
6877 | case 0xed15: /* SQDB - square root */ | |
6878 | case 0xed17: /* MEEB - multiply */ | |
6879 | case 0xed1c: /* MDB - multiply */ | |
6880 | case 0xed1d: /* DDB - divide */ | |
6881 | /* float destination + fpc */ | |
6882 | if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[2])) | |
6883 | return -1; | |
6884 | if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM)) | |
6885 | return -1; | |
6886 | break; | |
6887 | ||
6888 | case 0xed05: /* LXDB - load lengthened */ | |
6889 | case 0xed06: /* LXEB - load lengthened */ | |
6890 | case 0xed07: /* MXDB - multiply */ | |
6891 | /* float pair destination + fpc */ | |
6892 | if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[2])) | |
6893 | return -1; | |
6894 | if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + (inib[2] | 2))) | |
6895 | return -1; | |
6896 | if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM)) | |
6897 | return -1; | |
6898 | break; | |
6899 | ||
6900 | case 0xed0a: /* AEB - add */ | |
6901 | case 0xed0b: /* SEB - subtract */ | |
6902 | case 0xed1a: /* ADB - add */ | |
6903 | case 0xed1b: /* SDB - subtract */ | |
6904 | /* float destination + flags + fpc */ | |
6905 | if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[2])) | |
6906 | return -1; | |
6907 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
6908 | return -1; | |
6909 | if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM)) | |
6910 | return -1; | |
6911 | break; | |
6912 | ||
6913 | case 0xed0e: /* MAEB - multiply and add */ | |
6914 | case 0xed0f: /* MSEB - multiply and subtract */ | |
6915 | case 0xed1e: /* MADB - multiply and add */ | |
6916 | case 0xed1f: /* MSDB - multiply and subtract */ | |
6917 | case 0xed40: /* SLDT - shift significand left */ | |
6918 | case 0xed41: /* SRDT - shift significand right */ | |
6919 | case 0xedaa: /* CDZT - convert from zoned */ | |
6920 | case 0xedae: /* CDPT - convert from packed */ | |
6921 | /* float destination [RXF] + fpc */ | |
6922 | if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[8])) | |
6923 | return -1; | |
6924 | if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM)) | |
6925 | return -1; | |
6926 | break; | |
6927 | ||
6928 | /* 0xed13 undefined */ | |
6929 | /* 0xed16 undefined */ | |
6930 | /* 0xed20-0xed23 undefined */ | |
6931 | ||
6932 | case 0xed24: /* LDE - load lengthened */ | |
6933 | case 0xed34: /* SQE - square root */ | |
6934 | case 0xed35: /* SQD - square root */ | |
6935 | case 0xed37: /* MEE - multiply */ | |
6936 | case 0xed64: /* LEY - load */ | |
6937 | case 0xed65: /* LDY - load */ | |
6938 | /* float destination */ | |
6939 | if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[2])) | |
6940 | return -1; | |
6941 | break; | |
6942 | ||
6943 | case 0xed25: /* LXD - load lengthened */ | |
6944 | case 0xed26: /* LXE - load lengthened */ | |
6945 | /* float pair destination */ | |
6946 | if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[2])) | |
6947 | return -1; | |
6948 | if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + (inib[2] | 2))) | |
6949 | return -1; | |
6950 | break; | |
6951 | ||
6952 | /* 0xed27-0xed2d undefined */ | |
6953 | ||
6954 | case 0xed2e: /* MAE - multiply and add */ | |
6955 | case 0xed2f: /* MSE - multiply and subtract */ | |
6956 | case 0xed38: /* MAYL - multiply and add unnormalized */ | |
6957 | case 0xed39: /* MYL - multiply unnormalized */ | |
6958 | case 0xed3c: /* MAYH - multiply and add unnormalized */ | |
6959 | case 0xed3d: /* MYH - multiply unnormalized */ | |
6960 | case 0xed3e: /* MAD - multiply and add */ | |
6961 | case 0xed3f: /* MSD - multiply and subtract */ | |
6962 | /* float destination [RXF] */ | |
6963 | if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[8])) | |
6964 | return -1; | |
6965 | break; | |
6966 | ||
6967 | /* 0xed30-0xed33 undefined */ | |
6968 | /* 0xed36 undefined */ | |
6969 | ||
6970 | case 0xed3a: /* MAY - multiply and add unnormalized */ | |
6971 | case 0xed3b: /* MY - multiply unnormalized */ | |
6972 | /* float pair destination [RXF] */ | |
6973 | if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[8])) | |
6974 | return -1; | |
6975 | if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + (inib[8] | 2))) | |
6976 | return -1; | |
6977 | break; | |
6978 | ||
6979 | /* 0xed42-0xed47 undefind */ | |
6980 | ||
6981 | case 0xed48: /* SLXT - shift significand left */ | |
6982 | case 0xed49: /* SRXT - shift significand right */ | |
6983 | case 0xedab: /* CXZT - convert from zoned */ | |
6984 | case 0xedaf: /* CXPT - convert from packed */ | |
6985 | /* float pair destination [RXF] + fpc */ | |
6986 | if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[8])) | |
6987 | return -1; | |
6988 | if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + (inib[8] | 2))) | |
6989 | return -1; | |
6990 | if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM)) | |
6991 | return -1; | |
6992 | break; | |
6993 | ||
6994 | /* 0xed4a-0xed4f undefind */ | |
6995 | /* 0xed52-0xed53 undefind */ | |
6996 | /* 0xed56-0xed57 undefind */ | |
6997 | /* 0xed5a-0xed63 undefind */ | |
6998 | /* 0xed68-0xeda7 undefined */ | |
6999 | ||
7000 | case 0xeda8: /* CZDT - convert to zoned */ | |
7001 | case 0xeda9: /* CZXT - convert to zoned */ | |
7002 | case 0xedac: /* CPDT - convert to packed */ | |
7003 | case 0xedad: /* CPXT - convert to packed */ | |
7004 | oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0); | |
7005 | if (record_full_arch_list_add_mem (oaddr, ibyte[1] + 1)) | |
7006 | return -1; | |
7007 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
7008 | return -1; | |
7009 | break; | |
7010 | ||
7011 | /* 0xedb0-0xedff undefined */ | |
7012 | ||
7013 | default: | |
7014 | goto UNKNOWN_OP; | |
7015 | } | |
7016 | break; | |
7017 | ||
7018 | /* 0xe4 undefined */ | |
7019 | ||
7020 | case 0xe5: | |
7021 | /* SSE/SIL-format instruction */ | |
7022 | switch (insn[0]) | |
7023 | { | |
7024 | /* 0xe500-0xe543 undefined, privileged, or unsupported */ | |
7025 | ||
7026 | case 0xe544: /* MVHHI - move */ | |
7027 | oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0); | |
7028 | if (record_full_arch_list_add_mem (oaddr, 2)) | |
7029 | return -1; | |
7030 | break; | |
7031 | ||
7032 | /* 0xe545-0xe547 undefined */ | |
7033 | ||
7034 | case 0xe548: /* MVGHI - move */ | |
7035 | oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0); | |
7036 | if (record_full_arch_list_add_mem (oaddr, 8)) | |
7037 | return -1; | |
7038 | break; | |
7039 | ||
7040 | /* 0xe549-0xe54b undefined */ | |
7041 | ||
7042 | case 0xe54c: /* MVHI - move */ | |
7043 | oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0); | |
7044 | if (record_full_arch_list_add_mem (oaddr, 4)) | |
7045 | return -1; | |
7046 | break; | |
7047 | ||
7048 | /* 0xe54d-0xe553 undefined */ | |
7049 | ||
7050 | case 0xe554: /* CHHSI - compare halfword immediate */ | |
7051 | case 0xe555: /* CLHHSI - compare logical immediate */ | |
7052 | case 0xe558: /* CGHSI - compare halfword immediate */ | |
7053 | case 0xe559: /* CLGHSI - compare logical immediate */ | |
7054 | case 0xe55c: /* CHSI - compare halfword immediate */ | |
7055 | case 0xe55d: /* CLFHSI - compare logical immediate */ | |
7056 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
7057 | return -1; | |
7058 | break; | |
7059 | ||
7060 | /* 0xe556-0xe557 undefined */ | |
7061 | /* 0xe55a-0xe55b undefined */ | |
7062 | /* 0xe55e-0xe55f undefined */ | |
7063 | ||
7064 | case 0xe560: /* TBEGIN - transaction begin */ | |
7065 | /* The transaction will be immediately aborted after this | |
7066 | instruction, due to single-stepping. This instruction is | |
7067 | only supported so that the program can fail a few times | |
7068 | and go to the non-transactional fallback. */ | |
7069 | if (inib[4]) | |
7070 | { | |
7071 | /* Transaction diagnostic block - user. */ | |
7072 | oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0); | |
7073 | if (record_full_arch_list_add_mem (oaddr, 256)) | |
7074 | return -1; | |
7075 | } | |
7076 | /* Transaction diagnostic block - supervisor. */ | |
7077 | if (record_full_arch_list_add_reg (regcache, S390_TDB_DWORD0_REGNUM)) | |
7078 | return -1; | |
7079 | if (record_full_arch_list_add_reg (regcache, S390_TDB_ABORT_CODE_REGNUM)) | |
7080 | return -1; | |
7081 | if (record_full_arch_list_add_reg (regcache, S390_TDB_CONFLICT_TOKEN_REGNUM)) | |
7082 | return -1; | |
7083 | if (record_full_arch_list_add_reg (regcache, S390_TDB_ATIA_REGNUM)) | |
7084 | return -1; | |
7085 | for (i = 0; i < 16; i++) | |
7086 | if (record_full_arch_list_add_reg (regcache, S390_TDB_R0_REGNUM + i)) | |
7087 | return -1; | |
7088 | /* And flags. */ | |
7089 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
7090 | return -1; | |
7091 | break; | |
7092 | ||
7093 | /* 0xe561 unsupported: TBEGINC */ | |
7094 | /* 0xe562-0xe5ff undefined */ | |
7095 | ||
7096 | default: | |
7097 | goto UNKNOWN_OP; | |
7098 | } | |
7099 | break; | |
7100 | ||
7101 | /* 0xe6 undefined */ | |
7102 | ||
7103 | case 0xec: | |
7104 | /* RIE/RIS/RRS-format instruction */ | |
7105 | switch (ibyte[0] << 8 | ibyte[5]) | |
7106 | { | |
7107 | /* 0xec00-0xec41 undefined */ | |
7108 | ||
7109 | case 0xec42: /* LOCHI - load halfword immediate on condition */ | |
7110 | case 0xec51: /* RISBLG - rotate then insert selected bits low */ | |
7111 | /* 32-bit or native gpr destination */ | |
7112 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2])) | |
7113 | return -1; | |
7114 | break; | |
7115 | ||
7116 | /* 0xec43 undefined */ | |
7117 | ||
7118 | case 0xec44: /* BRXHG - branch relative on index high */ | |
7119 | case 0xec45: /* BRXLG - branch relative on index low or equal */ | |
7120 | case 0xec46: /* LOCGHI - load halfword immediate on condition */ | |
7121 | case 0xec59: /* RISBGN - rotate then insert selected bits */ | |
7122 | /* 64-bit gpr destination */ | |
7123 | if (s390_record_gpr_g (gdbarch, regcache, inib[2])) | |
7124 | return -1; | |
7125 | break; | |
7126 | ||
7127 | /* 0xec47-0xec4d undefined */ | |
7128 | ||
7129 | case 0xec4e: /* LOCHHI - load halfword immediate on condition */ | |
7130 | case 0xec5d: /* RISBHG - rotate then insert selected bits high */ | |
7131 | /* 32-bit high gpr destination */ | |
7132 | if (s390_record_gpr_h (gdbarch, regcache, inib[2])) | |
7133 | return -1; | |
7134 | break; | |
7135 | ||
7136 | /* 0xec4f-0xec50 undefined */ | |
7137 | /* 0xec52-0xec53 undefined */ | |
7138 | ||
7139 | case 0xec54: /* RNSBG - rotate then and selected bits */ | |
7140 | case 0xec55: /* RISBG - rotate then insert selected bits */ | |
7141 | case 0xec56: /* ROSBG - rotate then or selected bits */ | |
7142 | case 0xec57: /* RXSBG - rotate then xor selected bits */ | |
7143 | case 0xecd9: /* AGHIK - add immediate */ | |
7144 | case 0xecdb: /* ALGHSIK - add logical immediate */ | |
7145 | /* 64-bit gpr destination + flags */ | |
7146 | if (s390_record_gpr_g (gdbarch, regcache, inib[2])) | |
7147 | return -1; | |
7148 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
7149 | return -1; | |
7150 | break; | |
7151 | ||
7152 | /* 0xec58 undefined */ | |
7153 | /* 0xec5a-0xec5c undefined */ | |
7154 | /* 0xec5e-0xec63 undefined */ | |
7155 | ||
7156 | case 0xec64: /* CGRJ - compare and branch relative */ | |
7157 | case 0xec65: /* CLGRJ - compare logical and branch relative */ | |
7158 | case 0xec76: /* CRJ - compare and branch relative */ | |
7159 | case 0xec77: /* CLRJ - compare logical and branch relative */ | |
7160 | case 0xec7c: /* CGIJ - compare immediate and branch relative */ | |
7161 | case 0xec7d: /* CLGIJ - compare logical immediate and branch relative */ | |
7162 | case 0xec7e: /* CIJ - compare immediate and branch relative */ | |
7163 | case 0xec7f: /* CLIJ - compare logical immediate and branch relative */ | |
7164 | case 0xece4: /* CGRB - compare and branch */ | |
7165 | case 0xece5: /* CLGRB - compare logical and branch */ | |
7166 | case 0xecf6: /* CRB - compare and branch */ | |
7167 | case 0xecf7: /* CLRB - compare logical and branch */ | |
7168 | case 0xecfc: /* CGIB - compare immediate and branch */ | |
7169 | case 0xecfd: /* CLGIB - compare logical immediate and branch */ | |
7170 | case 0xecfe: /* CIB - compare immediate and branch */ | |
7171 | case 0xecff: /* CLIB - compare logical immediate and branch */ | |
7172 | break; | |
7173 | ||
7174 | /* 0xec66-0xec6f undefined */ | |
7175 | ||
7176 | case 0xec70: /* CGIT - compare immediate and trap */ | |
7177 | case 0xec71: /* CLGIT - compare logical immediate and trap */ | |
7178 | case 0xec72: /* CIT - compare immediate and trap */ | |
7179 | case 0xec73: /* CLFIT - compare logical immediate and trap */ | |
7180 | /* fpc only - including possible DXC write for trapping insns */ | |
7181 | if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM)) | |
7182 | return -1; | |
7183 | break; | |
7184 | ||
7185 | /* 0xec74-0xec75 undefined */ | |
7186 | /* 0xec78-0xec7b undefined */ | |
7187 | ||
7188 | /* 0xec80-0xecd7 undefined */ | |
7189 | ||
7190 | case 0xecd8: /* AHIK - add immediate */ | |
7191 | case 0xecda: /* ALHSIK - add logical immediate */ | |
7192 | /* 32-bit gpr destination + flags */ | |
7193 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2])) | |
7194 | return -1; | |
7195 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
7196 | return -1; | |
7197 | break; | |
7198 | ||
7199 | /* 0xecdc-0xece3 undefined */ | |
7200 | /* 0xece6-0xecf5 undefined */ | |
7201 | /* 0xecf8-0xecfb undefined */ | |
7202 | ||
7203 | default: | |
7204 | goto UNKNOWN_OP; | |
7205 | } | |
7206 | break; | |
7207 | ||
7208 | case 0xee: /* PLO - perform locked operation */ | |
7209 | regcache_raw_read_unsigned (regcache, S390_R0_REGNUM, &tmp); | |
7210 | oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0); | |
7211 | oaddr2 = s390_record_calc_disp (gdbarch, regcache, 0, insn[2], 0); | |
7212 | if (!(tmp & 0x100)) | |
7213 | { | |
7214 | uint8_t fc = tmp & 0xff; | |
7215 | gdb_byte buf[8]; | |
7216 | switch (fc) | |
7217 | { | |
7218 | case 0x00: /* CL */ | |
7219 | /* op1c */ | |
7220 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2])) | |
7221 | return -1; | |
7222 | /* op3 */ | |
7223 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[3])) | |
7224 | return -1; | |
7225 | break; | |
7226 | ||
7227 | case 0x01: /* CLG */ | |
7228 | /* op1c */ | |
7229 | if (record_full_arch_list_add_mem (oaddr2 + 0x08, 8)) | |
7230 | return -1; | |
7231 | /* op3 */ | |
7232 | if (record_full_arch_list_add_mem (oaddr2 + 0x28, 8)) | |
7233 | return -1; | |
7234 | break; | |
7235 | ||
7236 | case 0x02: /* CLGR */ | |
7237 | /* op1c */ | |
7238 | if (s390_record_gpr_g (gdbarch, regcache, inib[2])) | |
7239 | return -1; | |
7240 | /* op3 */ | |
7241 | if (s390_record_gpr_g (gdbarch, regcache, inib[3])) | |
7242 | return -1; | |
7243 | break; | |
7244 | ||
7245 | case 0x03: /* CLX */ | |
7246 | /* op1c */ | |
7247 | if (record_full_arch_list_add_mem (oaddr2 + 0x00, 16)) | |
7248 | return -1; | |
7249 | /* op3 */ | |
7250 | if (record_full_arch_list_add_mem (oaddr2 + 0x20, 16)) | |
7251 | return -1; | |
7252 | break; | |
7253 | ||
7254 | case 0x08: /* DCS */ | |
7255 | /* op3c */ | |
7256 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[3])) | |
7257 | return -1; | |
7258 | /* fallthru */ | |
7259 | case 0x0c: /* CSST */ | |
7260 | /* op4 */ | |
7261 | if (record_full_arch_list_add_mem (oaddr2, 4)) | |
7262 | return -1; | |
7263 | goto CS; | |
7264 | ||
7265 | case 0x14: /* CSTST */ | |
7266 | /* op8 */ | |
7267 | if (target_read_memory (oaddr2 + 0x88, buf, 8)) | |
7268 | return -1; | |
7269 | oaddr3 = extract_unsigned_integer (buf, 8, byte_order); | |
7270 | oaddr3 = s390_record_address_mask (gdbarch, regcache, oaddr3); | |
7271 | if (record_full_arch_list_add_mem (oaddr3, 4)) | |
7272 | return -1; | |
7273 | /* fallthru */ | |
7274 | case 0x10: /* CSDST */ | |
7275 | /* op6 */ | |
7276 | if (target_read_memory (oaddr2 + 0x68, buf, 8)) | |
7277 | return -1; | |
7278 | oaddr3 = extract_unsigned_integer (buf, 8, byte_order); | |
7279 | oaddr3 = s390_record_address_mask (gdbarch, regcache, oaddr3); | |
7280 | if (record_full_arch_list_add_mem (oaddr3, 4)) | |
7281 | return -1; | |
7282 | /* op4 */ | |
7283 | if (target_read_memory (oaddr2 + 0x48, buf, 8)) | |
7284 | return -1; | |
7285 | oaddr3 = extract_unsigned_integer (buf, 8, byte_order); | |
7286 | oaddr3 = s390_record_address_mask (gdbarch, regcache, oaddr3); | |
7287 | if (record_full_arch_list_add_mem (oaddr3, 4)) | |
7288 | return -1; | |
7289 | /* fallthru */ | |
7290 | case 0x04: /* CS */ | |
7291 | CS: | |
7292 | /* op1c */ | |
7293 | if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2])) | |
7294 | return -1; | |
7295 | /* op2 */ | |
7296 | if (record_full_arch_list_add_mem (oaddr, 4)) | |
7297 | return -1; | |
7298 | break; | |
7299 | ||
7300 | case 0x09: /* DCSG */ | |
7301 | /* op3c */ | |
7302 | if (record_full_arch_list_add_mem (oaddr2 + 0x28, 8)) | |
7303 | return -1; | |
7304 | goto CSSTG; | |
7305 | ||
7306 | case 0x15: /* CSTSTG */ | |
7307 | /* op8 */ | |
7308 | if (target_read_memory (oaddr2 + 0x88, buf, 8)) | |
7309 | return -1; | |
7310 | oaddr3 = extract_unsigned_integer (buf, 8, byte_order); | |
7311 | oaddr3 = s390_record_address_mask (gdbarch, regcache, oaddr3); | |
7312 | if (record_full_arch_list_add_mem (oaddr3, 8)) | |
7313 | return -1; | |
7314 | /* fallthru */ | |
7315 | case 0x11: /* CSDSTG */ | |
7316 | /* op6 */ | |
7317 | if (target_read_memory (oaddr2 + 0x68, buf, 8)) | |
7318 | return -1; | |
7319 | oaddr3 = extract_unsigned_integer (buf, 8, byte_order); | |
7320 | oaddr3 = s390_record_address_mask (gdbarch, regcache, oaddr3); | |
7321 | if (record_full_arch_list_add_mem (oaddr3, 8)) | |
7322 | return -1; | |
7323 | /* fallthru */ | |
7324 | case 0x0d: /* CSSTG */ | |
7325 | CSSTG: | |
7326 | /* op4 */ | |
7327 | if (target_read_memory (oaddr2 + 0x48, buf, 8)) | |
7328 | return -1; | |
7329 | oaddr3 = extract_unsigned_integer (buf, 8, byte_order); | |
7330 | oaddr3 = s390_record_address_mask (gdbarch, regcache, oaddr3); | |
7331 | if (record_full_arch_list_add_mem (oaddr3, 8)) | |
7332 | return -1; | |
7333 | /* fallthru */ | |
7334 | case 0x05: /* CSG */ | |
7335 | /* op1c */ | |
7336 | if (record_full_arch_list_add_mem (oaddr2 + 0x08, 8)) | |
7337 | return -1; | |
7338 | /* op2 */ | |
7339 | if (record_full_arch_list_add_mem (oaddr, 8)) | |
7340 | return -1; | |
7341 | break; | |
7342 | ||
7343 | case 0x0a: /* DCSGR */ | |
7344 | /* op3c */ | |
7345 | if (s390_record_gpr_g (gdbarch, regcache, inib[3])) | |
7346 | return -1; | |
7347 | /* fallthru */ | |
7348 | case 0x0e: /* CSSTGR */ | |
7349 | /* op4 */ | |
7350 | if (record_full_arch_list_add_mem (oaddr2, 8)) | |
7351 | return -1; | |
7352 | goto CSGR; | |
7353 | ||
7354 | case 0x16: /* CSTSTGR */ | |
7355 | /* op8 */ | |
7356 | if (target_read_memory (oaddr2 + 0x88, buf, 8)) | |
7357 | return -1; | |
7358 | oaddr3 = extract_unsigned_integer (buf, 8, byte_order); | |
7359 | oaddr3 = s390_record_address_mask (gdbarch, regcache, oaddr3); | |
7360 | if (record_full_arch_list_add_mem (oaddr3, 8)) | |
7361 | return -1; | |
7362 | /* fallthru */ | |
7363 | case 0x12: /* CSDSTGR */ | |
7364 | /* op6 */ | |
7365 | if (target_read_memory (oaddr2 + 0x68, buf, 8)) | |
7366 | return -1; | |
7367 | oaddr3 = extract_unsigned_integer (buf, 8, byte_order); | |
7368 | oaddr3 = s390_record_address_mask (gdbarch, regcache, oaddr3); | |
7369 | if (record_full_arch_list_add_mem (oaddr3, 8)) | |
7370 | return -1; | |
7371 | /* op4 */ | |
7372 | if (target_read_memory (oaddr2 + 0x48, buf, 8)) | |
7373 | return -1; | |
7374 | oaddr3 = extract_unsigned_integer (buf, 8, byte_order); | |
7375 | oaddr3 = s390_record_address_mask (gdbarch, regcache, oaddr3); | |
7376 | if (record_full_arch_list_add_mem (oaddr3, 8)) | |
7377 | return -1; | |
7378 | /* fallthru */ | |
7379 | case 0x06: /* CSGR */ | |
7380 | CSGR: | |
7381 | /* op1c */ | |
7382 | if (s390_record_gpr_g (gdbarch, regcache, inib[2])) | |
7383 | return -1; | |
7384 | /* op2 */ | |
7385 | if (record_full_arch_list_add_mem (oaddr, 8)) | |
7386 | return -1; | |
7387 | break; | |
7388 | ||
7389 | case 0x0b: /* DCSX */ | |
7390 | /* op3c */ | |
7391 | if (record_full_arch_list_add_mem (oaddr2 + 0x20, 16)) | |
7392 | return -1; | |
7393 | goto CSSTX; | |
7394 | ||
7395 | case 0x17: /* CSTSTX */ | |
7396 | /* op8 */ | |
7397 | if (target_read_memory (oaddr2 + 0x88, buf, 8)) | |
7398 | return -1; | |
7399 | oaddr3 = extract_unsigned_integer (buf, 8, byte_order); | |
7400 | oaddr3 = s390_record_address_mask (gdbarch, regcache, oaddr3); | |
7401 | if (record_full_arch_list_add_mem (oaddr3, 16)) | |
7402 | return -1; | |
7403 | /* fallthru */ | |
7404 | case 0x13: /* CSDSTX */ | |
7405 | /* op6 */ | |
7406 | if (target_read_memory (oaddr2 + 0x68, buf, 8)) | |
7407 | return -1; | |
7408 | oaddr3 = extract_unsigned_integer (buf, 8, byte_order); | |
7409 | oaddr3 = s390_record_address_mask (gdbarch, regcache, oaddr3); | |
7410 | if (record_full_arch_list_add_mem (oaddr3, 16)) | |
7411 | return -1; | |
7412 | /* fallthru */ | |
7413 | case 0x0f: /* CSSTX */ | |
7414 | CSSTX: | |
7415 | /* op4 */ | |
7416 | if (target_read_memory (oaddr2 + 0x48, buf, 8)) | |
7417 | return -1; | |
7418 | oaddr3 = extract_unsigned_integer (buf, 8, byte_order); | |
7419 | oaddr3 = s390_record_address_mask (gdbarch, regcache, oaddr3); | |
7420 | if (record_full_arch_list_add_mem (oaddr3, 16)) | |
7421 | return -1; | |
7422 | /* fallthru */ | |
7423 | case 0x07: /* CSX */ | |
7424 | /* op1c */ | |
7425 | if (record_full_arch_list_add_mem (oaddr2 + 0x00, 16)) | |
7426 | return -1; | |
7427 | /* op2 */ | |
7428 | if (record_full_arch_list_add_mem (oaddr, 16)) | |
7429 | return -1; | |
7430 | break; | |
7431 | ||
7432 | default: | |
7433 | fprintf_unfiltered (gdb_stdlog, "Warning: Unknown PLO FC %02x at %s.\n", | |
7434 | fc, paddress (gdbarch, addr)); | |
7435 | return -1; | |
7436 | } | |
7437 | } | |
7438 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
7439 | return -1; | |
7440 | break; | |
7441 | ||
7442 | case 0xef: /* LMD - load multiple disjoint */ | |
7443 | for (i = inib[2]; i != inib[3]; i++, i &= 0xf) | |
7444 | if (s390_record_gpr_g (gdbarch, regcache, i)) | |
7445 | return -1; | |
7446 | if (s390_record_gpr_g (gdbarch, regcache, inib[3])) | |
7447 | return -1; | |
7448 | break; | |
7449 | ||
7450 | case 0xf0: /* SRP - shift and round decimal */ | |
7451 | case 0xf8: /* ZAP - zero and add */ | |
7452 | case 0xfa: /* AP - add decimal */ | |
7453 | case 0xfb: /* SP - subtract decimal */ | |
7454 | oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0); | |
7455 | if (record_full_arch_list_add_mem (oaddr, inib[2] + 1)) | |
7456 | return -1; | |
7457 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
7458 | return -1; | |
7459 | /* DXC may be written */ | |
7460 | if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM)) | |
7461 | return -1; | |
7462 | break; | |
7463 | ||
7464 | case 0xf1: /* MVO - move with offset */ | |
7465 | case 0xf2: /* PACK - pack */ | |
7466 | case 0xf3: /* UNPK - unpack */ | |
7467 | oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0); | |
7468 | if (record_full_arch_list_add_mem (oaddr, inib[2] + 1)) | |
7469 | return -1; | |
7470 | break; | |
7471 | ||
7472 | /* 0xf4-0xf7 undefined */ | |
7473 | ||
7474 | case 0xf9: /* CP - compare decimal */ | |
7475 | if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM)) | |
7476 | return -1; | |
7477 | /* DXC may be written */ | |
7478 | if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM)) | |
7479 | return -1; | |
7480 | break; | |
7481 | ||
7482 | case 0xfc: /* MP - multiply decimal */ | |
7483 | case 0xfd: /* DP - divide decimal */ | |
7484 | oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0); | |
7485 | if (record_full_arch_list_add_mem (oaddr, inib[2] + 1)) | |
7486 | return -1; | |
7487 | /* DXC may be written */ | |
7488 | if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM)) | |
7489 | return -1; | |
7490 | break; | |
7491 | ||
7492 | /* 0xfe-0xff undefined */ | |
7493 | ||
7494 | default: | |
7495 | UNKNOWN_OP: | |
7496 | fprintf_unfiltered (gdb_stdlog, "Warning: Don't know how to record %04x " | |
7497 | "at %s.\n", insn[0], paddress (gdbarch, addr)); | |
7498 | return -1; | |
7499 | } | |
7500 | ||
7501 | if (record_full_arch_list_add_reg (regcache, S390_PSWA_REGNUM)) | |
7502 | return -1; | |
7503 | if (record_full_arch_list_add_end ()) | |
7504 | return -1; | |
7505 | return 0; | |
7506 | } | |
7507 | ||
7508 | /* Initialize linux_record_tdep if not initialized yet. */ | |
7509 | ||
7510 | static void | |
7511 | s390_init_linux_record_tdep (struct linux_record_tdep *record_tdep, | |
7512 | enum s390_abi_kind abi) | |
7513 | { | |
7514 | /* These values are the size of the type that will be used in a system | |
7515 | call. They are obtained from Linux Kernel source. */ | |
7516 | ||
7517 | if (abi == ABI_LINUX_ZSERIES) | |
7518 | { | |
7519 | record_tdep->size_pointer = 8; | |
7520 | /* no _old_kernel_stat */ | |
7521 | record_tdep->size_tms = 32; | |
7522 | record_tdep->size_loff_t = 8; | |
7523 | record_tdep->size_flock = 32; | |
7524 | record_tdep->size_ustat = 32; | |
7525 | record_tdep->size_old_sigaction = 32; | |
7526 | record_tdep->size_old_sigset_t = 8; | |
7527 | record_tdep->size_rlimit = 16; | |
7528 | record_tdep->size_rusage = 144; | |
7529 | record_tdep->size_timeval = 16; | |
7530 | record_tdep->size_timezone = 8; | |
7531 | /* old_[ug]id_t never used */ | |
7532 | record_tdep->size_fd_set = 128; | |
7533 | record_tdep->size_old_dirent = 280; | |
7534 | record_tdep->size_statfs = 88; | |
7535 | record_tdep->size_statfs64 = 88; | |
7536 | record_tdep->size_sockaddr = 16; | |
7537 | record_tdep->size_int = 4; | |
7538 | record_tdep->size_long = 8; | |
7539 | record_tdep->size_ulong = 8; | |
7540 | record_tdep->size_msghdr = 56; | |
7541 | record_tdep->size_itimerval = 32; | |
7542 | record_tdep->size_stat = 144; | |
7543 | /* old_utsname unused */ | |
7544 | record_tdep->size_sysinfo = 112; | |
7545 | record_tdep->size_msqid_ds = 120; | |
7546 | record_tdep->size_shmid_ds = 112; | |
7547 | record_tdep->size_new_utsname = 390; | |
7548 | record_tdep->size_timex = 208; | |
7549 | record_tdep->size_mem_dqinfo = 24; | |
7550 | record_tdep->size_if_dqblk = 72; | |
7551 | record_tdep->size_fs_quota_stat = 80; | |
7552 | record_tdep->size_timespec = 16; | |
7553 | record_tdep->size_pollfd = 8; | |
7554 | record_tdep->size_NFS_FHSIZE = 32; | |
7555 | record_tdep->size_knfsd_fh = 132; | |
7556 | record_tdep->size_TASK_COMM_LEN = 16; | |
7557 | record_tdep->size_sigaction = 32; | |
7558 | record_tdep->size_sigset_t = 8; | |
7559 | record_tdep->size_siginfo_t = 128; | |
7560 | record_tdep->size_cap_user_data_t = 12; | |
7561 | record_tdep->size_stack_t = 24; | |
7562 | record_tdep->size_off_t = 8; | |
7563 | /* stat64 unused */ | |
7564 | record_tdep->size_gid_t = 4; | |
7565 | record_tdep->size_uid_t = 4; | |
7566 | record_tdep->size_PAGE_SIZE = 0x1000; /* 4KB */ | |
7567 | record_tdep->size_flock64 = 32; | |
7568 | record_tdep->size_io_event = 32; | |
7569 | record_tdep->size_iocb = 64; | |
7570 | record_tdep->size_epoll_event = 16; | |
7571 | record_tdep->size_itimerspec = 32; | |
7572 | record_tdep->size_mq_attr = 64; | |
7573 | record_tdep->size_termios = 36; | |
7574 | record_tdep->size_termios2 = 44; | |
7575 | record_tdep->size_pid_t = 4; | |
7576 | record_tdep->size_winsize = 8; | |
7577 | record_tdep->size_serial_struct = 72; | |
7578 | record_tdep->size_serial_icounter_struct = 80; | |
7579 | record_tdep->size_size_t = 8; | |
7580 | record_tdep->size_iovec = 16; | |
7581 | record_tdep->size_time_t = 8; | |
7582 | } | |
7583 | else if (abi == ABI_LINUX_S390) | |
7584 | { | |
7585 | record_tdep->size_pointer = 4; | |
7586 | record_tdep->size__old_kernel_stat = 32; | |
7587 | record_tdep->size_tms = 16; | |
7588 | record_tdep->size_loff_t = 8; | |
7589 | record_tdep->size_flock = 16; | |
7590 | record_tdep->size_ustat = 20; | |
7591 | record_tdep->size_old_sigaction = 16; | |
7592 | record_tdep->size_old_sigset_t = 4; | |
7593 | record_tdep->size_rlimit = 8; | |
7594 | record_tdep->size_rusage = 72; | |
7595 | record_tdep->size_timeval = 8; | |
7596 | record_tdep->size_timezone = 8; | |
7597 | record_tdep->size_old_gid_t = 2; | |
7598 | record_tdep->size_old_uid_t = 2; | |
7599 | record_tdep->size_fd_set = 128; | |
7600 | record_tdep->size_old_dirent = 268; | |
7601 | record_tdep->size_statfs = 64; | |
7602 | record_tdep->size_statfs64 = 88; | |
7603 | record_tdep->size_sockaddr = 16; | |
7604 | record_tdep->size_int = 4; | |
7605 | record_tdep->size_long = 4; | |
7606 | record_tdep->size_ulong = 4; | |
7607 | record_tdep->size_msghdr = 28; | |
7608 | record_tdep->size_itimerval = 16; | |
7609 | record_tdep->size_stat = 64; | |
7610 | /* old_utsname unused */ | |
7611 | record_tdep->size_sysinfo = 64; | |
7612 | record_tdep->size_msqid_ds = 88; | |
7613 | record_tdep->size_shmid_ds = 84; | |
7614 | record_tdep->size_new_utsname = 390; | |
7615 | record_tdep->size_timex = 128; | |
7616 | record_tdep->size_mem_dqinfo = 24; | |
7617 | record_tdep->size_if_dqblk = 72; | |
7618 | record_tdep->size_fs_quota_stat = 80; | |
7619 | record_tdep->size_timespec = 8; | |
7620 | record_tdep->size_pollfd = 8; | |
7621 | record_tdep->size_NFS_FHSIZE = 32; | |
7622 | record_tdep->size_knfsd_fh = 132; | |
7623 | record_tdep->size_TASK_COMM_LEN = 16; | |
7624 | record_tdep->size_sigaction = 20; | |
7625 | record_tdep->size_sigset_t = 8; | |
7626 | record_tdep->size_siginfo_t = 128; | |
7627 | record_tdep->size_cap_user_data_t = 12; | |
7628 | record_tdep->size_stack_t = 12; | |
7629 | record_tdep->size_off_t = 4; | |
7630 | record_tdep->size_stat64 = 104; | |
7631 | record_tdep->size_gid_t = 4; | |
7632 | record_tdep->size_uid_t = 4; | |
7633 | record_tdep->size_PAGE_SIZE = 0x1000; /* 4KB */ | |
7634 | record_tdep->size_flock64 = 32; | |
7635 | record_tdep->size_io_event = 32; | |
7636 | record_tdep->size_iocb = 64; | |
7637 | record_tdep->size_epoll_event = 16; | |
7638 | record_tdep->size_itimerspec = 16; | |
7639 | record_tdep->size_mq_attr = 32; | |
7640 | record_tdep->size_termios = 36; | |
7641 | record_tdep->size_termios2 = 44; | |
7642 | record_tdep->size_pid_t = 4; | |
7643 | record_tdep->size_winsize = 8; | |
7644 | record_tdep->size_serial_struct = 60; | |
7645 | record_tdep->size_serial_icounter_struct = 80; | |
7646 | record_tdep->size_size_t = 4; | |
7647 | record_tdep->size_iovec = 8; | |
7648 | record_tdep->size_time_t = 4; | |
7649 | } | |
7650 | ||
7651 | /* These values are the second argument of system call "sys_fcntl" | |
7652 | and "sys_fcntl64". They are obtained from Linux Kernel source. */ | |
7653 | record_tdep->fcntl_F_GETLK = 5; | |
7654 | record_tdep->fcntl_F_GETLK64 = 12; | |
7655 | record_tdep->fcntl_F_SETLK64 = 13; | |
7656 | record_tdep->fcntl_F_SETLKW64 = 14; | |
7657 | ||
7658 | record_tdep->arg1 = S390_R2_REGNUM; | |
7659 | record_tdep->arg2 = S390_R3_REGNUM; | |
7660 | record_tdep->arg3 = S390_R4_REGNUM; | |
7661 | record_tdep->arg4 = S390_R5_REGNUM; | |
7662 | record_tdep->arg5 = S390_R6_REGNUM; | |
7663 | ||
7664 | /* These values are the second argument of system call "sys_ioctl". | |
7665 | They are obtained from Linux Kernel source. | |
7666 | See arch/s390/include/uapi/asm/ioctls.h. */ | |
7667 | ||
7668 | record_tdep->ioctl_TCGETS = 0x5401; | |
7669 | record_tdep->ioctl_TCSETS = 0x5402; | |
7670 | record_tdep->ioctl_TCSETSW = 0x5403; | |
7671 | record_tdep->ioctl_TCSETSF = 0x5404; | |
7672 | record_tdep->ioctl_TCGETA = 0x5405; | |
7673 | record_tdep->ioctl_TCSETA = 0x5406; | |
7674 | record_tdep->ioctl_TCSETAW = 0x5407; | |
7675 | record_tdep->ioctl_TCSETAF = 0x5408; | |
7676 | record_tdep->ioctl_TCSBRK = 0x5409; | |
7677 | record_tdep->ioctl_TCXONC = 0x540a; | |
7678 | record_tdep->ioctl_TCFLSH = 0x540b; | |
7679 | record_tdep->ioctl_TIOCEXCL = 0x540c; | |
7680 | record_tdep->ioctl_TIOCNXCL = 0x540d; | |
7681 | record_tdep->ioctl_TIOCSCTTY = 0x540e; | |
7682 | record_tdep->ioctl_TIOCGPGRP = 0x540f; | |
7683 | record_tdep->ioctl_TIOCSPGRP = 0x5410; | |
7684 | record_tdep->ioctl_TIOCOUTQ = 0x5411; | |
7685 | record_tdep->ioctl_TIOCSTI = 0x5412; | |
7686 | record_tdep->ioctl_TIOCGWINSZ = 0x5413; | |
7687 | record_tdep->ioctl_TIOCSWINSZ = 0x5414; | |
7688 | record_tdep->ioctl_TIOCMGET = 0x5415; | |
7689 | record_tdep->ioctl_TIOCMBIS = 0x5416; | |
7690 | record_tdep->ioctl_TIOCMBIC = 0x5417; | |
7691 | record_tdep->ioctl_TIOCMSET = 0x5418; | |
7692 | record_tdep->ioctl_TIOCGSOFTCAR = 0x5419; | |
7693 | record_tdep->ioctl_TIOCSSOFTCAR = 0x541a; | |
7694 | record_tdep->ioctl_FIONREAD = 0x541b; | |
7695 | record_tdep->ioctl_TIOCINQ = 0x541b; /* alias */ | |
7696 | record_tdep->ioctl_TIOCLINUX = 0x541c; | |
7697 | record_tdep->ioctl_TIOCCONS = 0x541d; | |
7698 | record_tdep->ioctl_TIOCGSERIAL = 0x541e; | |
7699 | record_tdep->ioctl_TIOCSSERIAL = 0x541f; | |
7700 | record_tdep->ioctl_TIOCPKT = 0x5420; | |
7701 | record_tdep->ioctl_FIONBIO = 0x5421; | |
7702 | record_tdep->ioctl_TIOCNOTTY = 0x5422; | |
7703 | record_tdep->ioctl_TIOCSETD = 0x5423; | |
7704 | record_tdep->ioctl_TIOCGETD = 0x5424; | |
7705 | record_tdep->ioctl_TCSBRKP = 0x5425; | |
7706 | record_tdep->ioctl_TIOCSBRK = 0x5427; | |
7707 | record_tdep->ioctl_TIOCCBRK = 0x5428; | |
7708 | record_tdep->ioctl_TIOCGSID = 0x5429; | |
7709 | record_tdep->ioctl_TCGETS2 = 0x802c542a; | |
7710 | record_tdep->ioctl_TCSETS2 = 0x402c542b; | |
7711 | record_tdep->ioctl_TCSETSW2 = 0x402c542c; | |
7712 | record_tdep->ioctl_TCSETSF2 = 0x402c542d; | |
7713 | record_tdep->ioctl_TIOCGPTN = 0x80045430; | |
7714 | record_tdep->ioctl_TIOCSPTLCK = 0x40045431; | |
7715 | record_tdep->ioctl_FIONCLEX = 0x5450; | |
7716 | record_tdep->ioctl_FIOCLEX = 0x5451; | |
7717 | record_tdep->ioctl_FIOASYNC = 0x5452; | |
7718 | record_tdep->ioctl_TIOCSERCONFIG = 0x5453; | |
7719 | record_tdep->ioctl_TIOCSERGWILD = 0x5454; | |
7720 | record_tdep->ioctl_TIOCSERSWILD = 0x5455; | |
7721 | record_tdep->ioctl_TIOCGLCKTRMIOS = 0x5456; | |
7722 | record_tdep->ioctl_TIOCSLCKTRMIOS = 0x5457; | |
7723 | record_tdep->ioctl_TIOCSERGSTRUCT = 0x5458; | |
7724 | record_tdep->ioctl_TIOCSERGETLSR = 0x5459; | |
7725 | record_tdep->ioctl_TIOCSERGETMULTI = 0x545a; | |
7726 | record_tdep->ioctl_TIOCSERSETMULTI = 0x545b; | |
7727 | record_tdep->ioctl_TIOCMIWAIT = 0x545c; | |
7728 | record_tdep->ioctl_TIOCGICOUNT = 0x545d; | |
7729 | record_tdep->ioctl_FIOQSIZE = 0x545e; | |
7730 | } | |
7731 | ||
a8c99f38 JB |
7732 | /* Set up gdbarch struct. */ |
7733 | ||
a78f21af | 7734 | static struct gdbarch * |
5769d3cd AC |
7735 | s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) |
7736 | { | |
7803799a UW |
7737 | const struct target_desc *tdesc = info.target_desc; |
7738 | struct tdesc_arch_data *tdesc_data = NULL; | |
5769d3cd AC |
7739 | struct gdbarch *gdbarch; |
7740 | struct gdbarch_tdep *tdep; | |
f486487f | 7741 | enum s390_abi_kind tdep_abi; |
417c80f9 | 7742 | enum s390_vector_abi_kind vector_abi; |
7803799a | 7743 | int have_upper = 0; |
c642a434 UW |
7744 | int have_linux_v1 = 0; |
7745 | int have_linux_v2 = 0; | |
5aa82d05 | 7746 | int have_tdb = 0; |
550bdf96 | 7747 | int have_vx = 0; |
7803799a | 7748 | int first_pseudo_reg, last_pseudo_reg; |
05c0465e SDJ |
7749 | static const char *const stap_register_prefixes[] = { "%", NULL }; |
7750 | static const char *const stap_register_indirection_prefixes[] = { "(", | |
7751 | NULL }; | |
7752 | static const char *const stap_register_indirection_suffixes[] = { ")", | |
7753 | NULL }; | |
7803799a UW |
7754 | |
7755 | /* Default ABI and register size. */ | |
7756 | switch (info.bfd_arch_info->mach) | |
7757 | { | |
7758 | case bfd_mach_s390_31: | |
7759 | tdep_abi = ABI_LINUX_S390; | |
7760 | break; | |
7761 | ||
7762 | case bfd_mach_s390_64: | |
7763 | tdep_abi = ABI_LINUX_ZSERIES; | |
7764 | break; | |
7765 | ||
7766 | default: | |
7767 | return NULL; | |
7768 | } | |
7769 | ||
7770 | /* Use default target description if none provided by the target. */ | |
7771 | if (!tdesc_has_registers (tdesc)) | |
7772 | { | |
7773 | if (tdep_abi == ABI_LINUX_S390) | |
7774 | tdesc = tdesc_s390_linux32; | |
7775 | else | |
7776 | tdesc = tdesc_s390x_linux64; | |
7777 | } | |
7778 | ||
7779 | /* Check any target description for validity. */ | |
7780 | if (tdesc_has_registers (tdesc)) | |
7781 | { | |
7782 | static const char *const gprs[] = { | |
7783 | "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", | |
7784 | "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15" | |
7785 | }; | |
7786 | static const char *const fprs[] = { | |
7787 | "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", | |
7788 | "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15" | |
7789 | }; | |
7790 | static const char *const acrs[] = { | |
7791 | "acr0", "acr1", "acr2", "acr3", "acr4", "acr5", "acr6", "acr7", | |
7792 | "acr8", "acr9", "acr10", "acr11", "acr12", "acr13", "acr14", "acr15" | |
7793 | }; | |
7794 | static const char *const gprs_lower[] = { | |
7795 | "r0l", "r1l", "r2l", "r3l", "r4l", "r5l", "r6l", "r7l", | |
7796 | "r8l", "r9l", "r10l", "r11l", "r12l", "r13l", "r14l", "r15l" | |
7797 | }; | |
7798 | static const char *const gprs_upper[] = { | |
7799 | "r0h", "r1h", "r2h", "r3h", "r4h", "r5h", "r6h", "r7h", | |
7800 | "r8h", "r9h", "r10h", "r11h", "r12h", "r13h", "r14h", "r15h" | |
7801 | }; | |
4ac33720 UW |
7802 | static const char *const tdb_regs[] = { |
7803 | "tdb0", "tac", "tct", "atia", | |
7804 | "tr0", "tr1", "tr2", "tr3", "tr4", "tr5", "tr6", "tr7", | |
7805 | "tr8", "tr9", "tr10", "tr11", "tr12", "tr13", "tr14", "tr15" | |
7806 | }; | |
550bdf96 AA |
7807 | static const char *const vxrs_low[] = { |
7808 | "v0l", "v1l", "v2l", "v3l", "v4l", "v5l", "v6l", "v7l", "v8l", | |
7809 | "v9l", "v10l", "v11l", "v12l", "v13l", "v14l", "v15l", | |
7810 | }; | |
7811 | static const char *const vxrs_high[] = { | |
7812 | "v16", "v17", "v18", "v19", "v20", "v21", "v22", "v23", "v24", | |
7813 | "v25", "v26", "v27", "v28", "v29", "v30", "v31", | |
7814 | }; | |
7803799a UW |
7815 | const struct tdesc_feature *feature; |
7816 | int i, valid_p = 1; | |
7817 | ||
7818 | feature = tdesc_find_feature (tdesc, "org.gnu.gdb.s390.core"); | |
7819 | if (feature == NULL) | |
7820 | return NULL; | |
7821 | ||
7822 | tdesc_data = tdesc_data_alloc (); | |
7823 | ||
7824 | valid_p &= tdesc_numbered_register (feature, tdesc_data, | |
7825 | S390_PSWM_REGNUM, "pswm"); | |
7826 | valid_p &= tdesc_numbered_register (feature, tdesc_data, | |
7827 | S390_PSWA_REGNUM, "pswa"); | |
7828 | ||
7829 | if (tdesc_unnumbered_register (feature, "r0")) | |
7830 | { | |
7831 | for (i = 0; i < 16; i++) | |
7832 | valid_p &= tdesc_numbered_register (feature, tdesc_data, | |
7833 | S390_R0_REGNUM + i, gprs[i]); | |
7834 | } | |
7835 | else | |
7836 | { | |
7837 | have_upper = 1; | |
7838 | ||
7839 | for (i = 0; i < 16; i++) | |
7840 | valid_p &= tdesc_numbered_register (feature, tdesc_data, | |
7841 | S390_R0_REGNUM + i, | |
7842 | gprs_lower[i]); | |
7843 | for (i = 0; i < 16; i++) | |
7844 | valid_p &= tdesc_numbered_register (feature, tdesc_data, | |
7845 | S390_R0_UPPER_REGNUM + i, | |
7846 | gprs_upper[i]); | |
7847 | } | |
7848 | ||
7849 | feature = tdesc_find_feature (tdesc, "org.gnu.gdb.s390.fpr"); | |
7850 | if (feature == NULL) | |
7851 | { | |
7852 | tdesc_data_cleanup (tdesc_data); | |
7853 | return NULL; | |
7854 | } | |
7855 | ||
7856 | valid_p &= tdesc_numbered_register (feature, tdesc_data, | |
7857 | S390_FPC_REGNUM, "fpc"); | |
7858 | for (i = 0; i < 16; i++) | |
7859 | valid_p &= tdesc_numbered_register (feature, tdesc_data, | |
7860 | S390_F0_REGNUM + i, fprs[i]); | |
5769d3cd | 7861 | |
7803799a UW |
7862 | feature = tdesc_find_feature (tdesc, "org.gnu.gdb.s390.acr"); |
7863 | if (feature == NULL) | |
7864 | { | |
7865 | tdesc_data_cleanup (tdesc_data); | |
7866 | return NULL; | |
7867 | } | |
7868 | ||
7869 | for (i = 0; i < 16; i++) | |
7870 | valid_p &= tdesc_numbered_register (feature, tdesc_data, | |
7871 | S390_A0_REGNUM + i, acrs[i]); | |
7872 | ||
94eae614 | 7873 | /* Optional GNU/Linux-specific "registers". */ |
c642a434 UW |
7874 | feature = tdesc_find_feature (tdesc, "org.gnu.gdb.s390.linux"); |
7875 | if (feature) | |
7876 | { | |
7877 | tdesc_numbered_register (feature, tdesc_data, | |
7878 | S390_ORIG_R2_REGNUM, "orig_r2"); | |
7879 | ||
7880 | if (tdesc_numbered_register (feature, tdesc_data, | |
7881 | S390_LAST_BREAK_REGNUM, "last_break")) | |
7882 | have_linux_v1 = 1; | |
7883 | ||
7884 | if (tdesc_numbered_register (feature, tdesc_data, | |
7885 | S390_SYSTEM_CALL_REGNUM, "system_call")) | |
7886 | have_linux_v2 = 1; | |
7887 | ||
7888 | if (have_linux_v2 > have_linux_v1) | |
7889 | valid_p = 0; | |
7890 | } | |
7891 | ||
4ac33720 UW |
7892 | /* Transaction diagnostic block. */ |
7893 | feature = tdesc_find_feature (tdesc, "org.gnu.gdb.s390.tdb"); | |
7894 | if (feature) | |
7895 | { | |
7896 | for (i = 0; i < ARRAY_SIZE (tdb_regs); i++) | |
7897 | valid_p &= tdesc_numbered_register (feature, tdesc_data, | |
7898 | S390_TDB_DWORD0_REGNUM + i, | |
7899 | tdb_regs[i]); | |
5aa82d05 | 7900 | have_tdb = 1; |
4ac33720 UW |
7901 | } |
7902 | ||
550bdf96 AA |
7903 | /* Vector registers. */ |
7904 | feature = tdesc_find_feature (tdesc, "org.gnu.gdb.s390.vx"); | |
7905 | if (feature) | |
7906 | { | |
7907 | for (i = 0; i < 16; i++) | |
7908 | valid_p &= tdesc_numbered_register (feature, tdesc_data, | |
7909 | S390_V0_LOWER_REGNUM + i, | |
7910 | vxrs_low[i]); | |
7911 | for (i = 0; i < 16; i++) | |
7912 | valid_p &= tdesc_numbered_register (feature, tdesc_data, | |
7913 | S390_V16_REGNUM + i, | |
7914 | vxrs_high[i]); | |
7915 | have_vx = 1; | |
7916 | } | |
7917 | ||
7803799a UW |
7918 | if (!valid_p) |
7919 | { | |
7920 | tdesc_data_cleanup (tdesc_data); | |
7921 | return NULL; | |
7922 | } | |
7923 | } | |
5769d3cd | 7924 | |
417c80f9 AA |
7925 | /* Determine vector ABI. */ |
7926 | vector_abi = S390_VECTOR_ABI_NONE; | |
7927 | #ifdef HAVE_ELF | |
7928 | if (have_vx | |
7929 | && info.abfd != NULL | |
7930 | && info.abfd->format == bfd_object | |
7931 | && bfd_get_flavour (info.abfd) == bfd_target_elf_flavour | |
7932 | && bfd_elf_get_obj_attr_int (info.abfd, OBJ_ATTR_GNU, | |
7933 | Tag_GNU_S390_ABI_Vector) == 2) | |
7934 | vector_abi = S390_VECTOR_ABI_128; | |
7935 | #endif | |
7936 | ||
7803799a UW |
7937 | /* Find a candidate among extant architectures. */ |
7938 | for (arches = gdbarch_list_lookup_by_info (arches, &info); | |
7939 | arches != NULL; | |
7940 | arches = gdbarch_list_lookup_by_info (arches->next, &info)) | |
7941 | { | |
7942 | tdep = gdbarch_tdep (arches->gdbarch); | |
7943 | if (!tdep) | |
7944 | continue; | |
7945 | if (tdep->abi != tdep_abi) | |
7946 | continue; | |
417c80f9 AA |
7947 | if (tdep->vector_abi != vector_abi) |
7948 | continue; | |
7803799a UW |
7949 | if ((tdep->gpr_full_regnum != -1) != have_upper) |
7950 | continue; | |
7951 | if (tdesc_data != NULL) | |
7952 | tdesc_data_cleanup (tdesc_data); | |
7953 | return arches->gdbarch; | |
7954 | } | |
5769d3cd | 7955 | |
7803799a | 7956 | /* Otherwise create a new gdbarch for the specified machine type. */ |
fc270c35 | 7957 | tdep = XCNEW (struct gdbarch_tdep); |
7803799a | 7958 | tdep->abi = tdep_abi; |
417c80f9 | 7959 | tdep->vector_abi = vector_abi; |
5aa82d05 AA |
7960 | tdep->have_linux_v1 = have_linux_v1; |
7961 | tdep->have_linux_v2 = have_linux_v2; | |
7962 | tdep->have_tdb = have_tdb; | |
d0f54f9d | 7963 | gdbarch = gdbarch_alloc (&info, tdep); |
5769d3cd AC |
7964 | |
7965 | set_gdbarch_believe_pcc_promotion (gdbarch, 0); | |
4e409299 | 7966 | set_gdbarch_char_signed (gdbarch, 0); |
5769d3cd | 7967 | |
1de90795 UW |
7968 | /* S/390 GNU/Linux uses either 64-bit or 128-bit long doubles. |
7969 | We can safely let them default to 128-bit, since the debug info | |
7970 | will give the size of type actually used in each case. */ | |
7971 | set_gdbarch_long_double_bit (gdbarch, 128); | |
7972 | set_gdbarch_long_double_format (gdbarch, floatformats_ia64_quad); | |
7973 | ||
aaab4dba | 7974 | /* Amount PC must be decremented by after a breakpoint. This is |
3b3b875c | 7975 | often the number of bytes returned by gdbarch_breakpoint_from_pc but not |
aaab4dba | 7976 | always. */ |
5769d3cd | 7977 | set_gdbarch_decr_pc_after_break (gdbarch, 2); |
5769d3cd AC |
7978 | /* Stack grows downward. */ |
7979 | set_gdbarch_inner_than (gdbarch, core_addr_lessthan); | |
04180708 YQ |
7980 | set_gdbarch_breakpoint_kind_from_pc (gdbarch, s390_breakpoint::kind_from_pc); |
7981 | set_gdbarch_sw_breakpoint_from_kind (gdbarch, s390_breakpoint::bp_from_kind); | |
6df55226 MK |
7982 | set_gdbarch_software_single_step (gdbarch, s390_software_single_step); |
7983 | set_gdbarch_displaced_step_hw_singlestep (gdbarch, s390_displaced_step_hw_singlestep); | |
5769d3cd | 7984 | set_gdbarch_skip_prologue (gdbarch, s390_skip_prologue); |
c9cf6e20 | 7985 | set_gdbarch_stack_frame_destroyed_p (gdbarch, s390_stack_frame_destroyed_p); |
a8c99f38 | 7986 | |
7803799a | 7987 | set_gdbarch_num_regs (gdbarch, S390_NUM_REGS); |
5769d3cd | 7988 | set_gdbarch_sp_regnum (gdbarch, S390_SP_REGNUM); |
d0f54f9d | 7989 | set_gdbarch_fp0_regnum (gdbarch, S390_F0_REGNUM); |
d0f54f9d | 7990 | set_gdbarch_stab_reg_to_regnum (gdbarch, s390_dwarf_reg_to_regnum); |
d0f54f9d | 7991 | set_gdbarch_dwarf2_reg_to_regnum (gdbarch, s390_dwarf_reg_to_regnum); |
9acbedc0 | 7992 | set_gdbarch_value_from_register (gdbarch, s390_value_from_register); |
7803799a | 7993 | set_gdbarch_core_read_description (gdbarch, s390_core_read_description); |
5aa82d05 AA |
7994 | set_gdbarch_iterate_over_regset_sections (gdbarch, |
7995 | s390_iterate_over_regset_sections); | |
c642a434 UW |
7996 | set_gdbarch_cannot_store_register (gdbarch, s390_cannot_store_register); |
7997 | set_gdbarch_write_pc (gdbarch, s390_write_pc); | |
f79a3bae | 7998 | set_gdbarch_guess_tracepoint_registers (gdbarch, s390_guess_tracepoint_registers); |
7803799a UW |
7999 | set_gdbarch_pseudo_register_read (gdbarch, s390_pseudo_register_read); |
8000 | set_gdbarch_pseudo_register_write (gdbarch, s390_pseudo_register_write); | |
8001 | set_tdesc_pseudo_register_name (gdbarch, s390_pseudo_register_name); | |
8002 | set_tdesc_pseudo_register_type (gdbarch, s390_pseudo_register_type); | |
8003 | set_tdesc_pseudo_register_reggroup_p (gdbarch, | |
34201ae3 | 8004 | s390_pseudo_register_reggroup_p); |
c4b3e547 MK |
8005 | set_gdbarch_ax_pseudo_register_collect (gdbarch, |
8006 | s390_ax_pseudo_register_collect); | |
8007 | set_gdbarch_ax_pseudo_register_push_stack | |
8008 | (gdbarch, s390_ax_pseudo_register_push_stack); | |
70104a90 | 8009 | set_gdbarch_gen_return_address (gdbarch, s390_gen_return_address); |
7803799a | 8010 | tdesc_use_registers (gdbarch, tdesc, tdesc_data); |
550bdf96 | 8011 | set_gdbarch_register_name (gdbarch, s390_register_name); |
7803799a UW |
8012 | |
8013 | /* Assign pseudo register numbers. */ | |
8014 | first_pseudo_reg = gdbarch_num_regs (gdbarch); | |
8015 | last_pseudo_reg = first_pseudo_reg; | |
8016 | tdep->gpr_full_regnum = -1; | |
8017 | if (have_upper) | |
8018 | { | |
8019 | tdep->gpr_full_regnum = last_pseudo_reg; | |
8020 | last_pseudo_reg += 16; | |
8021 | } | |
550bdf96 AA |
8022 | tdep->v0_full_regnum = -1; |
8023 | if (have_vx) | |
8024 | { | |
8025 | tdep->v0_full_regnum = last_pseudo_reg; | |
8026 | last_pseudo_reg += 16; | |
8027 | } | |
7803799a UW |
8028 | tdep->pc_regnum = last_pseudo_reg++; |
8029 | tdep->cc_regnum = last_pseudo_reg++; | |
8030 | set_gdbarch_pc_regnum (gdbarch, tdep->pc_regnum); | |
8031 | set_gdbarch_num_pseudo_regs (gdbarch, last_pseudo_reg - first_pseudo_reg); | |
5769d3cd | 8032 | |
b0cf273e JB |
8033 | /* Inferior function calls. */ |
8034 | set_gdbarch_push_dummy_call (gdbarch, s390_push_dummy_call); | |
f089c433 | 8035 | set_gdbarch_dummy_id (gdbarch, s390_dummy_id); |
4074e13c | 8036 | set_gdbarch_frame_align (gdbarch, s390_frame_align); |
b0cf273e | 8037 | set_gdbarch_return_value (gdbarch, s390_return_value); |
5769d3cd | 8038 | |
237b092b AA |
8039 | /* Syscall handling. */ |
8040 | set_gdbarch_get_syscall_number (gdbarch, s390_linux_get_syscall_number); | |
8041 | ||
a8c99f38 | 8042 | /* Frame handling. */ |
a431654a | 8043 | dwarf2_frame_set_init_reg (gdbarch, s390_dwarf2_frame_init_reg); |
7803799a | 8044 | dwarf2_frame_set_adjust_regnum (gdbarch, s390_adjust_frame_regnum); |
f089c433 | 8045 | dwarf2_append_unwinders (gdbarch); |
a431654a | 8046 | frame_base_append_sniffer (gdbarch, dwarf2_frame_base_sniffer); |
f089c433 UW |
8047 | frame_unwind_append_unwinder (gdbarch, &s390_stub_frame_unwind); |
8048 | frame_unwind_append_unwinder (gdbarch, &s390_sigtramp_frame_unwind); | |
8049 | frame_unwind_append_unwinder (gdbarch, &s390_frame_unwind); | |
a8c99f38 JB |
8050 | frame_base_set_default (gdbarch, &s390_frame_base); |
8051 | set_gdbarch_unwind_pc (gdbarch, s390_unwind_pc); | |
8052 | set_gdbarch_unwind_sp (gdbarch, s390_unwind_sp); | |
8053 | ||
1db4e8a0 UW |
8054 | /* Displaced stepping. */ |
8055 | set_gdbarch_displaced_step_copy_insn (gdbarch, | |
5ac21343 | 8056 | s390_displaced_step_copy_insn); |
1db4e8a0 UW |
8057 | set_gdbarch_displaced_step_fixup (gdbarch, s390_displaced_step_fixup); |
8058 | set_gdbarch_displaced_step_free_closure (gdbarch, | |
34201ae3 | 8059 | simple_displaced_step_free_closure); |
906d60cf | 8060 | set_gdbarch_displaced_step_location (gdbarch, linux_displaced_step_location); |
1db4e8a0 UW |
8061 | set_gdbarch_max_insn_length (gdbarch, S390_MAX_INSTR_SIZE); |
8062 | ||
70728992 PA |
8063 | /* Note that GNU/Linux is the only OS supported on this |
8064 | platform. */ | |
8065 | linux_init_abi (info, gdbarch); | |
8066 | ||
7803799a | 8067 | switch (tdep->abi) |
5769d3cd | 8068 | { |
7803799a | 8069 | case ABI_LINUX_S390: |
5769d3cd | 8070 | set_gdbarch_addr_bits_remove (gdbarch, s390_addr_bits_remove); |
76a9d10f MK |
8071 | set_solib_svr4_fetch_link_map_offsets |
8072 | (gdbarch, svr4_ilp32_fetch_link_map_offsets); | |
c642a434 | 8073 | |
458c8db8 | 8074 | set_xml_syscall_file_name (gdbarch, XML_SYSCALL_FILENAME_S390); |
5769d3cd | 8075 | break; |
b0cf273e | 8076 | |
7803799a | 8077 | case ABI_LINUX_ZSERIES: |
5769d3cd AC |
8078 | set_gdbarch_long_bit (gdbarch, 64); |
8079 | set_gdbarch_long_long_bit (gdbarch, 64); | |
8080 | set_gdbarch_ptr_bit (gdbarch, 64); | |
76a9d10f MK |
8081 | set_solib_svr4_fetch_link_map_offsets |
8082 | (gdbarch, svr4_lp64_fetch_link_map_offsets); | |
ffc65945 | 8083 | set_gdbarch_address_class_type_flags (gdbarch, |
34201ae3 | 8084 | s390_address_class_type_flags); |
ffc65945 | 8085 | set_gdbarch_address_class_type_flags_to_name (gdbarch, |
34201ae3 | 8086 | s390_address_class_type_flags_to_name); |
ffc65945 | 8087 | set_gdbarch_address_class_name_to_type_flags (gdbarch, |
34201ae3 | 8088 | s390_address_class_name_to_type_flags); |
d851a69a | 8089 | set_xml_syscall_file_name (gdbarch, XML_SYSCALL_FILENAME_S390X); |
5769d3cd AC |
8090 | break; |
8091 | } | |
8092 | ||
36482093 AC |
8093 | set_gdbarch_print_insn (gdbarch, print_insn_s390); |
8094 | ||
982e9687 UW |
8095 | set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target); |
8096 | ||
b2756930 KB |
8097 | /* Enable TLS support. */ |
8098 | set_gdbarch_fetch_tls_load_module_address (gdbarch, | |
34201ae3 | 8099 | svr4_fetch_objfile_link_map); |
b2756930 | 8100 | |
55aa24fb | 8101 | /* SystemTap functions. */ |
05c0465e SDJ |
8102 | set_gdbarch_stap_register_prefixes (gdbarch, stap_register_prefixes); |
8103 | set_gdbarch_stap_register_indirection_prefixes (gdbarch, | |
8104 | stap_register_indirection_prefixes); | |
8105 | set_gdbarch_stap_register_indirection_suffixes (gdbarch, | |
8106 | stap_register_indirection_suffixes); | |
55aa24fb | 8107 | set_gdbarch_stap_is_single_operand (gdbarch, s390_stap_is_single_operand); |
60abeae4 AA |
8108 | set_gdbarch_gcc_target_options (gdbarch, s390_gcc_target_options); |
8109 | set_gdbarch_gnu_triplet_regexp (gdbarch, s390_gnu_triplet_regexp); | |
55aa24fb | 8110 | |
566c56c9 MK |
8111 | /* Support reverse debugging. */ |
8112 | ||
8113 | set_gdbarch_process_record (gdbarch, s390_process_record); | |
8114 | set_gdbarch_process_record_signal (gdbarch, s390_linux_record_signal); | |
8115 | ||
8116 | s390_init_linux_record_tdep (&s390_linux_record_tdep, ABI_LINUX_S390); | |
8117 | s390_init_linux_record_tdep (&s390x_linux_record_tdep, ABI_LINUX_ZSERIES); | |
8118 | ||
65b48a81 PB |
8119 | set_gdbarch_disassembler_options (gdbarch, &s390_disassembler_options); |
8120 | set_gdbarch_valid_disassembler_options (gdbarch, | |
8121 | disassembler_options_s390 ()); | |
8122 | ||
5769d3cd AC |
8123 | return gdbarch; |
8124 | } | |
8125 | ||
8126 | ||
a78f21af AC |
8127 | extern initialize_file_ftype _initialize_s390_tdep; /* -Wmissing-prototypes */ |
8128 | ||
5769d3cd | 8129 | void |
5ae5f592 | 8130 | _initialize_s390_tdep (void) |
5769d3cd | 8131 | { |
5769d3cd AC |
8132 | /* Hook us into the gdbarch mechanism. */ |
8133 | register_gdbarch_init (bfd_arch_s390, s390_gdbarch_init); | |
7803799a | 8134 | |
94eae614 | 8135 | /* Initialize the GNU/Linux target descriptions. */ |
7803799a | 8136 | initialize_tdesc_s390_linux32 (); |
c642a434 UW |
8137 | initialize_tdesc_s390_linux32v1 (); |
8138 | initialize_tdesc_s390_linux32v2 (); | |
7803799a | 8139 | initialize_tdesc_s390_linux64 (); |
c642a434 UW |
8140 | initialize_tdesc_s390_linux64v1 (); |
8141 | initialize_tdesc_s390_linux64v2 (); | |
4ac33720 | 8142 | initialize_tdesc_s390_te_linux64 (); |
550bdf96 AA |
8143 | initialize_tdesc_s390_vx_linux64 (); |
8144 | initialize_tdesc_s390_tevx_linux64 (); | |
7803799a | 8145 | initialize_tdesc_s390x_linux64 (); |
c642a434 UW |
8146 | initialize_tdesc_s390x_linux64v1 (); |
8147 | initialize_tdesc_s390x_linux64v2 (); | |
4ac33720 | 8148 | initialize_tdesc_s390x_te_linux64 (); |
550bdf96 AA |
8149 | initialize_tdesc_s390x_vx_linux64 (); |
8150 | initialize_tdesc_s390x_tevx_linux64 (); | |
5769d3cd | 8151 | } |