1 /* Target-dependent code for GDB, the GNU debugger.
3 Copyright (C) 2001-2016 Free Software Foundation, Inc.
5 Contributed by D.J. Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com)
6 for IBM Deutschland Entwicklung GmbH, IBM Corporation.
8 This file is part of GDB.
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.
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.
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/>. */
24 #include "arch-utils.h"
33 #include "floatformat.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"
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"
50 #include "xml-syscall.h"
52 #include "stap-probe.h"
55 #include "user-regs.h"
56 #include "cli/cli-utils.h"
58 #include "elf/common.h"
63 #include "features/s390-linux32.c"
64 #include "features/s390-linux32v1.c"
65 #include "features/s390-linux32v2.c"
66 #include "features/s390-linux64.c"
67 #include "features/s390-linux64v1.c"
68 #include "features/s390-linux64v2.c"
69 #include "features/s390-te-linux64.c"
70 #include "features/s390-vx-linux64.c"
71 #include "features/s390-tevx-linux64.c"
72 #include "features/s390x-linux64.c"
73 #include "features/s390x-linux64v1.c"
74 #include "features/s390x-linux64v2.c"
75 #include "features/s390x-te-linux64.c"
76 #include "features/s390x-vx-linux64.c"
77 #include "features/s390x-tevx-linux64.c"
79 #define XML_SYSCALL_FILENAME_S390 "syscalls/s390-linux.xml"
80 #define XML_SYSCALL_FILENAME_S390X "syscalls/s390x-linux.xml"
88 enum s390_vector_abi_kind
94 /* The tdep structure. */
99 enum s390_abi_kind abi;
102 enum s390_vector_abi_kind vector_abi;
104 /* Pseudo register numbers. */
116 /* ABI call-saved register information. */
119 s390_register_call_saved (struct gdbarch *gdbarch, int regnum)
121 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
126 if ((regnum >= S390_R6_REGNUM && regnum <= S390_R15_REGNUM)
127 || regnum == S390_F4_REGNUM || regnum == S390_F6_REGNUM
128 || regnum == S390_A0_REGNUM)
133 case ABI_LINUX_ZSERIES:
134 if ((regnum >= S390_R6_REGNUM && regnum <= S390_R15_REGNUM)
135 || (regnum >= S390_F8_REGNUM && regnum <= S390_F15_REGNUM)
136 || (regnum >= S390_A0_REGNUM && regnum <= S390_A1_REGNUM))
146 s390_cannot_store_register (struct gdbarch *gdbarch, int regnum)
148 /* The last-break address is read-only. */
149 return regnum == S390_LAST_BREAK_REGNUM;
153 s390_write_pc (struct regcache *regcache, CORE_ADDR pc)
155 struct gdbarch *gdbarch = get_regcache_arch (regcache);
156 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
158 regcache_cooked_write_unsigned (regcache, tdep->pc_regnum, pc);
160 /* Set special SYSTEM_CALL register to 0 to prevent the kernel from
161 messing with the PC we just installed, if we happen to be within
162 an interrupted system call that the kernel wants to restart.
164 Note that after we return from the dummy call, the SYSTEM_CALL and
165 ORIG_R2 registers will be automatically restored, and the kernel
166 continues to restart the system call at this point. */
167 if (register_size (gdbarch, S390_SYSTEM_CALL_REGNUM) > 0)
168 regcache_cooked_write_unsigned (regcache, S390_SYSTEM_CALL_REGNUM, 0);
171 /* The "guess_tracepoint_registers" gdbarch method. */
174 s390_guess_tracepoint_registers (struct gdbarch *gdbarch,
175 struct regcache *regcache,
178 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
179 int sz = register_size (gdbarch, S390_PSWA_REGNUM);
180 gdb_byte *reg = (gdb_byte *) alloca (sz);
183 /* Set PSWA from the location and a default PSWM (the only part we're
184 unlikely to get right is the CC). */
185 if (tdep->abi == ABI_LINUX_S390)
187 /* 31-bit PSWA needs high bit set (it's very unlikely the target
188 was in 24-bit mode). */
189 pswa = addr | 0x80000000UL;
195 pswm = 0x0705000180000000ULL;
198 store_unsigned_integer (reg, sz, gdbarch_byte_order (gdbarch), pswa);
199 regcache_raw_supply (regcache, S390_PSWA_REGNUM, reg);
201 store_unsigned_integer (reg, sz, gdbarch_byte_order (gdbarch), pswm);
202 regcache_raw_supply (regcache, S390_PSWM_REGNUM, reg);
206 /* DWARF Register Mapping. */
208 static const short s390_dwarf_regmap[] =
210 /* 0-15: General Purpose Registers. */
211 S390_R0_REGNUM, S390_R1_REGNUM, S390_R2_REGNUM, S390_R3_REGNUM,
212 S390_R4_REGNUM, S390_R5_REGNUM, S390_R6_REGNUM, S390_R7_REGNUM,
213 S390_R8_REGNUM, S390_R9_REGNUM, S390_R10_REGNUM, S390_R11_REGNUM,
214 S390_R12_REGNUM, S390_R13_REGNUM, S390_R14_REGNUM, S390_R15_REGNUM,
216 /* 16-31: Floating Point Registers / Vector Registers 0-15. */
217 S390_F0_REGNUM, S390_F2_REGNUM, S390_F4_REGNUM, S390_F6_REGNUM,
218 S390_F1_REGNUM, S390_F3_REGNUM, S390_F5_REGNUM, S390_F7_REGNUM,
219 S390_F8_REGNUM, S390_F10_REGNUM, S390_F12_REGNUM, S390_F14_REGNUM,
220 S390_F9_REGNUM, S390_F11_REGNUM, S390_F13_REGNUM, S390_F15_REGNUM,
222 /* 32-47: Control Registers (not mapped). */
223 -1, -1, -1, -1, -1, -1, -1, -1,
224 -1, -1, -1, -1, -1, -1, -1, -1,
226 /* 48-63: Access Registers. */
227 S390_A0_REGNUM, S390_A1_REGNUM, S390_A2_REGNUM, S390_A3_REGNUM,
228 S390_A4_REGNUM, S390_A5_REGNUM, S390_A6_REGNUM, S390_A7_REGNUM,
229 S390_A8_REGNUM, S390_A9_REGNUM, S390_A10_REGNUM, S390_A11_REGNUM,
230 S390_A12_REGNUM, S390_A13_REGNUM, S390_A14_REGNUM, S390_A15_REGNUM,
232 /* 64-65: Program Status Word. */
236 /* 66-67: Reserved. */
239 /* 68-83: Vector Registers 16-31. */
240 S390_V16_REGNUM, S390_V18_REGNUM, S390_V20_REGNUM, S390_V22_REGNUM,
241 S390_V17_REGNUM, S390_V19_REGNUM, S390_V21_REGNUM, S390_V23_REGNUM,
242 S390_V24_REGNUM, S390_V26_REGNUM, S390_V28_REGNUM, S390_V30_REGNUM,
243 S390_V25_REGNUM, S390_V27_REGNUM, S390_V29_REGNUM, S390_V31_REGNUM,
245 /* End of "official" DWARF registers. The remainder of the map is
246 for GDB internal use only. */
248 /* GPR Lower Half Access. */
249 S390_R0_REGNUM, S390_R1_REGNUM, S390_R2_REGNUM, S390_R3_REGNUM,
250 S390_R4_REGNUM, S390_R5_REGNUM, S390_R6_REGNUM, S390_R7_REGNUM,
251 S390_R8_REGNUM, S390_R9_REGNUM, S390_R10_REGNUM, S390_R11_REGNUM,
252 S390_R12_REGNUM, S390_R13_REGNUM, S390_R14_REGNUM, S390_R15_REGNUM,
255 enum { s390_dwarf_reg_r0l = ARRAY_SIZE (s390_dwarf_regmap) - 16 };
257 /* Convert DWARF register number REG to the appropriate register
258 number used by GDB. */
260 s390_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int reg)
262 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
265 /* In a 32-on-64 debug scenario, debug info refers to the full
266 64-bit GPRs. Note that call frame information still refers to
267 the 32-bit lower halves, because s390_adjust_frame_regnum uses
268 special register numbers to access GPRs. */
269 if (tdep->gpr_full_regnum != -1 && reg >= 0 && reg < 16)
270 return tdep->gpr_full_regnum + reg;
272 if (reg >= 0 && reg < ARRAY_SIZE (s390_dwarf_regmap))
273 gdb_reg = s390_dwarf_regmap[reg];
275 if (tdep->v0_full_regnum == -1)
277 if (gdb_reg >= S390_V16_REGNUM && gdb_reg <= S390_V31_REGNUM)
282 if (gdb_reg >= S390_F0_REGNUM && gdb_reg <= S390_F15_REGNUM)
283 gdb_reg = gdb_reg - S390_F0_REGNUM + tdep->v0_full_regnum;
289 /* Translate a .eh_frame register to DWARF register, or adjust a
290 .debug_frame register. */
292 s390_adjust_frame_regnum (struct gdbarch *gdbarch, int num, int eh_frame_p)
294 /* See s390_dwarf_reg_to_regnum for comments. */
295 return (num >= 0 && num < 16) ? num + s390_dwarf_reg_r0l : num;
299 /* Pseudo registers. */
302 regnum_is_gpr_full (struct gdbarch_tdep *tdep, int regnum)
304 return (tdep->gpr_full_regnum != -1
305 && regnum >= tdep->gpr_full_regnum
306 && regnum <= tdep->gpr_full_regnum + 15);
309 /* Check whether REGNUM indicates a full vector register (v0-v15).
310 These pseudo-registers are composed of f0-f15 and v0l-v15l. */
313 regnum_is_vxr_full (struct gdbarch_tdep *tdep, int regnum)
315 return (tdep->v0_full_regnum != -1
316 && regnum >= tdep->v0_full_regnum
317 && regnum <= tdep->v0_full_regnum + 15);
320 /* Return the name of register REGNO. Return the empty string for
321 registers that shouldn't be visible. */
324 s390_register_name (struct gdbarch *gdbarch, int regnum)
326 if (regnum >= S390_V0_LOWER_REGNUM
327 && regnum <= S390_V15_LOWER_REGNUM)
329 return tdesc_register_name (gdbarch, regnum);
333 s390_pseudo_register_name (struct gdbarch *gdbarch, int regnum)
335 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
337 if (regnum == tdep->pc_regnum)
340 if (regnum == tdep->cc_regnum)
343 if (regnum_is_gpr_full (tdep, regnum))
345 static const char *full_name[] = {
346 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
347 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"
349 return full_name[regnum - tdep->gpr_full_regnum];
352 if (regnum_is_vxr_full (tdep, regnum))
354 static const char *full_name[] = {
355 "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7",
356 "v8", "v9", "v10", "v11", "v12", "v13", "v14", "v15"
358 return full_name[regnum - tdep->v0_full_regnum];
361 internal_error (__FILE__, __LINE__, _("invalid regnum"));
365 s390_pseudo_register_type (struct gdbarch *gdbarch, int regnum)
367 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
369 if (regnum == tdep->pc_regnum)
370 return builtin_type (gdbarch)->builtin_func_ptr;
372 if (regnum == tdep->cc_regnum)
373 return builtin_type (gdbarch)->builtin_int;
375 if (regnum_is_gpr_full (tdep, regnum))
376 return builtin_type (gdbarch)->builtin_uint64;
378 if (regnum_is_vxr_full (tdep, regnum))
379 return tdesc_find_type (gdbarch, "vec128");
381 internal_error (__FILE__, __LINE__, _("invalid regnum"));
384 static enum register_status
385 s390_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
386 int regnum, gdb_byte *buf)
388 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
389 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
390 int regsize = register_size (gdbarch, regnum);
393 if (regnum == tdep->pc_regnum)
395 enum register_status status;
397 status = regcache_raw_read_unsigned (regcache, S390_PSWA_REGNUM, &val);
398 if (status == REG_VALID)
400 if (register_size (gdbarch, S390_PSWA_REGNUM) == 4)
402 store_unsigned_integer (buf, regsize, byte_order, val);
407 if (regnum == tdep->cc_regnum)
409 enum register_status status;
411 status = regcache_raw_read_unsigned (regcache, S390_PSWM_REGNUM, &val);
412 if (status == REG_VALID)
414 if (register_size (gdbarch, S390_PSWA_REGNUM) == 4)
415 val = (val >> 12) & 3;
417 val = (val >> 44) & 3;
418 store_unsigned_integer (buf, regsize, byte_order, val);
423 if (regnum_is_gpr_full (tdep, regnum))
425 enum register_status status;
428 regnum -= tdep->gpr_full_regnum;
430 status = regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + regnum, &val);
431 if (status == REG_VALID)
432 status = regcache_raw_read_unsigned (regcache, S390_R0_UPPER_REGNUM + regnum,
434 if (status == REG_VALID)
436 val |= val_upper << 32;
437 store_unsigned_integer (buf, regsize, byte_order, val);
442 if (regnum_is_vxr_full (tdep, regnum))
444 enum register_status status;
446 regnum -= tdep->v0_full_regnum;
448 status = regcache_raw_read (regcache, S390_F0_REGNUM + regnum, buf);
449 if (status == REG_VALID)
450 status = regcache_raw_read (regcache,
451 S390_V0_LOWER_REGNUM + regnum, buf + 8);
455 internal_error (__FILE__, __LINE__, _("invalid regnum"));
459 s390_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
460 int regnum, const gdb_byte *buf)
462 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
463 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
464 int regsize = register_size (gdbarch, regnum);
467 if (regnum == tdep->pc_regnum)
469 val = extract_unsigned_integer (buf, regsize, byte_order);
470 if (register_size (gdbarch, S390_PSWA_REGNUM) == 4)
472 regcache_raw_read_unsigned (regcache, S390_PSWA_REGNUM, &psw);
473 val = (psw & 0x80000000) | (val & 0x7fffffff);
475 regcache_raw_write_unsigned (regcache, S390_PSWA_REGNUM, val);
479 if (regnum == tdep->cc_regnum)
481 val = extract_unsigned_integer (buf, regsize, byte_order);
482 regcache_raw_read_unsigned (regcache, S390_PSWM_REGNUM, &psw);
483 if (register_size (gdbarch, S390_PSWA_REGNUM) == 4)
484 val = (psw & ~((ULONGEST)3 << 12)) | ((val & 3) << 12);
486 val = (psw & ~((ULONGEST)3 << 44)) | ((val & 3) << 44);
487 regcache_raw_write_unsigned (regcache, S390_PSWM_REGNUM, val);
491 if (regnum_is_gpr_full (tdep, regnum))
493 regnum -= tdep->gpr_full_regnum;
494 val = extract_unsigned_integer (buf, regsize, byte_order);
495 regcache_raw_write_unsigned (regcache, S390_R0_REGNUM + regnum,
497 regcache_raw_write_unsigned (regcache, S390_R0_UPPER_REGNUM + regnum,
502 if (regnum_is_vxr_full (tdep, regnum))
504 regnum -= tdep->v0_full_regnum;
505 regcache_raw_write (regcache, S390_F0_REGNUM + regnum, buf);
506 regcache_raw_write (regcache, S390_V0_LOWER_REGNUM + regnum, buf + 8);
510 internal_error (__FILE__, __LINE__, _("invalid regnum"));
513 /* 'float' values are stored in the upper half of floating-point
514 registers, even though we are otherwise a big-endian platform. The
515 same applies to a 'float' value within a vector. */
517 static struct value *
518 s390_value_from_register (struct gdbarch *gdbarch, struct type *type,
519 int regnum, struct frame_id frame_id)
521 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
522 struct value *value = default_value_from_register (gdbarch, type,
524 check_typedef (type);
526 if ((regnum >= S390_F0_REGNUM && regnum <= S390_F15_REGNUM
527 && TYPE_LENGTH (type) < 8)
528 || regnum_is_vxr_full (tdep, regnum)
529 || (regnum >= S390_V16_REGNUM && regnum <= S390_V31_REGNUM))
530 set_value_offset (value, 0);
535 /* Register groups. */
538 s390_pseudo_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
539 struct reggroup *group)
541 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
543 /* We usually save/restore the whole PSW, which includes PC and CC.
544 However, some older gdbservers may not support saving/restoring
545 the whole PSW yet, and will return an XML register description
546 excluding those from the save/restore register groups. In those
547 cases, we still need to explicitly save/restore PC and CC in order
548 to push or pop frames. Since this doesn't hurt anything if we
549 already save/restore the whole PSW (it's just redundant), we add
550 PC and CC at this point unconditionally. */
551 if (group == save_reggroup || group == restore_reggroup)
552 return regnum == tdep->pc_regnum || regnum == tdep->cc_regnum;
554 if (group == vector_reggroup)
555 return regnum_is_vxr_full (tdep, regnum);
557 if (group == general_reggroup && regnum_is_vxr_full (tdep, regnum))
560 return default_register_reggroup_p (gdbarch, regnum, group);
563 /* The "ax_pseudo_register_collect" gdbarch method. */
566 s390_ax_pseudo_register_collect (struct gdbarch *gdbarch,
567 struct agent_expr *ax, int regnum)
569 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
570 if (regnum == tdep->pc_regnum)
572 ax_reg_mask (ax, S390_PSWA_REGNUM);
574 else if (regnum == tdep->cc_regnum)
576 ax_reg_mask (ax, S390_PSWM_REGNUM);
578 else if (regnum_is_gpr_full (tdep, regnum))
580 regnum -= tdep->gpr_full_regnum;
581 ax_reg_mask (ax, S390_R0_REGNUM + regnum);
582 ax_reg_mask (ax, S390_R0_UPPER_REGNUM + regnum);
584 else if (regnum_is_vxr_full (tdep, regnum))
586 regnum -= tdep->v0_full_regnum;
587 ax_reg_mask (ax, S390_F0_REGNUM + regnum);
588 ax_reg_mask (ax, S390_V0_LOWER_REGNUM + regnum);
592 internal_error (__FILE__, __LINE__, _("invalid regnum"));
597 /* The "ax_pseudo_register_push_stack" gdbarch method. */
600 s390_ax_pseudo_register_push_stack (struct gdbarch *gdbarch,
601 struct agent_expr *ax, int regnum)
603 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
604 if (regnum == tdep->pc_regnum)
606 ax_reg (ax, S390_PSWA_REGNUM);
607 if (register_size (gdbarch, S390_PSWA_REGNUM) == 4)
609 ax_zero_ext (ax, 31);
612 else if (regnum == tdep->cc_regnum)
614 ax_reg (ax, S390_PSWM_REGNUM);
615 if (register_size (gdbarch, S390_PSWA_REGNUM) == 4)
619 ax_simple (ax, aop_rsh_unsigned);
622 else if (regnum_is_gpr_full (tdep, regnum))
624 regnum -= tdep->gpr_full_regnum;
625 ax_reg (ax, S390_R0_REGNUM + regnum);
626 ax_reg (ax, S390_R0_UPPER_REGNUM + regnum);
628 ax_simple (ax, aop_lsh);
629 ax_simple (ax, aop_bit_or);
631 else if (regnum_is_vxr_full (tdep, regnum))
633 /* Too large to stuff on the stack. */
638 internal_error (__FILE__, __LINE__, _("invalid regnum"));
643 /* The "gen_return_address" gdbarch method. Since this is supposed to be
644 just a best-effort method, and we don't really have the means to run
645 the full unwinder here, just collect the link register. */
648 s390_gen_return_address (struct gdbarch *gdbarch,
649 struct agent_expr *ax, struct axs_value *value,
652 value->type = register_type (gdbarch, S390_R14_REGNUM);
653 value->kind = axs_lvalue_register;
654 value->u.reg = S390_R14_REGNUM;
658 /* A helper for s390_software_single_step, decides if an instruction
659 is a partial-execution instruction that needs to be executed until
660 completion when in record mode. If it is, returns 1 and writes
661 instruction length to a pointer. */
664 s390_is_partial_instruction (struct gdbarch *gdbarch, CORE_ADDR loc, int *len)
666 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
669 insn = read_memory_integer (loc, 2, byte_order);
673 case 0xa8: /* MVCLE */
679 insn = read_memory_integer (loc + 4, 2, byte_order);
680 if ((insn & 0xff) == 0x8e)
692 case 0xb255: /* MVST */
693 case 0xb263: /* CMPSC */
694 case 0xb2a5: /* TRE */
695 case 0xb2a6: /* CU21 */
696 case 0xb2a7: /* CU12 */
697 case 0xb9b0: /* CU14 */
698 case 0xb9b1: /* CU24 */
699 case 0xb9b2: /* CU41 */
700 case 0xb9b3: /* CU42 */
701 case 0xb92a: /* KMF */
702 case 0xb92b: /* KMO */
703 case 0xb92f: /* KMC */
704 case 0xb92d: /* KMCTR */
705 case 0xb92e: /* KM */
706 case 0xb93c: /* PPNO */
707 case 0xb990: /* TRTT */
708 case 0xb991: /* TRTO */
709 case 0xb992: /* TROT */
710 case 0xb993: /* TROO */
718 /* Implement the "software_single_step" gdbarch method, needed to single step
719 through instructions like MVCLE in record mode, to make sure they are
720 executed to completion. Without that, record will save the full length
721 of destination buffer on every iteration, even though the CPU will only
722 process about 4kiB of it each time, leading to O(n**2) memory and time
725 static VEC (CORE_ADDR) *
726 s390_software_single_step (struct frame_info *frame)
728 struct regcache *regcache = get_current_regcache ();
729 struct gdbarch *gdbarch = get_regcache_arch (regcache);
730 CORE_ADDR loc = regcache_read_pc (regcache);
731 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
734 VEC (CORE_ADDR) *next_pcs = NULL;
736 /* Special handling only if recording. */
737 if (!record_full_is_used ())
740 /* First, match a partial instruction. */
741 if (!s390_is_partial_instruction (gdbarch, loc, &len))
746 /* Second, look for a branch back to it. */
747 insn = read_memory_integer (loc, 2, byte_order);
748 if (insn != 0xa714) /* BRC with mask 1 */
751 insn = read_memory_integer (loc + 2, 2, byte_order);
752 if (insn != (uint16_t) -(len / 2))
757 /* Found it, step past the whole thing. */
758 VEC_safe_push (CORE_ADDR, next_pcs, loc);
764 s390_displaced_step_hw_singlestep (struct gdbarch *gdbarch,
765 struct displaced_step_closure *closure)
771 /* Maps for register sets. */
773 static const struct regcache_map_entry s390_gregmap[] =
775 { 1, S390_PSWM_REGNUM },
776 { 1, S390_PSWA_REGNUM },
777 { 16, S390_R0_REGNUM },
778 { 16, S390_A0_REGNUM },
779 { 1, S390_ORIG_R2_REGNUM },
783 static const struct regcache_map_entry s390_fpregmap[] =
785 { 1, S390_FPC_REGNUM, 8 },
786 { 16, S390_F0_REGNUM, 8 },
790 static const struct regcache_map_entry s390_regmap_upper[] =
792 { 16, S390_R0_UPPER_REGNUM, 4 },
796 static const struct regcache_map_entry s390_regmap_last_break[] =
798 { 1, REGCACHE_MAP_SKIP, 4 },
799 { 1, S390_LAST_BREAK_REGNUM, 4 },
803 static const struct regcache_map_entry s390x_regmap_last_break[] =
805 { 1, S390_LAST_BREAK_REGNUM, 8 },
809 static const struct regcache_map_entry s390_regmap_system_call[] =
811 { 1, S390_SYSTEM_CALL_REGNUM, 4 },
815 static const struct regcache_map_entry s390_regmap_tdb[] =
817 { 1, S390_TDB_DWORD0_REGNUM, 8 },
818 { 1, S390_TDB_ABORT_CODE_REGNUM, 8 },
819 { 1, S390_TDB_CONFLICT_TOKEN_REGNUM, 8 },
820 { 1, S390_TDB_ATIA_REGNUM, 8 },
821 { 12, REGCACHE_MAP_SKIP, 8 },
822 { 16, S390_TDB_R0_REGNUM, 8 },
826 static const struct regcache_map_entry s390_regmap_vxrs_low[] =
828 { 16, S390_V0_LOWER_REGNUM, 8 },
832 static const struct regcache_map_entry s390_regmap_vxrs_high[] =
834 { 16, S390_V16_REGNUM, 16 },
839 /* Supply the TDB regset. Like regcache_supply_regset, but invalidate
840 the TDB registers unless the TDB format field is valid. */
843 s390_supply_tdb_regset (const struct regset *regset, struct regcache *regcache,
844 int regnum, const void *regs, size_t len)
847 enum register_status ret;
849 regcache_supply_regset (regset, regcache, regnum, regs, len);
850 ret = regcache_cooked_read_unsigned (regcache, S390_TDB_DWORD0_REGNUM, &tdw);
851 if (ret != REG_VALID || (tdw >> 56) != 1)
852 regcache_supply_regset (regset, regcache, regnum, NULL, len);
855 const struct regset s390_gregset = {
857 regcache_supply_regset,
858 regcache_collect_regset
861 const struct regset s390_fpregset = {
863 regcache_supply_regset,
864 regcache_collect_regset
867 static const struct regset s390_upper_regset = {
869 regcache_supply_regset,
870 regcache_collect_regset
873 const struct regset s390_last_break_regset = {
874 s390_regmap_last_break,
875 regcache_supply_regset,
876 regcache_collect_regset
879 const struct regset s390x_last_break_regset = {
880 s390x_regmap_last_break,
881 regcache_supply_regset,
882 regcache_collect_regset
885 const struct regset s390_system_call_regset = {
886 s390_regmap_system_call,
887 regcache_supply_regset,
888 regcache_collect_regset
891 const struct regset s390_tdb_regset = {
893 s390_supply_tdb_regset,
894 regcache_collect_regset
897 const struct regset s390_vxrs_low_regset = {
898 s390_regmap_vxrs_low,
899 regcache_supply_regset,
900 regcache_collect_regset
903 const struct regset s390_vxrs_high_regset = {
904 s390_regmap_vxrs_high,
905 regcache_supply_regset,
906 regcache_collect_regset
909 /* Iterate over supported core file register note sections. */
912 s390_iterate_over_regset_sections (struct gdbarch *gdbarch,
913 iterate_over_regset_sections_cb *cb,
915 const struct regcache *regcache)
917 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
918 const int gregset_size = (tdep->abi == ABI_LINUX_S390 ?
919 s390_sizeof_gregset : s390x_sizeof_gregset);
921 cb (".reg", gregset_size, &s390_gregset, NULL, cb_data);
922 cb (".reg2", s390_sizeof_fpregset, &s390_fpregset, NULL, cb_data);
924 if (tdep->abi == ABI_LINUX_S390 && tdep->gpr_full_regnum != -1)
925 cb (".reg-s390-high-gprs", 16 * 4, &s390_upper_regset,
926 "s390 GPR upper halves", cb_data);
928 if (tdep->have_linux_v1)
929 cb (".reg-s390-last-break", 8,
930 (gdbarch_ptr_bit (gdbarch) == 32
931 ? &s390_last_break_regset : &s390x_last_break_regset),
932 "s390 last-break address", cb_data);
934 if (tdep->have_linux_v2)
935 cb (".reg-s390-system-call", 4, &s390_system_call_regset,
936 "s390 system-call", cb_data);
938 /* If regcache is set, we are in "write" (gcore) mode. In this
939 case, don't iterate over the TDB unless its registers are
943 || REG_VALID == regcache_register_status (regcache,
944 S390_TDB_DWORD0_REGNUM)))
945 cb (".reg-s390-tdb", s390_sizeof_tdbregset, &s390_tdb_regset,
946 "s390 TDB", cb_data);
948 if (tdep->v0_full_regnum != -1)
950 cb (".reg-s390-vxrs-low", 16 * 8, &s390_vxrs_low_regset,
951 "s390 vector registers 0-15 lower half", cb_data);
952 cb (".reg-s390-vxrs-high", 16 * 16, &s390_vxrs_high_regset,
953 "s390 vector registers 16-31", cb_data);
957 static const struct target_desc *
958 s390_core_read_description (struct gdbarch *gdbarch,
959 struct target_ops *target, bfd *abfd)
961 asection *section = bfd_get_section_by_name (abfd, ".reg");
963 int high_gprs, v1, v2, te, vx;
965 target_auxv_search (target, AT_HWCAP, &hwcap);
969 high_gprs = (bfd_get_section_by_name (abfd, ".reg-s390-high-gprs")
971 v1 = (bfd_get_section_by_name (abfd, ".reg-s390-last-break") != NULL);
972 v2 = (bfd_get_section_by_name (abfd, ".reg-s390-system-call") != NULL);
973 vx = (hwcap & HWCAP_S390_VX);
974 te = (hwcap & HWCAP_S390_TE);
976 switch (bfd_section_size (abfd, section))
978 case s390_sizeof_gregset:
980 return (te && vx ? tdesc_s390_tevx_linux64 :
981 vx ? tdesc_s390_vx_linux64 :
982 te ? tdesc_s390_te_linux64 :
983 v2 ? tdesc_s390_linux64v2 :
984 v1 ? tdesc_s390_linux64v1 : tdesc_s390_linux64);
986 return (v2 ? tdesc_s390_linux32v2 :
987 v1 ? tdesc_s390_linux32v1 : tdesc_s390_linux32);
989 case s390x_sizeof_gregset:
990 return (te && vx ? tdesc_s390x_tevx_linux64 :
991 vx ? tdesc_s390x_vx_linux64 :
992 te ? tdesc_s390x_te_linux64 :
993 v2 ? tdesc_s390x_linux64v2 :
994 v1 ? tdesc_s390x_linux64v1 : tdesc_s390x_linux64);
1002 /* Decoding S/390 instructions. */
1004 /* Named opcode values for the S/390 instructions we recognize. Some
1005 instructions have their opcode split across two fields; those are the
1006 op1_* and op2_* enums. */
1009 op1_lhi = 0xa7, op2_lhi = 0x08,
1010 op1_lghi = 0xa7, op2_lghi = 0x09,
1011 op1_lgfi = 0xc0, op2_lgfi = 0x01,
1015 op1_ly = 0xe3, op2_ly = 0x58,
1016 op1_lg = 0xe3, op2_lg = 0x04,
1018 op1_lmy = 0xeb, op2_lmy = 0x98,
1019 op1_lmg = 0xeb, op2_lmg = 0x04,
1021 op1_sty = 0xe3, op2_sty = 0x50,
1022 op1_stg = 0xe3, op2_stg = 0x24,
1025 op1_stmy = 0xeb, op2_stmy = 0x90,
1026 op1_stmg = 0xeb, op2_stmg = 0x24,
1027 op1_aghi = 0xa7, op2_aghi = 0x0b,
1028 op1_ahi = 0xa7, op2_ahi = 0x0a,
1029 op1_agfi = 0xc2, op2_agfi = 0x08,
1030 op1_afi = 0xc2, op2_afi = 0x09,
1031 op1_algfi= 0xc2, op2_algfi= 0x0a,
1032 op1_alfi = 0xc2, op2_alfi = 0x0b,
1036 op1_ay = 0xe3, op2_ay = 0x5a,
1037 op1_ag = 0xe3, op2_ag = 0x08,
1038 op1_slgfi= 0xc2, op2_slgfi= 0x04,
1039 op1_slfi = 0xc2, op2_slfi = 0x05,
1043 op1_sy = 0xe3, op2_sy = 0x5b,
1044 op1_sg = 0xe3, op2_sg = 0x09,
1048 op1_lay = 0xe3, op2_lay = 0x71,
1049 op1_larl = 0xc0, op2_larl = 0x00,
1057 op1_bctg = 0xe3, op2_bctg = 0x46,
1059 op1_bxhg = 0xeb, op2_bxhg = 0x44,
1061 op1_bxleg= 0xeb, op2_bxleg= 0x45,
1062 op1_bras = 0xa7, op2_bras = 0x05,
1063 op1_brasl= 0xc0, op2_brasl= 0x05,
1064 op1_brc = 0xa7, op2_brc = 0x04,
1065 op1_brcl = 0xc0, op2_brcl = 0x04,
1066 op1_brct = 0xa7, op2_brct = 0x06,
1067 op1_brctg= 0xa7, op2_brctg= 0x07,
1069 op1_brxhg= 0xec, op2_brxhg= 0x44,
1071 op1_brxlg= 0xec, op2_brxlg= 0x45,
1076 /* Read a single instruction from address AT. */
1078 #define S390_MAX_INSTR_SIZE 6
1080 s390_readinstruction (bfd_byte instr[], CORE_ADDR at)
1082 static int s390_instrlen[] = { 2, 4, 4, 6 };
1085 if (target_read_memory (at, &instr[0], 2))
1087 instrlen = s390_instrlen[instr[0] >> 6];
1090 if (target_read_memory (at + 2, &instr[2], instrlen - 2))
1097 /* The functions below are for recognizing and decoding S/390
1098 instructions of various formats. Each of them checks whether INSN
1099 is an instruction of the given format, with the specified opcodes.
1100 If it is, it sets the remaining arguments to the values of the
1101 instruction's fields, and returns a non-zero value; otherwise, it
1104 These functions' arguments appear in the order they appear in the
1105 instruction, not in the machine-language form. So, opcodes always
1106 come first, even though they're sometimes scattered around the
1107 instructions. And displacements appear before base and extension
1108 registers, as they do in the assembly syntax, not at the end, as
1109 they do in the machine language. */
1111 is_ri (bfd_byte *insn, int op1, int op2, unsigned int *r1, int *i2)
1113 if (insn[0] == op1 && (insn[1] & 0xf) == op2)
1115 *r1 = (insn[1] >> 4) & 0xf;
1116 /* i2 is a 16-bit signed quantity. */
1117 *i2 = (((insn[2] << 8) | insn[3]) ^ 0x8000) - 0x8000;
1126 is_ril (bfd_byte *insn, int op1, int op2,
1127 unsigned int *r1, int *i2)
1129 if (insn[0] == op1 && (insn[1] & 0xf) == op2)
1131 *r1 = (insn[1] >> 4) & 0xf;
1132 /* i2 is a signed quantity. If the host 'int' is 32 bits long,
1133 no sign extension is necessary, but we don't want to assume
1135 *i2 = (((insn[2] << 24)
1138 | (insn[5])) ^ 0x80000000) - 0x80000000;
1147 is_rr (bfd_byte *insn, int op, unsigned int *r1, unsigned int *r2)
1151 *r1 = (insn[1] >> 4) & 0xf;
1152 *r2 = insn[1] & 0xf;
1161 is_rre (bfd_byte *insn, int op, unsigned int *r1, unsigned int *r2)
1163 if (((insn[0] << 8) | insn[1]) == op)
1165 /* Yes, insn[3]. insn[2] is unused in RRE format. */
1166 *r1 = (insn[3] >> 4) & 0xf;
1167 *r2 = insn[3] & 0xf;
1176 is_rs (bfd_byte *insn, int op,
1177 unsigned int *r1, unsigned int *r3, int *d2, unsigned int *b2)
1181 *r1 = (insn[1] >> 4) & 0xf;
1182 *r3 = insn[1] & 0xf;
1183 *b2 = (insn[2] >> 4) & 0xf;
1184 *d2 = ((insn[2] & 0xf) << 8) | insn[3];
1193 is_rsy (bfd_byte *insn, int op1, int op2,
1194 unsigned int *r1, unsigned int *r3, int *d2, unsigned int *b2)
1199 *r1 = (insn[1] >> 4) & 0xf;
1200 *r3 = insn[1] & 0xf;
1201 *b2 = (insn[2] >> 4) & 0xf;
1202 /* The 'long displacement' is a 20-bit signed integer. */
1203 *d2 = ((((insn[2] & 0xf) << 8) | insn[3] | (insn[4] << 12))
1204 ^ 0x80000) - 0x80000;
1213 is_rsi (bfd_byte *insn, int op,
1214 unsigned int *r1, unsigned int *r3, int *i2)
1218 *r1 = (insn[1] >> 4) & 0xf;
1219 *r3 = insn[1] & 0xf;
1220 /* i2 is a 16-bit signed quantity. */
1221 *i2 = (((insn[2] << 8) | insn[3]) ^ 0x8000) - 0x8000;
1230 is_rie (bfd_byte *insn, int op1, int op2,
1231 unsigned int *r1, unsigned int *r3, int *i2)
1236 *r1 = (insn[1] >> 4) & 0xf;
1237 *r3 = insn[1] & 0xf;
1238 /* i2 is a 16-bit signed quantity. */
1239 *i2 = (((insn[2] << 8) | insn[3]) ^ 0x8000) - 0x8000;
1248 is_rx (bfd_byte *insn, int op,
1249 unsigned int *r1, int *d2, unsigned int *x2, unsigned int *b2)
1253 *r1 = (insn[1] >> 4) & 0xf;
1254 *x2 = insn[1] & 0xf;
1255 *b2 = (insn[2] >> 4) & 0xf;
1256 *d2 = ((insn[2] & 0xf) << 8) | insn[3];
1265 is_rxy (bfd_byte *insn, int op1, int op2,
1266 unsigned int *r1, int *d2, unsigned int *x2, unsigned int *b2)
1271 *r1 = (insn[1] >> 4) & 0xf;
1272 *x2 = insn[1] & 0xf;
1273 *b2 = (insn[2] >> 4) & 0xf;
1274 /* The 'long displacement' is a 20-bit signed integer. */
1275 *d2 = ((((insn[2] & 0xf) << 8) | insn[3] | (insn[4] << 12))
1276 ^ 0x80000) - 0x80000;
1284 /* Prologue analysis. */
1286 #define S390_NUM_GPRS 16
1287 #define S390_NUM_FPRS 16
1289 struct s390_prologue_data {
1292 struct pv_area *stack;
1294 /* The size and byte-order of a GPR or FPR. */
1297 enum bfd_endian byte_order;
1299 /* The general-purpose registers. */
1300 pv_t gpr[S390_NUM_GPRS];
1302 /* The floating-point registers. */
1303 pv_t fpr[S390_NUM_FPRS];
1305 /* The offset relative to the CFA where the incoming GPR N was saved
1306 by the function prologue. 0 if not saved or unknown. */
1307 int gpr_slot[S390_NUM_GPRS];
1309 /* Likewise for FPRs. */
1310 int fpr_slot[S390_NUM_FPRS];
1312 /* Nonzero if the backchain was saved. This is assumed to be the
1313 case when the incoming SP is saved at the current SP location. */
1314 int back_chain_saved_p;
1317 /* Return the effective address for an X-style instruction, like:
1321 Here, X2 and B2 are registers, and D2 is a signed 20-bit
1322 constant; the effective address is the sum of all three. If either
1323 X2 or B2 are zero, then it doesn't contribute to the sum --- this
1324 means that r0 can't be used as either X2 or B2. */
1326 s390_addr (struct s390_prologue_data *data,
1327 int d2, unsigned int x2, unsigned int b2)
1331 result = pv_constant (d2);
1333 result = pv_add (result, data->gpr[x2]);
1335 result = pv_add (result, data->gpr[b2]);
1340 /* Do a SIZE-byte store of VALUE to D2(X2,B2). */
1342 s390_store (struct s390_prologue_data *data,
1343 int d2, unsigned int x2, unsigned int b2, CORE_ADDR size,
1346 pv_t addr = s390_addr (data, d2, x2, b2);
1349 /* Check whether we are storing the backchain. */
1350 offset = pv_subtract (data->gpr[S390_SP_REGNUM - S390_R0_REGNUM], addr);
1352 if (pv_is_constant (offset) && offset.k == 0)
1353 if (size == data->gpr_size
1354 && pv_is_register_k (value, S390_SP_REGNUM, 0))
1356 data->back_chain_saved_p = 1;
1361 /* Check whether we are storing a register into the stack. */
1362 if (!pv_area_store_would_trash (data->stack, addr))
1363 pv_area_store (data->stack, addr, size, value);
1366 /* Note: If this is some store we cannot identify, you might think we
1367 should forget our cached values, as any of those might have been hit.
1369 However, we make the assumption that the register save areas are only
1370 ever stored to once in any given function, and we do recognize these
1371 stores. Thus every store we cannot recognize does not hit our data. */
1374 /* Do a SIZE-byte load from D2(X2,B2). */
1376 s390_load (struct s390_prologue_data *data,
1377 int d2, unsigned int x2, unsigned int b2, CORE_ADDR size)
1380 pv_t addr = s390_addr (data, d2, x2, b2);
1382 /* If it's a load from an in-line constant pool, then we can
1383 simulate that, under the assumption that the code isn't
1384 going to change between the time the processor actually
1385 executed it creating the current frame, and the time when
1386 we're analyzing the code to unwind past that frame. */
1387 if (pv_is_constant (addr))
1389 struct target_section *secp;
1390 secp = target_section_by_addr (¤t_target, addr.k);
1392 && (bfd_get_section_flags (secp->the_bfd_section->owner,
1393 secp->the_bfd_section)
1395 return pv_constant (read_memory_integer (addr.k, size,
1399 /* Check whether we are accessing one of our save slots. */
1400 return pv_area_fetch (data->stack, addr, size);
1403 /* Function for finding saved registers in a 'struct pv_area'; we pass
1404 this to pv_area_scan.
1406 If VALUE is a saved register, ADDR says it was saved at a constant
1407 offset from the frame base, and SIZE indicates that the whole
1408 register was saved, record its offset in the reg_offset table in
1409 PROLOGUE_UNTYPED. */
1411 s390_check_for_saved (void *data_untyped, pv_t addr,
1412 CORE_ADDR size, pv_t value)
1414 struct s390_prologue_data *data = (struct s390_prologue_data *) data_untyped;
1417 if (!pv_is_register (addr, S390_SP_REGNUM))
1420 offset = 16 * data->gpr_size + 32 - addr.k;
1422 /* If we are storing the original value of a register, we want to
1423 record the CFA offset. If the same register is stored multiple
1424 times, the stack slot with the highest address counts. */
1426 for (i = 0; i < S390_NUM_GPRS; i++)
1427 if (size == data->gpr_size
1428 && pv_is_register_k (value, S390_R0_REGNUM + i, 0))
1429 if (data->gpr_slot[i] == 0
1430 || data->gpr_slot[i] > offset)
1432 data->gpr_slot[i] = offset;
1436 for (i = 0; i < S390_NUM_FPRS; i++)
1437 if (size == data->fpr_size
1438 && pv_is_register_k (value, S390_F0_REGNUM + i, 0))
1439 if (data->fpr_slot[i] == 0
1440 || data->fpr_slot[i] > offset)
1442 data->fpr_slot[i] = offset;
1447 /* Analyze the prologue of the function starting at START_PC,
1448 continuing at most until CURRENT_PC. Initialize DATA to
1449 hold all information we find out about the state of the registers
1450 and stack slots. Return the address of the instruction after
1451 the last one that changed the SP, FP, or back chain; or zero
1454 s390_analyze_prologue (struct gdbarch *gdbarch,
1456 CORE_ADDR current_pc,
1457 struct s390_prologue_data *data)
1459 int word_size = gdbarch_ptr_bit (gdbarch) / 8;
1461 /* Our return value:
1462 The address of the instruction after the last one that changed
1463 the SP, FP, or back chain; zero if we got an error trying to
1465 CORE_ADDR result = start_pc;
1467 /* The current PC for our abstract interpretation. */
1470 /* The address of the next instruction after that. */
1473 /* Set up everything's initial value. */
1477 data->stack = make_pv_area (S390_SP_REGNUM, gdbarch_addr_bit (gdbarch));
1479 /* For the purpose of prologue tracking, we consider the GPR size to
1480 be equal to the ABI word size, even if it is actually larger
1481 (i.e. when running a 32-bit binary under a 64-bit kernel). */
1482 data->gpr_size = word_size;
1484 data->byte_order = gdbarch_byte_order (gdbarch);
1486 for (i = 0; i < S390_NUM_GPRS; i++)
1487 data->gpr[i] = pv_register (S390_R0_REGNUM + i, 0);
1489 for (i = 0; i < S390_NUM_FPRS; i++)
1490 data->fpr[i] = pv_register (S390_F0_REGNUM + i, 0);
1492 for (i = 0; i < S390_NUM_GPRS; i++)
1493 data->gpr_slot[i] = 0;
1495 for (i = 0; i < S390_NUM_FPRS; i++)
1496 data->fpr_slot[i] = 0;
1498 data->back_chain_saved_p = 0;
1501 /* Start interpreting instructions, until we hit the frame's
1502 current PC or the first branch instruction. */
1503 for (pc = start_pc; pc > 0 && pc < current_pc; pc = next_pc)
1505 bfd_byte insn[S390_MAX_INSTR_SIZE];
1506 int insn_len = s390_readinstruction (insn, pc);
1508 bfd_byte dummy[S390_MAX_INSTR_SIZE] = { 0 };
1509 bfd_byte *insn32 = word_size == 4 ? insn : dummy;
1510 bfd_byte *insn64 = word_size == 8 ? insn : dummy;
1512 /* Fields for various kinds of instructions. */
1513 unsigned int b2, r1, r2, x2, r3;
1516 /* The values of SP and FP before this instruction,
1517 for detecting instructions that change them. */
1518 pv_t pre_insn_sp, pre_insn_fp;
1519 /* Likewise for the flag whether the back chain was saved. */
1520 int pre_insn_back_chain_saved_p;
1522 /* If we got an error trying to read the instruction, report it. */
1529 next_pc = pc + insn_len;
1531 pre_insn_sp = data->gpr[S390_SP_REGNUM - S390_R0_REGNUM];
1532 pre_insn_fp = data->gpr[S390_FRAME_REGNUM - S390_R0_REGNUM];
1533 pre_insn_back_chain_saved_p = data->back_chain_saved_p;
1536 /* LHI r1, i2 --- load halfword immediate. */
1537 /* LGHI r1, i2 --- load halfword immediate (64-bit version). */
1538 /* LGFI r1, i2 --- load fullword immediate. */
1539 if (is_ri (insn32, op1_lhi, op2_lhi, &r1, &i2)
1540 || is_ri (insn64, op1_lghi, op2_lghi, &r1, &i2)
1541 || is_ril (insn, op1_lgfi, op2_lgfi, &r1, &i2))
1542 data->gpr[r1] = pv_constant (i2);
1544 /* LR r1, r2 --- load from register. */
1545 /* LGR r1, r2 --- load from register (64-bit version). */
1546 else if (is_rr (insn32, op_lr, &r1, &r2)
1547 || is_rre (insn64, op_lgr, &r1, &r2))
1548 data->gpr[r1] = data->gpr[r2];
1550 /* L r1, d2(x2, b2) --- load. */
1551 /* LY r1, d2(x2, b2) --- load (long-displacement version). */
1552 /* LG r1, d2(x2, b2) --- load (64-bit version). */
1553 else if (is_rx (insn32, op_l, &r1, &d2, &x2, &b2)
1554 || is_rxy (insn32, op1_ly, op2_ly, &r1, &d2, &x2, &b2)
1555 || is_rxy (insn64, op1_lg, op2_lg, &r1, &d2, &x2, &b2))
1556 data->gpr[r1] = s390_load (data, d2, x2, b2, data->gpr_size);
1558 /* ST r1, d2(x2, b2) --- store. */
1559 /* STY r1, d2(x2, b2) --- store (long-displacement version). */
1560 /* STG r1, d2(x2, b2) --- store (64-bit version). */
1561 else if (is_rx (insn32, op_st, &r1, &d2, &x2, &b2)
1562 || is_rxy (insn32, op1_sty, op2_sty, &r1, &d2, &x2, &b2)
1563 || is_rxy (insn64, op1_stg, op2_stg, &r1, &d2, &x2, &b2))
1564 s390_store (data, d2, x2, b2, data->gpr_size, data->gpr[r1]);
1566 /* STD r1, d2(x2,b2) --- store floating-point register. */
1567 else if (is_rx (insn, op_std, &r1, &d2, &x2, &b2))
1568 s390_store (data, d2, x2, b2, data->fpr_size, data->fpr[r1]);
1570 /* STM r1, r3, d2(b2) --- store multiple. */
1571 /* STMY r1, r3, d2(b2) --- store multiple (long-displacement
1573 /* STMG r1, r3, d2(b2) --- store multiple (64-bit version). */
1574 else if (is_rs (insn32, op_stm, &r1, &r3, &d2, &b2)
1575 || is_rsy (insn32, op1_stmy, op2_stmy, &r1, &r3, &d2, &b2)
1576 || is_rsy (insn64, op1_stmg, op2_stmg, &r1, &r3, &d2, &b2))
1578 for (; r1 <= r3; r1++, d2 += data->gpr_size)
1579 s390_store (data, d2, 0, b2, data->gpr_size, data->gpr[r1]);
1582 /* AHI r1, i2 --- add halfword immediate. */
1583 /* AGHI r1, i2 --- add halfword immediate (64-bit version). */
1584 /* AFI r1, i2 --- add fullword immediate. */
1585 /* AGFI r1, i2 --- add fullword immediate (64-bit version). */
1586 else if (is_ri (insn32, op1_ahi, op2_ahi, &r1, &i2)
1587 || is_ri (insn64, op1_aghi, op2_aghi, &r1, &i2)
1588 || is_ril (insn32, op1_afi, op2_afi, &r1, &i2)
1589 || is_ril (insn64, op1_agfi, op2_agfi, &r1, &i2))
1590 data->gpr[r1] = pv_add_constant (data->gpr[r1], i2);
1592 /* ALFI r1, i2 --- add logical immediate. */
1593 /* ALGFI r1, i2 --- add logical immediate (64-bit version). */
1594 else if (is_ril (insn32, op1_alfi, op2_alfi, &r1, &i2)
1595 || is_ril (insn64, op1_algfi, op2_algfi, &r1, &i2))
1596 data->gpr[r1] = pv_add_constant (data->gpr[r1],
1597 (CORE_ADDR)i2 & 0xffffffff);
1599 /* AR r1, r2 -- add register. */
1600 /* AGR r1, r2 -- add register (64-bit version). */
1601 else if (is_rr (insn32, op_ar, &r1, &r2)
1602 || is_rre (insn64, op_agr, &r1, &r2))
1603 data->gpr[r1] = pv_add (data->gpr[r1], data->gpr[r2]);
1605 /* A r1, d2(x2, b2) -- add. */
1606 /* AY r1, d2(x2, b2) -- add (long-displacement version). */
1607 /* AG r1, d2(x2, b2) -- add (64-bit version). */
1608 else if (is_rx (insn32, op_a, &r1, &d2, &x2, &b2)
1609 || is_rxy (insn32, op1_ay, op2_ay, &r1, &d2, &x2, &b2)
1610 || is_rxy (insn64, op1_ag, op2_ag, &r1, &d2, &x2, &b2))
1611 data->gpr[r1] = pv_add (data->gpr[r1],
1612 s390_load (data, d2, x2, b2, data->gpr_size));
1614 /* SLFI r1, i2 --- subtract logical immediate. */
1615 /* SLGFI r1, i2 --- subtract logical immediate (64-bit version). */
1616 else if (is_ril (insn32, op1_slfi, op2_slfi, &r1, &i2)
1617 || is_ril (insn64, op1_slgfi, op2_slgfi, &r1, &i2))
1618 data->gpr[r1] = pv_add_constant (data->gpr[r1],
1619 -((CORE_ADDR)i2 & 0xffffffff));
1621 /* SR r1, r2 -- subtract register. */
1622 /* SGR r1, r2 -- subtract register (64-bit version). */
1623 else if (is_rr (insn32, op_sr, &r1, &r2)
1624 || is_rre (insn64, op_sgr, &r1, &r2))
1625 data->gpr[r1] = pv_subtract (data->gpr[r1], data->gpr[r2]);
1627 /* S r1, d2(x2, b2) -- subtract. */
1628 /* SY r1, d2(x2, b2) -- subtract (long-displacement version). */
1629 /* SG r1, d2(x2, b2) -- subtract (64-bit version). */
1630 else if (is_rx (insn32, op_s, &r1, &d2, &x2, &b2)
1631 || is_rxy (insn32, op1_sy, op2_sy, &r1, &d2, &x2, &b2)
1632 || is_rxy (insn64, op1_sg, op2_sg, &r1, &d2, &x2, &b2))
1633 data->gpr[r1] = pv_subtract (data->gpr[r1],
1634 s390_load (data, d2, x2, b2, data->gpr_size));
1636 /* LA r1, d2(x2, b2) --- load address. */
1637 /* LAY r1, d2(x2, b2) --- load address (long-displacement version). */
1638 else if (is_rx (insn, op_la, &r1, &d2, &x2, &b2)
1639 || is_rxy (insn, op1_lay, op2_lay, &r1, &d2, &x2, &b2))
1640 data->gpr[r1] = s390_addr (data, d2, x2, b2);
1642 /* LARL r1, i2 --- load address relative long. */
1643 else if (is_ril (insn, op1_larl, op2_larl, &r1, &i2))
1644 data->gpr[r1] = pv_constant (pc + i2 * 2);
1646 /* BASR r1, 0 --- branch and save.
1647 Since r2 is zero, this saves the PC in r1, but doesn't branch. */
1648 else if (is_rr (insn, op_basr, &r1, &r2)
1650 data->gpr[r1] = pv_constant (next_pc);
1652 /* BRAS r1, i2 --- branch relative and save. */
1653 else if (is_ri (insn, op1_bras, op2_bras, &r1, &i2))
1655 data->gpr[r1] = pv_constant (next_pc);
1656 next_pc = pc + i2 * 2;
1658 /* We'd better not interpret any backward branches. We'll
1664 /* BRC/BRCL -- branch relative on condition. Ignore "branch
1665 never", branch to following instruction, and "conditional
1666 trap" (BRC +2). Otherwise terminate search. */
1667 else if (is_ri (insn, op1_brc, op2_brc, &r1, &i2))
1669 if (r1 != 0 && i2 != 1 && i2 != 2)
1672 else if (is_ril (insn, op1_brcl, op2_brcl, &r1, &i2))
1674 if (r1 != 0 && i2 != 3)
1678 /* Terminate search when hitting any other branch instruction. */
1679 else if (is_rr (insn, op_basr, &r1, &r2)
1680 || is_rx (insn, op_bas, &r1, &d2, &x2, &b2)
1681 || is_rr (insn, op_bcr, &r1, &r2)
1682 || is_rx (insn, op_bc, &r1, &d2, &x2, &b2)
1683 || is_ril (insn, op1_brasl, op2_brasl, &r2, &i2))
1688 /* An instruction we don't know how to simulate. The only
1689 safe thing to do would be to set every value we're tracking
1690 to 'unknown'. Instead, we'll be optimistic: we assume that
1691 we *can* interpret every instruction that the compiler uses
1692 to manipulate any of the data we're interested in here --
1693 then we can just ignore anything else. */
1696 /* Record the address after the last instruction that changed
1697 the FP, SP, or backlink. Ignore instructions that changed
1698 them back to their original values --- those are probably
1699 restore instructions. (The back chain is never restored,
1702 pv_t sp = data->gpr[S390_SP_REGNUM - S390_R0_REGNUM];
1703 pv_t fp = data->gpr[S390_FRAME_REGNUM - S390_R0_REGNUM];
1705 if ((! pv_is_identical (pre_insn_sp, sp)
1706 && ! pv_is_register_k (sp, S390_SP_REGNUM, 0)
1707 && sp.kind != pvk_unknown)
1708 || (! pv_is_identical (pre_insn_fp, fp)
1709 && ! pv_is_register_k (fp, S390_FRAME_REGNUM, 0)
1710 && fp.kind != pvk_unknown)
1711 || pre_insn_back_chain_saved_p != data->back_chain_saved_p)
1716 /* Record where all the registers were saved. */
1717 pv_area_scan (data->stack, s390_check_for_saved, data);
1719 free_pv_area (data->stack);
1725 /* Advance PC across any function entry prologue instructions to reach
1726 some "real" code. */
1728 s390_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
1730 struct s390_prologue_data data;
1731 CORE_ADDR skip_pc, func_addr;
1733 if (find_pc_partial_function (pc, NULL, &func_addr, NULL))
1735 CORE_ADDR post_prologue_pc
1736 = skip_prologue_using_sal (gdbarch, func_addr);
1737 if (post_prologue_pc != 0)
1738 return std::max (pc, post_prologue_pc);
1741 skip_pc = s390_analyze_prologue (gdbarch, pc, (CORE_ADDR)-1, &data);
1742 return skip_pc ? skip_pc : pc;
1745 /* Implmement the stack_frame_destroyed_p gdbarch method. */
1747 s390_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
1749 int word_size = gdbarch_ptr_bit (gdbarch) / 8;
1751 /* In frameless functions, there's not frame to destroy and thus
1752 we don't care about the epilogue.
1754 In functions with frame, the epilogue sequence is a pair of
1755 a LM-type instruction that restores (amongst others) the
1756 return register %r14 and the stack pointer %r15, followed
1757 by a branch 'br %r14' --or equivalent-- that effects the
1760 In that situation, this function needs to return 'true' in
1761 exactly one case: when pc points to that branch instruction.
1763 Thus we try to disassemble the one instructions immediately
1764 preceding pc and check whether it is an LM-type instruction
1765 modifying the stack pointer.
1767 Note that disassembling backwards is not reliable, so there
1768 is a slight chance of false positives here ... */
1771 unsigned int r1, r3, b2;
1775 && !target_read_memory (pc - 4, insn, 4)
1776 && is_rs (insn, op_lm, &r1, &r3, &d2, &b2)
1777 && r3 == S390_SP_REGNUM - S390_R0_REGNUM)
1781 && !target_read_memory (pc - 6, insn, 6)
1782 && is_rsy (insn, op1_lmy, op2_lmy, &r1, &r3, &d2, &b2)
1783 && r3 == S390_SP_REGNUM - S390_R0_REGNUM)
1787 && !target_read_memory (pc - 6, insn, 6)
1788 && is_rsy (insn, op1_lmg, op2_lmg, &r1, &r3, &d2, &b2)
1789 && r3 == S390_SP_REGNUM - S390_R0_REGNUM)
1795 /* Displaced stepping. */
1797 /* Return true if INSN is a non-branch RIL-b or RIL-c format
1801 is_non_branch_ril (gdb_byte *insn)
1803 gdb_byte op1 = insn[0];
1807 gdb_byte op2 = insn[1] & 0x0f;
1811 case 0x02: /* llhrl */
1812 case 0x04: /* lghrl */
1813 case 0x05: /* lhrl */
1814 case 0x06: /* llghrl */
1815 case 0x07: /* sthrl */
1816 case 0x08: /* lgrl */
1817 case 0x0b: /* stgrl */
1818 case 0x0c: /* lgfrl */
1819 case 0x0d: /* lrl */
1820 case 0x0e: /* llgfrl */
1821 case 0x0f: /* strl */
1825 else if (op1 == 0xc6)
1827 gdb_byte op2 = insn[1] & 0x0f;
1831 case 0x00: /* exrl */
1832 case 0x02: /* pfdrl */
1833 case 0x04: /* cghrl */
1834 case 0x05: /* chrl */
1835 case 0x06: /* clghrl */
1836 case 0x07: /* clhrl */
1837 case 0x08: /* cgrl */
1838 case 0x0a: /* clgrl */
1839 case 0x0c: /* cgfrl */
1840 case 0x0d: /* crl */
1841 case 0x0e: /* clgfrl */
1842 case 0x0f: /* clrl */
1850 /* Implementation of gdbarch_displaced_step_copy_insn. */
1852 static struct displaced_step_closure *
1853 s390_displaced_step_copy_insn (struct gdbarch *gdbarch,
1854 CORE_ADDR from, CORE_ADDR to,
1855 struct regcache *regs)
1857 size_t len = gdbarch_max_insn_length (gdbarch);
1858 gdb_byte *buf = (gdb_byte *) xmalloc (len);
1859 struct cleanup *old_chain = make_cleanup (xfree, buf);
1861 read_memory (from, buf, len);
1863 /* Adjust the displacement field of PC-relative RIL instructions,
1864 except branches. The latter are handled in the fixup hook. */
1865 if (is_non_branch_ril (buf))
1869 offset = extract_signed_integer (buf + 2, 4, BFD_ENDIAN_BIG);
1870 offset = (from - to + offset * 2) / 2;
1872 /* If the instruction is too far from the jump pad, punt. This
1873 will usually happen with instructions in shared libraries.
1874 We could probably support these by rewriting them to be
1875 absolute or fully emulating them. */
1876 if (offset < INT32_MIN || offset > INT32_MAX)
1878 /* Let the core fall back to stepping over the breakpoint
1880 if (debug_displaced)
1882 fprintf_unfiltered (gdb_stdlog,
1883 "displaced: can't displaced step "
1884 "RIL instruction: offset %s out of range\n",
1887 do_cleanups (old_chain);
1891 store_signed_integer (buf + 2, 4, BFD_ENDIAN_BIG, offset);
1894 write_memory (to, buf, len);
1896 if (debug_displaced)
1898 fprintf_unfiltered (gdb_stdlog, "displaced: copy %s->%s: ",
1899 paddress (gdbarch, from), paddress (gdbarch, to));
1900 displaced_step_dump_bytes (gdb_stdlog, buf, len);
1903 discard_cleanups (old_chain);
1904 return (struct displaced_step_closure *) buf;
1907 /* Fix up the state of registers and memory after having single-stepped
1908 a displaced instruction. */
1910 s390_displaced_step_fixup (struct gdbarch *gdbarch,
1911 struct displaced_step_closure *closure,
1912 CORE_ADDR from, CORE_ADDR to,
1913 struct regcache *regs)
1915 /* Our closure is a copy of the instruction. */
1916 gdb_byte *insn = (gdb_byte *) closure;
1917 static int s390_instrlen[] = { 2, 4, 4, 6 };
1918 int insnlen = s390_instrlen[insn[0] >> 6];
1920 /* Fields for various kinds of instructions. */
1921 unsigned int b2, r1, r2, x2, r3;
1924 /* Get current PC and addressing mode bit. */
1925 CORE_ADDR pc = regcache_read_pc (regs);
1928 if (register_size (gdbarch, S390_PSWA_REGNUM) == 4)
1930 regcache_cooked_read_unsigned (regs, S390_PSWA_REGNUM, &amode);
1931 amode &= 0x80000000;
1934 if (debug_displaced)
1935 fprintf_unfiltered (gdb_stdlog,
1936 "displaced: (s390) fixup (%s, %s) pc %s len %d amode 0x%x\n",
1937 paddress (gdbarch, from), paddress (gdbarch, to),
1938 paddress (gdbarch, pc), insnlen, (int) amode);
1940 /* Handle absolute branch and save instructions. */
1941 if (is_rr (insn, op_basr, &r1, &r2)
1942 || is_rx (insn, op_bas, &r1, &d2, &x2, &b2))
1944 /* Recompute saved return address in R1. */
1945 regcache_cooked_write_unsigned (regs, S390_R0_REGNUM + r1,
1946 amode | (from + insnlen));
1949 /* Handle absolute branch instructions. */
1950 else if (is_rr (insn, op_bcr, &r1, &r2)
1951 || is_rx (insn, op_bc, &r1, &d2, &x2, &b2)
1952 || is_rr (insn, op_bctr, &r1, &r2)
1953 || is_rre (insn, op_bctgr, &r1, &r2)
1954 || is_rx (insn, op_bct, &r1, &d2, &x2, &b2)
1955 || is_rxy (insn, op1_bctg, op2_brctg, &r1, &d2, &x2, &b2)
1956 || is_rs (insn, op_bxh, &r1, &r3, &d2, &b2)
1957 || is_rsy (insn, op1_bxhg, op2_bxhg, &r1, &r3, &d2, &b2)
1958 || is_rs (insn, op_bxle, &r1, &r3, &d2, &b2)
1959 || is_rsy (insn, op1_bxleg, op2_bxleg, &r1, &r3, &d2, &b2))
1961 /* Update PC iff branch was *not* taken. */
1962 if (pc == to + insnlen)
1963 regcache_write_pc (regs, from + insnlen);
1966 /* Handle PC-relative branch and save instructions. */
1967 else if (is_ri (insn, op1_bras, op2_bras, &r1, &i2)
1968 || is_ril (insn, op1_brasl, op2_brasl, &r1, &i2))
1971 regcache_write_pc (regs, pc - to + from);
1972 /* Recompute saved return address in R1. */
1973 regcache_cooked_write_unsigned (regs, S390_R0_REGNUM + r1,
1974 amode | (from + insnlen));
1977 /* Handle PC-relative branch instructions. */
1978 else if (is_ri (insn, op1_brc, op2_brc, &r1, &i2)
1979 || is_ril (insn, op1_brcl, op2_brcl, &r1, &i2)
1980 || is_ri (insn, op1_brct, op2_brct, &r1, &i2)
1981 || is_ri (insn, op1_brctg, op2_brctg, &r1, &i2)
1982 || is_rsi (insn, op_brxh, &r1, &r3, &i2)
1983 || is_rie (insn, op1_brxhg, op2_brxhg, &r1, &r3, &i2)
1984 || is_rsi (insn, op_brxle, &r1, &r3, &i2)
1985 || is_rie (insn, op1_brxlg, op2_brxlg, &r1, &r3, &i2))
1988 regcache_write_pc (regs, pc - to + from);
1991 /* Handle LOAD ADDRESS RELATIVE LONG. */
1992 else if (is_ril (insn, op1_larl, op2_larl, &r1, &i2))
1995 regcache_write_pc (regs, from + insnlen);
1996 /* Recompute output address in R1. */
1997 regcache_cooked_write_unsigned (regs, S390_R0_REGNUM + r1,
1998 amode | (from + i2 * 2));
2001 /* If we executed a breakpoint instruction, point PC right back at it. */
2002 else if (insn[0] == 0x0 && insn[1] == 0x1)
2003 regcache_write_pc (regs, from);
2005 /* For any other insn, PC points right after the original instruction. */
2007 regcache_write_pc (regs, from + insnlen);
2009 if (debug_displaced)
2010 fprintf_unfiltered (gdb_stdlog,
2011 "displaced: (s390) pc is now %s\n",
2012 paddress (gdbarch, regcache_read_pc (regs)));
2016 /* Helper routine to unwind pseudo registers. */
2018 static struct value *
2019 s390_unwind_pseudo_register (struct frame_info *this_frame, int regnum)
2021 struct gdbarch *gdbarch = get_frame_arch (this_frame);
2022 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
2023 struct type *type = register_type (gdbarch, regnum);
2025 /* Unwind PC via PSW address. */
2026 if (regnum == tdep->pc_regnum)
2030 val = frame_unwind_register_value (this_frame, S390_PSWA_REGNUM);
2031 if (!value_optimized_out (val))
2033 LONGEST pswa = value_as_long (val);
2035 if (TYPE_LENGTH (type) == 4)
2036 return value_from_pointer (type, pswa & 0x7fffffff);
2038 return value_from_pointer (type, pswa);
2042 /* Unwind CC via PSW mask. */
2043 if (regnum == tdep->cc_regnum)
2047 val = frame_unwind_register_value (this_frame, S390_PSWM_REGNUM);
2048 if (!value_optimized_out (val))
2050 LONGEST pswm = value_as_long (val);
2052 if (TYPE_LENGTH (type) == 4)
2053 return value_from_longest (type, (pswm >> 12) & 3);
2055 return value_from_longest (type, (pswm >> 44) & 3);
2059 /* Unwind full GPRs to show at least the lower halves (as the
2060 upper halves are undefined). */
2061 if (regnum_is_gpr_full (tdep, regnum))
2063 int reg = regnum - tdep->gpr_full_regnum;
2066 val = frame_unwind_register_value (this_frame, S390_R0_REGNUM + reg);
2067 if (!value_optimized_out (val))
2068 return value_cast (type, val);
2071 return allocate_optimized_out_value (type);
2074 static struct value *
2075 s390_trad_frame_prev_register (struct frame_info *this_frame,
2076 struct trad_frame_saved_reg saved_regs[],
2079 if (regnum < S390_NUM_REGS)
2080 return trad_frame_get_prev_register (this_frame, saved_regs, regnum);
2082 return s390_unwind_pseudo_register (this_frame, regnum);
2086 /* Normal stack frames. */
2088 struct s390_unwind_cache {
2091 CORE_ADDR frame_base;
2092 CORE_ADDR local_base;
2094 struct trad_frame_saved_reg *saved_regs;
2098 s390_prologue_frame_unwind_cache (struct frame_info *this_frame,
2099 struct s390_unwind_cache *info)
2101 struct gdbarch *gdbarch = get_frame_arch (this_frame);
2102 int word_size = gdbarch_ptr_bit (gdbarch) / 8;
2103 struct s390_prologue_data data;
2104 pv_t *fp = &data.gpr[S390_FRAME_REGNUM - S390_R0_REGNUM];
2105 pv_t *sp = &data.gpr[S390_SP_REGNUM - S390_R0_REGNUM];
2114 struct frame_info *next_frame;
2116 /* Try to find the function start address. If we can't find it, we don't
2117 bother searching for it -- with modern compilers this would be mostly
2118 pointless anyway. Trust that we'll either have valid DWARF-2 CFI data
2119 or else a valid backchain ... */
2120 if (!get_frame_func_if_available (this_frame, &info->func))
2127 /* Try to analyze the prologue. */
2128 result = s390_analyze_prologue (gdbarch, func,
2129 get_frame_pc (this_frame), &data);
2133 /* If this was successful, we should have found the instruction that
2134 sets the stack pointer register to the previous value of the stack
2135 pointer minus the frame size. */
2136 if (!pv_is_register (*sp, S390_SP_REGNUM))
2139 /* A frame size of zero at this point can mean either a real
2140 frameless function, or else a failure to find the prologue.
2141 Perform some sanity checks to verify we really have a
2142 frameless function. */
2145 /* If the next frame is a NORMAL_FRAME, this frame *cannot* have frame
2146 size zero. This is only possible if the next frame is a sentinel
2147 frame, a dummy frame, or a signal trampoline frame. */
2148 /* FIXME: cagney/2004-05-01: This sanity check shouldn't be
2149 needed, instead the code should simpliy rely on its
2151 next_frame = get_next_frame (this_frame);
2152 while (next_frame && get_frame_type (next_frame) == INLINE_FRAME)
2153 next_frame = get_next_frame (next_frame);
2155 && get_frame_type (get_next_frame (this_frame)) == NORMAL_FRAME)
2158 /* If we really have a frameless function, %r14 must be valid
2159 -- in particular, it must point to a different function. */
2160 reg = get_frame_register_unsigned (this_frame, S390_RETADDR_REGNUM);
2161 reg = gdbarch_addr_bits_remove (gdbarch, reg) - 1;
2162 if (get_pc_function_start (reg) == func)
2164 /* However, there is one case where it *is* valid for %r14
2165 to point to the same function -- if this is a recursive
2166 call, and we have stopped in the prologue *before* the
2167 stack frame was allocated.
2169 Recognize this case by looking ahead a bit ... */
2171 struct s390_prologue_data data2;
2172 pv_t *sp = &data2.gpr[S390_SP_REGNUM - S390_R0_REGNUM];
2174 if (!(s390_analyze_prologue (gdbarch, func, (CORE_ADDR)-1, &data2)
2175 && pv_is_register (*sp, S390_SP_REGNUM)
2182 /* OK, we've found valid prologue data. */
2185 /* If the frame pointer originally also holds the same value
2186 as the stack pointer, we're probably using it. If it holds
2187 some other value -- even a constant offset -- it is most
2188 likely used as temp register. */
2189 if (pv_is_identical (*sp, *fp))
2190 frame_pointer = S390_FRAME_REGNUM;
2192 frame_pointer = S390_SP_REGNUM;
2194 /* If we've detected a function with stack frame, we'll still have to
2195 treat it as frameless if we're currently within the function epilog
2196 code at a point where the frame pointer has already been restored.
2197 This can only happen in an innermost frame. */
2198 /* FIXME: cagney/2004-05-01: This sanity check shouldn't be needed,
2199 instead the code should simpliy rely on its analysis. */
2200 next_frame = get_next_frame (this_frame);
2201 while (next_frame && get_frame_type (next_frame) == INLINE_FRAME)
2202 next_frame = get_next_frame (next_frame);
2204 && (next_frame == NULL
2205 || get_frame_type (get_next_frame (this_frame)) != NORMAL_FRAME))
2207 /* See the comment in s390_stack_frame_destroyed_p on why this is
2208 not completely reliable ... */
2209 if (s390_stack_frame_destroyed_p (gdbarch, get_frame_pc (this_frame)))
2211 memset (&data, 0, sizeof (data));
2213 frame_pointer = S390_SP_REGNUM;
2217 /* Once we know the frame register and the frame size, we can unwind
2218 the current value of the frame register from the next frame, and
2219 add back the frame size to arrive that the previous frame's
2220 stack pointer value. */
2221 prev_sp = get_frame_register_unsigned (this_frame, frame_pointer) + size;
2222 cfa = prev_sp + 16*word_size + 32;
2224 /* Set up ABI call-saved/call-clobbered registers. */
2225 for (i = 0; i < S390_NUM_REGS; i++)
2226 if (!s390_register_call_saved (gdbarch, i))
2227 trad_frame_set_unknown (info->saved_regs, i);
2229 /* CC is always call-clobbered. */
2230 trad_frame_set_unknown (info->saved_regs, S390_PSWM_REGNUM);
2232 /* Record the addresses of all register spill slots the prologue parser
2233 has recognized. Consider only registers defined as call-saved by the
2234 ABI; for call-clobbered registers the parser may have recognized
2237 for (i = 0; i < 16; i++)
2238 if (s390_register_call_saved (gdbarch, S390_R0_REGNUM + i)
2239 && data.gpr_slot[i] != 0)
2240 info->saved_regs[S390_R0_REGNUM + i].addr = cfa - data.gpr_slot[i];
2242 for (i = 0; i < 16; i++)
2243 if (s390_register_call_saved (gdbarch, S390_F0_REGNUM + i)
2244 && data.fpr_slot[i] != 0)
2245 info->saved_regs[S390_F0_REGNUM + i].addr = cfa - data.fpr_slot[i];
2247 /* Function return will set PC to %r14. */
2248 info->saved_regs[S390_PSWA_REGNUM] = info->saved_regs[S390_RETADDR_REGNUM];
2250 /* In frameless functions, we unwind simply by moving the return
2251 address to the PC. However, if we actually stored to the
2252 save area, use that -- we might only think the function frameless
2253 because we're in the middle of the prologue ... */
2255 && !trad_frame_addr_p (info->saved_regs, S390_PSWA_REGNUM))
2257 info->saved_regs[S390_PSWA_REGNUM].realreg = S390_RETADDR_REGNUM;
2260 /* Another sanity check: unless this is a frameless function,
2261 we should have found spill slots for SP and PC.
2262 If not, we cannot unwind further -- this happens e.g. in
2263 libc's thread_start routine. */
2266 if (!trad_frame_addr_p (info->saved_regs, S390_SP_REGNUM)
2267 || !trad_frame_addr_p (info->saved_regs, S390_PSWA_REGNUM))
2271 /* We use the current value of the frame register as local_base,
2272 and the top of the register save area as frame_base. */
2275 info->frame_base = prev_sp + 16*word_size + 32;
2276 info->local_base = prev_sp - size;
2283 s390_backchain_frame_unwind_cache (struct frame_info *this_frame,
2284 struct s390_unwind_cache *info)
2286 struct gdbarch *gdbarch = get_frame_arch (this_frame);
2287 int word_size = gdbarch_ptr_bit (gdbarch) / 8;
2288 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
2289 CORE_ADDR backchain;
2294 /* Set up ABI call-saved/call-clobbered registers. */
2295 for (i = 0; i < S390_NUM_REGS; i++)
2296 if (!s390_register_call_saved (gdbarch, i))
2297 trad_frame_set_unknown (info->saved_regs, i);
2299 /* CC is always call-clobbered. */
2300 trad_frame_set_unknown (info->saved_regs, S390_PSWM_REGNUM);
2302 /* Get the backchain. */
2303 reg = get_frame_register_unsigned (this_frame, S390_SP_REGNUM);
2304 if (!safe_read_memory_integer (reg, word_size, byte_order, &tmp))
2306 backchain = (CORE_ADDR) tmp;
2308 /* A zero backchain terminates the frame chain. As additional
2309 sanity check, let's verify that the spill slot for SP in the
2310 save area pointed to by the backchain in fact links back to
2313 && safe_read_memory_integer (backchain + 15*word_size,
2314 word_size, byte_order, &sp)
2315 && (CORE_ADDR)sp == backchain)
2317 /* We don't know which registers were saved, but it will have
2318 to be at least %r14 and %r15. This will allow us to continue
2319 unwinding, but other prev-frame registers may be incorrect ... */
2320 info->saved_regs[S390_SP_REGNUM].addr = backchain + 15*word_size;
2321 info->saved_regs[S390_RETADDR_REGNUM].addr = backchain + 14*word_size;
2323 /* Function return will set PC to %r14. */
2324 info->saved_regs[S390_PSWA_REGNUM]
2325 = info->saved_regs[S390_RETADDR_REGNUM];
2327 /* We use the current value of the frame register as local_base,
2328 and the top of the register save area as frame_base. */
2329 info->frame_base = backchain + 16*word_size + 32;
2330 info->local_base = reg;
2333 info->func = get_frame_pc (this_frame);
2336 static struct s390_unwind_cache *
2337 s390_frame_unwind_cache (struct frame_info *this_frame,
2338 void **this_prologue_cache)
2340 struct s390_unwind_cache *info;
2342 if (*this_prologue_cache)
2343 return (struct s390_unwind_cache *) *this_prologue_cache;
2345 info = FRAME_OBSTACK_ZALLOC (struct s390_unwind_cache);
2346 *this_prologue_cache = info;
2347 info->saved_regs = trad_frame_alloc_saved_regs (this_frame);
2349 info->frame_base = -1;
2350 info->local_base = -1;
2354 /* Try to use prologue analysis to fill the unwind cache.
2355 If this fails, fall back to reading the stack backchain. */
2356 if (!s390_prologue_frame_unwind_cache (this_frame, info))
2357 s390_backchain_frame_unwind_cache (this_frame, info);
2359 CATCH (ex, RETURN_MASK_ERROR)
2361 if (ex.error != NOT_AVAILABLE_ERROR)
2362 throw_exception (ex);
2370 s390_frame_this_id (struct frame_info *this_frame,
2371 void **this_prologue_cache,
2372 struct frame_id *this_id)
2374 struct s390_unwind_cache *info
2375 = s390_frame_unwind_cache (this_frame, this_prologue_cache);
2377 if (info->frame_base == -1)
2379 if (info->func != -1)
2380 *this_id = frame_id_build_unavailable_stack (info->func);
2384 *this_id = frame_id_build (info->frame_base, info->func);
2387 static struct value *
2388 s390_frame_prev_register (struct frame_info *this_frame,
2389 void **this_prologue_cache, int regnum)
2391 struct s390_unwind_cache *info
2392 = s390_frame_unwind_cache (this_frame, this_prologue_cache);
2394 return s390_trad_frame_prev_register (this_frame, info->saved_regs, regnum);
2397 static const struct frame_unwind s390_frame_unwind = {
2399 default_frame_unwind_stop_reason,
2401 s390_frame_prev_register,
2403 default_frame_sniffer
2407 /* Code stubs and their stack frames. For things like PLTs and NULL
2408 function calls (where there is no true frame and the return address
2409 is in the RETADDR register). */
2411 struct s390_stub_unwind_cache
2413 CORE_ADDR frame_base;
2414 struct trad_frame_saved_reg *saved_regs;
2417 static struct s390_stub_unwind_cache *
2418 s390_stub_frame_unwind_cache (struct frame_info *this_frame,
2419 void **this_prologue_cache)
2421 struct gdbarch *gdbarch = get_frame_arch (this_frame);
2422 int word_size = gdbarch_ptr_bit (gdbarch) / 8;
2423 struct s390_stub_unwind_cache *info;
2426 if (*this_prologue_cache)
2427 return (struct s390_stub_unwind_cache *) *this_prologue_cache;
2429 info = FRAME_OBSTACK_ZALLOC (struct s390_stub_unwind_cache);
2430 *this_prologue_cache = info;
2431 info->saved_regs = trad_frame_alloc_saved_regs (this_frame);
2433 /* The return address is in register %r14. */
2434 info->saved_regs[S390_PSWA_REGNUM].realreg = S390_RETADDR_REGNUM;
2436 /* Retrieve stack pointer and determine our frame base. */
2437 reg = get_frame_register_unsigned (this_frame, S390_SP_REGNUM);
2438 info->frame_base = reg + 16*word_size + 32;
2444 s390_stub_frame_this_id (struct frame_info *this_frame,
2445 void **this_prologue_cache,
2446 struct frame_id *this_id)
2448 struct s390_stub_unwind_cache *info
2449 = s390_stub_frame_unwind_cache (this_frame, this_prologue_cache);
2450 *this_id = frame_id_build (info->frame_base, get_frame_pc (this_frame));
2453 static struct value *
2454 s390_stub_frame_prev_register (struct frame_info *this_frame,
2455 void **this_prologue_cache, int regnum)
2457 struct s390_stub_unwind_cache *info
2458 = s390_stub_frame_unwind_cache (this_frame, this_prologue_cache);
2459 return s390_trad_frame_prev_register (this_frame, info->saved_regs, regnum);
2463 s390_stub_frame_sniffer (const struct frame_unwind *self,
2464 struct frame_info *this_frame,
2465 void **this_prologue_cache)
2467 CORE_ADDR addr_in_block;
2468 bfd_byte insn[S390_MAX_INSTR_SIZE];
2470 /* If the current PC points to non-readable memory, we assume we
2471 have trapped due to an invalid function pointer call. We handle
2472 the non-existing current function like a PLT stub. */
2473 addr_in_block = get_frame_address_in_block (this_frame);
2474 if (in_plt_section (addr_in_block)
2475 || s390_readinstruction (insn, get_frame_pc (this_frame)) < 0)
2480 static const struct frame_unwind s390_stub_frame_unwind = {
2482 default_frame_unwind_stop_reason,
2483 s390_stub_frame_this_id,
2484 s390_stub_frame_prev_register,
2486 s390_stub_frame_sniffer
2490 /* Signal trampoline stack frames. */
2492 struct s390_sigtramp_unwind_cache {
2493 CORE_ADDR frame_base;
2494 struct trad_frame_saved_reg *saved_regs;
2497 static struct s390_sigtramp_unwind_cache *
2498 s390_sigtramp_frame_unwind_cache (struct frame_info *this_frame,
2499 void **this_prologue_cache)
2501 struct gdbarch *gdbarch = get_frame_arch (this_frame);
2502 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
2503 int word_size = gdbarch_ptr_bit (gdbarch) / 8;
2504 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
2505 struct s390_sigtramp_unwind_cache *info;
2506 ULONGEST this_sp, prev_sp;
2507 CORE_ADDR next_ra, next_cfa, sigreg_ptr, sigreg_high_off;
2510 if (*this_prologue_cache)
2511 return (struct s390_sigtramp_unwind_cache *) *this_prologue_cache;
2513 info = FRAME_OBSTACK_ZALLOC (struct s390_sigtramp_unwind_cache);
2514 *this_prologue_cache = info;
2515 info->saved_regs = trad_frame_alloc_saved_regs (this_frame);
2517 this_sp = get_frame_register_unsigned (this_frame, S390_SP_REGNUM);
2518 next_ra = get_frame_pc (this_frame);
2519 next_cfa = this_sp + 16*word_size + 32;
2521 /* New-style RT frame:
2522 retcode + alignment (8 bytes)
2524 ucontext (contains sigregs at offset 5 words). */
2525 if (next_ra == next_cfa)
2527 sigreg_ptr = next_cfa + 8 + 128 + align_up (5*word_size, 8);
2528 /* sigregs are followed by uc_sigmask (8 bytes), then by the
2529 upper GPR halves if present. */
2530 sigreg_high_off = 8;
2533 /* Old-style RT frame and all non-RT frames:
2534 old signal mask (8 bytes)
2535 pointer to sigregs. */
2538 sigreg_ptr = read_memory_unsigned_integer (next_cfa + 8,
2539 word_size, byte_order);
2540 /* sigregs are followed by signo (4 bytes), then by the
2541 upper GPR halves if present. */
2542 sigreg_high_off = 4;
2545 /* The sigregs structure looks like this:
2554 /* PSW mask and address. */
2555 info->saved_regs[S390_PSWM_REGNUM].addr = sigreg_ptr;
2556 sigreg_ptr += word_size;
2557 info->saved_regs[S390_PSWA_REGNUM].addr = sigreg_ptr;
2558 sigreg_ptr += word_size;
2560 /* Then the GPRs. */
2561 for (i = 0; i < 16; i++)
2563 info->saved_regs[S390_R0_REGNUM + i].addr = sigreg_ptr;
2564 sigreg_ptr += word_size;
2567 /* Then the ACRs. */
2568 for (i = 0; i < 16; i++)
2570 info->saved_regs[S390_A0_REGNUM + i].addr = sigreg_ptr;
2574 /* The floating-point control word. */
2575 info->saved_regs[S390_FPC_REGNUM].addr = sigreg_ptr;
2578 /* And finally the FPRs. */
2579 for (i = 0; i < 16; i++)
2581 info->saved_regs[S390_F0_REGNUM + i].addr = sigreg_ptr;
2585 /* If we have them, the GPR upper halves are appended at the end. */
2586 sigreg_ptr += sigreg_high_off;
2587 if (tdep->gpr_full_regnum != -1)
2588 for (i = 0; i < 16; i++)
2590 info->saved_regs[S390_R0_UPPER_REGNUM + i].addr = sigreg_ptr;
2594 /* Restore the previous frame's SP. */
2595 prev_sp = read_memory_unsigned_integer (
2596 info->saved_regs[S390_SP_REGNUM].addr,
2597 word_size, byte_order);
2599 /* Determine our frame base. */
2600 info->frame_base = prev_sp + 16*word_size + 32;
2606 s390_sigtramp_frame_this_id (struct frame_info *this_frame,
2607 void **this_prologue_cache,
2608 struct frame_id *this_id)
2610 struct s390_sigtramp_unwind_cache *info
2611 = s390_sigtramp_frame_unwind_cache (this_frame, this_prologue_cache);
2612 *this_id = frame_id_build (info->frame_base, get_frame_pc (this_frame));
2615 static struct value *
2616 s390_sigtramp_frame_prev_register (struct frame_info *this_frame,
2617 void **this_prologue_cache, int regnum)
2619 struct s390_sigtramp_unwind_cache *info
2620 = s390_sigtramp_frame_unwind_cache (this_frame, this_prologue_cache);
2621 return s390_trad_frame_prev_register (this_frame, info->saved_regs, regnum);
2625 s390_sigtramp_frame_sniffer (const struct frame_unwind *self,
2626 struct frame_info *this_frame,
2627 void **this_prologue_cache)
2629 CORE_ADDR pc = get_frame_pc (this_frame);
2630 bfd_byte sigreturn[2];
2632 if (target_read_memory (pc, sigreturn, 2))
2635 if (sigreturn[0] != op_svc)
2638 if (sigreturn[1] != 119 /* sigreturn */
2639 && sigreturn[1] != 173 /* rt_sigreturn */)
2645 static const struct frame_unwind s390_sigtramp_frame_unwind = {
2647 default_frame_unwind_stop_reason,
2648 s390_sigtramp_frame_this_id,
2649 s390_sigtramp_frame_prev_register,
2651 s390_sigtramp_frame_sniffer
2654 /* Retrieve the syscall number at a ptrace syscall-stop. Return -1
2658 s390_linux_get_syscall_number (struct gdbarch *gdbarch,
2661 struct regcache *regs = get_thread_regcache (ptid);
2662 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
2663 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
2665 ULONGEST svc_number = -1;
2668 /* Assume that the PC points after the 2-byte SVC instruction. We
2669 don't currently support SVC via EXECUTE. */
2670 regcache_cooked_read_unsigned (regs, tdep->pc_regnum, &pc);
2672 opcode = read_memory_unsigned_integer ((CORE_ADDR) pc, 1, byte_order);
2673 if (opcode != op_svc)
2676 svc_number = read_memory_unsigned_integer ((CORE_ADDR) pc + 1, 1,
2678 if (svc_number == 0)
2679 regcache_cooked_read_unsigned (regs, S390_R1_REGNUM, &svc_number);
2684 /* Process record-replay */
2686 static struct linux_record_tdep s390_linux_record_tdep;
2687 static struct linux_record_tdep s390x_linux_record_tdep;
2689 /* Record all registers but PC register for process-record. */
2692 s390_all_but_pc_registers_record (struct regcache *regcache)
2694 struct gdbarch *gdbarch = get_regcache_arch (regcache);
2695 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
2698 for (i = 0; i < 16; i++)
2700 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + i))
2702 if (record_full_arch_list_add_reg (regcache, S390_A0_REGNUM + i))
2704 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + i))
2706 if (tdep->gpr_full_regnum != -1)
2707 if (record_full_arch_list_add_reg (regcache, S390_R0_UPPER_REGNUM + i))
2709 if (tdep->v0_full_regnum != -1)
2711 if (record_full_arch_list_add_reg (regcache, S390_V0_LOWER_REGNUM + i))
2713 if (record_full_arch_list_add_reg (regcache, S390_V16_REGNUM + i))
2717 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
2719 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
2725 static enum gdb_syscall
2726 s390_canonicalize_syscall (int syscall, enum s390_abi_kind abi)
2730 /* s390 syscall numbers < 222 are mostly the same as x86, so just list
2733 return gdb_sys_no_syscall;
2735 return gdb_sys_restart_syscall;
2736 /* These syscalls work only on 31-bit. */
2738 case 16: /* lchown[16] */
2739 case 23: /* setuid[16] */
2740 case 24: /* getuid[16] */
2741 case 25: /* stime */
2742 case 46: /* setgid[16] */
2743 case 47: /* getgid[16] */
2744 case 49: /* seteuid[16] */
2745 case 50: /* getegid[16] */
2746 case 70: /* setreuid[16] */
2747 case 71: /* setregid[16] */
2748 case 76: /* [old_]getrlimit */
2749 case 80: /* getgroups[16] */
2750 case 81: /* setgroups[16] */
2751 case 95: /* fchown[16] */
2752 case 101: /* ioperm */
2753 case 138: /* setfsuid[16] */
2754 case 139: /* setfsgid[16] */
2755 case 140: /* _llseek */
2756 case 164: /* setresuid[16] */
2757 case 165: /* getresuid[16] */
2758 case 170: /* setresgid[16] */
2759 case 171: /* getresgid[16] */
2760 case 182: /* chown[16] */
2761 case 192: /* mmap2 */
2762 case 193: /* truncate64 */
2763 case 194: /* ftruncate64 */
2764 case 195: /* stat64 */
2765 case 196: /* lstat64 */
2766 case 197: /* fstat64 */
2767 case 221: /* fcntl64 */
2768 if (abi == ABI_LINUX_S390)
2769 return (enum gdb_syscall) syscall;
2770 return gdb_sys_no_syscall;
2771 /* These syscalls don't exist on s390. */
2772 case 17: /* break */
2773 case 18: /* oldstat */
2774 case 28: /* oldfstat */
2777 case 35: /* ftime */
2781 case 58: /* ulimit */
2782 case 59: /* oldolduname */
2783 case 68: /* sgetmask */
2784 case 69: /* ssetmask */
2785 case 82: /* [old_]select */
2786 case 84: /* oldlstat */
2787 case 98: /* profil */
2788 case 109: /* olduname */
2789 case 113: /* vm86old */
2790 case 123: /* modify_ldt */
2791 case 166: /* vm86 */
2792 return gdb_sys_no_syscall;
2794 return gdb_sys_lookup_dcookie;
2795 /* Here come the differences. */
2797 return gdb_sys_readahead;
2799 if (abi == ABI_LINUX_S390)
2800 return gdb_sys_sendfile64;
2801 return gdb_sys_no_syscall;
2802 /* 224-235 handled below */
2804 return gdb_sys_gettid;
2806 return gdb_sys_tkill;
2808 return gdb_sys_futex;
2810 return gdb_sys_sched_setaffinity;
2812 return gdb_sys_sched_getaffinity;
2814 return gdb_sys_tgkill;
2817 return gdb_sys_io_setup;
2819 return gdb_sys_io_destroy;
2821 return gdb_sys_io_getevents;
2823 return gdb_sys_io_submit;
2825 return gdb_sys_io_cancel;
2827 return gdb_sys_exit_group;
2829 return gdb_sys_epoll_create;
2831 return gdb_sys_epoll_ctl;
2833 return gdb_sys_epoll_wait;
2835 return gdb_sys_set_tid_address;
2837 return gdb_sys_fadvise64;
2838 /* 254-262 handled below */
2841 if (abi == ABI_LINUX_S390)
2842 return gdb_sys_fadvise64_64;
2843 return gdb_sys_no_syscall;
2845 return gdb_sys_statfs64;
2847 return gdb_sys_fstatfs64;
2849 return gdb_sys_remap_file_pages;
2850 /* 268-270 reserved */
2851 /* 271-277 handled below */
2853 return gdb_sys_add_key;
2855 return gdb_sys_request_key;
2857 return gdb_sys_keyctl;
2859 return gdb_sys_waitid;
2860 /* 282-312 handled below */
2862 if (abi == ABI_LINUX_S390)
2863 return gdb_sys_fstatat64;
2864 return gdb_sys_newfstatat;
2865 /* 313+ not yet supported */
2870 /* Most "old" syscalls copied from i386. */
2873 /* xattr syscalls. */
2874 else if (syscall >= 224 && syscall <= 235)
2876 /* timer syscalls. */
2877 else if (syscall >= 254 && syscall <= 262)
2879 /* mq_* and kexec_load */
2880 else if (syscall >= 271 && syscall <= 277)
2882 /* ioprio_set .. epoll_pwait */
2883 else if (syscall >= 282 && syscall <= 312)
2886 ret = gdb_sys_no_syscall;
2888 return (enum gdb_syscall) ret;
2894 s390_linux_syscall_record (struct regcache *regcache, LONGEST syscall_native)
2896 struct gdbarch *gdbarch = get_regcache_arch (regcache);
2897 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
2899 enum gdb_syscall syscall_gdb;
2901 /* On s390, syscall number can be passed either as immediate field of svc
2902 instruction, or in %r1 (with svc 0). */
2903 if (syscall_native == 0)
2904 regcache_raw_read_signed (regcache, S390_R1_REGNUM, &syscall_native);
2906 syscall_gdb = s390_canonicalize_syscall (syscall_native, tdep->abi);
2908 if (syscall_gdb < 0)
2910 printf_unfiltered (_("Process record and replay target doesn't "
2911 "support syscall number %s\n"),
2912 plongest (syscall_native));
2916 if (syscall_gdb == gdb_sys_sigreturn
2917 || syscall_gdb == gdb_sys_rt_sigreturn)
2919 if (s390_all_but_pc_registers_record (regcache))
2924 if (tdep->abi == ABI_LINUX_ZSERIES)
2925 ret = record_linux_system_call (syscall_gdb, regcache,
2926 &s390x_linux_record_tdep);
2928 ret = record_linux_system_call (syscall_gdb, regcache,
2929 &s390_linux_record_tdep);
2934 /* Record the return value of the system call. */
2935 if (record_full_arch_list_add_reg (regcache, S390_R2_REGNUM))
2942 s390_linux_record_signal (struct gdbarch *gdbarch, struct regcache *regcache,
2943 enum gdb_signal signal)
2945 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
2946 /* There are two kinds of signal frames on s390. rt_sigframe is always
2947 the larger one, so don't even bother with sigframe. */
2948 const int sizeof_rt_sigframe = (tdep->abi == ABI_LINUX_ZSERIES ?
2949 160 + 8 + 128 + 1024 : 96 + 8 + 128 + 1000);
2953 for (i = 0; i < 16; i++)
2955 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + i))
2957 if (tdep->gpr_full_regnum != -1)
2958 if (record_full_arch_list_add_reg (regcache, S390_R0_UPPER_REGNUM + i))
2961 if (record_full_arch_list_add_reg (regcache, S390_PSWA_REGNUM))
2963 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
2966 /* Record the change in the stack.
2967 frame-size = sizeof (struct rt_sigframe) + SIGNAL_FRAMESIZE */
2968 regcache_raw_read_unsigned (regcache, S390_SP_REGNUM, &sp);
2969 sp -= sizeof_rt_sigframe;
2971 if (record_full_arch_list_add_mem (sp, sizeof_rt_sigframe))
2974 if (record_full_arch_list_add_end ())
2980 /* Frame base handling. */
2983 s390_frame_base_address (struct frame_info *this_frame, void **this_cache)
2985 struct s390_unwind_cache *info
2986 = s390_frame_unwind_cache (this_frame, this_cache);
2987 return info->frame_base;
2991 s390_local_base_address (struct frame_info *this_frame, void **this_cache)
2993 struct s390_unwind_cache *info
2994 = s390_frame_unwind_cache (this_frame, this_cache);
2995 return info->local_base;
2998 static const struct frame_base s390_frame_base = {
3000 s390_frame_base_address,
3001 s390_local_base_address,
3002 s390_local_base_address
3006 s390_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
3008 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
3010 pc = frame_unwind_register_unsigned (next_frame, tdep->pc_regnum);
3011 return gdbarch_addr_bits_remove (gdbarch, pc);
3015 s390_unwind_sp (struct gdbarch *gdbarch, struct frame_info *next_frame)
3018 sp = frame_unwind_register_unsigned (next_frame, S390_SP_REGNUM);
3019 return gdbarch_addr_bits_remove (gdbarch, sp);
3023 /* DWARF-2 frame support. */
3025 static struct value *
3026 s390_dwarf2_prev_register (struct frame_info *this_frame, void **this_cache,
3029 return s390_unwind_pseudo_register (this_frame, regnum);
3033 s390_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
3034 struct dwarf2_frame_state_reg *reg,
3035 struct frame_info *this_frame)
3037 /* The condition code (and thus PSW mask) is call-clobbered. */
3038 if (regnum == S390_PSWM_REGNUM)
3039 reg->how = DWARF2_FRAME_REG_UNDEFINED;
3041 /* The PSW address unwinds to the return address. */
3042 else if (regnum == S390_PSWA_REGNUM)
3043 reg->how = DWARF2_FRAME_REG_RA;
3045 /* Fixed registers are call-saved or call-clobbered
3046 depending on the ABI in use. */
3047 else if (regnum < S390_NUM_REGS)
3049 if (s390_register_call_saved (gdbarch, regnum))
3050 reg->how = DWARF2_FRAME_REG_SAME_VALUE;
3052 reg->how = DWARF2_FRAME_REG_UNDEFINED;
3055 /* We install a special function to unwind pseudos. */
3058 reg->how = DWARF2_FRAME_REG_FN;
3059 reg->loc.fn = s390_dwarf2_prev_register;
3064 /* Dummy function calls. */
3066 /* Unwrap any single-field structs in TYPE and return the effective
3067 "inner" type. E.g., yield "float" for all these cases:
3071 struct { struct { float x; } x; };
3072 struct { struct { struct { float x; } x; } x; };
3074 However, if an inner type is smaller than MIN_SIZE, abort the
3077 static struct type *
3078 s390_effective_inner_type (struct type *type, unsigned int min_size)
3080 while (TYPE_CODE (type) == TYPE_CODE_STRUCT
3081 && TYPE_NFIELDS (type) == 1)
3083 struct type *inner = check_typedef (TYPE_FIELD_TYPE (type, 0));
3085 if (TYPE_LENGTH (inner) < min_size)
3093 /* Return non-zero if TYPE should be passed like "float" or
3097 s390_function_arg_float (struct type *type)
3099 /* Note that long double as well as complex types are intentionally
3101 if (TYPE_LENGTH (type) > 8)
3104 /* A struct containing just a float or double is passed like a float
3106 type = s390_effective_inner_type (type, 0);
3108 return (TYPE_CODE (type) == TYPE_CODE_FLT
3109 || TYPE_CODE (type) == TYPE_CODE_DECFLOAT);
3112 /* Return non-zero if TYPE should be passed like a vector. */
3115 s390_function_arg_vector (struct type *type)
3117 if (TYPE_LENGTH (type) > 16)
3120 /* Structs containing just a vector are passed like a vector. */
3121 type = s390_effective_inner_type (type, TYPE_LENGTH (type));
3123 return TYPE_CODE (type) == TYPE_CODE_ARRAY && TYPE_VECTOR (type);
3126 /* Determine whether N is a power of two. */
3129 is_power_of_two (unsigned int n)
3131 return n && ((n & (n - 1)) == 0);
3134 /* For an argument whose type is TYPE and which is not passed like a
3135 float or vector, return non-zero if it should be passed like "int"
3139 s390_function_arg_integer (struct type *type)
3141 enum type_code code = TYPE_CODE (type);
3143 if (TYPE_LENGTH (type) > 8)
3146 if (code == TYPE_CODE_INT
3147 || code == TYPE_CODE_ENUM
3148 || code == TYPE_CODE_RANGE
3149 || code == TYPE_CODE_CHAR
3150 || code == TYPE_CODE_BOOL
3151 || code == TYPE_CODE_PTR
3152 || code == TYPE_CODE_REF)
3155 return ((code == TYPE_CODE_UNION || code == TYPE_CODE_STRUCT)
3156 && is_power_of_two (TYPE_LENGTH (type)));
3159 /* Argument passing state: Internal data structure passed to helper
3160 routines of s390_push_dummy_call. */
3162 struct s390_arg_state
3164 /* Register cache, or NULL, if we are in "preparation mode". */
3165 struct regcache *regcache;
3166 /* Next available general/floating-point/vector register for
3167 argument passing. */
3169 /* Current pointer to copy area (grows downwards). */
3171 /* Current pointer to parameter area (grows upwards). */
3175 /* Prepare one argument ARG for a dummy call and update the argument
3176 passing state AS accordingly. If the regcache field in AS is set,
3177 operate in "write mode" and write ARG into the inferior. Otherwise
3178 run "preparation mode" and skip all updates to the inferior. */
3181 s390_handle_arg (struct s390_arg_state *as, struct value *arg,
3182 struct gdbarch_tdep *tdep, int word_size,
3183 enum bfd_endian byte_order, int is_unnamed)
3185 struct type *type = check_typedef (value_type (arg));
3186 unsigned int length = TYPE_LENGTH (type);
3187 int write_mode = as->regcache != NULL;
3189 if (s390_function_arg_float (type))
3191 /* The GNU/Linux for S/390 ABI uses FPRs 0 and 2 to pass
3192 arguments. The GNU/Linux for zSeries ABI uses 0, 2, 4, and
3194 if (as->fr <= (tdep->abi == ABI_LINUX_S390 ? 2 : 6))
3196 /* When we store a single-precision value in an FP register,
3197 it occupies the leftmost bits. */
3199 regcache_cooked_write_part (as->regcache,
3200 S390_F0_REGNUM + as->fr,
3202 value_contents (arg));
3207 /* When we store a single-precision value in a stack slot,
3208 it occupies the rightmost bits. */
3209 as->argp = align_up (as->argp + length, word_size);
3211 write_memory (as->argp - length, value_contents (arg),
3215 else if (tdep->vector_abi == S390_VECTOR_ABI_128
3216 && s390_function_arg_vector (type))
3218 static const char use_vr[] = {24, 26, 28, 30, 25, 27, 29, 31};
3220 if (!is_unnamed && as->vr < ARRAY_SIZE (use_vr))
3222 int regnum = S390_V24_REGNUM + use_vr[as->vr] - 24;
3225 regcache_cooked_write_part (as->regcache, regnum,
3227 value_contents (arg));
3233 write_memory (as->argp, value_contents (arg), length);
3234 as->argp = align_up (as->argp + length, word_size);
3237 else if (s390_function_arg_integer (type) && length <= word_size)
3239 /* Initialize it just to avoid a GCC false warning. */
3244 /* Place value in least significant bits of the register or
3245 memory word and sign- or zero-extend to full word size.
3246 This also applies to a struct or union. */
3247 val = TYPE_UNSIGNED (type)
3248 ? extract_unsigned_integer (value_contents (arg),
3250 : extract_signed_integer (value_contents (arg),
3251 length, byte_order);
3257 regcache_cooked_write_unsigned (as->regcache,
3258 S390_R0_REGNUM + as->gr,
3265 write_memory_unsigned_integer (as->argp, word_size,
3267 as->argp += word_size;
3270 else if (s390_function_arg_integer (type) && length == 8)
3276 regcache_cooked_write (as->regcache,
3277 S390_R0_REGNUM + as->gr,
3278 value_contents (arg));
3279 regcache_cooked_write (as->regcache,
3280 S390_R0_REGNUM + as->gr + 1,
3281 value_contents (arg) + word_size);
3287 /* If we skipped r6 because we couldn't fit a DOUBLE_ARG
3288 in it, then don't go back and use it again later. */
3292 write_memory (as->argp, value_contents (arg), length);
3298 /* This argument type is never passed in registers. Place the
3299 value in the copy area and pass a pointer to it. Use 8-byte
3300 alignment as a conservative assumption. */
3301 as->copy = align_down (as->copy - length, 8);
3303 write_memory (as->copy, value_contents (arg), length);
3308 regcache_cooked_write_unsigned (as->regcache,
3309 S390_R0_REGNUM + as->gr,
3316 write_memory_unsigned_integer (as->argp, word_size,
3317 byte_order, as->copy);
3318 as->argp += word_size;
3323 /* Put the actual parameter values pointed to by ARGS[0..NARGS-1] in
3324 place to be passed to a function, as specified by the "GNU/Linux
3325 for S/390 ELF Application Binary Interface Supplement".
3327 SP is the current stack pointer. We must put arguments, links,
3328 padding, etc. whereever they belong, and return the new stack
3331 If STRUCT_RETURN is non-zero, then the function we're calling is
3332 going to return a structure by value; STRUCT_ADDR is the address of
3333 a block we've allocated for it on the stack.
3335 Our caller has taken care of any type promotions needed to satisfy
3336 prototypes or the old K&R argument-passing rules. */
3339 s390_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
3340 struct regcache *regcache, CORE_ADDR bp_addr,
3341 int nargs, struct value **args, CORE_ADDR sp,
3342 int struct_return, CORE_ADDR struct_addr)
3344 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
3345 int word_size = gdbarch_ptr_bit (gdbarch) / 8;
3346 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
3348 struct s390_arg_state arg_state, arg_prep;
3349 CORE_ADDR param_area_start, new_sp;
3350 struct type *ftype = check_typedef (value_type (function));
3352 if (TYPE_CODE (ftype) == TYPE_CODE_PTR)
3353 ftype = check_typedef (TYPE_TARGET_TYPE (ftype));
3356 arg_prep.gr = struct_return ? 3 : 2;
3360 arg_prep.regcache = NULL;
3362 /* Initialize arg_state for "preparation mode". */
3363 arg_state = arg_prep;
3365 /* Update arg_state.copy with the start of the reference-to-copy area
3366 and arg_state.argp with the size of the parameter area. */
3367 for (i = 0; i < nargs; i++)
3368 s390_handle_arg (&arg_state, args[i], tdep, word_size, byte_order,
3369 TYPE_VARARGS (ftype) && i >= TYPE_NFIELDS (ftype));
3371 param_area_start = align_down (arg_state.copy - arg_state.argp, 8);
3373 /* Allocate the standard frame areas: the register save area, the
3374 word reserved for the compiler, and the back chain pointer. */
3375 new_sp = param_area_start - (16 * word_size + 32);
3377 /* Now we have the final stack pointer. Make sure we didn't
3378 underflow; on 31-bit, this would result in addresses with the
3379 high bit set, which causes confusion elsewhere. Note that if we
3380 error out here, stack and registers remain untouched. */
3381 if (gdbarch_addr_bits_remove (gdbarch, new_sp) != new_sp)
3382 error (_("Stack overflow"));
3384 /* Pass the structure return address in general register 2. */
3386 regcache_cooked_write_unsigned (regcache, S390_R2_REGNUM, struct_addr);
3388 /* Initialize arg_state for "write mode". */
3389 arg_state = arg_prep;
3390 arg_state.argp = param_area_start;
3391 arg_state.regcache = regcache;
3393 /* Write all parameters. */
3394 for (i = 0; i < nargs; i++)
3395 s390_handle_arg (&arg_state, args[i], tdep, word_size, byte_order,
3396 TYPE_VARARGS (ftype) && i >= TYPE_NFIELDS (ftype));
3398 /* Store return PSWA. In 31-bit mode, keep addressing mode bit. */
3402 regcache_cooked_read_unsigned (regcache, S390_PSWA_REGNUM, &pswa);
3403 bp_addr = (bp_addr & 0x7fffffff) | (pswa & 0x80000000);
3405 regcache_cooked_write_unsigned (regcache, S390_RETADDR_REGNUM, bp_addr);
3407 /* Store updated stack pointer. */
3408 regcache_cooked_write_unsigned (regcache, S390_SP_REGNUM, new_sp);
3410 /* We need to return the 'stack part' of the frame ID,
3411 which is actually the top of the register save area. */
3412 return param_area_start;
3415 /* Assuming THIS_FRAME is a dummy, return the frame ID of that
3416 dummy frame. The frame ID's base needs to match the TOS value
3417 returned by push_dummy_call, and the PC match the dummy frame's
3419 static struct frame_id
3420 s390_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame)
3422 int word_size = gdbarch_ptr_bit (gdbarch) / 8;
3423 CORE_ADDR sp = get_frame_register_unsigned (this_frame, S390_SP_REGNUM);
3424 sp = gdbarch_addr_bits_remove (gdbarch, sp);
3426 return frame_id_build (sp + 16*word_size + 32,
3427 get_frame_pc (this_frame));
3431 s390_frame_align (struct gdbarch *gdbarch, CORE_ADDR addr)
3433 /* Both the 32- and 64-bit ABI's say that the stack pointer should
3434 always be aligned on an eight-byte boundary. */
3439 /* Helper for s390_return_value: Set or retrieve a function return
3440 value if it resides in a register. */
3443 s390_register_return_value (struct gdbarch *gdbarch, struct type *type,
3444 struct regcache *regcache,
3445 gdb_byte *out, const gdb_byte *in)
3447 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
3448 int word_size = gdbarch_ptr_bit (gdbarch) / 8;
3449 int length = TYPE_LENGTH (type);
3450 int code = TYPE_CODE (type);
3452 if (code == TYPE_CODE_FLT || code == TYPE_CODE_DECFLOAT)
3454 /* Float-like value: left-aligned in f0. */
3456 regcache_cooked_write_part (regcache, S390_F0_REGNUM,
3459 regcache_cooked_read_part (regcache, S390_F0_REGNUM,
3462 else if (code == TYPE_CODE_ARRAY)
3464 /* Vector: left-aligned in v24. */
3466 regcache_cooked_write_part (regcache, S390_V24_REGNUM,
3469 regcache_cooked_read_part (regcache, S390_V24_REGNUM,
3472 else if (length <= word_size)
3474 /* Integer: zero- or sign-extended in r2. */
3476 regcache_cooked_read_part (regcache, S390_R2_REGNUM,
3477 word_size - length, length, out);
3478 else if (TYPE_UNSIGNED (type))
3479 regcache_cooked_write_unsigned
3480 (regcache, S390_R2_REGNUM,
3481 extract_unsigned_integer (in, length, byte_order));
3483 regcache_cooked_write_signed
3484 (regcache, S390_R2_REGNUM,
3485 extract_signed_integer (in, length, byte_order));
3487 else if (length == 2 * word_size)
3489 /* Double word: in r2 and r3. */
3492 regcache_cooked_write (regcache, S390_R2_REGNUM, in);
3493 regcache_cooked_write (regcache, S390_R3_REGNUM,
3498 regcache_cooked_read (regcache, S390_R2_REGNUM, out);
3499 regcache_cooked_read (regcache, S390_R3_REGNUM,
3504 internal_error (__FILE__, __LINE__, _("invalid return type"));
3508 /* Implement the 'return_value' gdbarch method. */
3510 static enum return_value_convention
3511 s390_return_value (struct gdbarch *gdbarch, struct value *function,
3512 struct type *type, struct regcache *regcache,
3513 gdb_byte *out, const gdb_byte *in)
3515 enum return_value_convention rvc;
3517 type = check_typedef (type);
3519 switch (TYPE_CODE (type))
3521 case TYPE_CODE_STRUCT:
3522 case TYPE_CODE_UNION:
3523 case TYPE_CODE_COMPLEX:
3524 rvc = RETURN_VALUE_STRUCT_CONVENTION;
3526 case TYPE_CODE_ARRAY:
3527 rvc = (gdbarch_tdep (gdbarch)->vector_abi == S390_VECTOR_ABI_128
3528 && TYPE_LENGTH (type) <= 16 && TYPE_VECTOR (type))
3529 ? RETURN_VALUE_REGISTER_CONVENTION
3530 : RETURN_VALUE_STRUCT_CONVENTION;
3533 rvc = TYPE_LENGTH (type) <= 8
3534 ? RETURN_VALUE_REGISTER_CONVENTION
3535 : RETURN_VALUE_STRUCT_CONVENTION;
3538 if (in != NULL || out != NULL)
3540 if (rvc == RETURN_VALUE_REGISTER_CONVENTION)
3541 s390_register_return_value (gdbarch, type, regcache, out, in);
3542 else if (in != NULL)
3543 error (_("Cannot set function return value."));
3545 error (_("Function return value unknown."));
3553 constexpr gdb_byte s390_break_insn[] = { 0x0, 0x1 };
3555 typedef BP_MANIPULATION (s390_break_insn) s390_breakpoint;
3557 /* Address handling. */
3560 s390_addr_bits_remove (struct gdbarch *gdbarch, CORE_ADDR addr)
3562 return addr & 0x7fffffff;
3566 s390_address_class_type_flags (int byte_size, int dwarf2_addr_class)
3569 return TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1;
3575 s390_address_class_type_flags_to_name (struct gdbarch *gdbarch, int type_flags)
3577 if (type_flags & TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1)
3584 s390_address_class_name_to_type_flags (struct gdbarch *gdbarch,
3586 int *type_flags_ptr)
3588 if (strcmp (name, "mode32") == 0)
3590 *type_flags_ptr = TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1;
3597 /* Implement gdbarch_gcc_target_options. GCC does not know "-m32" or
3598 "-mcmodel=large". */
3601 s390_gcc_target_options (struct gdbarch *gdbarch)
3603 return xstrdup (gdbarch_ptr_bit (gdbarch) == 64 ? "-m64" : "-m31");
3606 /* Implement gdbarch_gnu_triplet_regexp. Target triplets are "s390-*"
3607 for 31-bit and "s390x-*" for 64-bit, while the BFD arch name is
3608 always "s390". Note that an s390x compiler supports "-m31" as
3612 s390_gnu_triplet_regexp (struct gdbarch *gdbarch)
3617 /* Implementation of `gdbarch_stap_is_single_operand', as defined in
3621 s390_stap_is_single_operand (struct gdbarch *gdbarch, const char *s)
3623 return ((isdigit (*s) && s[1] == '(' && s[2] == '%') /* Displacement
3625 || *s == '%' /* Register access. */
3626 || isdigit (*s)); /* Literal number. */
3629 /* Process record and replay helpers. */
3631 /* Takes the intermediate sum of address calculations and masks off upper
3632 bits according to current addressing mode. */
3635 s390_record_address_mask (struct gdbarch *gdbarch, struct regcache *regcache,
3637 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
3638 ULONGEST pswm, pswa;
3640 if (tdep->abi == ABI_LINUX_S390)
3642 regcache_raw_read_unsigned (regcache, S390_PSWA_REGNUM, &pswa);
3643 am = pswa >> 31 & 1;
3647 regcache_raw_read_unsigned (regcache, S390_PSWM_REGNUM, &pswm);
3648 am = pswm >> 31 & 3;
3653 return val & 0xffffff;
3655 return val & 0x7fffffff;
3659 fprintf_unfiltered (gdb_stdlog, "Warning: Addressing mode %d used.", am);
3664 /* Calculates memory address using pre-calculated index, raw instruction word
3665 with b and d/dl fields, and raw instruction byte with dh field. Index and
3666 dh should be set to 0 if unused. */
3669 s390_record_calc_disp_common (struct gdbarch *gdbarch, struct regcache *regcache,
3670 ULONGEST x, uint16_t bd, int8_t dh)
3672 uint8_t rb = bd >> 12 & 0xf;
3673 int32_t d = (bd & 0xfff) | ((int32_t)dh << 12);
3675 CORE_ADDR res = d + x;
3678 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + rb, &b);
3681 return s390_record_address_mask (gdbarch, regcache, res);
3684 /* Calculates memory address using raw x, b + d/dl, dh fields from
3685 instruction. rx and dh should be set to 0 if unused. */
3688 s390_record_calc_disp (struct gdbarch *gdbarch, struct regcache *regcache,
3689 uint8_t rx, uint16_t bd, int8_t dh)
3693 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + rx, &x);
3694 return s390_record_calc_disp_common (gdbarch, regcache, x, bd, dh);
3697 /* Calculates memory address for VSCE[GF] instructions. */
3700 s390_record_calc_disp_vsce (struct gdbarch *gdbarch, struct regcache *regcache,
3701 uint8_t vx, uint8_t el, uint8_t es, uint16_t bd,
3702 int8_t dh, CORE_ADDR *res)
3704 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
3705 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
3708 if (tdep->v0_full_regnum == -1 || el * es >= 16)
3711 regcache_cooked_read (regcache, tdep->v0_full_regnum + vx, buf);
3713 regcache_raw_read (regcache, S390_V16_REGNUM + vx - 16, buf);
3714 x = extract_unsigned_integer (buf + el * es, es, byte_order);
3715 *res = s390_record_calc_disp_common (gdbarch, regcache, x, bd, dh);
3719 /* Calculates memory address for instructions with relative long addressing. */
3722 s390_record_calc_rl (struct gdbarch *gdbarch, struct regcache *regcache,
3723 CORE_ADDR addr, uint16_t i1, uint16_t i2)
3725 int32_t ri = i1 << 16 | i2;
3726 return s390_record_address_mask (gdbarch, regcache, addr + (LONGEST)ri * 2);
3729 /* Population count helper. */
3731 static int s390_popcnt (unsigned int x) {
3742 /* Record 64-bit register. */
3745 s390_record_gpr_g (struct gdbarch *gdbarch, struct regcache *regcache, int i)
3747 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
3748 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + i))
3750 if (tdep->abi == ABI_LINUX_S390)
3751 if (record_full_arch_list_add_reg (regcache, S390_R0_UPPER_REGNUM + i))
3756 /* Record high 32 bits of a register. */
3759 s390_record_gpr_h (struct gdbarch *gdbarch, struct regcache *regcache, int i)
3761 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
3762 if (tdep->abi == ABI_LINUX_S390)
3764 if (record_full_arch_list_add_reg (regcache, S390_R0_UPPER_REGNUM + i))
3769 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + i))
3775 /* Record vector register. */
3778 s390_record_vr (struct gdbarch *gdbarch, struct regcache *regcache, int i)
3782 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + i))
3784 if (record_full_arch_list_add_reg (regcache, S390_V0_LOWER_REGNUM + i))
3789 if (record_full_arch_list_add_reg (regcache, S390_V16_REGNUM + i - 16))
3796 s390_process_record (struct gdbarch *gdbarch, struct regcache *regcache,
3799 uint16_t insn[3] = {0};
3800 /* Instruction as bytes. */
3802 /* Instruction as nibbles. */
3804 /* Instruction vector registers. */
3806 CORE_ADDR oaddr, oaddr2, oaddr3;
3809 /* if EX/EXRL instruction used, here's the reg parameter */
3811 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
3813 /* Attempting to use EX or EXRL jumps back here */
3816 /* Read instruction. */
3817 insn[0] = read_memory_unsigned_integer (addr, 2, byte_order);
3818 /* If execute was involved, do the adjustment. */
3820 insn[0] |= ex & 0xff;
3821 /* Two highest bits determine instruction size. */
3822 if (insn[0] >= 0x4000)
3823 insn[1] = read_memory_unsigned_integer (addr+2, 2, byte_order);
3825 /* Not necessary, but avoids uninitialized variable warnings. */
3827 if (insn[0] >= 0xc000)
3828 insn[2] = read_memory_unsigned_integer (addr+4, 2, byte_order);
3831 /* Split instruction into bytes and nibbles. */
3832 for (i = 0; i < 3; i++)
3834 ibyte[i*2] = insn[i] >> 8 & 0xff;
3835 ibyte[i*2+1] = insn[i] & 0xff;
3837 for (i = 0; i < 6; i++)
3839 inib[i*2] = ibyte[i] >> 4 & 0xf;
3840 inib[i*2+1] = ibyte[i] & 0xf;
3842 /* Compute vector registers, if applicable. */
3843 ivec[0] = (inib[9] >> 3 & 1) << 4 | inib[2];
3844 ivec[1] = (inib[9] >> 2 & 1) << 4 | inib[3];
3845 ivec[2] = (inib[9] >> 1 & 1) << 4 | inib[4];
3846 ivec[3] = (inib[9] >> 0 & 1) << 4 | inib[8];
3850 /* 0x00 undefined */
3853 /* E-format instruction */
3856 /* 0x00 undefined */
3857 /* 0x01 unsupported: PR - program return */
3858 /* 0x02 unsupported: UPT */
3859 /* 0x03 undefined */
3860 /* 0x04 privileged: PTFF - perform timing facility function */
3861 /* 0x05-0x06 undefined */
3862 /* 0x07 privileged: SCKPF - set clock programmable field */
3863 /* 0x08-0x09 undefined */
3865 case 0x0a: /* PFPO - perform floating point operation */
3866 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM, &tmp);
3867 if (!(tmp & 0x80000000u))
3869 uint8_t ofc = tmp >> 16 & 0xff;
3872 case 0x00: /* HFP32 */
3873 case 0x01: /* HFP64 */
3874 case 0x05: /* BFP32 */
3875 case 0x06: /* BFP64 */
3876 case 0x08: /* DFP32 */
3877 case 0x09: /* DFP64 */
3878 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM))
3881 case 0x02: /* HFP128 */
3882 case 0x07: /* BFP128 */
3883 case 0x0a: /* DFP128 */
3884 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM))
3886 if (record_full_arch_list_add_reg (regcache, S390_F2_REGNUM))
3890 fprintf_unfiltered (gdb_stdlog, "Warning: Unknown PFPO OFC %02x at %s.\n",
3891 ofc, paddress (gdbarch, addr));
3895 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
3898 if (record_full_arch_list_add_reg (regcache, S390_R1_REGNUM))
3900 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
3904 case 0x0b: /* TAM - test address mode */
3905 case 0x0c: /* SAM24 - set address mode 24 */
3906 case 0x0d: /* SAM31 - set address mode 31 */
3907 case 0x0e: /* SAM64 - set address mode 64 */
3908 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
3912 /* 0x0f-0xfe undefined */
3914 /* 0xff unsupported: TRAP */
3921 /* 0x02 undefined */
3922 /* 0x03 undefined */
3924 case 0x04: /* SPM - set program mask */
3925 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
3929 case 0x05: /* BALR - branch and link */
3930 case 0x45: /* BAL - branch and link */
3931 case 0x06: /* BCTR - branch on count */
3932 case 0x46: /* BCT - branch on count */
3933 case 0x0d: /* BASR - branch and save */
3934 case 0x4d: /* BAS - branch and save */
3935 case 0x84: /* BRXH - branch relative on index high */
3936 case 0x85: /* BRXLE - branch relative on index low or equal */
3937 case 0x86: /* BXH - branch on index high */
3938 case 0x87: /* BXLE - branch on index low or equal */
3939 /* BA[SL]* use native-size destination for linkage info, BCT*, BRX*, BX*
3940 use 32-bit destination as counter. */
3941 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
3945 case 0x07: /* BCR - branch on condition */
3946 case 0x47: /* BC - branch on condition */
3947 /* No effect other than PC transfer. */
3950 /* 0x08 undefined */
3951 /* 0x09 undefined */
3954 /* SVC - supervisor call */
3955 if (s390_linux_syscall_record (regcache, ibyte[1]))
3959 case 0x0b: /* BSM - branch and set mode */
3961 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
3963 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
3967 case 0x0c: /* BASSM - branch and save and set mode */
3968 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
3970 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
3974 case 0x0e: /* MVCL - move long [interruptible] */
3975 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[2], &tmp);
3976 oaddr = s390_record_address_mask (gdbarch, regcache, tmp);
3977 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + (inib[2] | 1), &tmp);
3979 if (record_full_arch_list_add_mem (oaddr, tmp))
3981 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
3983 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[2] | 1)))
3985 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[3]))
3987 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[3] | 1)))
3989 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
3993 case 0x0f: /* CLCL - compare logical long [interruptible] */
3994 case 0xa9: /* CLCLE - compare logical long extended [partial] */
3995 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
3997 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[2] | 1)))
3999 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[3]))
4001 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[3] | 1)))
4003 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4007 case 0x10: /* LPR - load positive */
4008 case 0x11: /* LNR - load negative */
4009 case 0x12: /* LTR - load and test */
4010 case 0x13: /* LCR - load complement */
4011 case 0x14: /* NR - and */
4012 case 0x16: /* OR - or */
4013 case 0x17: /* XR - xor */
4014 case 0x1a: /* AR - add */
4015 case 0x1b: /* SR - subtract */
4016 case 0x1e: /* ALR - add logical */
4017 case 0x1f: /* SLR - subtract logical */
4018 case 0x54: /* N - and */
4019 case 0x56: /* O - or */
4020 case 0x57: /* X - xor */
4021 case 0x5a: /* A - add */
4022 case 0x5b: /* S - subtract */
4023 case 0x5e: /* AL - add logical */
4024 case 0x5f: /* SL - subtract logical */
4025 case 0x4a: /* AH - add halfword */
4026 case 0x4b: /* SH - subtract halfword */
4027 case 0x8a: /* SRA - shift right single */
4028 case 0x8b: /* SLA - shift left single */
4029 case 0xbf: /* ICM - insert characters under mask */
4030 /* 32-bit destination + flags */
4031 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
4033 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4037 case 0x15: /* CLR - compare logical */
4038 case 0x55: /* CL - compare logical */
4039 case 0x19: /* CR - compare */
4040 case 0x29: /* CDR - compare */
4041 case 0x39: /* CER - compare */
4042 case 0x49: /* CH - compare halfword */
4043 case 0x59: /* C - compare */
4044 case 0x69: /* CD - compare */
4045 case 0x79: /* CE - compare */
4046 case 0x91: /* TM - test under mask */
4047 case 0x95: /* CLI - compare logical */
4048 case 0xbd: /* CLM - compare logical under mask */
4049 case 0xd5: /* CLC - compare logical */
4050 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4054 case 0x18: /* LR - load */
4055 case 0x48: /* LH - load halfword */
4056 case 0x58: /* L - load */
4057 case 0x41: /* LA - load address */
4058 case 0x43: /* IC - insert character */
4059 case 0x4c: /* MH - multiply halfword */
4060 case 0x71: /* MS - multiply single */
4061 case 0x88: /* SRL - shift right single logical */
4062 case 0x89: /* SLL - shift left single logical */
4063 /* 32-bit, 8-bit (IC), or native width (LA) destination, no flags */
4064 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
4068 case 0x1c: /* MR - multiply */
4069 case 0x5c: /* M - multiply */
4070 case 0x1d: /* DR - divide */
4071 case 0x5d: /* D - divide */
4072 case 0x8c: /* SRDL - shift right double logical */
4073 case 0x8d: /* SLDL - shift left double logical */
4074 /* 32-bit pair destination, no flags */
4075 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
4077 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[2] | 1)))
4081 case 0x20: /* LPDR - load positive */
4082 case 0x30: /* LPER - load positive */
4083 case 0x21: /* LNDR - load negative */
4084 case 0x31: /* LNER - load negative */
4085 case 0x22: /* LTDR - load and test */
4086 case 0x32: /* LTER - load and test */
4087 case 0x23: /* LCDR - load complement */
4088 case 0x33: /* LCER - load complement */
4089 case 0x2a: /* ADR - add */
4090 case 0x3a: /* AER - add */
4091 case 0x6a: /* AD - add */
4092 case 0x7a: /* AE - add */
4093 case 0x2b: /* SDR - subtract */
4094 case 0x3b: /* SER - subtract */
4095 case 0x6b: /* SD - subtract */
4096 case 0x7b: /* SE - subtract */
4097 case 0x2e: /* AWR - add unnormalized */
4098 case 0x3e: /* AUR - add unnormalized */
4099 case 0x6e: /* AW - add unnormalized */
4100 case 0x7e: /* AU - add unnormalized */
4101 case 0x2f: /* SWR - subtract unnormalized */
4102 case 0x3f: /* SUR - subtract unnormalized */
4103 case 0x6f: /* SW - subtract unnormalized */
4104 case 0x7f: /* SU - subtract unnormalized */
4105 /* float destination + flags */
4106 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[2]))
4108 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4112 case 0x24: /* HDR - halve */
4113 case 0x34: /* HER - halve */
4114 case 0x25: /* LDXR - load rounded */
4115 case 0x35: /* LEDR - load rounded */
4116 case 0x28: /* LDR - load */
4117 case 0x38: /* LER - load */
4118 case 0x68: /* LD - load */
4119 case 0x78: /* LE - load */
4120 case 0x2c: /* MDR - multiply */
4121 case 0x3c: /* MDER - multiply */
4122 case 0x6c: /* MD - multiply */
4123 case 0x7c: /* MDE - multiply */
4124 case 0x2d: /* DDR - divide */
4125 case 0x3d: /* DER - divide */
4126 case 0x6d: /* DD - divide */
4127 case 0x7d: /* DE - divide */
4128 /* float destination, no flags */
4129 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[2]))
4133 case 0x26: /* MXR - multiply */
4134 case 0x27: /* MXDR - multiply */
4135 case 0x67: /* MXD - multiply */
4136 /* float pair destination, no flags */
4137 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[2]))
4139 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + (inib[2] | 2)))
4143 case 0x36: /* AXR - add */
4144 case 0x37: /* SXR - subtract */
4145 /* float pair destination + flags */
4146 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[2]))
4148 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + (inib[2] | 2)))
4150 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4154 case 0x40: /* STH - store halfword */
4155 oaddr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], 0);
4156 if (record_full_arch_list_add_mem (oaddr, 2))
4160 case 0x42: /* STC - store character */
4161 oaddr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], 0);
4162 if (record_full_arch_list_add_mem (oaddr, 1))
4166 case 0x44: /* EX - execute */
4169 fprintf_unfiltered (gdb_stdlog, "Warning: Double execute at %s.\n",
4170 paddress (gdbarch, addr));
4173 addr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], 0);
4176 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[2], &tmp);
4185 case 0x4e: /* CVD - convert to decimal */
4186 case 0x60: /* STD - store */
4187 oaddr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], 0);
4188 if (record_full_arch_list_add_mem (oaddr, 8))
4192 case 0x4f: /* CVB - convert to binary */
4193 /* 32-bit gpr destination + FPC (DXC write) */
4194 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
4196 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
4200 case 0x50: /* ST - store */
4201 case 0x70: /* STE - store */
4202 oaddr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], 0);
4203 if (record_full_arch_list_add_mem (oaddr, 4))
4207 case 0x51: /* LAE - load address extended */
4208 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
4210 if (record_full_arch_list_add_reg (regcache, S390_A0_REGNUM + inib[2]))
4214 /* 0x52 undefined */
4215 /* 0x53 undefined */
4217 /* 0x61-0x66 undefined */
4219 /* 0x72-0x77 undefined */
4221 /* 0x80 privileged: SSM - set system mask */
4222 /* 0x81 undefined */
4223 /* 0x82 privileged: LPSW - load PSW */
4224 /* 0x83 privileged: diagnose */
4226 case 0x8e: /* SRDA - shift right double */
4227 case 0x8f: /* SLDA - shift left double */
4228 /* 32-bit pair destination + flags */
4229 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
4231 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[2] | 1)))
4233 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4237 case 0x90: /* STM - store multiple */
4238 case 0x9b: /* STAM - store access multiple */
4239 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
4240 if (inib[2] <= inib[3])
4241 n = inib[3] - inib[2] + 1;
4243 n = inib[3] + 0x10 - inib[2] + 1;
4244 if (record_full_arch_list_add_mem (oaddr, n * 4))
4248 case 0x92: /* MVI - move */
4249 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
4250 if (record_full_arch_list_add_mem (oaddr, 1))
4254 case 0x93: /* TS - test and set */
4255 case 0x94: /* NI - and */
4256 case 0x96: /* OI - or */
4257 case 0x97: /* XI - xor */
4258 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
4259 if (record_full_arch_list_add_mem (oaddr, 1))
4261 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4265 case 0x98: /* LM - load multiple */
4266 for (i = inib[2]; i != inib[3]; i++, i &= 0xf)
4267 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + i))
4269 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[3]))
4273 /* 0x99 privileged: TRACE */
4275 case 0x9a: /* LAM - load access multiple */
4276 for (i = inib[2]; i != inib[3]; i++, i &= 0xf)
4277 if (record_full_arch_list_add_reg (regcache, S390_A0_REGNUM + i))
4279 if (record_full_arch_list_add_reg (regcache, S390_A0_REGNUM + inib[3]))
4283 /* 0x9c-0x9f privileged and obsolete (old I/O) */
4284 /* 0xa0-0xa4 undefined */
4288 /* RI-format instruction */
4289 switch (ibyte[0] << 4 | inib[3])
4291 case 0xa50: /* IIHH - insert immediate */
4292 case 0xa51: /* IIHL - insert immediate */
4293 /* high 32-bit destination */
4294 if (s390_record_gpr_h (gdbarch, regcache, inib[2]))
4298 case 0xa52: /* IILH - insert immediate */
4299 case 0xa53: /* IILL - insert immediate */
4300 case 0xa75: /* BRAS - branch relative and save */
4301 case 0xa76: /* BRCT - branch relative on count */
4302 case 0xa78: /* LHI - load halfword immediate */
4303 case 0xa7c: /* MHI - multiply halfword immediate */
4304 /* 32-bit or native destination */
4305 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
4309 case 0xa54: /* NIHH - and immediate */
4310 case 0xa55: /* NIHL - and immediate */
4311 case 0xa58: /* OIHH - or immediate */
4312 case 0xa59: /* OIHL - or immediate */
4313 /* high 32-bit destination + flags */
4314 if (s390_record_gpr_h (gdbarch, regcache, inib[2]))
4316 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4320 case 0xa56: /* NILH - and immediate */
4321 case 0xa57: /* NILL - and immediate */
4322 case 0xa5a: /* OILH - or immediate */
4323 case 0xa5b: /* OILL - or immediate */
4324 case 0xa7a: /* AHI - add halfword immediate */
4325 /* 32-bit destination + flags */
4326 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
4328 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4332 case 0xa5c: /* LLIHH - load logical immediate */
4333 case 0xa5d: /* LLIHL - load logical immediate */
4334 case 0xa5e: /* LLILH - load logical immediate */
4335 case 0xa5f: /* LLILL - load logical immediate */
4336 case 0xa77: /* BRCTG - branch relative on count */
4337 case 0xa79: /* LGHI - load halfword immediate */
4338 case 0xa7d: /* MGHI - multiply halfword immediate */
4339 /* 64-bit destination */
4340 if (s390_record_gpr_g (gdbarch, regcache, inib[2]))
4344 case 0xa70: /* TMLH - test under mask */
4345 case 0xa71: /* TMLL - test under mask */
4346 case 0xa72: /* TMHH - test under mask */
4347 case 0xa73: /* TMHL - test under mask */
4348 case 0xa7e: /* CHI - compare halfword immediate */
4349 case 0xa7f: /* CGHI - compare halfword immediate */
4351 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4355 case 0xa74: /* BRC - branch relative on condition */
4356 /* no register change */
4359 case 0xa7b: /* AGHI - add halfword immediate */
4360 /* 64-bit destination + flags */
4361 if (s390_record_gpr_g (gdbarch, regcache, inib[2]))
4363 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4372 /* 0xa6 undefined */
4374 case 0xa8: /* MVCLE - move long extended [partial] */
4375 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[2], &tmp);
4376 oaddr = s390_record_address_mask (gdbarch, regcache, tmp);
4377 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + (inib[2] | 1), &tmp);
4378 if (record_full_arch_list_add_mem (oaddr, tmp))
4380 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
4382 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[2] | 1)))
4384 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[3]))
4386 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[3] | 1)))
4388 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4392 /* 0xaa-0xab undefined */
4393 /* 0xac privileged: STNSM - store then and system mask */
4394 /* 0xad privileged: STOSM - store then or system mask */
4395 /* 0xae privileged: SIGP - signal processor */
4396 /* 0xaf unsupported: MC - monitor call */
4397 /* 0xb0 undefined */
4398 /* 0xb1 privileged: LRA - load real address */
4403 /* S/RRD/RRE/RRF/IE-format instruction */
4406 /* 0xb200-0xb204 undefined or privileged */
4408 case 0xb205: /* STCK - store clock */
4409 case 0xb27c: /* STCKF - store clock fast */
4410 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
4411 if (record_full_arch_list_add_mem (oaddr, 8))
4413 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4417 /* 0xb206-0xb219 undefined, privileged, or unsupported */
4418 /* 0xb21a unsupported: CFC */
4419 /* 0xb21b-0xb221 undefined or privileged */
4421 case 0xb222: /* IPM - insert program mask */
4422 case 0xb24f: /* EAR - extract access */
4423 case 0xb252: /* MSR - multiply single */
4424 case 0xb2ec: /* ETND - extract transaction nesting depth */
4425 case 0xb38c: /* EFPC - extract fpc */
4426 case 0xb91f: /* LRVR - load reversed */
4427 case 0xb926: /* LBR - load byte */
4428 case 0xb927: /* LHR - load halfword */
4429 case 0xb994: /* LLCR - load logical character */
4430 case 0xb995: /* LLHR - load logical halfword */
4431 case 0xb9f2: /* LOCR - load on condition */
4432 /* 32-bit gpr destination */
4433 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6]))
4437 /* 0xb223-0xb22c privileged or unsupported */
4439 case 0xb22d: /* DXR - divide */
4440 case 0xb325: /* LXDR - load lengthened */
4441 case 0xb326: /* LXER - load lengthened */
4442 case 0xb336: /* SQXR - square root */
4443 case 0xb365: /* LXR - load */
4444 case 0xb367: /* FIXR - load fp integer */
4445 case 0xb376: /* LZXR - load zero */
4446 case 0xb3b6: /* CXFR - convert from fixed */
4447 case 0xb3c6: /* CXGR - convert from fixed */
4448 case 0xb3fe: /* IEXTR - insert biased exponent */
4449 /* float pair destination */
4450 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[6]))
4452 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + (inib[6] | 2)))
4456 /* 0xb22e-0xb240 undefined, privileged, or unsupported */
4458 case 0xb241: /* CKSM - checksum [partial] */
4459 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6]))
4461 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[7]))
4463 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[7] | 1)))
4465 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4469 /* 0xb242-0xb243 undefined */
4471 case 0xb244: /* SQDR - square root */
4472 case 0xb245: /* SQER - square root */
4473 case 0xb324: /* LDER - load lengthened */
4474 case 0xb337: /* MEER - multiply */
4475 case 0xb366: /* LEXR - load rounded */
4476 case 0xb370: /* LPDFR - load positive */
4477 case 0xb371: /* LNDFR - load negative */
4478 case 0xb372: /* CSDFR - copy sign */
4479 case 0xb373: /* LCDFR - load complement */
4480 case 0xb374: /* LZER - load zero */
4481 case 0xb375: /* LZDR - load zero */
4482 case 0xb377: /* FIER - load fp integer */
4483 case 0xb37f: /* FIDR - load fp integer */
4484 case 0xb3b4: /* CEFR - convert from fixed */
4485 case 0xb3b5: /* CDFR - convert from fixed */
4486 case 0xb3c1: /* LDGR - load fpr from gr */
4487 case 0xb3c4: /* CEGR - convert from fixed */
4488 case 0xb3c5: /* CDGR - convert from fixed */
4489 case 0xb3f6: /* IEDTR - insert biased exponent */
4490 /* float destination */
4491 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[6]))
4495 /* 0xb246-0xb24c: privileged or unsupported */
4497 case 0xb24d: /* CPYA - copy access */
4498 case 0xb24e: /* SAR - set access */
4499 if (record_full_arch_list_add_reg (regcache, S390_A0_REGNUM + inib[6]))
4503 /* 0xb250-0xb251 undefined or privileged */
4504 /* 0xb253-0xb254 undefined or privileged */
4506 case 0xb255: /* MVST - move string [partial] */
4511 /* Read ending byte. */
4512 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM, &tmp);
4514 /* Get address of second operand. */
4515 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[7], &tmp);
4516 oaddr = s390_record_address_mask (gdbarch, regcache, tmp);
4517 /* Search for ending byte and compute length. */
4520 if (target_read_memory (oaddr, &cur, 1))
4523 } while (cur != end);
4524 /* Get address of first operand and record it. */
4525 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[6], &tmp);
4526 oaddr = s390_record_address_mask (gdbarch, regcache, tmp);
4527 if (record_full_arch_list_add_mem (oaddr, num))
4529 /* Record the registers. */
4530 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6]))
4532 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[7]))
4534 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4539 /* 0xb256 undefined */
4541 case 0xb257: /* CUSE - compare until substring equal [interruptible] */
4542 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6]))
4544 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[6] | 1)))
4546 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[7]))
4548 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[7] | 1)))
4550 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4554 /* 0xb258-0xb25c undefined, privileged, or unsupported */
4556 case 0xb25d: /* CLST - compare logical string [partial] */
4557 case 0xb25e: /* SRST - search string [partial] */
4558 case 0xb9be: /* SRSTU - search string unicode [partial] */
4559 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6]))
4561 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[7]))
4563 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4567 /* 0xb25f-0xb262 undefined */
4569 case 0xb263: /* CMPSC - compression call [interruptible] */
4570 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[6], &tmp);
4571 oaddr = s390_record_address_mask (gdbarch, regcache, tmp);
4572 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + (inib[6] | 1), &tmp);
4573 if (record_full_arch_list_add_mem (oaddr, tmp))
4575 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6]))
4577 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[6] | 1)))
4579 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[7]))
4581 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[7] | 1)))
4583 if (record_full_arch_list_add_reg (regcache, S390_R1_REGNUM))
4585 /* DXC may be written */
4586 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
4588 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4592 /* 0xb264-0xb277 undefined, privileged, or unsupported */
4594 case 0xb278: /* STCKE - store clock extended */
4595 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
4596 if (record_full_arch_list_add_mem (oaddr, 16))
4598 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4602 /* 0xb279-0xb27b undefined or unsupported */
4603 /* 0xb27d-0xb298 undefined or privileged */
4605 case 0xb299: /* SRNM - set rounding mode */
4606 case 0xb2b8: /* SRNMB - set bfp rounding mode */
4607 case 0xb2b9: /* SRNMT - set dfp rounding mode */
4608 case 0xb29d: /* LFPC - load fpc */
4609 case 0xb2bd: /* LFAS - load fpc and signal */
4610 case 0xb384: /* SFPC - set fpc */
4611 case 0xb385: /* SFASR - set fpc and signal */
4612 case 0xb960: /* CGRT - compare and trap */
4613 case 0xb961: /* CLGRT - compare logical and trap */
4614 case 0xb972: /* CRT - compare and trap */
4615 case 0xb973: /* CLRT - compare logical and trap */
4616 /* fpc only - including possible DXC write for trapping insns */
4617 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
4621 /* 0xb29a-0xb29b undefined */
4623 case 0xb29c: /* STFPC - store fpc */
4624 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
4625 if (record_full_arch_list_add_mem (oaddr, 4))
4629 /* 0xb29e-0xb2a4 undefined */
4631 case 0xb2a5: /* TRE - translate extended [partial] */
4632 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[6], &tmp);
4633 oaddr = s390_record_address_mask (gdbarch, regcache, tmp);
4634 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + (inib[6] | 1), &tmp);
4635 if (record_full_arch_list_add_mem (oaddr, tmp))
4637 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6]))
4639 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[6] | 1)))
4641 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4645 case 0xb2a6: /* CU21 - convert UTF-16 to UTF-8 [partial] */
4646 case 0xb2a7: /* CU12 - convert UTF-8 to UTF-16 [partial] */
4647 case 0xb9b0: /* CU14 - convert UTF-8 to UTF-32 [partial] */
4648 case 0xb9b1: /* CU24 - convert UTF-16 to UTF-32 [partial] */
4649 case 0xb9b2: /* CU41 - convert UTF-32 to UTF-8 [partial] */
4650 case 0xb9b3: /* CU42 - convert UTF-32 to UTF-16 [partial] */
4651 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[6], &tmp);
4652 oaddr = s390_record_address_mask (gdbarch, regcache, tmp);
4653 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + (inib[6] | 1), &tmp);
4654 if (record_full_arch_list_add_mem (oaddr, tmp))
4656 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6]))
4658 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[6] | 1)))
4660 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[7]))
4662 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[7] | 1)))
4664 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4668 /* 0xb2a8-0xb2af undefined */
4670 case 0xb2b0: /* STFLE - store facility list extended */
4671 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
4672 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM, &tmp);
4674 if (record_full_arch_list_add_mem (oaddr, 8 * (tmp + 1)))
4676 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM))
4678 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4682 /* 0xb2b1-0xb2b7 undefined or privileged */
4683 /* 0xb2ba-0xb2bc undefined */
4684 /* 0xb2be-0xb2e7 undefined */
4685 /* 0xb2e9-0xb2eb undefined */
4686 /* 0xb2ed-0xb2f7 undefined */
4687 /* 0xb2f8 unsupported: TEND */
4688 /* 0xb2f9 undefined */
4690 case 0xb2e8: /* PPA - perform processor assist */
4691 case 0xb2fa: /* NIAI - next instruction access intent */
4692 /* no visible effects */
4695 /* 0xb2fb undefined */
4696 /* 0xb2fc unsupported: TABORT */
4697 /* 0xb2fd-0xb2fe undefined */
4698 /* 0xb2ff unsupported: TRAP */
4700 case 0xb300: /* LPEBR - load positive */
4701 case 0xb301: /* LNEBR - load negative */
4702 case 0xb303: /* LCEBR - load complement */
4703 case 0xb310: /* LPDBR - load positive */
4704 case 0xb311: /* LNDBR - load negative */
4705 case 0xb313: /* LCDBR - load complement */
4706 case 0xb350: /* TBEDR - convert hfp to bfp */
4707 case 0xb351: /* TBDR - convert hfp to bfp */
4708 case 0xb358: /* THDER - convert bfp to hfp */
4709 case 0xb359: /* THDR - convert bfp to hfp */
4710 /* float destination + flags */
4711 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[6]))
4713 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4717 case 0xb304: /* LDEBR - load lengthened */
4718 case 0xb30c: /* MDEBR - multiply */
4719 case 0xb30d: /* DEBR - divide */
4720 case 0xb314: /* SQEBR - square root */
4721 case 0xb315: /* SQDBR - square root */
4722 case 0xb317: /* MEEBR - multiply */
4723 case 0xb31c: /* MDBR - multiply */
4724 case 0xb31d: /* DDBR - divide */
4725 case 0xb344: /* LEDBRA - load rounded */
4726 case 0xb345: /* LDXBRA - load rounded */
4727 case 0xb346: /* LEXBRA - load rounded */
4728 case 0xb357: /* FIEBRA - load fp integer */
4729 case 0xb35f: /* FIDBRA - load fp integer */
4730 case 0xb390: /* CELFBR - convert from logical */
4731 case 0xb391: /* CDLFBR - convert from logical */
4732 case 0xb394: /* CEFBR - convert from fixed */
4733 case 0xb395: /* CDFBR - convert from fixed */
4734 case 0xb3a0: /* CELGBR - convert from logical */
4735 case 0xb3a1: /* CDLGBR - convert from logical */
4736 case 0xb3a4: /* CEGBR - convert from fixed */
4737 case 0xb3a5: /* CDGBR - convert from fixed */
4738 case 0xb3d0: /* MDTR - multiply */
4739 case 0xb3d1: /* DDTR - divide */
4740 case 0xb3d4: /* LDETR - load lengthened */
4741 case 0xb3d5: /* LEDTR - load lengthened */
4742 case 0xb3d7: /* FIDTR - load fp integer */
4743 case 0xb3dd: /* LDXTR - load lengthened */
4744 case 0xb3f1: /* CDGTR - convert from fixed */
4745 case 0xb3f2: /* CDUTR - convert from unsigned packed */
4746 case 0xb3f3: /* CDSTR - convert from signed packed */
4747 case 0xb3f5: /* QADTR - quantize */
4748 case 0xb3f7: /* RRDTR - reround */
4749 case 0xb951: /* CDFTR - convert from fixed */
4750 case 0xb952: /* CDLGTR - convert from logical */
4751 case 0xb953: /* CDLFTR - convert from logical */
4752 /* float destination + fpc */
4753 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[6]))
4755 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
4759 case 0xb305: /* LXDBR - load lengthened */
4760 case 0xb306: /* LXEBR - load lengthened */
4761 case 0xb307: /* MXDBR - multiply */
4762 case 0xb316: /* SQXBR - square root */
4763 case 0xb34c: /* MXBR - multiply */
4764 case 0xb34d: /* DXBR - divide */
4765 case 0xb347: /* FIXBRA - load fp integer */
4766 case 0xb392: /* CXLFBR - convert from logical */
4767 case 0xb396: /* CXFBR - convert from fixed */
4768 case 0xb3a2: /* CXLGBR - convert from logical */
4769 case 0xb3a6: /* CXGBR - convert from fixed */
4770 case 0xb3d8: /* MXTR - multiply */
4771 case 0xb3d9: /* DXTR - divide */
4772 case 0xb3dc: /* LXDTR - load lengthened */
4773 case 0xb3df: /* FIXTR - load fp integer */
4774 case 0xb3f9: /* CXGTR - convert from fixed */
4775 case 0xb3fa: /* CXUTR - convert from unsigned packed */
4776 case 0xb3fb: /* CXSTR - convert from signed packed */
4777 case 0xb3fd: /* QAXTR - quantize */
4778 case 0xb3ff: /* RRXTR - reround */
4779 case 0xb959: /* CXFTR - convert from fixed */
4780 case 0xb95a: /* CXLGTR - convert from logical */
4781 case 0xb95b: /* CXLFTR - convert from logical */
4782 /* float pair destination + fpc */
4783 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[6]))
4785 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + (inib[6] | 2)))
4787 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
4791 case 0xb308: /* KEBR - compare and signal */
4792 case 0xb309: /* CEBR - compare */
4793 case 0xb318: /* KDBR - compare and signal */
4794 case 0xb319: /* CDBR - compare */
4795 case 0xb348: /* KXBR - compare and signal */
4796 case 0xb349: /* CXBR - compare */
4797 case 0xb3e0: /* KDTR - compare and signal */
4798 case 0xb3e4: /* CDTR - compare */
4799 case 0xb3e8: /* KXTR - compare and signal */
4800 case 0xb3ec: /* CXTR - compare */
4801 /* flags + fpc only */
4802 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4804 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
4808 case 0xb302: /* LTEBR - load and test */
4809 case 0xb312: /* LTDBR - load and test */
4810 case 0xb30a: /* AEBR - add */
4811 case 0xb30b: /* SEBR - subtract */
4812 case 0xb31a: /* ADBR - add */
4813 case 0xb31b: /* SDBR - subtract */
4814 case 0xb3d2: /* ADTR - add */
4815 case 0xb3d3: /* SDTR - subtract */
4816 case 0xb3d6: /* LTDTR - load and test */
4817 /* float destination + flags + fpc */
4818 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[6]))
4820 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4822 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
4826 case 0xb30e: /* MAEBR - multiply and add */
4827 case 0xb30f: /* MSEBR - multiply and subtract */
4828 case 0xb31e: /* MADBR - multiply and add */
4829 case 0xb31f: /* MSDBR - multiply and subtract */
4830 /* float destination [RRD] + fpc */
4831 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[4]))
4833 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
4837 /* 0xb320-0xb323 undefined */
4838 /* 0xb327-0xb32d undefined */
4840 case 0xb32e: /* MAER - multiply and add */
4841 case 0xb32f: /* MSER - multiply and subtract */
4842 case 0xb338: /* MAYLR - multiply and add unnormalized */
4843 case 0xb339: /* MYLR - multiply unnormalized */
4844 case 0xb33c: /* MAYHR - multiply and add unnormalized */
4845 case 0xb33d: /* MYHR - multiply unnormalized */
4846 case 0xb33e: /* MADR - multiply and add */
4847 case 0xb33f: /* MSDR - multiply and subtract */
4848 /* float destination [RRD] */
4849 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[4]))
4853 /* 0xb330-0xb335 undefined */
4855 case 0xb33a: /* MAYR - multiply and add unnormalized */
4856 case 0xb33b: /* MYR - multiply unnormalized */
4857 /* float pair destination [RRD] */
4858 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[4]))
4860 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + (inib[4] | 2)))
4864 case 0xb340: /* LPXBR - load positive */
4865 case 0xb341: /* LNXBR - load negative */
4866 case 0xb343: /* LCXBR - load complement */
4867 case 0xb360: /* LPXR - load positive */
4868 case 0xb361: /* LNXR - load negative */
4869 case 0xb362: /* LTXR - load and test */
4870 case 0xb363: /* LCXR - load complement */
4871 /* float pair destination + flags */
4872 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[6]))
4874 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + (inib[6] | 2)))
4876 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4880 case 0xb342: /* LTXBR - load and test */
4881 case 0xb34a: /* AXBR - add */
4882 case 0xb34b: /* SXBR - subtract */
4883 case 0xb3da: /* AXTR - add */
4884 case 0xb3db: /* SXTR - subtract */
4885 case 0xb3de: /* LTXTR - load and test */
4886 /* float pair destination + flags + fpc */
4887 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[6]))
4889 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + (inib[6] | 2)))
4891 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4893 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
4897 /* 0xb34e-0xb34f undefined */
4898 /* 0xb352 undefined */
4900 case 0xb353: /* DIEBR - divide to integer */
4901 case 0xb35b: /* DIDBR - divide to integer */
4902 /* two float destinations + flags + fpc */
4903 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[4]))
4905 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[6]))
4907 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4909 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
4913 /* 0xb354-0xb356 undefined */
4914 /* 0xb35a undefined */
4916 /* 0xb35c-0xb35e undefined */
4917 /* 0xb364 undefined */
4918 /* 0xb368 undefined */
4920 case 0xb369: /* CXR - compare */
4921 case 0xb3f4: /* CEDTR - compare biased exponent */
4922 case 0xb3fc: /* CEXTR - compare biased exponent */
4923 case 0xb920: /* CGR - compare */
4924 case 0xb921: /* CLGR - compare logical */
4925 case 0xb930: /* CGFR - compare */
4926 case 0xb931: /* CLGFR - compare logical */
4927 case 0xb9cd: /* CHHR - compare high */
4928 case 0xb9cf: /* CLHHR - compare logical high */
4929 case 0xb9dd: /* CHLR - compare high */
4930 case 0xb9df: /* CLHLR - compare logical high */
4932 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4936 /* 0xb36a-0xb36f undefined */
4937 /* 0xb377-0xb37e undefined */
4938 /* 0xb380-0xb383 undefined */
4939 /* 0xb386-0xb38b undefined */
4940 /* 0xb38d-0xb38f undefined */
4941 /* 0xb393 undefined */
4942 /* 0xb397 undefined */
4944 case 0xb398: /* CFEBR - convert to fixed */
4945 case 0xb399: /* CFDBR - convert to fixed */
4946 case 0xb39a: /* CFXBR - convert to fixed */
4947 case 0xb39c: /* CLFEBR - convert to logical */
4948 case 0xb39d: /* CLFDBR - convert to logical */
4949 case 0xb39e: /* CLFXBR - convert to logical */
4950 case 0xb941: /* CFDTR - convert to fixed */
4951 case 0xb949: /* CFXTR - convert to fixed */
4952 case 0xb943: /* CLFDTR - convert to logical */
4953 case 0xb94b: /* CLFXTR - convert to logical */
4954 /* 32-bit gpr destination + flags + fpc */
4955 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6]))
4957 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4959 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
4963 /* 0xb39b undefined */
4964 /* 0xb39f undefined */
4966 /* 0xb3a3 undefined */
4967 /* 0xb3a7 undefined */
4969 case 0xb3a8: /* CGEBR - convert to fixed */
4970 case 0xb3a9: /* CGDBR - convert to fixed */
4971 case 0xb3aa: /* CGXBR - convert to fixed */
4972 case 0xb3ac: /* CLGEBR - convert to logical */
4973 case 0xb3ad: /* CLGDBR - convert to logical */
4974 case 0xb3ae: /* CLGXBR - convert to logical */
4975 case 0xb3e1: /* CGDTR - convert to fixed */
4976 case 0xb3e9: /* CGXTR - convert to fixed */
4977 case 0xb942: /* CLGDTR - convert to logical */
4978 case 0xb94a: /* CLGXTR - convert to logical */
4979 /* 64-bit gpr destination + flags + fpc */
4980 if (s390_record_gpr_g (gdbarch, regcache, inib[6]))
4982 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
4984 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
4988 /* 0xb3ab undefined */
4989 /* 0xb3af-0xb3b3 undefined */
4990 /* 0xb3b7 undefined */
4992 case 0xb3b8: /* CFER - convert to fixed */
4993 case 0xb3b9: /* CFDR - convert to fixed */
4994 case 0xb3ba: /* CFXR - convert to fixed */
4995 case 0xb998: /* ALCR - add logical with carry */
4996 case 0xb999: /* SLBR - subtract logical with borrow */
4997 case 0xb9f4: /* NRK - and */
4998 case 0xb9f6: /* ORK - or */
4999 case 0xb9f7: /* XRK - xor */
5000 case 0xb9f8: /* ARK - add */
5001 case 0xb9f9: /* SRK - subtract */
5002 case 0xb9fa: /* ALRK - add logical */
5003 case 0xb9fb: /* SLRK - subtract logical */
5004 /* 32-bit gpr destination + flags */
5005 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6]))
5007 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
5011 case 0xb3c8: /* CGER - convert to fixed */
5012 case 0xb3c9: /* CGDR - convert to fixed */
5013 case 0xb3ca: /* CGXR - convert to fixed */
5014 case 0xb900: /* LPGR - load positive */
5015 case 0xb901: /* LNGR - load negative */
5016 case 0xb902: /* LTGR - load and test */
5017 case 0xb903: /* LCGR - load complement */
5018 case 0xb908: /* AGR - add */
5019 case 0xb909: /* SGR - subtract */
5020 case 0xb90a: /* ALGR - add logical */
5021 case 0xb90b: /* SLGR - subtract logical */
5022 case 0xb910: /* LPGFR - load positive */
5023 case 0xb911: /* LNGFR - load negative */
5024 case 0xb912: /* LTGFR - load and test */
5025 case 0xb913: /* LCGFR - load complement */
5026 case 0xb918: /* AGFR - add */
5027 case 0xb919: /* SGFR - subtract */
5028 case 0xb91a: /* ALGFR - add logical */
5029 case 0xb91b: /* SLGFR - subtract logical */
5030 case 0xb980: /* NGR - and */
5031 case 0xb981: /* OGR - or */
5032 case 0xb982: /* XGR - xor */
5033 case 0xb988: /* ALCGR - add logical with carry */
5034 case 0xb989: /* SLBGR - subtract logical with borrow */
5035 case 0xb9e1: /* POPCNT - population count */
5036 case 0xb9e4: /* NGRK - and */
5037 case 0xb9e6: /* OGRK - or */
5038 case 0xb9e7: /* XGRK - xor */
5039 case 0xb9e8: /* AGRK - add */
5040 case 0xb9e9: /* SGRK - subtract */
5041 case 0xb9ea: /* ALGRK - add logical */
5042 case 0xb9eb: /* SLGRK - subtract logical */
5043 /* 64-bit gpr destination + flags */
5044 if (s390_record_gpr_g (gdbarch, regcache, inib[6]))
5046 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
5050 /* 0xb3bb-0xb3c0 undefined */
5051 /* 0xb3c2-0xb3c3 undefined */
5052 /* 0xb3c7 undefined */
5053 /* 0xb3cb-0xb3cc undefined */
5055 case 0xb3cd: /* LGDR - load gr from fpr */
5056 case 0xb3e2: /* CUDTR - convert to unsigned packed */
5057 case 0xb3e3: /* CSDTR - convert to signed packed */
5058 case 0xb3e5: /* EEDTR - extract biased exponent */
5059 case 0xb3e7: /* ESDTR - extract significance */
5060 case 0xb3ed: /* EEXTR - extract biased exponent */
5061 case 0xb3ef: /* ESXTR - extract significance */
5062 case 0xb904: /* LGR - load */
5063 case 0xb906: /* LGBR - load byte */
5064 case 0xb907: /* LGHR - load halfword */
5065 case 0xb90c: /* MSGR - multiply single */
5066 case 0xb90f: /* LRVGR - load reversed */
5067 case 0xb914: /* LGFR - load */
5068 case 0xb916: /* LLGFR - load logical */
5069 case 0xb917: /* LLGTR - load logical thirty one bits */
5070 case 0xb91c: /* MSGFR - load */
5071 case 0xb946: /* BCTGR - branch on count */
5072 case 0xb984: /* LLGCR - load logical character */
5073 case 0xb985: /* LLGHR - load logical halfword */
5074 case 0xb9e2: /* LOCGR - load on condition */
5075 /* 64-bit gpr destination */
5076 if (s390_record_gpr_g (gdbarch, regcache, inib[6]))
5080 /* 0xb3ce-0xb3cf undefined */
5081 /* 0xb3e6 undefined */
5083 case 0xb3ea: /* CUXTR - convert to unsigned packed */
5084 case 0xb3eb: /* CSXTR - convert to signed packed */
5085 case 0xb90d: /* DSGR - divide single */
5086 case 0xb91d: /* DSGFR - divide single */
5087 case 0xb986: /* MLGR - multiply logical */
5088 case 0xb987: /* DLGR - divide logical */
5089 /* 64-bit gpr pair destination */
5090 if (s390_record_gpr_g (gdbarch, regcache, inib[6]))
5092 if (s390_record_gpr_g (gdbarch, regcache, inib[6] | 1))
5096 /* 0xb3ee undefined */
5097 /* 0xb3f0 undefined */
5098 /* 0xb3f8 undefined */
5100 /* 0xb905 privileged */
5102 /* 0xb90e unsupported: EREGG */
5104 /* 0xb915 undefined */
5106 case 0xb91e: /* KMAC - compute message authentication code [partial] */
5107 regcache_raw_read_unsigned (regcache, S390_R1_REGNUM, &tmp);
5108 oaddr = s390_record_address_mask (gdbarch, regcache, tmp);
5109 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM, &tmp);
5113 case 0x00: /* KMAC-Query */
5114 if (record_full_arch_list_add_mem (oaddr, 16))
5118 case 0x01: /* KMAC-DEA */
5119 case 0x02: /* KMAC-TDEA-128 */
5120 case 0x03: /* KMAC-TDEA-192 */
5121 case 0x09: /* KMAC-Encrypted-DEA */
5122 case 0x0a: /* KMAC-Encrypted-TDEA-128 */
5123 case 0x0b: /* KMAC-Encrypted-TDEA-192 */
5124 if (record_full_arch_list_add_mem (oaddr, 8))
5128 case 0x12: /* KMAC-AES-128 */
5129 case 0x13: /* KMAC-AES-192 */
5130 case 0x14: /* KMAC-AES-256 */
5131 case 0x1a: /* KMAC-Encrypted-AES-128 */
5132 case 0x1b: /* KMAC-Encrypted-AES-192 */
5133 case 0x1c: /* KMAC-Encrypted-AES-256 */
5134 if (record_full_arch_list_add_mem (oaddr, 16))
5139 fprintf_unfiltered (gdb_stdlog, "Warning: Unknown KMAC function %02x at %s.\n",
5140 (int)tmp, paddress (gdbarch, addr));
5145 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[7]))
5147 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[7] | 1)))
5150 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
5154 /* 0xb922-0xb924 undefined */
5155 /* 0xb925 privileged */
5156 /* 0xb928 privileged */
5157 /* 0xb929 undefined */
5159 case 0xb92a: /* KMF - cipher message with cipher feedback [partial] */
5160 case 0xb92b: /* KMO - cipher message with output feedback [partial] */
5161 case 0xb92f: /* KMC - cipher message with chaining [partial] */
5162 regcache_raw_read_unsigned (regcache, S390_R1_REGNUM, &tmp);
5163 oaddr = s390_record_address_mask (gdbarch, regcache, tmp);
5164 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM, &tmp);
5168 case 0x00: /* KM*-Query */
5169 if (record_full_arch_list_add_mem (oaddr, 16))
5173 case 0x01: /* KM*-DEA */
5174 case 0x02: /* KM*-TDEA-128 */
5175 case 0x03: /* KM*-TDEA-192 */
5176 case 0x09: /* KM*-Encrypted-DEA */
5177 case 0x0a: /* KM*-Encrypted-TDEA-128 */
5178 case 0x0b: /* KM*-Encrypted-TDEA-192 */
5179 if (record_full_arch_list_add_mem (oaddr, 8))
5183 case 0x12: /* KM*-AES-128 */
5184 case 0x13: /* KM*-AES-192 */
5185 case 0x14: /* KM*-AES-256 */
5186 case 0x1a: /* KM*-Encrypted-AES-128 */
5187 case 0x1b: /* KM*-Encrypted-AES-192 */
5188 case 0x1c: /* KM*-Encrypted-AES-256 */
5189 if (record_full_arch_list_add_mem (oaddr, 16))
5193 case 0x43: /* KMC-PRNG */
5194 /* Only valid for KMC. */
5195 if (insn[0] == 0xb92f)
5197 if (record_full_arch_list_add_mem (oaddr, 8))
5201 /* For other instructions, fallthru. */
5203 fprintf_unfiltered (gdb_stdlog, "Warning: Unknown KM* function %02x at %s.\n",
5204 (int)tmp, paddress (gdbarch, addr));
5209 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[6], &tmp);
5210 oaddr2 = s390_record_address_mask (gdbarch, regcache, tmp);
5211 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + (inib[7] | 1), &tmp);
5212 if (record_full_arch_list_add_mem (oaddr2, tmp))
5214 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6]))
5216 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[7]))
5218 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[7] | 1)))
5221 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
5225 case 0xb92c: /* PCC - perform cryptographic computation [partial] */
5226 regcache_raw_read_unsigned (regcache, S390_R1_REGNUM, &tmp);
5227 oaddr = s390_record_address_mask (gdbarch, regcache, tmp);
5228 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM, &tmp);
5232 case 0x00: /* PCC-Query */
5233 if (record_full_arch_list_add_mem (oaddr, 16))
5237 case 0x01: /* PCC-Compute-Last-Block-CMAC-Using-DEA */
5238 case 0x02: /* PCC-Compute-Last-Block-CMAC-Using-TDEA-128 */
5239 case 0x03: /* PCC-Compute-Last-Block-CMAC-Using-TDEA-192 */
5240 case 0x09: /* PCC-Compute-Last-Block-CMAC-Using-Encrypted-DEA */
5241 case 0x0a: /* PCC-Compute-Last-Block-CMAC-Using-Encrypted-TDEA-128 */
5242 case 0x0b: /* PCC-Compute-Last-Block-CMAC-Using-Encrypted-TDEA-192 */
5243 if (record_full_arch_list_add_mem (oaddr + 0x10, 8))
5247 case 0x12: /* PCC-Compute-Last-Block-CMAC-Using-AES-128 */
5248 case 0x13: /* PCC-Compute-Last-Block-CMAC-Using-AES-192 */
5249 case 0x14: /* PCC-Compute-Last-Block-CMAC-Using-AES-256 */
5250 case 0x1a: /* PCC-Compute-Last-Block-CMAC-Using-Encrypted-AES-128 */
5251 case 0x1b: /* PCC-Compute-Last-Block-CMAC-Using-Encrypted-AES-192 */
5252 case 0x1c: /* PCC-Compute-Last-Block-CMAC-Using-Encrypted-AES-256 */
5253 if (record_full_arch_list_add_mem (oaddr + 0x18, 16))
5257 case 0x32: /* PCC-Compute-XTS-Parameter-Using-AES-128 */
5258 if (record_full_arch_list_add_mem (oaddr + 0x30, 32))
5262 case 0x34: /* PCC-Compute-XTS-Parameter-Using-AES-256 */
5263 if (record_full_arch_list_add_mem (oaddr + 0x40, 32))
5267 case 0x3a: /* PCC-Compute-XTS-Parameter-Using-Encrypted-AES-128 */
5268 if (record_full_arch_list_add_mem (oaddr + 0x50, 32))
5272 case 0x3c: /* PCC-Compute-XTS-Parameter-Using-Encrypted-AES-256 */
5273 if (record_full_arch_list_add_mem (oaddr + 0x60, 32))
5278 fprintf_unfiltered (gdb_stdlog, "Warning: Unknown PCC function %02x at %s.\n",
5279 (int)tmp, paddress (gdbarch, addr));
5282 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
5286 case 0xb92d: /* KMCTR - cipher message with counter [partial] */
5287 regcache_raw_read_unsigned (regcache, S390_R1_REGNUM, &tmp);
5288 oaddr = s390_record_address_mask (gdbarch, regcache, tmp);
5289 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM, &tmp);
5293 case 0x00: /* KMCTR-Query */
5294 if (record_full_arch_list_add_mem (oaddr, 16))
5298 case 0x01: /* KMCTR-DEA */
5299 case 0x02: /* KMCTR-TDEA-128 */
5300 case 0x03: /* KMCTR-TDEA-192 */
5301 case 0x09: /* KMCTR-Encrypted-DEA */
5302 case 0x0a: /* KMCTR-Encrypted-TDEA-128 */
5303 case 0x0b: /* KMCTR-Encrypted-TDEA-192 */
5304 case 0x12: /* KMCTR-AES-128 */
5305 case 0x13: /* KMCTR-AES-192 */
5306 case 0x14: /* KMCTR-AES-256 */
5307 case 0x1a: /* KMCTR-Encrypted-AES-128 */
5308 case 0x1b: /* KMCTR-Encrypted-AES-192 */
5309 case 0x1c: /* KMCTR-Encrypted-AES-256 */
5313 fprintf_unfiltered (gdb_stdlog, "Warning: Unknown KMCTR function %02x at %s.\n",
5314 (int)tmp, paddress (gdbarch, addr));
5319 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[6], &tmp);
5320 oaddr2 = s390_record_address_mask (gdbarch, regcache, tmp);
5321 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + (inib[7] | 1), &tmp);
5322 if (record_full_arch_list_add_mem (oaddr2, tmp))
5324 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6]))
5326 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[7]))
5328 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[7] | 1)))
5330 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[4]))
5333 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
5337 case 0xb92e: /* KM - cipher message [partial] */
5338 regcache_raw_read_unsigned (regcache, S390_R1_REGNUM, &tmp);
5339 oaddr = s390_record_address_mask (gdbarch, regcache, tmp);
5340 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM, &tmp);
5344 case 0x00: /* KM-Query */
5345 if (record_full_arch_list_add_mem (oaddr, 16))
5349 case 0x01: /* KM-DEA */
5350 case 0x02: /* KM-TDEA-128 */
5351 case 0x03: /* KM-TDEA-192 */
5352 case 0x09: /* KM-Encrypted-DEA */
5353 case 0x0a: /* KM-Encrypted-TDEA-128 */
5354 case 0x0b: /* KM-Encrypted-TDEA-192 */
5355 case 0x12: /* KM-AES-128 */
5356 case 0x13: /* KM-AES-192 */
5357 case 0x14: /* KM-AES-256 */
5358 case 0x1a: /* KM-Encrypted-AES-128 */
5359 case 0x1b: /* KM-Encrypted-AES-192 */
5360 case 0x1c: /* KM-Encrypted-AES-256 */
5363 case 0x32: /* KM-XTS-AES-128 */
5364 if (record_full_arch_list_add_mem (oaddr + 0x10, 16))
5368 case 0x34: /* KM-XTS-AES-256 */
5369 if (record_full_arch_list_add_mem (oaddr + 0x20, 16))
5373 case 0x3a: /* KM-XTS-Encrypted-AES-128 */
5374 if (record_full_arch_list_add_mem (oaddr + 0x30, 16))
5378 case 0x3c: /* KM-XTS-Encrypted-AES-256 */
5379 if (record_full_arch_list_add_mem (oaddr + 0x40, 16))
5384 fprintf_unfiltered (gdb_stdlog, "Warning: Unknown KM function %02x at %s.\n",
5385 (int)tmp, paddress (gdbarch, addr));
5390 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[6], &tmp);
5391 oaddr2 = s390_record_address_mask (gdbarch, regcache, tmp);
5392 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + (inib[7] | 1), &tmp);
5393 if (record_full_arch_list_add_mem (oaddr2, tmp))
5395 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6]))
5397 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[7]))
5399 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[7] | 1)))
5402 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
5406 /* 0xb932-0xb93b undefined */
5408 case 0xb93c: /* PPNO - perform pseudorandom number operation [partial] */
5409 regcache_raw_read_unsigned (regcache, S390_R1_REGNUM, &tmp);
5410 oaddr = s390_record_address_mask (gdbarch, regcache, tmp);
5411 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM, &tmp);
5415 case 0x00: /* PPNO-Query */
5416 case 0x80: /* PPNO-Query */
5417 if (record_full_arch_list_add_mem (oaddr, 16))
5421 case 0x03: /* PPNO-SHA-512-DRNG - generate */
5422 if (record_full_arch_list_add_mem (oaddr, 240))
5424 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[6], &tmp);
5425 oaddr2 = s390_record_address_mask (gdbarch, regcache, tmp);
5426 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + (inib[6] | 1), &tmp);
5427 if (record_full_arch_list_add_mem (oaddr2, tmp))
5429 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6]))
5431 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[6] | 1)))
5435 case 0x83: /* PPNO-SHA-512-DRNG - seed */
5436 if (record_full_arch_list_add_mem (oaddr, 240))
5438 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[7]))
5440 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[7] | 1)))
5445 fprintf_unfiltered (gdb_stdlog, "Warning: Unknown PPNO function %02x at %s.\n",
5446 (int)tmp, paddress (gdbarch, addr));
5449 /* DXC may be written */
5450 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
5452 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
5456 /* 0xb93d undefined */
5458 case 0xb93e: /* KIMD - compute intermediate message digest [partial] */
5459 case 0xb93f: /* KLMD - compute last message digest [partial] */
5460 regcache_raw_read_unsigned (regcache, S390_R1_REGNUM, &tmp);
5461 oaddr = s390_record_address_mask (gdbarch, regcache, tmp);
5462 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM, &tmp);
5466 case 0x00: /* K*MD-Query */
5467 if (record_full_arch_list_add_mem (oaddr, 16))
5471 case 0x01: /* K*MD-SHA-1 */
5472 if (record_full_arch_list_add_mem (oaddr, 20))
5476 case 0x02: /* K*MD-SHA-256 */
5477 if (record_full_arch_list_add_mem (oaddr, 32))
5481 case 0x03: /* K*MD-SHA-512 */
5482 if (record_full_arch_list_add_mem (oaddr, 64))
5486 case 0x41: /* KIMD-GHASH */
5487 /* Only valid for KIMD. */
5488 if (insn[0] == 0xb93e)
5490 if (record_full_arch_list_add_mem (oaddr, 16))
5494 /* For KLMD, fallthru. */
5496 fprintf_unfiltered (gdb_stdlog, "Warning: Unknown KMAC function %02x at %s.\n",
5497 (int)tmp, paddress (gdbarch, addr));
5502 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[7]))
5504 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[7] | 1)))
5507 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
5511 /* 0xb940 undefined */
5512 /* 0xb944-0xb945 undefined */
5513 /* 0xb947-0xb948 undefined */
5514 /* 0xb94c-0xb950 undefined */
5515 /* 0xb954-0xb958 undefined */
5516 /* 0xb95c-0xb95f undefined */
5517 /* 0xb962-0xb971 undefined */
5518 /* 0xb974-0xb97f undefined */
5520 case 0xb983: /* FLOGR - find leftmost one */
5521 /* 64-bit gpr pair destination + flags */
5522 if (s390_record_gpr_g (gdbarch, regcache, inib[6]))
5524 if (s390_record_gpr_g (gdbarch, regcache, inib[6] | 1))
5526 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
5530 /* 0xb98a privileged */
5531 /* 0xb98b-0xb98c undefined */
5533 case 0xb98d: /* EPSW - extract psw */
5534 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6]))
5537 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[7]))
5541 /* 0xb98e-0xb98f privileged */
5543 case 0xb990: /* TRTT - translate two to two [partial] */
5544 case 0xb991: /* TRTO - translate two to one [partial] */
5545 case 0xb992: /* TROT - translate one to two [partial] */
5546 case 0xb993: /* TROO - translate one to one [partial] */
5547 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[6], &tmp);
5548 oaddr = s390_record_address_mask (gdbarch, regcache, tmp);
5549 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + (inib[6] | 1), &tmp);
5550 /* tmp is source length, we want destination length. Adjust. */
5551 if (insn[0] == 0xb991)
5553 if (insn[0] == 0xb992)
5555 if (record_full_arch_list_add_mem (oaddr, tmp))
5557 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6]))
5559 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[6] | 1)))
5561 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[7]))
5563 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
5567 case 0xb996: /* MLR - multiply logical */
5568 case 0xb997: /* DLR - divide logical */
5569 /* 32-bit gpr pair destination */
5570 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6]))
5572 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[6] | 1)))
5576 /* 0xb99a-0xb9af unsupported, privileged, or undefined */
5577 /* 0xb9b4-0xb9bc undefined */
5579 case 0xb9bd: /* TRTRE - translate and test reverse extended [partial] */
5580 case 0xb9bf: /* TRTE - translate and test extended [partial] */
5581 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[6]))
5583 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[6] | 1)))
5585 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[7]))
5587 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
5591 /* 0xb9c0-0xb9c7 undefined */
5593 case 0xb9c8: /* AHHHR - add high */
5594 case 0xb9c9: /* SHHHR - subtract high */
5595 case 0xb9ca: /* ALHHHR - add logical high */
5596 case 0xb9cb: /* SLHHHR - subtract logical high */
5597 case 0xb9d8: /* AHHLR - add high */
5598 case 0xb9d9: /* SHHLR - subtract high */
5599 case 0xb9da: /* ALHHLR - add logical high */
5600 case 0xb9db: /* SLHHLR - subtract logical high */
5601 /* 32-bit high gpr destination + flags */
5602 if (s390_record_gpr_h (gdbarch, regcache, inib[6]))
5604 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
5608 /* 0xb9cc undefined */
5609 /* 0xb9ce undefined */
5610 /* 0xb9d0-0xb9d7 undefined */
5611 /* 0xb9dc undefined */
5612 /* 0xb9de undefined */
5614 case 0xb9e0: /* LOCFHR - load high on condition */
5615 /* 32-bit high gpr destination */
5616 if (s390_record_gpr_h (gdbarch, regcache, inib[6]))
5620 /* 0xb9e3 undefined */
5621 /* 0xb9e5 undefined */
5622 /* 0xb9ec-0xb9f1 undefined */
5623 /* 0xb9f3 undefined */
5624 /* 0xb9f5 undefined */
5625 /* 0xb9fc-0xb9ff undefined */
5632 /* 0xb4-0xb5 undefined */
5633 /* 0xb6 privileged: STCTL - store control */
5634 /* 0xb7 privileged: LCTL - load control */
5635 /* 0xb8 undefined */
5637 case 0xba: /* CS - compare and swap */
5638 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
5639 if (record_full_arch_list_add_mem (oaddr, 4))
5641 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
5643 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
5647 case 0xbb: /* CDS - compare double and swap */
5648 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
5649 if (record_full_arch_list_add_mem (oaddr, 8))
5651 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
5653 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[2] | 1)))
5655 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
5659 /* 0xbc undefined */
5661 case 0xbe: /* STCM - store characters under mask */
5662 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
5663 if (record_full_arch_list_add_mem (oaddr, s390_popcnt (inib[3])))
5672 /* RIL-format instruction */
5673 switch (ibyte[0] << 4 | inib[3])
5675 case 0xc00: /* LARL - load address relative long */
5676 case 0xc05: /* BRASL - branch relative and save long */
5677 case 0xc09: /* IILF - insert immediate */
5678 case 0xc21: /* MSFI - multiply single immediate */
5679 case 0xc42: /* LLHRL - load logical halfword relative long */
5680 case 0xc45: /* LHRL - load halfword relative long */
5681 case 0xc4d: /* LRL - load relative long */
5682 /* 32-bit or native gpr destination */
5683 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
5687 case 0xc01: /* LGFI - load immediate */
5688 case 0xc0e: /* LLIHF - load logical immediate */
5689 case 0xc0f: /* LLILF - load logical immediate */
5690 case 0xc20: /* MSGFI - multiply single immediate */
5691 case 0xc44: /* LGHRL - load halfword relative long */
5692 case 0xc46: /* LLGHRL - load logical halfword relative long */
5693 case 0xc48: /* LGRL - load relative long */
5694 case 0xc4c: /* LGFRL - load relative long */
5695 case 0xc4e: /* LLGFRL - load logical relative long */
5696 /* 64-bit gpr destination */
5697 if (s390_record_gpr_g (gdbarch, regcache, inib[2]))
5701 /* 0xc02-0xc03 undefined */
5703 case 0xc04: /* BRCL - branch relative on condition long */
5704 case 0xc62: /* PFDRL - prefetch data relative long */
5707 case 0xc06: /* XIHF - xor immediate */
5708 case 0xc0a: /* NIHF - and immediate */
5709 case 0xc0c: /* OIHF - or immediate */
5710 case 0xcc8: /* AIH - add immediate high */
5711 case 0xcca: /* ALSIH - add logical with signed immediate high */
5712 /* 32-bit high gpr destination + flags */
5713 if (s390_record_gpr_h (gdbarch, regcache, inib[2]))
5715 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
5719 case 0xc07: /* XILF - xor immediate */
5720 case 0xc0b: /* NILF - and immediate */
5721 case 0xc0d: /* OILF - or immediate */
5722 case 0xc25: /* SLFI - subtract logical immediate */
5723 case 0xc29: /* AFI - add immediate */
5724 case 0xc2b: /* ALFI - add logical immediate */
5725 /* 32-bit gpr destination + flags */
5726 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
5728 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
5732 case 0xc08: /* IIHF - insert immediate */
5733 case 0xcc6: /* BRCTH - branch relative on count high */
5734 case 0xccb: /* ALSIHN - add logical with signed immediate high */
5735 /* 32-bit high gpr destination */
5736 if (s390_record_gpr_h (gdbarch, regcache, inib[2]))
5740 /* 0xc22-0xc23 undefined */
5742 case 0xc24: /* SLGFI - subtract logical immediate */
5743 case 0xc28: /* AGFI - add immediate */
5744 case 0xc2a: /* ALGFI - add logical immediate */
5745 /* 64-bit gpr destination + flags */
5746 if (s390_record_gpr_g (gdbarch, regcache, inib[2]))
5748 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
5752 /* 0xc26-0xc27 undefined */
5754 case 0xc2c: /* CGFI - compare immediate */
5755 case 0xc2d: /* CFI - compare immediate */
5756 case 0xc2e: /* CLGFI - compare logical immediate */
5757 case 0xc2f: /* CLFI - compare logical immediate */
5758 case 0xc64: /* CGHRL - compare halfword relative long */
5759 case 0xc65: /* CHRL - compare halfword relative long */
5760 case 0xc66: /* CLGHRL - compare logical halfword relative long */
5761 case 0xc67: /* CLHRL - compare logical halfword relative long */
5762 case 0xc68: /* CGRL - compare relative long */
5763 case 0xc6a: /* CLGRL - compare logical relative long */
5764 case 0xc6c: /* CGFRL - compare relative long */
5765 case 0xc6d: /* CRL - compare relative long */
5766 case 0xc6e: /* CLGFRL - compare logical relative long */
5767 case 0xc6f: /* CLRL - compare logical relative long */
5768 case 0xccd: /* CIH - compare immediate high */
5769 case 0xccf: /* CLIH - compare logical immediate high */
5771 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
5775 /* 0xc40-0xc41 undefined */
5776 /* 0xc43 undefined */
5778 case 0xc47: /* STHRL - store halfword relative long */
5779 oaddr = s390_record_calc_rl (gdbarch, regcache, addr, insn[1], insn[2]);
5780 if (record_full_arch_list_add_mem (oaddr, 2))
5784 /* 0xc49-0xc4a undefined */
5786 case 0xc4b: /* STGRL - store relative long */
5787 oaddr = s390_record_calc_rl (gdbarch, regcache, addr, insn[1], insn[2]);
5788 if (record_full_arch_list_add_mem (oaddr, 8))
5792 case 0xc4f: /* STRL - store relative long */
5793 oaddr = s390_record_calc_rl (gdbarch, regcache, addr, insn[1], insn[2]);
5794 if (record_full_arch_list_add_mem (oaddr, 4))
5798 case 0xc60: /* EXRL - execute relative long */
5801 fprintf_unfiltered (gdb_stdlog, "Warning: Double execute at %s.\n",
5802 paddress (gdbarch, addr));
5805 addr = s390_record_calc_rl (gdbarch, regcache, addr, insn[1], insn[2]);
5808 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[2], &tmp);
5817 /* 0xc61 undefined */
5818 /* 0xc63 undefined */
5819 /* 0xc69 undefined */
5820 /* 0xc6b undefined */
5821 /* 0xcc0-0xcc5 undefined */
5822 /* 0xcc7 undefined */
5823 /* 0xcc9 undefined */
5824 /* 0xccc undefined */
5825 /* 0xcce undefined */
5832 /* 0xc1 undefined */
5833 /* 0xc3 undefined */
5835 case 0xc5: /* BPRP - branch prediction relative preload */
5836 case 0xc7: /* BPP - branch prediction preload */
5837 /* no visible effect */
5841 /* SSF-format instruction */
5842 switch (ibyte[0] << 4 | inib[3])
5844 /* 0xc80 unsupported */
5846 case 0xc81: /* ECTG - extract cpu time */
5847 if (s390_record_gpr_g (gdbarch, regcache, inib[2]))
5849 if (s390_record_gpr_g (gdbarch, regcache, 0))
5851 if (s390_record_gpr_g (gdbarch, regcache, 1))
5855 case 0xc82: /* CSST - compare and swap and store */
5858 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM, &tmp);
5860 sc = tmp >> 8 & 0xff;
5862 /* First and third operands. */
5863 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
5866 case 0x00: /* 32-bit */
5867 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
5869 if (record_full_arch_list_add_mem (oaddr, 4))
5873 case 0x01: /* 64-bit */
5874 if (s390_record_gpr_g (gdbarch, regcache, inib[2]))
5876 if (record_full_arch_list_add_mem (oaddr, 8))
5880 case 0x02: /* 128-bit */
5881 if (s390_record_gpr_g (gdbarch, regcache, inib[2]))
5883 if (s390_record_gpr_g (gdbarch, regcache, inib[2] | 1))
5885 if (record_full_arch_list_add_mem (oaddr, 16))
5890 fprintf_unfiltered (gdb_stdlog, "Warning: Unknown CSST FC %02x at %s.\n",
5891 fc, paddress (gdbarch, addr));
5895 /* Second operand. */
5896 oaddr2 = s390_record_calc_disp (gdbarch, regcache, 0, insn[2], 0);
5899 fprintf_unfiltered (gdb_stdlog, "Warning: Unknown CSST FC %02x at %s.\n",
5900 sc, paddress (gdbarch, addr));
5904 if (record_full_arch_list_add_mem (oaddr2, 1 << sc))
5908 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
5913 /* 0xc83 undefined */
5915 case 0xc84: /* LPD - load pair disjoint */
5916 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
5918 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[2] | 1)))
5920 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
5924 case 0xc85: /* LPDG - load pair disjoint */
5925 if (s390_record_gpr_g (gdbarch, regcache, inib[2]))
5927 if (s390_record_gpr_g (gdbarch, regcache, inib[2] | 1))
5929 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
5933 /* 0xc86-0xc8f undefined */
5940 /* 0xc9-0xcb undefined */
5941 /* 0xcd-0xcf undefined */
5943 case 0xd0: /* TRTR - translate and test reversed */
5944 case 0xdd: /* TRT - translate and test */
5945 if (record_full_arch_list_add_reg (regcache, S390_R1_REGNUM))
5947 if (record_full_arch_list_add_reg (regcache, S390_R2_REGNUM))
5949 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
5953 case 0xd1: /* MVN - move numbers */
5954 case 0xd2: /* MVC - move */
5955 case 0xd3: /* MVZ - move zones */
5956 case 0xdc: /* TR - translate */
5957 case 0xe8: /* MVCIN - move inverse */
5958 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
5959 if (record_full_arch_list_add_mem (oaddr, ibyte[1] + 1))
5963 case 0xd4: /* NC - and */
5964 case 0xd6: /* OC - or*/
5965 case 0xd7: /* XC - xor */
5966 case 0xe2: /* UNPKU - unpack unicode */
5967 case 0xea: /* UNPKA - unpack ASCII */
5968 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
5969 if (record_full_arch_list_add_mem (oaddr, ibyte[1] + 1))
5971 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
5975 case 0xde: /* ED - edit */
5976 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
5977 if (record_full_arch_list_add_mem (oaddr, ibyte[1] + 1))
5979 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
5981 /* DXC may be written */
5982 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
5986 case 0xdf: /* EDMK - edit and mark */
5987 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
5988 if (record_full_arch_list_add_mem (oaddr, ibyte[1] + 1))
5990 if (record_full_arch_list_add_reg (regcache, S390_R1_REGNUM))
5992 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
5994 /* DXC may be written */
5995 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
5999 /* 0xd8 undefined */
6000 /* 0xd9 unsupported: MVCK - move with key */
6001 /* 0xda unsupported: MVCP - move to primary */
6002 /* 0xdb unsupported: MVCS - move to secondary */
6003 /* 0xe0 undefined */
6005 case 0xe1: /* PKU - pack unicode */
6006 case 0xe9: /* PKA - pack ASCII */
6007 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
6008 if (record_full_arch_list_add_mem (oaddr, 16))
6016 /* RXY/RXE/RXF/RSL/RSY/SIY/V*-format instruction */
6017 switch (ibyte[0] << 8 | ibyte[5])
6019 /* 0xe300-0xe301 undefined */
6021 case 0xe302: /* LTG - load and test */
6022 case 0xe308: /* AG - add */
6023 case 0xe309: /* SG - subtract */
6024 case 0xe30a: /* ALG - add logical */
6025 case 0xe30b: /* SLG - subtract logical */
6026 case 0xe318: /* AGF - add */
6027 case 0xe319: /* SGF - subtract */
6028 case 0xe31a: /* ALGF - add logical */
6029 case 0xe31b: /* SLGF - subtract logical */
6030 case 0xe332: /* LTGF - load and test */
6031 case 0xe380: /* NG - and */
6032 case 0xe381: /* OG - or */
6033 case 0xe382: /* XG - xor */
6034 case 0xe388: /* ALCG - add logical with carry */
6035 case 0xe389: /* SLBG - subtract logical with borrow */
6036 case 0xeb0a: /* SRAG - shift right single */
6037 case 0xeb0b: /* SLAG - shift left single */
6038 /* 64-bit gpr destination + flags */
6039 if (s390_record_gpr_g (gdbarch, regcache, inib[2]))
6041 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
6045 /* 0xe303 privileged */
6047 case 0xe304: /* LG - load */
6048 case 0xe30c: /* MSG - multiply single */
6049 case 0xe30f: /* LRVG - load reversed */
6050 case 0xe314: /* LGF - load */
6051 case 0xe315: /* LGH - load halfword */
6052 case 0xe316: /* LLGF - load logical */
6053 case 0xe317: /* LLGT - load logical thirty one bits */
6054 case 0xe31c: /* MSGF - multiply single */
6055 case 0xe32a: /* LZRG - load and zero rightmost byte */
6056 case 0xe33a: /* LLZRGF - load logical and zero rightmost byte */
6057 case 0xe346: /* BCTG - branch on count */
6058 case 0xe377: /* LGB - load byte */
6059 case 0xe390: /* LLGC - load logical character */
6060 case 0xe391: /* LLGH - load logical halfword */
6061 case 0xeb0c: /* SRLG - shift right single logical */
6062 case 0xeb0d: /* SLLG - shift left single logical */
6063 case 0xeb1c: /* RLLG - rotate left single logical */
6064 case 0xeb44: /* BXHG - branch on index high */
6065 case 0xeb45: /* BXLEG - branch on index low or equal */
6066 case 0xeb4c: /* ECAG - extract cpu attribute */
6067 case 0xebe2: /* LOCG - load on condition */
6068 /* 64-bit gpr destination */
6069 if (s390_record_gpr_g (gdbarch, regcache, inib[2]))
6073 /* 0xe305 undefined */
6075 case 0xe306: /* CVBY - convert to binary */
6076 /* 32-bit or native gpr destination + FPC (DXC write) */
6077 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
6079 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
6083 /* 0xe307 undefined */
6085 case 0xe30d: /* DSG - divide single */
6086 case 0xe31d: /* DSGF - divide single */
6087 case 0xe386: /* MLG - multiply logical */
6088 case 0xe387: /* DLG - divide logical */
6089 case 0xe38f: /* LPQ - load pair from quadword */
6090 /* 64-bit gpr pair destination */
6091 if (s390_record_gpr_g (gdbarch, regcache, inib[2]))
6093 if (s390_record_gpr_g (gdbarch, regcache, inib[2] | 1))
6097 case 0xe30e: /* CVBG - convert to binary */
6098 /* 64-bit gpr destination + FPC (DXC write) */
6099 if (s390_record_gpr_g (gdbarch, regcache, inib[2]))
6101 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
6105 /* 0xe310-0xe311 undefined */
6107 case 0xe312: /* LT - load and test */
6108 case 0xe354: /* NY - and */
6109 case 0xe356: /* OY - or */
6110 case 0xe357: /* XY - xor */
6111 case 0xe35a: /* AY - add */
6112 case 0xe35b: /* SY - subtract */
6113 case 0xe35e: /* ALY - add logical */
6114 case 0xe35f: /* SLY - subtract logical */
6115 case 0xe37a: /* AHY - add halfword */
6116 case 0xe37b: /* SHY - subtract halfword */
6117 case 0xe398: /* ALC - add logical with carry */
6118 case 0xe399: /* SLB - subtract logical with borrow */
6119 case 0xe727: /* LCBB - load count to block bounduary */
6120 case 0xeb81: /* ICMY - insert characters under mask */
6121 case 0xebdc: /* SRAK - shift left single */
6122 case 0xebdd: /* SLAK - shift left single */
6123 /* 32-bit gpr destination + flags */
6124 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
6126 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
6130 /* 0xe313 privileged */
6132 case 0xe31e: /* LRV - load reversed */
6133 case 0xe31f: /* LRVH - load reversed */
6134 case 0xe33b: /* LZRF - load and zero rightmost byte */
6135 case 0xe351: /* MSY - multiply single */
6136 case 0xe358: /* LY - load */
6137 case 0xe371: /* LAY - load address */
6138 case 0xe373: /* ICY - insert character */
6139 case 0xe376: /* LB - load byte */
6140 case 0xe378: /* LHY - load */
6141 case 0xe37c: /* MHY - multiply halfword */
6142 case 0xe394: /* LLC - load logical character */
6143 case 0xe395: /* LLH - load logical halfword */
6144 case 0xeb1d: /* RLL - rotate left single logical */
6145 case 0xebde: /* SRLK - shift left single logical */
6146 case 0xebdf: /* SLLK - shift left single logical */
6147 case 0xebf2: /* LOC - load on condition */
6148 /* 32-bit or native gpr destination */
6149 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
6153 case 0xe320: /* CG - compare */
6154 case 0xe321: /* CLG - compare logical */
6155 case 0xe330: /* CGF - compare */
6156 case 0xe331: /* CLGF - compare logical */
6157 case 0xe334: /* CGH - compare halfword */
6158 case 0xe355: /* CLY - compare logical */
6159 case 0xe359: /* CY - compare */
6160 case 0xe379: /* CHY - compare halfword */
6161 case 0xe3cd: /* CHF - compare high */
6162 case 0xe3cf: /* CLHF - compare logical high */
6163 case 0xeb20: /* CLMH - compare logical under mask high */
6164 case 0xeb21: /* CLMY - compare logical under mask */
6165 case 0xeb51: /* TMY - test under mask */
6166 case 0xeb55: /* CLIY - compare logical */
6167 case 0xebc0: /* TP - test decimal */
6168 case 0xed10: /* TCEB - test data class */
6169 case 0xed11: /* TCDB - test data class */
6170 case 0xed12: /* TCXB - test data class */
6171 case 0xed50: /* TDCET - test data class */
6172 case 0xed51: /* TDGET - test data group */
6173 case 0xed54: /* TDCDT - test data class */
6174 case 0xed55: /* TDGDT - test data group */
6175 case 0xed58: /* TDCXT - test data class */
6176 case 0xed59: /* TDGXT - test data group */
6178 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
6182 /* 0xe322-0xe323 undefined */
6184 case 0xe324: /* STG - store */
6185 case 0xe325: /* NTSTG - nontransactional store */
6186 case 0xe326: /* CVDY - convert to decimal */
6187 case 0xe32f: /* STRVG - store reversed */
6188 case 0xebe3: /* STOCG - store on condition */
6189 case 0xed67: /* STDY - store */
6190 oaddr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], ibyte[4]);
6191 if (record_full_arch_list_add_mem (oaddr, 8))
6195 /* 0xe327-0xe329 undefined */
6196 /* 0xe32b-0xe32d undefined */
6198 case 0xe32e: /* CVDG - convert to decimal */
6199 case 0xe38e: /* STPQ - store pair to quadword */
6200 oaddr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], ibyte[4]);
6201 if (record_full_arch_list_add_mem (oaddr, 16))
6205 /* 0xe333 undefined */
6206 /* 0xe335 undefined */
6208 case 0xe336: /* PFD - prefetch data */
6211 /* 0xe337-0xe339 undefined */
6212 /* 0xe33c-0xe33d undefined */
6214 case 0xe33e: /* STRV - store reversed */
6215 case 0xe350: /* STY - store */
6216 case 0xe3cb: /* STFH - store high */
6217 case 0xebe1: /* STOCFH - store high on condition */
6218 case 0xebf3: /* STOC - store on condition */
6219 case 0xed66: /* STEY - store */
6220 oaddr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], ibyte[4]);
6221 if (record_full_arch_list_add_mem (oaddr, 4))
6225 case 0xe33f: /* STRVH - store reversed */
6226 case 0xe370: /* STHY - store halfword */
6227 case 0xe3c7: /* STHH - store halfword high */
6228 oaddr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], ibyte[4]);
6229 if (record_full_arch_list_add_mem (oaddr, 2))
6233 /* 0xe340-0xe345 undefined */
6234 /* 0xe347-0xe34f undefined */
6235 /* 0xe352-0xe353 undefined */
6237 case 0xe35c: /* MFY - multiply */
6238 case 0xe396: /* ML - multiply logical */
6239 case 0xe397: /* DL - divide logical */
6240 /* 32-bit gpr pair destination */
6241 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
6243 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[2] | 1)))
6247 /* 0xe35d undefined */
6248 /* 0xe360-0xe36f undefined */
6250 case 0xe372: /* STCY - store character */
6251 case 0xe3c3: /* STCH - store character high */
6252 oaddr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], ibyte[4]);
6253 if (record_full_arch_list_add_mem (oaddr, 1))
6257 /* 0xe374 undefined */
6259 case 0xe375: /* LAEY - load address extended */
6260 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
6262 if (record_full_arch_list_add_reg (regcache, S390_A0_REGNUM + inib[2]))
6266 /* 0xe37d-0xe37f undefined */
6267 /* 0xe383-0xe384 undefined */
6269 case 0xe385: /* LGAT - load and trap */
6270 case 0xe39c: /* LLGTAT - load logical thirty one bits and trap */
6271 case 0xe39d: /* LLGFAT - load logical and trap */
6272 case 0xe721: /* VLGV - vector load gr from vr element */
6273 /* 64-bit gpr destination + fpc for possible DXC write */
6274 if (s390_record_gpr_g (gdbarch, regcache, inib[2]))
6276 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
6280 /* 0xe38a-0xe38d undefined */
6281 /* 0xe392-0xe393 undefined */
6282 /* 0xe39a-0xe39b undefined */
6283 /* 0xe39e undefined */
6285 case 0xe39f: /* LAT - load and trap */
6286 /* 32-bit gpr destination + fpc for possible DXC write */
6287 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
6289 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
6293 /* 0xe3a0-0xe3bf undefined */
6295 case 0xe3c0: /* LBH - load byte high */
6296 case 0xe3c2: /* LLCH - load logical character high */
6297 case 0xe3c4: /* LHH - load halfword high */
6298 case 0xe3c6: /* LLHH - load logical halfword high */
6299 case 0xe3ca: /* LFH - load high */
6300 case 0xebe0: /* LOCFH - load high on condition */
6301 /* 32-bit high gpr destination */
6302 if (s390_record_gpr_h (gdbarch, regcache, inib[2]))
6306 /* 0xe3c1 undefined */
6307 /* 0xe3c5 undefined */
6309 case 0xe3c8: /* LFHAT - load high and trap */
6310 /* 32-bit high gpr destination + fpc for possible DXC write */
6311 if (s390_record_gpr_h (gdbarch, regcache, inib[2]))
6313 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
6317 /* 0xe3c9 undefined */
6318 /* 0xe3cc undefined */
6319 /* 0xe3ce undefined */
6320 /* 0xe3d0-0xe3ff undefined */
6322 case 0xe700: /* VLEB - vector load element */
6323 case 0xe701: /* VLEH - vector load element */
6324 case 0xe702: /* VLEG - vector load element */
6325 case 0xe703: /* VLEF - vector load element */
6326 case 0xe704: /* VLLEZ - vector load logical element and zero */
6327 case 0xe705: /* VLREP - vector load and replicate */
6328 case 0xe706: /* VL - vector load */
6329 case 0xe707: /* VLBB - vector load to block bounduary */
6330 case 0xe712: /* VGEG - vector gather element */
6331 case 0xe713: /* VGEF - vector gather element */
6332 case 0xe722: /* VLVG - vector load vr element from gr */
6333 case 0xe730: /* VESL - vector element shift left */
6334 case 0xe733: /* VERLL - vector element rotate left logical */
6335 case 0xe737: /* VLL - vector load with length */
6336 case 0xe738: /* VESRL - vector element shift right logical */
6337 case 0xe73a: /* VESRA - vector element shift right arithmetic */
6338 case 0xe740: /* VLEIB - vector load element immediate */
6339 case 0xe741: /* VLEIH - vector load element immediate */
6340 case 0xe742: /* VLEIG - vector load element immediate */
6341 case 0xe743: /* VLEIF - vector load element immediate */
6342 case 0xe744: /* VGBM - vector generate byte mask */
6343 case 0xe745: /* VREPI - vector replicate immediate */
6344 case 0xe746: /* VGM - vector generate mask */
6345 case 0xe74d: /* VREP - vector replicate */
6346 case 0xe750: /* VPOPCT - vector population count */
6347 case 0xe752: /* VCTZ - vector count trailing zeros */
6348 case 0xe753: /* VCLZ - vector count leading zeros */
6349 case 0xe756: /* VLR - vector load */
6350 case 0xe75f: /* VSEG -vector sign extend to doubleword */
6351 case 0xe760: /* VMRL - vector merge low */
6352 case 0xe761: /* VMRH - vector merge high */
6353 case 0xe762: /* VLVGP - vector load vr from grs disjoint */
6354 case 0xe764: /* VSUM - vector sum across word */
6355 case 0xe765: /* VSUMG - vector sum across doubleword */
6356 case 0xe766: /* VCKSM - vector checksum */
6357 case 0xe767: /* VSUMQ - vector sum across quadword */
6358 case 0xe768: /* VN - vector and */
6359 case 0xe769: /* VNC - vector and with complement */
6360 case 0xe76a: /* VO - vector or */
6361 case 0xe76b: /* VNO - vector nor */
6362 case 0xe76d: /* VX - vector xor */
6363 case 0xe770: /* VESLV - vector element shift left */
6364 case 0xe772: /* VERIM - vector element rotate and insert under mask */
6365 case 0xe773: /* VERLLV - vector element rotate left logical */
6366 case 0xe774: /* VSL - vector shift left */
6367 case 0xe775: /* VSLB - vector shift left by byte */
6368 case 0xe777: /* VSLDB - vector shift left double by byte */
6369 case 0xe778: /* VESRLV - vector element shift right logical */
6370 case 0xe77a: /* VESRAV - vector element shift right arithmetic */
6371 case 0xe77c: /* VSRL - vector shift right logical */
6372 case 0xe77d: /* VSRLB - vector shift right logical by byte */
6373 case 0xe77e: /* VSRA - vector shift right arithmetic */
6374 case 0xe77f: /* VSRAB - vector shift right arithmetic by byte */
6375 case 0xe784: /* VPDI - vector permute doubleword immediate */
6376 case 0xe78c: /* VPERM - vector permute */
6377 case 0xe78d: /* VSEL - vector select */
6378 case 0xe78e: /* VFMS - vector fp multiply and subtract */
6379 case 0xe78f: /* VFMA - vector fp multiply and add */
6380 case 0xe794: /* VPK - vector pack */
6381 case 0xe7a1: /* VMLH - vector multiply logical high */
6382 case 0xe7a2: /* VML - vector multiply low */
6383 case 0xe7a3: /* VMH - vector multiply high */
6384 case 0xe7a4: /* VMLE - vector multiply logical even */
6385 case 0xe7a5: /* VMLO - vector multiply logical odd */
6386 case 0xe7a6: /* VME - vector multiply even */
6387 case 0xe7a7: /* VMO - vector multiply odd */
6388 case 0xe7a9: /* VMALH - vector multiply and add logical high */
6389 case 0xe7aa: /* VMAL - vector multiply and add low */
6390 case 0xe7ab: /* VMAH - vector multiply and add high */
6391 case 0xe7ac: /* VMALE - vector multiply and add logical even */
6392 case 0xe7ad: /* VMALO - vector multiply and add logical odd */
6393 case 0xe7ae: /* VMAE - vector multiply and add even */
6394 case 0xe7af: /* VMAO - vector multiply and add odd */
6395 case 0xe7b4: /* VGFM - vector Galois field multiply sum */
6396 case 0xe7b9: /* VACCC - vector add with carry compute carry */
6397 case 0xe7bb: /* VAC - vector add with carry */
6398 case 0xe7bc: /* VGFMA - vector Galois field multiply sum and accumulate */
6399 case 0xe7bd: /* VSBCBI - vector subtract with borrow compute borrow indication */
6400 case 0xe7bf: /* VSBI - vector subtract with borrow indication */
6401 case 0xe7c0: /* VCLGD - vector convert to logical 64-bit */
6402 case 0xe7c1: /* VCDLG - vector convert from logical 64-bit */
6403 case 0xe7c2: /* VCGD - vector convert to fixed 64-bit */
6404 case 0xe7c3: /* VCDG - vector convert from fixed 64-bit */
6405 case 0xe7c4: /* VLDE - vector fp load lengthened */
6406 case 0xe7c5: /* VLED - vector fp load rounded */
6407 case 0xe7c7: /* VFI - vector load fp integer */
6408 case 0xe7cc: /* VFPSO - vector fp perform sign operation */
6409 case 0xe7ce: /* VFSQ - vector fp square root */
6410 case 0xe7d4: /* VUPLL - vector unpack logical low */
6411 case 0xe7d6: /* VUPL - vector unpack low */
6412 case 0xe7d5: /* VUPLH - vector unpack logical high */
6413 case 0xe7d7: /* VUPH - vector unpack high */
6414 case 0xe7de: /* VLC - vector load complement */
6415 case 0xe7df: /* VLP - vector load positive */
6416 case 0xe7e2: /* VFA - vector fp subtract */
6417 case 0xe7e3: /* VFA - vector fp add */
6418 case 0xe7e5: /* VFD - vector fp divide */
6419 case 0xe7e7: /* VFM - vector fp multiply */
6420 case 0xe7f0: /* VAVGL - vector average logical */
6421 case 0xe7f1: /* VACC - vector add and compute carry */
6422 case 0xe7f2: /* VAVG - vector average */
6423 case 0xe7f3: /* VA - vector add */
6424 case 0xe7f5: /* VSCBI - vector subtract compute borrow indication */
6425 case 0xe7f7: /* VS - vector subtract */
6426 case 0xe7fc: /* VMNL - vector minimum logical */
6427 case 0xe7fd: /* VMXL - vector maximum logical */
6428 case 0xe7fe: /* VMN - vector minimum */
6429 case 0xe7ff: /* VMX - vector maximum */
6430 /* vector destination + FPC */
6431 if (s390_record_vr (gdbarch, regcache, ivec[0]))
6433 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
6437 case 0xe708: /* VSTEB - vector store element */
6438 oaddr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], 0);
6439 if (record_full_arch_list_add_mem (oaddr, 1))
6441 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
6445 case 0xe709: /* VSTEH - vector store element */
6446 oaddr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], 0);
6447 if (record_full_arch_list_add_mem (oaddr, 2))
6449 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
6453 case 0xe70a: /* VSTEG - vector store element */
6454 oaddr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], 0);
6455 if (record_full_arch_list_add_mem (oaddr, 8))
6457 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
6461 case 0xe70b: /* VSTEF - vector store element */
6462 oaddr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], 0);
6463 if (record_full_arch_list_add_mem (oaddr, 4))
6465 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
6469 /* 0xe70c-0xe70d undefined */
6471 case 0xe70e: /* VST - vector store */
6472 oaddr = s390_record_calc_disp (gdbarch, regcache, inib[3], insn[1], 0);
6473 if (record_full_arch_list_add_mem (oaddr, 16))
6475 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
6479 /* 0xe70f-0xe711 undefined */
6480 /* 0xe714-0xe719 undefined */
6482 case 0xe71a: /* VSCEG - vector scatter element */
6483 if (s390_record_calc_disp_vsce (gdbarch, regcache, ivec[1], inib[8], 8, insn[1], 0, &oaddr))
6485 if (record_full_arch_list_add_mem (oaddr, 8))
6487 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
6491 case 0xe71b: /* VSCEF - vector scatter element */
6492 if (s390_record_calc_disp_vsce (gdbarch, regcache, ivec[1], inib[8], 4, insn[1], 0, &oaddr))
6494 if (record_full_arch_list_add_mem (oaddr, 4))
6496 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
6500 /* 0xe71c-0xe720 undefined */
6501 /* 0xe723-0xe726 undefined */
6502 /* 0xe728-0xe72f undefined */
6503 /* 0xe731-0xe732 undefined */
6504 /* 0xe734-0xe735 undefined */
6506 case 0xe736: /* VLM - vector load multiple */
6507 for (i = ivec[0]; i != ivec[1]; i++, i &= 0x1f)
6508 if (s390_record_vr (gdbarch, regcache, i))
6510 if (s390_record_vr (gdbarch, regcache, ivec[1]))
6512 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
6516 /* 0xe739 undefined */
6517 /* 0xe73b-0xe73d undefined */
6519 case 0xe73e: /* VSTM - vector store multiple */
6520 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
6521 if (ivec[0] <= ivec[1])
6522 n = ivec[1] - ivec[0] + 1;
6524 n = ivec[1] + 0x20 - ivec[0] + 1;
6525 if (record_full_arch_list_add_mem (oaddr, n * 16))
6527 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
6531 case 0xe73f: /* VSTL - vector store with length */
6532 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
6533 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[3], &tmp);
6537 if (record_full_arch_list_add_mem (oaddr, tmp))
6539 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
6543 /* 0xe747-0xe749 undefined */
6545 case 0xe74a: /* VFTCI - vector fp test data class immediate */
6546 case 0xe75c: /* VISTR - vector isolate string */
6547 case 0xe780: /* VFEE - vector find element equal */
6548 case 0xe781: /* VFENE - vector find element not equal */
6549 case 0xe782: /* VFA - vector find any element equal */
6550 case 0xe78a: /* VSTRC - vector string range compare */
6551 case 0xe795: /* VPKLS - vector pack logical saturate */
6552 case 0xe797: /* VPKS - vector pack saturate */
6553 case 0xe7e8: /* VFCE - vector fp compare equal */
6554 case 0xe7ea: /* VFCHE - vector fp compare high or equal */
6555 case 0xe7eb: /* VFCE - vector fp compare high */
6556 case 0xe7f8: /* VCEQ - vector compare equal */
6557 case 0xe7f9: /* VCHL - vector compare high logical */
6558 case 0xe7fb: /* VCH - vector compare high */
6559 /* vector destination + flags + FPC */
6560 if (s390_record_vr (gdbarch, regcache, ivec[0]))
6562 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
6564 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
6568 /* 0xe74b-0xe74c undefined */
6569 /* 0xe74e-0xe74f undefined */
6570 /* 0xe751 undefined */
6571 /* 0xe754-0xe755 undefined */
6572 /* 0xe757-0xe75b undefined */
6573 /* 0xe75d-0xe75e undefined */
6574 /* 0xe763 undefined */
6575 /* 0xe76c undefined */
6576 /* 0xe76e-0xe76f undefined */
6577 /* 0xe771 undefined */
6578 /* 0xe776 undefined */
6579 /* 0xe779 undefined */
6580 /* 0xe77b undefined */
6581 /* 0xe783 undefined */
6582 /* 0xe785-0xe789 undefined */
6583 /* 0xe78b undefined */
6584 /* 0xe790-0xe793 undefined */
6585 /* 0xe796 undefined */
6586 /* 0xe798-0xe7a0 undefined */
6587 /* 0xe7a8 undefined */
6588 /* 0xe7b0-0xe7b3 undefined */
6589 /* 0xe7b5-0xe7b8 undefined */
6590 /* 0xe7ba undefined */
6591 /* 0xe7be undefined */
6592 /* 0xe7c6 undefined */
6593 /* 0xe7c8-0xe7c9 undefined */
6595 case 0xe7ca: /* WFK - vector fp compare and signal scalar */
6596 case 0xe7cb: /* WFC - vector fp compare scalar */
6597 case 0xe7d8: /* VTM - vector test under mask */
6598 case 0xe7d9: /* VECL - vector element compare logical */
6599 case 0xe7db: /* VEC - vector element compare */
6600 case 0xed08: /* KEB - compare and signal */
6601 case 0xed09: /* CEB - compare */
6602 case 0xed18: /* KDB - compare and signal */
6603 case 0xed19: /* CDB - compare */
6604 /* flags + fpc only */
6605 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
6607 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
6611 /* 0xe7cd undefined */
6612 /* 0xe7cf-0xe7d3 undefined */
6613 /* 0xe7da undefined */
6614 /* 0xe7dc-0xe7dd undefined */
6615 /* 0xe7e0-0xe7e1 undefined */
6616 /* 0xe7e4 undefined */
6617 /* 0xe7e6 undefined */
6618 /* 0xe7e9 undefined */
6619 /* 0xe7ec-0xe7ef undefined */
6620 /* 0xe7f4 undefined */
6621 /* 0xe7f6 undefined */
6622 /* 0xe7fa undefined */
6624 /* 0xeb00-0xeb03 undefined */
6626 case 0xeb04: /* LMG - load multiple */
6627 for (i = inib[2]; i != inib[3]; i++, i &= 0xf)
6628 if (s390_record_gpr_g (gdbarch, regcache, i))
6630 if (s390_record_gpr_g (gdbarch, regcache, inib[3]))
6634 /* 0xeb05-0xeb09 undefined */
6635 /* 0xeb0e undefined */
6636 /* 0xeb0f privileged: TRACG */
6637 /* 0xeb10-0xeb13 undefined */
6639 case 0xeb14: /* CSY - compare and swap */
6640 case 0xebf4: /* LAN - load and and */
6641 case 0xebf6: /* LAO - load and or */
6642 case 0xebf7: /* LAX - load and xor */
6643 case 0xebf8: /* LAA - load and add */
6644 case 0xebfa: /* LAAL - load and add logical */
6645 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], ibyte[4]);
6646 if (record_full_arch_list_add_mem (oaddr, 4))
6648 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
6650 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
6654 /* 0xeb15-0xeb1b undefined */
6655 /* 0xeb1e-0xeb1f undefined */
6656 /* 0xeb22 undefined */
6658 case 0xeb23: /* CLT - compare logical and trap */
6659 case 0xeb2b: /* CLGT - compare logical and trap */
6660 /* fpc only - including possible DXC write for trapping insns */
6661 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
6665 case 0xeb24: /* STMG - store multiple */
6666 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], ibyte[4]);
6667 if (inib[2] <= inib[3])
6668 n = inib[3] - inib[2] + 1;
6670 n = inib[3] + 0x10 - inib[2] + 1;
6671 if (record_full_arch_list_add_mem (oaddr, n * 8))
6675 /* 0xeb25 privileged */
6677 case 0xeb26: /* STMH - store multiple high */
6678 case 0xeb90: /* STMY - store multiple */
6679 case 0xeb9b: /* STAMY - store access multiple */
6680 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], ibyte[4]);
6681 if (inib[2] <= inib[3])
6682 n = inib[3] - inib[2] + 1;
6684 n = inib[3] + 0x10 - inib[2] + 1;
6685 if (record_full_arch_list_add_mem (oaddr, n * 4))
6689 /* 0xeb27-0xeb2a undefined */
6691 case 0xeb2c: /* STCMH - store characters under mask */
6692 case 0xeb2d: /* STCMY - store characters under mask */
6693 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], ibyte[4]);
6694 if (record_full_arch_list_add_mem (oaddr, s390_popcnt (inib[3])))
6698 /* 0xeb2e undefined */
6699 /* 0xeb2f privileged */
6701 case 0xeb30: /* CSG - compare and swap */
6702 case 0xebe4: /* LANG - load and and */
6703 case 0xebe6: /* LAOG - load and or */
6704 case 0xebe7: /* LAXG - load and xor */
6705 case 0xebe8: /* LAAG - load and add */
6706 case 0xebea: /* LAALG - load and add logical */
6707 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], ibyte[4]);
6708 if (record_full_arch_list_add_mem (oaddr, 8))
6710 if (s390_record_gpr_g (gdbarch, regcache, inib[2]))
6712 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
6716 case 0xeb31: /* CDSY - compare double and swap */
6717 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], ibyte[4]);
6718 if (record_full_arch_list_add_mem (oaddr, 8))
6720 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
6722 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[2] | 1)))
6724 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
6728 /* 0xeb32-0xeb3d undefined */
6730 case 0xeb3e: /* CDSG - compare double and swap */
6731 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], ibyte[4]);
6732 if (record_full_arch_list_add_mem (oaddr, 16))
6734 if (s390_record_gpr_g (gdbarch, regcache, inib[2]))
6736 if (s390_record_gpr_g (gdbarch, regcache, inib[2] | 1))
6738 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
6742 /* 0xeb3f-0xeb43 undefined */
6743 /* 0xeb46-0xeb4b undefined */
6744 /* 0xeb4d-0xeb50 undefined */
6746 case 0xeb52: /* MVIY - move */
6747 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], ibyte[4]);
6748 if (record_full_arch_list_add_mem (oaddr, 1))
6752 case 0xeb54: /* NIY - and */
6753 case 0xeb56: /* OIY - or */
6754 case 0xeb57: /* XIY - xor */
6755 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], ibyte[4]);
6756 if (record_full_arch_list_add_mem (oaddr, 1))
6758 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
6762 /* 0xeb53 undefined */
6763 /* 0xeb58-0xeb69 undefined */
6765 case 0xeb6a: /* ASI - add immediate */
6766 case 0xeb6e: /* ALSI - add immediate */
6767 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], ibyte[4]);
6768 if (record_full_arch_list_add_mem (oaddr, 4))
6770 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
6774 /* 0xeb6b-0xeb6d undefined */
6775 /* 0xeb6f-0xeb79 undefined */
6777 case 0xeb7a: /* AGSI - add immediate */
6778 case 0xeb7e: /* ALGSI - add immediate */
6779 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], ibyte[4]);
6780 if (record_full_arch_list_add_mem (oaddr, 8))
6782 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
6786 /* 0xeb7b-0xeb7d undefined */
6787 /* 0xeb7f undefined */
6789 case 0xeb80: /* ICMH - insert characters under mask */
6790 /* 32-bit high gpr destination + flags */
6791 if (s390_record_gpr_h (gdbarch, regcache, inib[2]))
6793 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
6797 /* 0xeb82-0xeb8d undefined */
6799 case 0xeb8e: /* MVCLU - move long unicode [partial] */
6800 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + inib[2], &tmp);
6801 oaddr = s390_record_address_mask (gdbarch, regcache, tmp);
6802 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM + (inib[2] | 1), &tmp);
6803 if (record_full_arch_list_add_mem (oaddr, tmp))
6805 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
6807 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[2] | 1)))
6809 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[3]))
6811 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[3] | 1)))
6813 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
6817 case 0xeb8f: /* CLCLU - compare logical long unicode [partial] */
6818 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
6820 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[2] | 1)))
6822 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[3]))
6824 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + (inib[3] | 1)))
6826 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
6830 /* 0xeb91-0xeb95 undefined */
6832 case 0xeb96: /* LMH - load multiple high */
6833 for (i = inib[2]; i != inib[3]; i++, i &= 0xf)
6834 if (s390_record_gpr_h (gdbarch, regcache, i))
6836 if (s390_record_gpr_h (gdbarch, regcache, inib[3]))
6840 /* 0xeb97 undefined */
6842 case 0xeb98: /* LMY - load multiple */
6843 for (i = inib[2]; i != inib[3]; i++, i &= 0xf)
6844 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + i))
6846 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[3]))
6850 /* 0xeb99 undefined */
6852 case 0xeb9a: /* LAMY - load access multiple */
6853 for (i = inib[2]; i != inib[3]; i++, i &= 0xf)
6854 if (record_full_arch_list_add_reg (regcache, S390_A0_REGNUM + i))
6856 if (record_full_arch_list_add_reg (regcache, S390_A0_REGNUM + inib[3]))
6860 /* 0xeb9c-0xebbf undefined */
6861 /* 0xebc1-0xebdb undefined */
6862 /* 0xebe5 undefined */
6863 /* 0xebe9 undefined */
6864 /* 0xebeb-0xebf1 undefined */
6865 /* 0xebf5 undefined */
6866 /* 0xebf9 undefined */
6867 /* 0xebfb-0xebff undefined */
6869 /* 0xed00-0xed03 undefined */
6871 case 0xed04: /* LDEB - load lengthened */
6872 case 0xed0c: /* MDEB - multiply */
6873 case 0xed0d: /* DEB - divide */
6874 case 0xed14: /* SQEB - square root */
6875 case 0xed15: /* SQDB - square root */
6876 case 0xed17: /* MEEB - multiply */
6877 case 0xed1c: /* MDB - multiply */
6878 case 0xed1d: /* DDB - divide */
6879 /* float destination + fpc */
6880 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[2]))
6882 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
6886 case 0xed05: /* LXDB - load lengthened */
6887 case 0xed06: /* LXEB - load lengthened */
6888 case 0xed07: /* MXDB - multiply */
6889 /* float pair destination + fpc */
6890 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[2]))
6892 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + (inib[2] | 2)))
6894 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
6898 case 0xed0a: /* AEB - add */
6899 case 0xed0b: /* SEB - subtract */
6900 case 0xed1a: /* ADB - add */
6901 case 0xed1b: /* SDB - subtract */
6902 /* float destination + flags + fpc */
6903 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[2]))
6905 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
6907 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
6911 case 0xed0e: /* MAEB - multiply and add */
6912 case 0xed0f: /* MSEB - multiply and subtract */
6913 case 0xed1e: /* MADB - multiply and add */
6914 case 0xed1f: /* MSDB - multiply and subtract */
6915 case 0xed40: /* SLDT - shift significand left */
6916 case 0xed41: /* SRDT - shift significand right */
6917 case 0xedaa: /* CDZT - convert from zoned */
6918 case 0xedae: /* CDPT - convert from packed */
6919 /* float destination [RXF] + fpc */
6920 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[8]))
6922 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
6926 /* 0xed13 undefined */
6927 /* 0xed16 undefined */
6928 /* 0xed20-0xed23 undefined */
6930 case 0xed24: /* LDE - load lengthened */
6931 case 0xed34: /* SQE - square root */
6932 case 0xed35: /* SQD - square root */
6933 case 0xed37: /* MEE - multiply */
6934 case 0xed64: /* LEY - load */
6935 case 0xed65: /* LDY - load */
6936 /* float destination */
6937 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[2]))
6941 case 0xed25: /* LXD - load lengthened */
6942 case 0xed26: /* LXE - load lengthened */
6943 /* float pair destination */
6944 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[2]))
6946 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + (inib[2] | 2)))
6950 /* 0xed27-0xed2d undefined */
6952 case 0xed2e: /* MAE - multiply and add */
6953 case 0xed2f: /* MSE - multiply and subtract */
6954 case 0xed38: /* MAYL - multiply and add unnormalized */
6955 case 0xed39: /* MYL - multiply unnormalized */
6956 case 0xed3c: /* MAYH - multiply and add unnormalized */
6957 case 0xed3d: /* MYH - multiply unnormalized */
6958 case 0xed3e: /* MAD - multiply and add */
6959 case 0xed3f: /* MSD - multiply and subtract */
6960 /* float destination [RXF] */
6961 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[8]))
6965 /* 0xed30-0xed33 undefined */
6966 /* 0xed36 undefined */
6968 case 0xed3a: /* MAY - multiply and add unnormalized */
6969 case 0xed3b: /* MY - multiply unnormalized */
6970 /* float pair destination [RXF] */
6971 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[8]))
6973 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + (inib[8] | 2)))
6977 /* 0xed42-0xed47 undefind */
6979 case 0xed48: /* SLXT - shift significand left */
6980 case 0xed49: /* SRXT - shift significand right */
6981 case 0xedab: /* CXZT - convert from zoned */
6982 case 0xedaf: /* CXPT - convert from packed */
6983 /* float pair destination [RXF] + fpc */
6984 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + inib[8]))
6986 if (record_full_arch_list_add_reg (regcache, S390_F0_REGNUM + (inib[8] | 2)))
6988 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
6992 /* 0xed4a-0xed4f undefind */
6993 /* 0xed52-0xed53 undefind */
6994 /* 0xed56-0xed57 undefind */
6995 /* 0xed5a-0xed63 undefind */
6996 /* 0xed68-0xeda7 undefined */
6998 case 0xeda8: /* CZDT - convert to zoned */
6999 case 0xeda9: /* CZXT - convert to zoned */
7000 case 0xedac: /* CPDT - convert to packed */
7001 case 0xedad: /* CPXT - convert to packed */
7002 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
7003 if (record_full_arch_list_add_mem (oaddr, ibyte[1] + 1))
7005 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
7009 /* 0xedb0-0xedff undefined */
7016 /* 0xe4 undefined */
7019 /* SSE/SIL-format instruction */
7022 /* 0xe500-0xe543 undefined, privileged, or unsupported */
7024 case 0xe544: /* MVHHI - move */
7025 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
7026 if (record_full_arch_list_add_mem (oaddr, 2))
7030 /* 0xe545-0xe547 undefined */
7032 case 0xe548: /* MVGHI - move */
7033 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
7034 if (record_full_arch_list_add_mem (oaddr, 8))
7038 /* 0xe549-0xe54b undefined */
7040 case 0xe54c: /* MVHI - move */
7041 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
7042 if (record_full_arch_list_add_mem (oaddr, 4))
7046 /* 0xe54d-0xe553 undefined */
7048 case 0xe554: /* CHHSI - compare halfword immediate */
7049 case 0xe555: /* CLHHSI - compare logical immediate */
7050 case 0xe558: /* CGHSI - compare halfword immediate */
7051 case 0xe559: /* CLGHSI - compare logical immediate */
7052 case 0xe55c: /* CHSI - compare halfword immediate */
7053 case 0xe55d: /* CLFHSI - compare logical immediate */
7054 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
7058 /* 0xe556-0xe557 undefined */
7059 /* 0xe55a-0xe55b undefined */
7060 /* 0xe55e-0xe55f undefined */
7062 case 0xe560: /* TBEGIN - transaction begin */
7063 /* The transaction will be immediately aborted after this
7064 instruction, due to single-stepping. This instruction is
7065 only supported so that the program can fail a few times
7066 and go to the non-transactional fallback. */
7069 /* Transaction diagnostic block - user. */
7070 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
7071 if (record_full_arch_list_add_mem (oaddr, 256))
7074 /* Transaction diagnostic block - supervisor. */
7075 if (record_full_arch_list_add_reg (regcache, S390_TDB_DWORD0_REGNUM))
7077 if (record_full_arch_list_add_reg (regcache, S390_TDB_ABORT_CODE_REGNUM))
7079 if (record_full_arch_list_add_reg (regcache, S390_TDB_CONFLICT_TOKEN_REGNUM))
7081 if (record_full_arch_list_add_reg (regcache, S390_TDB_ATIA_REGNUM))
7083 for (i = 0; i < 16; i++)
7084 if (record_full_arch_list_add_reg (regcache, S390_TDB_R0_REGNUM + i))
7087 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
7091 /* 0xe561 unsupported: TBEGINC */
7092 /* 0xe562-0xe5ff undefined */
7099 /* 0xe6 undefined */
7102 /* RIE/RIS/RRS-format instruction */
7103 switch (ibyte[0] << 8 | ibyte[5])
7105 /* 0xec00-0xec41 undefined */
7107 case 0xec42: /* LOCHI - load halfword immediate on condition */
7108 case 0xec51: /* RISBLG - rotate then insert selected bits low */
7109 /* 32-bit or native gpr destination */
7110 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
7114 /* 0xec43 undefined */
7116 case 0xec44: /* BRXHG - branch relative on index high */
7117 case 0xec45: /* BRXLG - branch relative on index low or equal */
7118 case 0xec46: /* LOCGHI - load halfword immediate on condition */
7119 case 0xec59: /* RISBGN - rotate then insert selected bits */
7120 /* 64-bit gpr destination */
7121 if (s390_record_gpr_g (gdbarch, regcache, inib[2]))
7125 /* 0xec47-0xec4d undefined */
7127 case 0xec4e: /* LOCHHI - load halfword immediate on condition */
7128 case 0xec5d: /* RISBHG - rotate then insert selected bits high */
7129 /* 32-bit high gpr destination */
7130 if (s390_record_gpr_h (gdbarch, regcache, inib[2]))
7134 /* 0xec4f-0xec50 undefined */
7135 /* 0xec52-0xec53 undefined */
7137 case 0xec54: /* RNSBG - rotate then and selected bits */
7138 case 0xec55: /* RISBG - rotate then insert selected bits */
7139 case 0xec56: /* ROSBG - rotate then or selected bits */
7140 case 0xec57: /* RXSBG - rotate then xor selected bits */
7141 case 0xecd9: /* AGHIK - add immediate */
7142 case 0xecdb: /* ALGHSIK - add logical immediate */
7143 /* 64-bit gpr destination + flags */
7144 if (s390_record_gpr_g (gdbarch, regcache, inib[2]))
7146 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
7150 /* 0xec58 undefined */
7151 /* 0xec5a-0xec5c undefined */
7152 /* 0xec5e-0xec63 undefined */
7154 case 0xec64: /* CGRJ - compare and branch relative */
7155 case 0xec65: /* CLGRJ - compare logical and branch relative */
7156 case 0xec76: /* CRJ - compare and branch relative */
7157 case 0xec77: /* CLRJ - compare logical and branch relative */
7158 case 0xec7c: /* CGIJ - compare immediate and branch relative */
7159 case 0xec7d: /* CLGIJ - compare logical immediate and branch relative */
7160 case 0xec7e: /* CIJ - compare immediate and branch relative */
7161 case 0xec7f: /* CLIJ - compare logical immediate and branch relative */
7162 case 0xece4: /* CGRB - compare and branch */
7163 case 0xece5: /* CLGRB - compare logical and branch */
7164 case 0xecf6: /* CRB - compare and branch */
7165 case 0xecf7: /* CLRB - compare logical and branch */
7166 case 0xecfc: /* CGIB - compare immediate and branch */
7167 case 0xecfd: /* CLGIB - compare logical immediate and branch */
7168 case 0xecfe: /* CIB - compare immediate and branch */
7169 case 0xecff: /* CLIB - compare logical immediate and branch */
7172 /* 0xec66-0xec6f undefined */
7174 case 0xec70: /* CGIT - compare immediate and trap */
7175 case 0xec71: /* CLGIT - compare logical immediate and trap */
7176 case 0xec72: /* CIT - compare immediate and trap */
7177 case 0xec73: /* CLFIT - compare logical immediate and trap */
7178 /* fpc only - including possible DXC write for trapping insns */
7179 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
7183 /* 0xec74-0xec75 undefined */
7184 /* 0xec78-0xec7b undefined */
7186 /* 0xec80-0xecd7 undefined */
7188 case 0xecd8: /* AHIK - add immediate */
7189 case 0xecda: /* ALHSIK - add logical immediate */
7190 /* 32-bit gpr destination + flags */
7191 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
7193 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
7197 /* 0xecdc-0xece3 undefined */
7198 /* 0xece6-0xecf5 undefined */
7199 /* 0xecf8-0xecfb undefined */
7206 case 0xee: /* PLO - perform locked operation */
7207 regcache_raw_read_unsigned (regcache, S390_R0_REGNUM, &tmp);
7208 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
7209 oaddr2 = s390_record_calc_disp (gdbarch, regcache, 0, insn[2], 0);
7212 uint8_t fc = tmp & 0xff;
7218 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
7221 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[3]))
7225 case 0x01: /* CLG */
7227 if (record_full_arch_list_add_mem (oaddr2 + 0x08, 8))
7230 if (record_full_arch_list_add_mem (oaddr2 + 0x28, 8))
7234 case 0x02: /* CLGR */
7236 if (s390_record_gpr_g (gdbarch, regcache, inib[2]))
7239 if (s390_record_gpr_g (gdbarch, regcache, inib[3]))
7243 case 0x03: /* CLX */
7245 if (record_full_arch_list_add_mem (oaddr2 + 0x00, 16))
7248 if (record_full_arch_list_add_mem (oaddr2 + 0x20, 16))
7252 case 0x08: /* DCS */
7254 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[3]))
7257 case 0x0c: /* CSST */
7259 if (record_full_arch_list_add_mem (oaddr2, 4))
7263 case 0x14: /* CSTST */
7265 if (target_read_memory (oaddr2 + 0x88, buf, 8))
7267 oaddr3 = extract_unsigned_integer (buf, 8, byte_order);
7268 oaddr3 = s390_record_address_mask (gdbarch, regcache, oaddr3);
7269 if (record_full_arch_list_add_mem (oaddr3, 4))
7272 case 0x10: /* CSDST */
7274 if (target_read_memory (oaddr2 + 0x68, buf, 8))
7276 oaddr3 = extract_unsigned_integer (buf, 8, byte_order);
7277 oaddr3 = s390_record_address_mask (gdbarch, regcache, oaddr3);
7278 if (record_full_arch_list_add_mem (oaddr3, 4))
7281 if (target_read_memory (oaddr2 + 0x48, buf, 8))
7283 oaddr3 = extract_unsigned_integer (buf, 8, byte_order);
7284 oaddr3 = s390_record_address_mask (gdbarch, regcache, oaddr3);
7285 if (record_full_arch_list_add_mem (oaddr3, 4))
7291 if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + inib[2]))
7294 if (record_full_arch_list_add_mem (oaddr, 4))
7298 case 0x09: /* DCSG */
7300 if (record_full_arch_list_add_mem (oaddr2 + 0x28, 8))
7304 case 0x15: /* CSTSTG */
7306 if (target_read_memory (oaddr2 + 0x88, buf, 8))
7308 oaddr3 = extract_unsigned_integer (buf, 8, byte_order);
7309 oaddr3 = s390_record_address_mask (gdbarch, regcache, oaddr3);
7310 if (record_full_arch_list_add_mem (oaddr3, 8))
7313 case 0x11: /* CSDSTG */
7315 if (target_read_memory (oaddr2 + 0x68, buf, 8))
7317 oaddr3 = extract_unsigned_integer (buf, 8, byte_order);
7318 oaddr3 = s390_record_address_mask (gdbarch, regcache, oaddr3);
7319 if (record_full_arch_list_add_mem (oaddr3, 8))
7322 case 0x0d: /* CSSTG */
7325 if (target_read_memory (oaddr2 + 0x48, buf, 8))
7327 oaddr3 = extract_unsigned_integer (buf, 8, byte_order);
7328 oaddr3 = s390_record_address_mask (gdbarch, regcache, oaddr3);
7329 if (record_full_arch_list_add_mem (oaddr3, 8))
7332 case 0x05: /* CSG */
7334 if (record_full_arch_list_add_mem (oaddr2 + 0x08, 8))
7337 if (record_full_arch_list_add_mem (oaddr, 8))
7341 case 0x0a: /* DCSGR */
7343 if (s390_record_gpr_g (gdbarch, regcache, inib[3]))
7346 case 0x0e: /* CSSTGR */
7348 if (record_full_arch_list_add_mem (oaddr2, 8))
7352 case 0x16: /* CSTSTGR */
7354 if (target_read_memory (oaddr2 + 0x88, buf, 8))
7356 oaddr3 = extract_unsigned_integer (buf, 8, byte_order);
7357 oaddr3 = s390_record_address_mask (gdbarch, regcache, oaddr3);
7358 if (record_full_arch_list_add_mem (oaddr3, 8))
7361 case 0x12: /* CSDSTGR */
7363 if (target_read_memory (oaddr2 + 0x68, buf, 8))
7365 oaddr3 = extract_unsigned_integer (buf, 8, byte_order);
7366 oaddr3 = s390_record_address_mask (gdbarch, regcache, oaddr3);
7367 if (record_full_arch_list_add_mem (oaddr3, 8))
7370 if (target_read_memory (oaddr2 + 0x48, buf, 8))
7372 oaddr3 = extract_unsigned_integer (buf, 8, byte_order);
7373 oaddr3 = s390_record_address_mask (gdbarch, regcache, oaddr3);
7374 if (record_full_arch_list_add_mem (oaddr3, 8))
7377 case 0x06: /* CSGR */
7380 if (s390_record_gpr_g (gdbarch, regcache, inib[2]))
7383 if (record_full_arch_list_add_mem (oaddr, 8))
7387 case 0x0b: /* DCSX */
7389 if (record_full_arch_list_add_mem (oaddr2 + 0x20, 16))
7393 case 0x17: /* CSTSTX */
7395 if (target_read_memory (oaddr2 + 0x88, buf, 8))
7397 oaddr3 = extract_unsigned_integer (buf, 8, byte_order);
7398 oaddr3 = s390_record_address_mask (gdbarch, regcache, oaddr3);
7399 if (record_full_arch_list_add_mem (oaddr3, 16))
7402 case 0x13: /* CSDSTX */
7404 if (target_read_memory (oaddr2 + 0x68, buf, 8))
7406 oaddr3 = extract_unsigned_integer (buf, 8, byte_order);
7407 oaddr3 = s390_record_address_mask (gdbarch, regcache, oaddr3);
7408 if (record_full_arch_list_add_mem (oaddr3, 16))
7411 case 0x0f: /* CSSTX */
7414 if (target_read_memory (oaddr2 + 0x48, buf, 8))
7416 oaddr3 = extract_unsigned_integer (buf, 8, byte_order);
7417 oaddr3 = s390_record_address_mask (gdbarch, regcache, oaddr3);
7418 if (record_full_arch_list_add_mem (oaddr3, 16))
7421 case 0x07: /* CSX */
7423 if (record_full_arch_list_add_mem (oaddr2 + 0x00, 16))
7426 if (record_full_arch_list_add_mem (oaddr, 16))
7431 fprintf_unfiltered (gdb_stdlog, "Warning: Unknown PLO FC %02x at %s.\n",
7432 fc, paddress (gdbarch, addr));
7436 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
7440 case 0xef: /* LMD - load multiple disjoint */
7441 for (i = inib[2]; i != inib[3]; i++, i &= 0xf)
7442 if (s390_record_gpr_g (gdbarch, regcache, i))
7444 if (s390_record_gpr_g (gdbarch, regcache, inib[3]))
7448 case 0xf0: /* SRP - shift and round decimal */
7449 case 0xf8: /* ZAP - zero and add */
7450 case 0xfa: /* AP - add decimal */
7451 case 0xfb: /* SP - subtract decimal */
7452 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
7453 if (record_full_arch_list_add_mem (oaddr, inib[2] + 1))
7455 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
7457 /* DXC may be written */
7458 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
7462 case 0xf1: /* MVO - move with offset */
7463 case 0xf2: /* PACK - pack */
7464 case 0xf3: /* UNPK - unpack */
7465 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
7466 if (record_full_arch_list_add_mem (oaddr, inib[2] + 1))
7470 /* 0xf4-0xf7 undefined */
7472 case 0xf9: /* CP - compare decimal */
7473 if (record_full_arch_list_add_reg (regcache, S390_PSWM_REGNUM))
7475 /* DXC may be written */
7476 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
7480 case 0xfc: /* MP - multiply decimal */
7481 case 0xfd: /* DP - divide decimal */
7482 oaddr = s390_record_calc_disp (gdbarch, regcache, 0, insn[1], 0);
7483 if (record_full_arch_list_add_mem (oaddr, inib[2] + 1))
7485 /* DXC may be written */
7486 if (record_full_arch_list_add_reg (regcache, S390_FPC_REGNUM))
7490 /* 0xfe-0xff undefined */
7494 fprintf_unfiltered (gdb_stdlog, "Warning: Don't know how to record %04x "
7495 "at %s.\n", insn[0], paddress (gdbarch, addr));
7499 if (record_full_arch_list_add_reg (regcache, S390_PSWA_REGNUM))
7501 if (record_full_arch_list_add_end ())
7506 /* Initialize linux_record_tdep if not initialized yet. */
7509 s390_init_linux_record_tdep (struct linux_record_tdep *record_tdep,
7510 enum s390_abi_kind abi)
7512 /* These values are the size of the type that will be used in a system
7513 call. They are obtained from Linux Kernel source. */
7515 if (abi == ABI_LINUX_ZSERIES)
7517 record_tdep->size_pointer = 8;
7518 /* no _old_kernel_stat */
7519 record_tdep->size_tms = 32;
7520 record_tdep->size_loff_t = 8;
7521 record_tdep->size_flock = 32;
7522 record_tdep->size_ustat = 32;
7523 record_tdep->size_old_sigaction = 32;
7524 record_tdep->size_old_sigset_t = 8;
7525 record_tdep->size_rlimit = 16;
7526 record_tdep->size_rusage = 144;
7527 record_tdep->size_timeval = 16;
7528 record_tdep->size_timezone = 8;
7529 /* old_[ug]id_t never used */
7530 record_tdep->size_fd_set = 128;
7531 record_tdep->size_old_dirent = 280;
7532 record_tdep->size_statfs = 88;
7533 record_tdep->size_statfs64 = 88;
7534 record_tdep->size_sockaddr = 16;
7535 record_tdep->size_int = 4;
7536 record_tdep->size_long = 8;
7537 record_tdep->size_ulong = 8;
7538 record_tdep->size_msghdr = 56;
7539 record_tdep->size_itimerval = 32;
7540 record_tdep->size_stat = 144;
7541 /* old_utsname unused */
7542 record_tdep->size_sysinfo = 112;
7543 record_tdep->size_msqid_ds = 120;
7544 record_tdep->size_shmid_ds = 112;
7545 record_tdep->size_new_utsname = 390;
7546 record_tdep->size_timex = 208;
7547 record_tdep->size_mem_dqinfo = 24;
7548 record_tdep->size_if_dqblk = 72;
7549 record_tdep->size_fs_quota_stat = 80;
7550 record_tdep->size_timespec = 16;
7551 record_tdep->size_pollfd = 8;
7552 record_tdep->size_NFS_FHSIZE = 32;
7553 record_tdep->size_knfsd_fh = 132;
7554 record_tdep->size_TASK_COMM_LEN = 16;
7555 record_tdep->size_sigaction = 32;
7556 record_tdep->size_sigset_t = 8;
7557 record_tdep->size_siginfo_t = 128;
7558 record_tdep->size_cap_user_data_t = 12;
7559 record_tdep->size_stack_t = 24;
7560 record_tdep->size_off_t = 8;
7562 record_tdep->size_gid_t = 4;
7563 record_tdep->size_uid_t = 4;
7564 record_tdep->size_PAGE_SIZE = 0x1000; /* 4KB */
7565 record_tdep->size_flock64 = 32;
7566 record_tdep->size_io_event = 32;
7567 record_tdep->size_iocb = 64;
7568 record_tdep->size_epoll_event = 16;
7569 record_tdep->size_itimerspec = 32;
7570 record_tdep->size_mq_attr = 64;
7571 record_tdep->size_termios = 36;
7572 record_tdep->size_termios2 = 44;
7573 record_tdep->size_pid_t = 4;
7574 record_tdep->size_winsize = 8;
7575 record_tdep->size_serial_struct = 72;
7576 record_tdep->size_serial_icounter_struct = 80;
7577 record_tdep->size_size_t = 8;
7578 record_tdep->size_iovec = 16;
7579 record_tdep->size_time_t = 8;
7581 else if (abi == ABI_LINUX_S390)
7583 record_tdep->size_pointer = 4;
7584 record_tdep->size__old_kernel_stat = 32;
7585 record_tdep->size_tms = 16;
7586 record_tdep->size_loff_t = 8;
7587 record_tdep->size_flock = 16;
7588 record_tdep->size_ustat = 20;
7589 record_tdep->size_old_sigaction = 16;
7590 record_tdep->size_old_sigset_t = 4;
7591 record_tdep->size_rlimit = 8;
7592 record_tdep->size_rusage = 72;
7593 record_tdep->size_timeval = 8;
7594 record_tdep->size_timezone = 8;
7595 record_tdep->size_old_gid_t = 2;
7596 record_tdep->size_old_uid_t = 2;
7597 record_tdep->size_fd_set = 128;
7598 record_tdep->size_old_dirent = 268;
7599 record_tdep->size_statfs = 64;
7600 record_tdep->size_statfs64 = 88;
7601 record_tdep->size_sockaddr = 16;
7602 record_tdep->size_int = 4;
7603 record_tdep->size_long = 4;
7604 record_tdep->size_ulong = 4;
7605 record_tdep->size_msghdr = 28;
7606 record_tdep->size_itimerval = 16;
7607 record_tdep->size_stat = 64;
7608 /* old_utsname unused */
7609 record_tdep->size_sysinfo = 64;
7610 record_tdep->size_msqid_ds = 88;
7611 record_tdep->size_shmid_ds = 84;
7612 record_tdep->size_new_utsname = 390;
7613 record_tdep->size_timex = 128;
7614 record_tdep->size_mem_dqinfo = 24;
7615 record_tdep->size_if_dqblk = 72;
7616 record_tdep->size_fs_quota_stat = 80;
7617 record_tdep->size_timespec = 8;
7618 record_tdep->size_pollfd = 8;
7619 record_tdep->size_NFS_FHSIZE = 32;
7620 record_tdep->size_knfsd_fh = 132;
7621 record_tdep->size_TASK_COMM_LEN = 16;
7622 record_tdep->size_sigaction = 20;
7623 record_tdep->size_sigset_t = 8;
7624 record_tdep->size_siginfo_t = 128;
7625 record_tdep->size_cap_user_data_t = 12;
7626 record_tdep->size_stack_t = 12;
7627 record_tdep->size_off_t = 4;
7628 record_tdep->size_stat64 = 104;
7629 record_tdep->size_gid_t = 4;
7630 record_tdep->size_uid_t = 4;
7631 record_tdep->size_PAGE_SIZE = 0x1000; /* 4KB */
7632 record_tdep->size_flock64 = 32;
7633 record_tdep->size_io_event = 32;
7634 record_tdep->size_iocb = 64;
7635 record_tdep->size_epoll_event = 16;
7636 record_tdep->size_itimerspec = 16;
7637 record_tdep->size_mq_attr = 32;
7638 record_tdep->size_termios = 36;
7639 record_tdep->size_termios2 = 44;
7640 record_tdep->size_pid_t = 4;
7641 record_tdep->size_winsize = 8;
7642 record_tdep->size_serial_struct = 60;
7643 record_tdep->size_serial_icounter_struct = 80;
7644 record_tdep->size_size_t = 4;
7645 record_tdep->size_iovec = 8;
7646 record_tdep->size_time_t = 4;
7649 /* These values are the second argument of system call "sys_fcntl"
7650 and "sys_fcntl64". They are obtained from Linux Kernel source. */
7651 record_tdep->fcntl_F_GETLK = 5;
7652 record_tdep->fcntl_F_GETLK64 = 12;
7653 record_tdep->fcntl_F_SETLK64 = 13;
7654 record_tdep->fcntl_F_SETLKW64 = 14;
7656 record_tdep->arg1 = S390_R2_REGNUM;
7657 record_tdep->arg2 = S390_R3_REGNUM;
7658 record_tdep->arg3 = S390_R4_REGNUM;
7659 record_tdep->arg4 = S390_R5_REGNUM;
7660 record_tdep->arg5 = S390_R6_REGNUM;
7662 /* These values are the second argument of system call "sys_ioctl".
7663 They are obtained from Linux Kernel source.
7664 See arch/s390/include/uapi/asm/ioctls.h. */
7666 record_tdep->ioctl_TCGETS = 0x5401;
7667 record_tdep->ioctl_TCSETS = 0x5402;
7668 record_tdep->ioctl_TCSETSW = 0x5403;
7669 record_tdep->ioctl_TCSETSF = 0x5404;
7670 record_tdep->ioctl_TCGETA = 0x5405;
7671 record_tdep->ioctl_TCSETA = 0x5406;
7672 record_tdep->ioctl_TCSETAW = 0x5407;
7673 record_tdep->ioctl_TCSETAF = 0x5408;
7674 record_tdep->ioctl_TCSBRK = 0x5409;
7675 record_tdep->ioctl_TCXONC = 0x540a;
7676 record_tdep->ioctl_TCFLSH = 0x540b;
7677 record_tdep->ioctl_TIOCEXCL = 0x540c;
7678 record_tdep->ioctl_TIOCNXCL = 0x540d;
7679 record_tdep->ioctl_TIOCSCTTY = 0x540e;
7680 record_tdep->ioctl_TIOCGPGRP = 0x540f;
7681 record_tdep->ioctl_TIOCSPGRP = 0x5410;
7682 record_tdep->ioctl_TIOCOUTQ = 0x5411;
7683 record_tdep->ioctl_TIOCSTI = 0x5412;
7684 record_tdep->ioctl_TIOCGWINSZ = 0x5413;
7685 record_tdep->ioctl_TIOCSWINSZ = 0x5414;
7686 record_tdep->ioctl_TIOCMGET = 0x5415;
7687 record_tdep->ioctl_TIOCMBIS = 0x5416;
7688 record_tdep->ioctl_TIOCMBIC = 0x5417;
7689 record_tdep->ioctl_TIOCMSET = 0x5418;
7690 record_tdep->ioctl_TIOCGSOFTCAR = 0x5419;
7691 record_tdep->ioctl_TIOCSSOFTCAR = 0x541a;
7692 record_tdep->ioctl_FIONREAD = 0x541b;
7693 record_tdep->ioctl_TIOCINQ = 0x541b; /* alias */
7694 record_tdep->ioctl_TIOCLINUX = 0x541c;
7695 record_tdep->ioctl_TIOCCONS = 0x541d;
7696 record_tdep->ioctl_TIOCGSERIAL = 0x541e;
7697 record_tdep->ioctl_TIOCSSERIAL = 0x541f;
7698 record_tdep->ioctl_TIOCPKT = 0x5420;
7699 record_tdep->ioctl_FIONBIO = 0x5421;
7700 record_tdep->ioctl_TIOCNOTTY = 0x5422;
7701 record_tdep->ioctl_TIOCSETD = 0x5423;
7702 record_tdep->ioctl_TIOCGETD = 0x5424;
7703 record_tdep->ioctl_TCSBRKP = 0x5425;
7704 record_tdep->ioctl_TIOCSBRK = 0x5427;
7705 record_tdep->ioctl_TIOCCBRK = 0x5428;
7706 record_tdep->ioctl_TIOCGSID = 0x5429;
7707 record_tdep->ioctl_TCGETS2 = 0x802c542a;
7708 record_tdep->ioctl_TCSETS2 = 0x402c542b;
7709 record_tdep->ioctl_TCSETSW2 = 0x402c542c;
7710 record_tdep->ioctl_TCSETSF2 = 0x402c542d;
7711 record_tdep->ioctl_TIOCGPTN = 0x80045430;
7712 record_tdep->ioctl_TIOCSPTLCK = 0x40045431;
7713 record_tdep->ioctl_FIONCLEX = 0x5450;
7714 record_tdep->ioctl_FIOCLEX = 0x5451;
7715 record_tdep->ioctl_FIOASYNC = 0x5452;
7716 record_tdep->ioctl_TIOCSERCONFIG = 0x5453;
7717 record_tdep->ioctl_TIOCSERGWILD = 0x5454;
7718 record_tdep->ioctl_TIOCSERSWILD = 0x5455;
7719 record_tdep->ioctl_TIOCGLCKTRMIOS = 0x5456;
7720 record_tdep->ioctl_TIOCSLCKTRMIOS = 0x5457;
7721 record_tdep->ioctl_TIOCSERGSTRUCT = 0x5458;
7722 record_tdep->ioctl_TIOCSERGETLSR = 0x5459;
7723 record_tdep->ioctl_TIOCSERGETMULTI = 0x545a;
7724 record_tdep->ioctl_TIOCSERSETMULTI = 0x545b;
7725 record_tdep->ioctl_TIOCMIWAIT = 0x545c;
7726 record_tdep->ioctl_TIOCGICOUNT = 0x545d;
7727 record_tdep->ioctl_FIOQSIZE = 0x545e;
7730 /* Set up gdbarch struct. */
7732 static struct gdbarch *
7733 s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
7735 const struct target_desc *tdesc = info.target_desc;
7736 struct tdesc_arch_data *tdesc_data = NULL;
7737 struct gdbarch *gdbarch;
7738 struct gdbarch_tdep *tdep;
7739 enum s390_abi_kind tdep_abi;
7740 enum s390_vector_abi_kind vector_abi;
7742 int have_linux_v1 = 0;
7743 int have_linux_v2 = 0;
7746 int first_pseudo_reg, last_pseudo_reg;
7747 static const char *const stap_register_prefixes[] = { "%", NULL };
7748 static const char *const stap_register_indirection_prefixes[] = { "(",
7750 static const char *const stap_register_indirection_suffixes[] = { ")",
7753 /* Default ABI and register size. */
7754 switch (info.bfd_arch_info->mach)
7756 case bfd_mach_s390_31:
7757 tdep_abi = ABI_LINUX_S390;
7760 case bfd_mach_s390_64:
7761 tdep_abi = ABI_LINUX_ZSERIES;
7768 /* Use default target description if none provided by the target. */
7769 if (!tdesc_has_registers (tdesc))
7771 if (tdep_abi == ABI_LINUX_S390)
7772 tdesc = tdesc_s390_linux32;
7774 tdesc = tdesc_s390x_linux64;
7777 /* Check any target description for validity. */
7778 if (tdesc_has_registers (tdesc))
7780 static const char *const gprs[] = {
7781 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
7782 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"
7784 static const char *const fprs[] = {
7785 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7",
7786 "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15"
7788 static const char *const acrs[] = {
7789 "acr0", "acr1", "acr2", "acr3", "acr4", "acr5", "acr6", "acr7",
7790 "acr8", "acr9", "acr10", "acr11", "acr12", "acr13", "acr14", "acr15"
7792 static const char *const gprs_lower[] = {
7793 "r0l", "r1l", "r2l", "r3l", "r4l", "r5l", "r6l", "r7l",
7794 "r8l", "r9l", "r10l", "r11l", "r12l", "r13l", "r14l", "r15l"
7796 static const char *const gprs_upper[] = {
7797 "r0h", "r1h", "r2h", "r3h", "r4h", "r5h", "r6h", "r7h",
7798 "r8h", "r9h", "r10h", "r11h", "r12h", "r13h", "r14h", "r15h"
7800 static const char *const tdb_regs[] = {
7801 "tdb0", "tac", "tct", "atia",
7802 "tr0", "tr1", "tr2", "tr3", "tr4", "tr5", "tr6", "tr7",
7803 "tr8", "tr9", "tr10", "tr11", "tr12", "tr13", "tr14", "tr15"
7805 static const char *const vxrs_low[] = {
7806 "v0l", "v1l", "v2l", "v3l", "v4l", "v5l", "v6l", "v7l", "v8l",
7807 "v9l", "v10l", "v11l", "v12l", "v13l", "v14l", "v15l",
7809 static const char *const vxrs_high[] = {
7810 "v16", "v17", "v18", "v19", "v20", "v21", "v22", "v23", "v24",
7811 "v25", "v26", "v27", "v28", "v29", "v30", "v31",
7813 const struct tdesc_feature *feature;
7816 feature = tdesc_find_feature (tdesc, "org.gnu.gdb.s390.core");
7817 if (feature == NULL)
7820 tdesc_data = tdesc_data_alloc ();
7822 valid_p &= tdesc_numbered_register (feature, tdesc_data,
7823 S390_PSWM_REGNUM, "pswm");
7824 valid_p &= tdesc_numbered_register (feature, tdesc_data,
7825 S390_PSWA_REGNUM, "pswa");
7827 if (tdesc_unnumbered_register (feature, "r0"))
7829 for (i = 0; i < 16; i++)
7830 valid_p &= tdesc_numbered_register (feature, tdesc_data,
7831 S390_R0_REGNUM + i, gprs[i]);
7837 for (i = 0; i < 16; i++)
7838 valid_p &= tdesc_numbered_register (feature, tdesc_data,
7841 for (i = 0; i < 16; i++)
7842 valid_p &= tdesc_numbered_register (feature, tdesc_data,
7843 S390_R0_UPPER_REGNUM + i,
7847 feature = tdesc_find_feature (tdesc, "org.gnu.gdb.s390.fpr");
7848 if (feature == NULL)
7850 tdesc_data_cleanup (tdesc_data);
7854 valid_p &= tdesc_numbered_register (feature, tdesc_data,
7855 S390_FPC_REGNUM, "fpc");
7856 for (i = 0; i < 16; i++)
7857 valid_p &= tdesc_numbered_register (feature, tdesc_data,
7858 S390_F0_REGNUM + i, fprs[i]);
7860 feature = tdesc_find_feature (tdesc, "org.gnu.gdb.s390.acr");
7861 if (feature == NULL)
7863 tdesc_data_cleanup (tdesc_data);
7867 for (i = 0; i < 16; i++)
7868 valid_p &= tdesc_numbered_register (feature, tdesc_data,
7869 S390_A0_REGNUM + i, acrs[i]);
7871 /* Optional GNU/Linux-specific "registers". */
7872 feature = tdesc_find_feature (tdesc, "org.gnu.gdb.s390.linux");
7875 tdesc_numbered_register (feature, tdesc_data,
7876 S390_ORIG_R2_REGNUM, "orig_r2");
7878 if (tdesc_numbered_register (feature, tdesc_data,
7879 S390_LAST_BREAK_REGNUM, "last_break"))
7882 if (tdesc_numbered_register (feature, tdesc_data,
7883 S390_SYSTEM_CALL_REGNUM, "system_call"))
7886 if (have_linux_v2 > have_linux_v1)
7890 /* Transaction diagnostic block. */
7891 feature = tdesc_find_feature (tdesc, "org.gnu.gdb.s390.tdb");
7894 for (i = 0; i < ARRAY_SIZE (tdb_regs); i++)
7895 valid_p &= tdesc_numbered_register (feature, tdesc_data,
7896 S390_TDB_DWORD0_REGNUM + i,
7901 /* Vector registers. */
7902 feature = tdesc_find_feature (tdesc, "org.gnu.gdb.s390.vx");
7905 for (i = 0; i < 16; i++)
7906 valid_p &= tdesc_numbered_register (feature, tdesc_data,
7907 S390_V0_LOWER_REGNUM + i,
7909 for (i = 0; i < 16; i++)
7910 valid_p &= tdesc_numbered_register (feature, tdesc_data,
7911 S390_V16_REGNUM + i,
7918 tdesc_data_cleanup (tdesc_data);
7923 /* Determine vector ABI. */
7924 vector_abi = S390_VECTOR_ABI_NONE;
7927 && info.abfd != NULL
7928 && info.abfd->format == bfd_object
7929 && bfd_get_flavour (info.abfd) == bfd_target_elf_flavour
7930 && bfd_elf_get_obj_attr_int (info.abfd, OBJ_ATTR_GNU,
7931 Tag_GNU_S390_ABI_Vector) == 2)
7932 vector_abi = S390_VECTOR_ABI_128;
7935 /* Find a candidate among extant architectures. */
7936 for (arches = gdbarch_list_lookup_by_info (arches, &info);
7938 arches = gdbarch_list_lookup_by_info (arches->next, &info))
7940 tdep = gdbarch_tdep (arches->gdbarch);
7943 if (tdep->abi != tdep_abi)
7945 if (tdep->vector_abi != vector_abi)
7947 if ((tdep->gpr_full_regnum != -1) != have_upper)
7949 if (tdesc_data != NULL)
7950 tdesc_data_cleanup (tdesc_data);
7951 return arches->gdbarch;
7954 /* Otherwise create a new gdbarch for the specified machine type. */
7955 tdep = XCNEW (struct gdbarch_tdep);
7956 tdep->abi = tdep_abi;
7957 tdep->vector_abi = vector_abi;
7958 tdep->have_linux_v1 = have_linux_v1;
7959 tdep->have_linux_v2 = have_linux_v2;
7960 tdep->have_tdb = have_tdb;
7961 gdbarch = gdbarch_alloc (&info, tdep);
7963 set_gdbarch_believe_pcc_promotion (gdbarch, 0);
7964 set_gdbarch_char_signed (gdbarch, 0);
7966 /* S/390 GNU/Linux uses either 64-bit or 128-bit long doubles.
7967 We can safely let them default to 128-bit, since the debug info
7968 will give the size of type actually used in each case. */
7969 set_gdbarch_long_double_bit (gdbarch, 128);
7970 set_gdbarch_long_double_format (gdbarch, floatformats_ia64_quad);
7972 /* Amount PC must be decremented by after a breakpoint. This is
7973 often the number of bytes returned by gdbarch_breakpoint_from_pc but not
7975 set_gdbarch_decr_pc_after_break (gdbarch, 2);
7976 /* Stack grows downward. */
7977 set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
7978 set_gdbarch_breakpoint_kind_from_pc (gdbarch, s390_breakpoint::kind_from_pc);
7979 set_gdbarch_sw_breakpoint_from_kind (gdbarch, s390_breakpoint::bp_from_kind);
7980 set_gdbarch_software_single_step (gdbarch, s390_software_single_step);
7981 set_gdbarch_displaced_step_hw_singlestep (gdbarch, s390_displaced_step_hw_singlestep);
7982 set_gdbarch_skip_prologue (gdbarch, s390_skip_prologue);
7983 set_gdbarch_stack_frame_destroyed_p (gdbarch, s390_stack_frame_destroyed_p);
7985 set_gdbarch_num_regs (gdbarch, S390_NUM_REGS);
7986 set_gdbarch_sp_regnum (gdbarch, S390_SP_REGNUM);
7987 set_gdbarch_fp0_regnum (gdbarch, S390_F0_REGNUM);
7988 set_gdbarch_stab_reg_to_regnum (gdbarch, s390_dwarf_reg_to_regnum);
7989 set_gdbarch_dwarf2_reg_to_regnum (gdbarch, s390_dwarf_reg_to_regnum);
7990 set_gdbarch_value_from_register (gdbarch, s390_value_from_register);
7991 set_gdbarch_core_read_description (gdbarch, s390_core_read_description);
7992 set_gdbarch_iterate_over_regset_sections (gdbarch,
7993 s390_iterate_over_regset_sections);
7994 set_gdbarch_cannot_store_register (gdbarch, s390_cannot_store_register);
7995 set_gdbarch_write_pc (gdbarch, s390_write_pc);
7996 set_gdbarch_guess_tracepoint_registers (gdbarch, s390_guess_tracepoint_registers);
7997 set_gdbarch_pseudo_register_read (gdbarch, s390_pseudo_register_read);
7998 set_gdbarch_pseudo_register_write (gdbarch, s390_pseudo_register_write);
7999 set_tdesc_pseudo_register_name (gdbarch, s390_pseudo_register_name);
8000 set_tdesc_pseudo_register_type (gdbarch, s390_pseudo_register_type);
8001 set_tdesc_pseudo_register_reggroup_p (gdbarch,
8002 s390_pseudo_register_reggroup_p);
8003 set_gdbarch_ax_pseudo_register_collect (gdbarch,
8004 s390_ax_pseudo_register_collect);
8005 set_gdbarch_ax_pseudo_register_push_stack
8006 (gdbarch, s390_ax_pseudo_register_push_stack);
8007 set_gdbarch_gen_return_address (gdbarch, s390_gen_return_address);
8008 tdesc_use_registers (gdbarch, tdesc, tdesc_data);
8009 set_gdbarch_register_name (gdbarch, s390_register_name);
8011 /* Assign pseudo register numbers. */
8012 first_pseudo_reg = gdbarch_num_regs (gdbarch);
8013 last_pseudo_reg = first_pseudo_reg;
8014 tdep->gpr_full_regnum = -1;
8017 tdep->gpr_full_regnum = last_pseudo_reg;
8018 last_pseudo_reg += 16;
8020 tdep->v0_full_regnum = -1;
8023 tdep->v0_full_regnum = last_pseudo_reg;
8024 last_pseudo_reg += 16;
8026 tdep->pc_regnum = last_pseudo_reg++;
8027 tdep->cc_regnum = last_pseudo_reg++;
8028 set_gdbarch_pc_regnum (gdbarch, tdep->pc_regnum);
8029 set_gdbarch_num_pseudo_regs (gdbarch, last_pseudo_reg - first_pseudo_reg);
8031 /* Inferior function calls. */
8032 set_gdbarch_push_dummy_call (gdbarch, s390_push_dummy_call);
8033 set_gdbarch_dummy_id (gdbarch, s390_dummy_id);
8034 set_gdbarch_frame_align (gdbarch, s390_frame_align);
8035 set_gdbarch_return_value (gdbarch, s390_return_value);
8037 /* Syscall handling. */
8038 set_gdbarch_get_syscall_number (gdbarch, s390_linux_get_syscall_number);
8040 /* Frame handling. */
8041 dwarf2_frame_set_init_reg (gdbarch, s390_dwarf2_frame_init_reg);
8042 dwarf2_frame_set_adjust_regnum (gdbarch, s390_adjust_frame_regnum);
8043 dwarf2_append_unwinders (gdbarch);
8044 frame_base_append_sniffer (gdbarch, dwarf2_frame_base_sniffer);
8045 frame_unwind_append_unwinder (gdbarch, &s390_stub_frame_unwind);
8046 frame_unwind_append_unwinder (gdbarch, &s390_sigtramp_frame_unwind);
8047 frame_unwind_append_unwinder (gdbarch, &s390_frame_unwind);
8048 frame_base_set_default (gdbarch, &s390_frame_base);
8049 set_gdbarch_unwind_pc (gdbarch, s390_unwind_pc);
8050 set_gdbarch_unwind_sp (gdbarch, s390_unwind_sp);
8052 /* Displaced stepping. */
8053 set_gdbarch_displaced_step_copy_insn (gdbarch,
8054 s390_displaced_step_copy_insn);
8055 set_gdbarch_displaced_step_fixup (gdbarch, s390_displaced_step_fixup);
8056 set_gdbarch_displaced_step_free_closure (gdbarch,
8057 simple_displaced_step_free_closure);
8058 set_gdbarch_displaced_step_location (gdbarch, linux_displaced_step_location);
8059 set_gdbarch_max_insn_length (gdbarch, S390_MAX_INSTR_SIZE);
8061 /* Note that GNU/Linux is the only OS supported on this
8063 linux_init_abi (info, gdbarch);
8067 case ABI_LINUX_S390:
8068 set_gdbarch_addr_bits_remove (gdbarch, s390_addr_bits_remove);
8069 set_solib_svr4_fetch_link_map_offsets
8070 (gdbarch, svr4_ilp32_fetch_link_map_offsets);
8072 set_xml_syscall_file_name (gdbarch, XML_SYSCALL_FILENAME_S390);
8075 case ABI_LINUX_ZSERIES:
8076 set_gdbarch_long_bit (gdbarch, 64);
8077 set_gdbarch_long_long_bit (gdbarch, 64);
8078 set_gdbarch_ptr_bit (gdbarch, 64);
8079 set_solib_svr4_fetch_link_map_offsets
8080 (gdbarch, svr4_lp64_fetch_link_map_offsets);
8081 set_gdbarch_address_class_type_flags (gdbarch,
8082 s390_address_class_type_flags);
8083 set_gdbarch_address_class_type_flags_to_name (gdbarch,
8084 s390_address_class_type_flags_to_name);
8085 set_gdbarch_address_class_name_to_type_flags (gdbarch,
8086 s390_address_class_name_to_type_flags);
8087 set_xml_syscall_file_name (gdbarch, XML_SYSCALL_FILENAME_S390X);
8091 set_gdbarch_print_insn (gdbarch, print_insn_s390);
8093 set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
8095 /* Enable TLS support. */
8096 set_gdbarch_fetch_tls_load_module_address (gdbarch,
8097 svr4_fetch_objfile_link_map);
8099 /* SystemTap functions. */
8100 set_gdbarch_stap_register_prefixes (gdbarch, stap_register_prefixes);
8101 set_gdbarch_stap_register_indirection_prefixes (gdbarch,
8102 stap_register_indirection_prefixes);
8103 set_gdbarch_stap_register_indirection_suffixes (gdbarch,
8104 stap_register_indirection_suffixes);
8105 set_gdbarch_stap_is_single_operand (gdbarch, s390_stap_is_single_operand);
8106 set_gdbarch_gcc_target_options (gdbarch, s390_gcc_target_options);
8107 set_gdbarch_gnu_triplet_regexp (gdbarch, s390_gnu_triplet_regexp);
8109 /* Support reverse debugging. */
8111 set_gdbarch_process_record (gdbarch, s390_process_record);
8112 set_gdbarch_process_record_signal (gdbarch, s390_linux_record_signal);
8114 s390_init_linux_record_tdep (&s390_linux_record_tdep, ABI_LINUX_S390);
8115 s390_init_linux_record_tdep (&s390x_linux_record_tdep, ABI_LINUX_ZSERIES);
8121 extern initialize_file_ftype _initialize_s390_tdep; /* -Wmissing-prototypes */
8124 _initialize_s390_tdep (void)
8126 /* Hook us into the gdbarch mechanism. */
8127 register_gdbarch_init (bfd_arch_s390, s390_gdbarch_init);
8129 /* Initialize the GNU/Linux target descriptions. */
8130 initialize_tdesc_s390_linux32 ();
8131 initialize_tdesc_s390_linux32v1 ();
8132 initialize_tdesc_s390_linux32v2 ();
8133 initialize_tdesc_s390_linux64 ();
8134 initialize_tdesc_s390_linux64v1 ();
8135 initialize_tdesc_s390_linux64v2 ();
8136 initialize_tdesc_s390_te_linux64 ();
8137 initialize_tdesc_s390_vx_linux64 ();
8138 initialize_tdesc_s390_tevx_linux64 ();
8139 initialize_tdesc_s390x_linux64 ();
8140 initialize_tdesc_s390x_linux64v1 ();
8141 initialize_tdesc_s390x_linux64v2 ();
8142 initialize_tdesc_s390x_te_linux64 ();
8143 initialize_tdesc_s390x_vx_linux64 ();
8144 initialize_tdesc_s390x_tevx_linux64 ();