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