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