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