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