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