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