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