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