1 /* Target-dependent code for GDB, the GNU debugger.
3 Copyright (C) 2001-2013 Free Software Foundation, Inc.
5 Contributed by D.J. Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com)
6 for IBM Deutschland Entwicklung GmbH, IBM Corporation.
8 This file is part of GDB.
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>. */
24 #include "arch-utils.h"
32 #include "floatformat.h"
34 #include "trad-frame.h"
35 #include "frame-base.h"
36 #include "frame-unwind.h"
37 #include "dwarf2-frame.h"
38 #include "reggroups.h"
41 #include "gdb_assert.h"
43 #include "solib-svr4.h"
44 #include "prologue-value.h"
45 #include "linux-tdep.h"
46 #include "s390-tdep.h"
48 #include "stap-probe.h"
51 #include "user-regs.h"
52 #include "cli/cli-utils.h"
55 #include "features/s390-linux32.c"
56 #include "features/s390-linux32v1.c"
57 #include "features/s390-linux32v2.c"
58 #include "features/s390-linux64.c"
59 #include "features/s390-linux64v1.c"
60 #include "features/s390-linux64v2.c"
61 #include "features/s390x-linux64.c"
62 #include "features/s390x-linux64v1.c"
63 #include "features/s390x-linux64v2.c"
65 /* The tdep structure. */
70 enum { ABI_LINUX_S390
, ABI_LINUX_ZSERIES
} abi
;
72 /* Pseudo register numbers. */
77 /* Core file register sets. */
78 const struct regset
*gregset
;
81 const struct regset
*fpregset
;
86 /* ABI call-saved register information. */
89 s390_register_call_saved (struct gdbarch
*gdbarch
, int regnum
)
91 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
96 if ((regnum
>= S390_R6_REGNUM
&& regnum
<= S390_R15_REGNUM
)
97 || regnum
== S390_F4_REGNUM
|| regnum
== S390_F6_REGNUM
98 || regnum
== S390_A0_REGNUM
)
103 case ABI_LINUX_ZSERIES
:
104 if ((regnum
>= S390_R6_REGNUM
&& regnum
<= S390_R15_REGNUM
)
105 || (regnum
>= S390_F8_REGNUM
&& regnum
<= S390_F15_REGNUM
)
106 || (regnum
>= S390_A0_REGNUM
&& regnum
<= S390_A1_REGNUM
))
116 s390_cannot_store_register (struct gdbarch
*gdbarch
, int regnum
)
118 /* The last-break address is read-only. */
119 return regnum
== S390_LAST_BREAK_REGNUM
;
123 s390_write_pc (struct regcache
*regcache
, CORE_ADDR pc
)
125 struct gdbarch
*gdbarch
= get_regcache_arch (regcache
);
126 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
128 regcache_cooked_write_unsigned (regcache
, tdep
->pc_regnum
, pc
);
130 /* Set special SYSTEM_CALL register to 0 to prevent the kernel from
131 messing with the PC we just installed, if we happen to be within
132 an interrupted system call that the kernel wants to restart.
134 Note that after we return from the dummy call, the SYSTEM_CALL and
135 ORIG_R2 registers will be automatically restored, and the kernel
136 continues to restart the system call at this point. */
137 if (register_size (gdbarch
, S390_SYSTEM_CALL_REGNUM
) > 0)
138 regcache_cooked_write_unsigned (regcache
, S390_SYSTEM_CALL_REGNUM
, 0);
142 /* DWARF Register Mapping. */
144 static int s390_dwarf_regmap
[] =
146 /* General Purpose Registers. */
147 S390_R0_REGNUM
, S390_R1_REGNUM
, S390_R2_REGNUM
, S390_R3_REGNUM
,
148 S390_R4_REGNUM
, S390_R5_REGNUM
, S390_R6_REGNUM
, S390_R7_REGNUM
,
149 S390_R8_REGNUM
, S390_R9_REGNUM
, S390_R10_REGNUM
, S390_R11_REGNUM
,
150 S390_R12_REGNUM
, S390_R13_REGNUM
, S390_R14_REGNUM
, S390_R15_REGNUM
,
152 /* Floating Point Registers. */
153 S390_F0_REGNUM
, S390_F2_REGNUM
, S390_F4_REGNUM
, S390_F6_REGNUM
,
154 S390_F1_REGNUM
, S390_F3_REGNUM
, S390_F5_REGNUM
, S390_F7_REGNUM
,
155 S390_F8_REGNUM
, S390_F10_REGNUM
, S390_F12_REGNUM
, S390_F14_REGNUM
,
156 S390_F9_REGNUM
, S390_F11_REGNUM
, S390_F13_REGNUM
, S390_F15_REGNUM
,
158 /* Control Registers (not mapped). */
159 -1, -1, -1, -1, -1, -1, -1, -1,
160 -1, -1, -1, -1, -1, -1, -1, -1,
162 /* Access Registers. */
163 S390_A0_REGNUM
, S390_A1_REGNUM
, S390_A2_REGNUM
, S390_A3_REGNUM
,
164 S390_A4_REGNUM
, S390_A5_REGNUM
, S390_A6_REGNUM
, S390_A7_REGNUM
,
165 S390_A8_REGNUM
, S390_A9_REGNUM
, S390_A10_REGNUM
, S390_A11_REGNUM
,
166 S390_A12_REGNUM
, S390_A13_REGNUM
, S390_A14_REGNUM
, S390_A15_REGNUM
,
168 /* Program Status Word. */
172 /* GPR Lower Half Access. */
173 S390_R0_REGNUM
, S390_R1_REGNUM
, S390_R2_REGNUM
, S390_R3_REGNUM
,
174 S390_R4_REGNUM
, S390_R5_REGNUM
, S390_R6_REGNUM
, S390_R7_REGNUM
,
175 S390_R8_REGNUM
, S390_R9_REGNUM
, S390_R10_REGNUM
, S390_R11_REGNUM
,
176 S390_R12_REGNUM
, S390_R13_REGNUM
, S390_R14_REGNUM
, S390_R15_REGNUM
,
178 /* GNU/Linux-specific registers (not mapped). */
182 /* Convert DWARF register number REG to the appropriate register
183 number used by GDB. */
185 s390_dwarf_reg_to_regnum (struct gdbarch
*gdbarch
, int reg
)
187 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
189 /* In a 32-on-64 debug scenario, debug info refers to the full 64-bit
190 GPRs. Note that call frame information still refers to the 32-bit
191 lower halves, because s390_adjust_frame_regnum uses register numbers
192 66 .. 81 to access GPRs. */
193 if (tdep
->gpr_full_regnum
!= -1 && reg
>= 0 && reg
< 16)
194 return tdep
->gpr_full_regnum
+ reg
;
196 if (reg
>= 0 && reg
< ARRAY_SIZE (s390_dwarf_regmap
))
197 return s390_dwarf_regmap
[reg
];
199 warning (_("Unmapped DWARF Register #%d encountered."), reg
);
203 /* Translate a .eh_frame register to DWARF register, or adjust a
204 .debug_frame register. */
206 s390_adjust_frame_regnum (struct gdbarch
*gdbarch
, int num
, int eh_frame_p
)
208 /* See s390_dwarf_reg_to_regnum for comments. */
209 return (num
>= 0 && num
< 16)? num
+ 66 : num
;
213 /* Pseudo registers. */
216 s390_pseudo_register_name (struct gdbarch
*gdbarch
, int regnum
)
218 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
220 if (regnum
== tdep
->pc_regnum
)
223 if (regnum
== tdep
->cc_regnum
)
226 if (tdep
->gpr_full_regnum
!= -1
227 && regnum
>= tdep
->gpr_full_regnum
228 && regnum
< tdep
->gpr_full_regnum
+ 16)
230 static const char *full_name
[] = {
231 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
232 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"
234 return full_name
[regnum
- tdep
->gpr_full_regnum
];
237 internal_error (__FILE__
, __LINE__
, _("invalid regnum"));
241 s390_pseudo_register_type (struct gdbarch
*gdbarch
, int regnum
)
243 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
245 if (regnum
== tdep
->pc_regnum
)
246 return builtin_type (gdbarch
)->builtin_func_ptr
;
248 if (regnum
== tdep
->cc_regnum
)
249 return builtin_type (gdbarch
)->builtin_int
;
251 if (tdep
->gpr_full_regnum
!= -1
252 && regnum
>= tdep
->gpr_full_regnum
253 && regnum
< tdep
->gpr_full_regnum
+ 16)
254 return builtin_type (gdbarch
)->builtin_uint64
;
256 internal_error (__FILE__
, __LINE__
, _("invalid regnum"));
259 static enum register_status
260 s390_pseudo_register_read (struct gdbarch
*gdbarch
, struct regcache
*regcache
,
261 int regnum
, gdb_byte
*buf
)
263 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
264 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
265 int regsize
= register_size (gdbarch
, regnum
);
268 if (regnum
== tdep
->pc_regnum
)
270 enum register_status status
;
272 status
= regcache_raw_read_unsigned (regcache
, S390_PSWA_REGNUM
, &val
);
273 if (status
== REG_VALID
)
275 if (register_size (gdbarch
, S390_PSWA_REGNUM
) == 4)
277 store_unsigned_integer (buf
, regsize
, byte_order
, val
);
282 if (regnum
== tdep
->cc_regnum
)
284 enum register_status status
;
286 status
= regcache_raw_read_unsigned (regcache
, S390_PSWM_REGNUM
, &val
);
287 if (status
== REG_VALID
)
289 if (register_size (gdbarch
, S390_PSWA_REGNUM
) == 4)
290 val
= (val
>> 12) & 3;
292 val
= (val
>> 44) & 3;
293 store_unsigned_integer (buf
, regsize
, byte_order
, val
);
298 if (tdep
->gpr_full_regnum
!= -1
299 && regnum
>= tdep
->gpr_full_regnum
300 && regnum
< tdep
->gpr_full_regnum
+ 16)
302 enum register_status status
;
305 regnum
-= tdep
->gpr_full_regnum
;
307 status
= regcache_raw_read_unsigned (regcache
, S390_R0_REGNUM
+ regnum
, &val
);
308 if (status
== REG_VALID
)
309 status
= regcache_raw_read_unsigned (regcache
, S390_R0_UPPER_REGNUM
+ regnum
,
311 if (status
== REG_VALID
)
313 val
|= val_upper
<< 32;
314 store_unsigned_integer (buf
, regsize
, byte_order
, val
);
319 internal_error (__FILE__
, __LINE__
, _("invalid regnum"));
323 s390_pseudo_register_write (struct gdbarch
*gdbarch
, struct regcache
*regcache
,
324 int regnum
, const gdb_byte
*buf
)
326 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
327 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
328 int regsize
= register_size (gdbarch
, regnum
);
331 if (regnum
== tdep
->pc_regnum
)
333 val
= extract_unsigned_integer (buf
, regsize
, byte_order
);
334 if (register_size (gdbarch
, S390_PSWA_REGNUM
) == 4)
336 regcache_raw_read_unsigned (regcache
, S390_PSWA_REGNUM
, &psw
);
337 val
= (psw
& 0x80000000) | (val
& 0x7fffffff);
339 regcache_raw_write_unsigned (regcache
, S390_PSWA_REGNUM
, val
);
343 if (regnum
== tdep
->cc_regnum
)
345 val
= extract_unsigned_integer (buf
, regsize
, byte_order
);
346 regcache_raw_read_unsigned (regcache
, S390_PSWM_REGNUM
, &psw
);
347 if (register_size (gdbarch
, S390_PSWA_REGNUM
) == 4)
348 val
= (psw
& ~((ULONGEST
)3 << 12)) | ((val
& 3) << 12);
350 val
= (psw
& ~((ULONGEST
)3 << 44)) | ((val
& 3) << 44);
351 regcache_raw_write_unsigned (regcache
, S390_PSWM_REGNUM
, val
);
355 if (tdep
->gpr_full_regnum
!= -1
356 && regnum
>= tdep
->gpr_full_regnum
357 && regnum
< tdep
->gpr_full_regnum
+ 16)
359 regnum
-= tdep
->gpr_full_regnum
;
360 val
= extract_unsigned_integer (buf
, regsize
, byte_order
);
361 regcache_raw_write_unsigned (regcache
, S390_R0_REGNUM
+ regnum
,
363 regcache_raw_write_unsigned (regcache
, S390_R0_UPPER_REGNUM
+ regnum
,
368 internal_error (__FILE__
, __LINE__
, _("invalid regnum"));
371 /* 'float' values are stored in the upper half of floating-point
372 registers, even though we are otherwise a big-endian platform. */
374 static struct value
*
375 s390_value_from_register (struct type
*type
, int regnum
,
376 struct frame_info
*frame
)
378 struct value
*value
= default_value_from_register (type
, regnum
, frame
);
380 check_typedef (type
);
382 if (regnum
>= S390_F0_REGNUM
&& regnum
<= S390_F15_REGNUM
383 && TYPE_LENGTH (type
) < 8)
384 set_value_offset (value
, 0);
389 /* Register groups. */
392 s390_pseudo_register_reggroup_p (struct gdbarch
*gdbarch
, int regnum
,
393 struct reggroup
*group
)
395 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
397 /* We usually save/restore the whole PSW, which includes PC and CC.
398 However, some older gdbservers may not support saving/restoring
399 the whole PSW yet, and will return an XML register description
400 excluding those from the save/restore register groups. In those
401 cases, we still need to explicitly save/restore PC and CC in order
402 to push or pop frames. Since this doesn't hurt anything if we
403 already save/restore the whole PSW (it's just redundant), we add
404 PC and CC at this point unconditionally. */
405 if (group
== save_reggroup
|| group
== restore_reggroup
)
406 return regnum
== tdep
->pc_regnum
|| regnum
== tdep
->cc_regnum
;
408 return default_register_reggroup_p (gdbarch
, regnum
, group
);
412 /* Core file register sets. */
414 int s390_regmap_gregset
[S390_NUM_REGS
] =
416 /* Program Status Word. */
418 /* General Purpose Registers. */
419 0x08, 0x0c, 0x10, 0x14,
420 0x18, 0x1c, 0x20, 0x24,
421 0x28, 0x2c, 0x30, 0x34,
422 0x38, 0x3c, 0x40, 0x44,
423 /* Access Registers. */
424 0x48, 0x4c, 0x50, 0x54,
425 0x58, 0x5c, 0x60, 0x64,
426 0x68, 0x6c, 0x70, 0x74,
427 0x78, 0x7c, 0x80, 0x84,
428 /* Floating Point Control Word. */
430 /* Floating Point Registers. */
431 -1, -1, -1, -1, -1, -1, -1, -1,
432 -1, -1, -1, -1, -1, -1, -1, -1,
433 /* GPR Uppper Halves. */
434 -1, -1, -1, -1, -1, -1, -1, -1,
435 -1, -1, -1, -1, -1, -1, -1, -1,
436 /* GNU/Linux-specific optional "registers". */
440 int s390x_regmap_gregset
[S390_NUM_REGS
] =
442 /* Program Status Word. */
444 /* General Purpose Registers. */
445 0x10, 0x18, 0x20, 0x28,
446 0x30, 0x38, 0x40, 0x48,
447 0x50, 0x58, 0x60, 0x68,
448 0x70, 0x78, 0x80, 0x88,
449 /* Access Registers. */
450 0x90, 0x94, 0x98, 0x9c,
451 0xa0, 0xa4, 0xa8, 0xac,
452 0xb0, 0xb4, 0xb8, 0xbc,
453 0xc0, 0xc4, 0xc8, 0xcc,
454 /* Floating Point Control Word. */
456 /* Floating Point Registers. */
457 -1, -1, -1, -1, -1, -1, -1, -1,
458 -1, -1, -1, -1, -1, -1, -1, -1,
459 /* GPR Uppper Halves. */
460 0x10, 0x18, 0x20, 0x28,
461 0x30, 0x38, 0x40, 0x48,
462 0x50, 0x58, 0x60, 0x68,
463 0x70, 0x78, 0x80, 0x88,
464 /* GNU/Linux-specific optional "registers". */
468 int s390_regmap_fpregset
[S390_NUM_REGS
] =
470 /* Program Status Word. */
472 /* General Purpose Registers. */
473 -1, -1, -1, -1, -1, -1, -1, -1,
474 -1, -1, -1, -1, -1, -1, -1, -1,
475 /* Access Registers. */
476 -1, -1, -1, -1, -1, -1, -1, -1,
477 -1, -1, -1, -1, -1, -1, -1, -1,
478 /* Floating Point Control Word. */
480 /* Floating Point Registers. */
481 0x08, 0x10, 0x18, 0x20,
482 0x28, 0x30, 0x38, 0x40,
483 0x48, 0x50, 0x58, 0x60,
484 0x68, 0x70, 0x78, 0x80,
485 /* GPR Uppper Halves. */
486 -1, -1, -1, -1, -1, -1, -1, -1,
487 -1, -1, -1, -1, -1, -1, -1, -1,
488 /* GNU/Linux-specific optional "registers". */
492 int s390_regmap_upper
[S390_NUM_REGS
] =
494 /* Program Status Word. */
496 /* General Purpose Registers. */
497 -1, -1, -1, -1, -1, -1, -1, -1,
498 -1, -1, -1, -1, -1, -1, -1, -1,
499 /* Access Registers. */
500 -1, -1, -1, -1, -1, -1, -1, -1,
501 -1, -1, -1, -1, -1, -1, -1, -1,
502 /* Floating Point Control Word. */
504 /* Floating Point Registers. */
505 -1, -1, -1, -1, -1, -1, -1, -1,
506 -1, -1, -1, -1, -1, -1, -1, -1,
507 /* GPR Uppper Halves. */
508 0x00, 0x04, 0x08, 0x0c,
509 0x10, 0x14, 0x18, 0x1c,
510 0x20, 0x24, 0x28, 0x2c,
511 0x30, 0x34, 0x38, 0x3c,
512 /* GNU/Linux-specific optional "registers". */
516 int s390_regmap_last_break
[S390_NUM_REGS
] =
518 /* Program Status Word. */
520 /* General Purpose Registers. */
521 -1, -1, -1, -1, -1, -1, -1, -1,
522 -1, -1, -1, -1, -1, -1, -1, -1,
523 /* Access Registers. */
524 -1, -1, -1, -1, -1, -1, -1, -1,
525 -1, -1, -1, -1, -1, -1, -1, -1,
526 /* Floating Point Control Word. */
528 /* Floating Point Registers. */
529 -1, -1, -1, -1, -1, -1, -1, -1,
530 -1, -1, -1, -1, -1, -1, -1, -1,
531 /* GPR Uppper Halves. */
532 -1, -1, -1, -1, -1, -1, -1, -1,
533 -1, -1, -1, -1, -1, -1, -1, -1,
534 /* GNU/Linux-specific optional "registers". */
538 int s390x_regmap_last_break
[S390_NUM_REGS
] =
540 /* Program Status Word. */
542 /* General Purpose Registers. */
543 -1, -1, -1, -1, -1, -1, -1, -1,
544 -1, -1, -1, -1, -1, -1, -1, -1,
545 /* Access Registers. */
546 -1, -1, -1, -1, -1, -1, -1, -1,
547 -1, -1, -1, -1, -1, -1, -1, -1,
548 /* Floating Point Control Word. */
550 /* Floating Point Registers. */
551 -1, -1, -1, -1, -1, -1, -1, -1,
552 -1, -1, -1, -1, -1, -1, -1, -1,
553 /* GPR Uppper Halves. */
554 -1, -1, -1, -1, -1, -1, -1, -1,
555 -1, -1, -1, -1, -1, -1, -1, -1,
556 /* GNU/Linux-specific optional "registers". */
560 int s390_regmap_system_call
[S390_NUM_REGS
] =
562 /* Program Status Word. */
564 /* General Purpose Registers. */
565 -1, -1, -1, -1, -1, -1, -1, -1,
566 -1, -1, -1, -1, -1, -1, -1, -1,
567 /* Access Registers. */
568 -1, -1, -1, -1, -1, -1, -1, -1,
569 -1, -1, -1, -1, -1, -1, -1, -1,
570 /* Floating Point Control Word. */
572 /* Floating Point Registers. */
573 -1, -1, -1, -1, -1, -1, -1, -1,
574 -1, -1, -1, -1, -1, -1, -1, -1,
575 /* GPR Uppper Halves. */
576 -1, -1, -1, -1, -1, -1, -1, -1,
577 -1, -1, -1, -1, -1, -1, -1, -1,
578 /* GNU/Linux-specific optional "registers". */
582 /* Supply register REGNUM from the register set REGSET to register cache
583 REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */
585 s390_supply_regset (const struct regset
*regset
, struct regcache
*regcache
,
586 int regnum
, const void *regs
, size_t len
)
588 const int *offset
= regset
->descr
;
591 for (i
= 0; i
< S390_NUM_REGS
; i
++)
593 if ((regnum
== i
|| regnum
== -1) && offset
[i
] != -1)
594 regcache_raw_supply (regcache
, i
, (const char *)regs
+ offset
[i
]);
598 /* Collect register REGNUM from the register cache REGCACHE and store
599 it in the buffer specified by REGS and LEN as described by the
600 general-purpose register set REGSET. If REGNUM is -1, do this for
601 all registers in REGSET. */
603 s390_collect_regset (const struct regset
*regset
,
604 const struct regcache
*regcache
,
605 int regnum
, void *regs
, size_t len
)
607 const int *offset
= regset
->descr
;
610 for (i
= 0; i
< S390_NUM_REGS
; i
++)
612 if ((regnum
== i
|| regnum
== -1) && offset
[i
] != -1)
613 regcache_raw_collect (regcache
, i
, (char *)regs
+ offset
[i
]);
617 static const struct regset s390_gregset
= {
623 static const struct regset s390x_gregset
= {
624 s390x_regmap_gregset
,
629 static const struct regset s390_fpregset
= {
630 s390_regmap_fpregset
,
635 static const struct regset s390_upper_regset
= {
641 static const struct regset s390_last_break_regset
= {
642 s390_regmap_last_break
,
647 static const struct regset s390x_last_break_regset
= {
648 s390x_regmap_last_break
,
653 static const struct regset s390_system_call_regset
= {
654 s390_regmap_system_call
,
659 static struct core_regset_section s390_linux32_regset_sections
[] =
661 { ".reg", s390_sizeof_gregset
, "general-purpose" },
662 { ".reg2", s390_sizeof_fpregset
, "floating-point" },
666 static struct core_regset_section s390_linux32v1_regset_sections
[] =
668 { ".reg", s390_sizeof_gregset
, "general-purpose" },
669 { ".reg2", s390_sizeof_fpregset
, "floating-point" },
670 { ".reg-s390-last-break", 8, "s390 last-break address" },
674 static struct core_regset_section s390_linux32v2_regset_sections
[] =
676 { ".reg", s390_sizeof_gregset
, "general-purpose" },
677 { ".reg2", s390_sizeof_fpregset
, "floating-point" },
678 { ".reg-s390-last-break", 8, "s390 last-break address" },
679 { ".reg-s390-system-call", 4, "s390 system-call" },
683 static struct core_regset_section s390_linux64_regset_sections
[] =
685 { ".reg", s390_sizeof_gregset
, "general-purpose" },
686 { ".reg2", s390_sizeof_fpregset
, "floating-point" },
687 { ".reg-s390-high-gprs", 16*4, "s390 GPR upper halves" },
691 static struct core_regset_section s390_linux64v1_regset_sections
[] =
693 { ".reg", s390_sizeof_gregset
, "general-purpose" },
694 { ".reg2", s390_sizeof_fpregset
, "floating-point" },
695 { ".reg-s390-high-gprs", 16*4, "s390 GPR upper halves" },
696 { ".reg-s390-last-break", 8, "s930 last-break address" },
700 static struct core_regset_section s390_linux64v2_regset_sections
[] =
702 { ".reg", s390_sizeof_gregset
, "general-purpose" },
703 { ".reg2", s390_sizeof_fpregset
, "floating-point" },
704 { ".reg-s390-high-gprs", 16*4, "s390 GPR upper halves" },
705 { ".reg-s390-last-break", 8, "s930 last-break address" },
706 { ".reg-s390-system-call", 4, "s390 system-call" },
710 static struct core_regset_section s390x_linux64_regset_sections
[] =
712 { ".reg", s390x_sizeof_gregset
, "general-purpose" },
713 { ".reg2", s390_sizeof_fpregset
, "floating-point" },
717 static struct core_regset_section s390x_linux64v1_regset_sections
[] =
719 { ".reg", s390x_sizeof_gregset
, "general-purpose" },
720 { ".reg2", s390_sizeof_fpregset
, "floating-point" },
721 { ".reg-s390-last-break", 8, "s930 last-break address" },
725 static struct core_regset_section s390x_linux64v2_regset_sections
[] =
727 { ".reg", s390x_sizeof_gregset
, "general-purpose" },
728 { ".reg2", s390_sizeof_fpregset
, "floating-point" },
729 { ".reg-s390-last-break", 8, "s930 last-break address" },
730 { ".reg-s390-system-call", 4, "s390 system-call" },
735 /* Return the appropriate register set for the core section identified
736 by SECT_NAME and SECT_SIZE. */
737 static const struct regset
*
738 s390_regset_from_core_section (struct gdbarch
*gdbarch
,
739 const char *sect_name
, size_t sect_size
)
741 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
743 if (strcmp (sect_name
, ".reg") == 0 && sect_size
>= tdep
->sizeof_gregset
)
744 return tdep
->gregset
;
746 if (strcmp (sect_name
, ".reg2") == 0 && sect_size
>= tdep
->sizeof_fpregset
)
747 return tdep
->fpregset
;
749 if (strcmp (sect_name
, ".reg-s390-high-gprs") == 0 && sect_size
>= 16*4)
750 return &s390_upper_regset
;
752 if (strcmp (sect_name
, ".reg-s390-last-break") == 0 && sect_size
>= 8)
753 return (gdbarch_ptr_bit (gdbarch
) == 32
754 ? &s390_last_break_regset
: &s390x_last_break_regset
);
756 if (strcmp (sect_name
, ".reg-s390-system-call") == 0 && sect_size
>= 4)
757 return &s390_system_call_regset
;
762 static const struct target_desc
*
763 s390_core_read_description (struct gdbarch
*gdbarch
,
764 struct target_ops
*target
, bfd
*abfd
)
766 asection
*high_gprs
= bfd_get_section_by_name (abfd
, ".reg-s390-high-gprs");
767 asection
*v1
= bfd_get_section_by_name (abfd
, ".reg-s390-last-break");
768 asection
*v2
= bfd_get_section_by_name (abfd
, ".reg-s390-system-call");
769 asection
*section
= bfd_get_section_by_name (abfd
, ".reg");
773 switch (bfd_section_size (abfd
, section
))
775 case s390_sizeof_gregset
:
777 return (v2
? tdesc_s390_linux64v2
:
778 v1
? tdesc_s390_linux64v1
: tdesc_s390_linux64
);
780 return (v2
? tdesc_s390_linux32v2
:
781 v1
? tdesc_s390_linux32v1
: tdesc_s390_linux32
);
783 case s390x_sizeof_gregset
:
784 return (v2
? tdesc_s390x_linux64v2
:
785 v1
? tdesc_s390x_linux64v1
: tdesc_s390x_linux64
);
793 /* Decoding S/390 instructions. */
795 /* Named opcode values for the S/390 instructions we recognize. Some
796 instructions have their opcode split across two fields; those are the
797 op1_* and op2_* enums. */
800 op1_lhi
= 0xa7, op2_lhi
= 0x08,
801 op1_lghi
= 0xa7, op2_lghi
= 0x09,
802 op1_lgfi
= 0xc0, op2_lgfi
= 0x01,
806 op1_ly
= 0xe3, op2_ly
= 0x58,
807 op1_lg
= 0xe3, op2_lg
= 0x04,
809 op1_lmy
= 0xeb, op2_lmy
= 0x98,
810 op1_lmg
= 0xeb, op2_lmg
= 0x04,
812 op1_sty
= 0xe3, op2_sty
= 0x50,
813 op1_stg
= 0xe3, op2_stg
= 0x24,
816 op1_stmy
= 0xeb, op2_stmy
= 0x90,
817 op1_stmg
= 0xeb, op2_stmg
= 0x24,
818 op1_aghi
= 0xa7, op2_aghi
= 0x0b,
819 op1_ahi
= 0xa7, op2_ahi
= 0x0a,
820 op1_agfi
= 0xc2, op2_agfi
= 0x08,
821 op1_afi
= 0xc2, op2_afi
= 0x09,
822 op1_algfi
= 0xc2, op2_algfi
= 0x0a,
823 op1_alfi
= 0xc2, op2_alfi
= 0x0b,
827 op1_ay
= 0xe3, op2_ay
= 0x5a,
828 op1_ag
= 0xe3, op2_ag
= 0x08,
829 op1_slgfi
= 0xc2, op2_slgfi
= 0x04,
830 op1_slfi
= 0xc2, op2_slfi
= 0x05,
834 op1_sy
= 0xe3, op2_sy
= 0x5b,
835 op1_sg
= 0xe3, op2_sg
= 0x09,
839 op1_lay
= 0xe3, op2_lay
= 0x71,
840 op1_larl
= 0xc0, op2_larl
= 0x00,
848 op1_bctg
= 0xe3, op2_bctg
= 0x46,
850 op1_bxhg
= 0xeb, op2_bxhg
= 0x44,
852 op1_bxleg
= 0xeb, op2_bxleg
= 0x45,
853 op1_bras
= 0xa7, op2_bras
= 0x05,
854 op1_brasl
= 0xc0, op2_brasl
= 0x05,
855 op1_brc
= 0xa7, op2_brc
= 0x04,
856 op1_brcl
= 0xc0, op2_brcl
= 0x04,
857 op1_brct
= 0xa7, op2_brct
= 0x06,
858 op1_brctg
= 0xa7, op2_brctg
= 0x07,
860 op1_brxhg
= 0xec, op2_brxhg
= 0x44,
862 op1_brxlg
= 0xec, op2_brxlg
= 0x45,
866 /* Read a single instruction from address AT. */
868 #define S390_MAX_INSTR_SIZE 6
870 s390_readinstruction (bfd_byte instr
[], CORE_ADDR at
)
872 static int s390_instrlen
[] = { 2, 4, 4, 6 };
875 if (target_read_memory (at
, &instr
[0], 2))
877 instrlen
= s390_instrlen
[instr
[0] >> 6];
880 if (target_read_memory (at
+ 2, &instr
[2], instrlen
- 2))
887 /* The functions below are for recognizing and decoding S/390
888 instructions of various formats. Each of them checks whether INSN
889 is an instruction of the given format, with the specified opcodes.
890 If it is, it sets the remaining arguments to the values of the
891 instruction's fields, and returns a non-zero value; otherwise, it
894 These functions' arguments appear in the order they appear in the
895 instruction, not in the machine-language form. So, opcodes always
896 come first, even though they're sometimes scattered around the
897 instructions. And displacements appear before base and extension
898 registers, as they do in the assembly syntax, not at the end, as
899 they do in the machine language. */
901 is_ri (bfd_byte
*insn
, int op1
, int op2
, unsigned int *r1
, int *i2
)
903 if (insn
[0] == op1
&& (insn
[1] & 0xf) == op2
)
905 *r1
= (insn
[1] >> 4) & 0xf;
906 /* i2 is a 16-bit signed quantity. */
907 *i2
= (((insn
[2] << 8) | insn
[3]) ^ 0x8000) - 0x8000;
916 is_ril (bfd_byte
*insn
, int op1
, int op2
,
917 unsigned int *r1
, int *i2
)
919 if (insn
[0] == op1
&& (insn
[1] & 0xf) == op2
)
921 *r1
= (insn
[1] >> 4) & 0xf;
922 /* i2 is a signed quantity. If the host 'int' is 32 bits long,
923 no sign extension is necessary, but we don't want to assume
925 *i2
= (((insn
[2] << 24)
928 | (insn
[5])) ^ 0x80000000) - 0x80000000;
937 is_rr (bfd_byte
*insn
, int op
, unsigned int *r1
, unsigned int *r2
)
941 *r1
= (insn
[1] >> 4) & 0xf;
951 is_rre (bfd_byte
*insn
, int op
, unsigned int *r1
, unsigned int *r2
)
953 if (((insn
[0] << 8) | insn
[1]) == op
)
955 /* Yes, insn[3]. insn[2] is unused in RRE format. */
956 *r1
= (insn
[3] >> 4) & 0xf;
966 is_rs (bfd_byte
*insn
, int op
,
967 unsigned int *r1
, unsigned int *r3
, int *d2
, unsigned int *b2
)
971 *r1
= (insn
[1] >> 4) & 0xf;
973 *b2
= (insn
[2] >> 4) & 0xf;
974 *d2
= ((insn
[2] & 0xf) << 8) | insn
[3];
983 is_rsy (bfd_byte
*insn
, int op1
, int op2
,
984 unsigned int *r1
, unsigned int *r3
, int *d2
, unsigned int *b2
)
989 *r1
= (insn
[1] >> 4) & 0xf;
991 *b2
= (insn
[2] >> 4) & 0xf;
992 /* The 'long displacement' is a 20-bit signed integer. */
993 *d2
= ((((insn
[2] & 0xf) << 8) | insn
[3] | (insn
[4] << 12))
994 ^ 0x80000) - 0x80000;
1003 is_rsi (bfd_byte
*insn
, int op
,
1004 unsigned int *r1
, unsigned int *r3
, int *i2
)
1008 *r1
= (insn
[1] >> 4) & 0xf;
1009 *r3
= insn
[1] & 0xf;
1010 /* i2 is a 16-bit signed quantity. */
1011 *i2
= (((insn
[2] << 8) | insn
[3]) ^ 0x8000) - 0x8000;
1020 is_rie (bfd_byte
*insn
, int op1
, int op2
,
1021 unsigned int *r1
, unsigned int *r3
, int *i2
)
1026 *r1
= (insn
[1] >> 4) & 0xf;
1027 *r3
= insn
[1] & 0xf;
1028 /* i2 is a 16-bit signed quantity. */
1029 *i2
= (((insn
[2] << 8) | insn
[3]) ^ 0x8000) - 0x8000;
1038 is_rx (bfd_byte
*insn
, int op
,
1039 unsigned int *r1
, int *d2
, unsigned int *x2
, unsigned int *b2
)
1043 *r1
= (insn
[1] >> 4) & 0xf;
1044 *x2
= insn
[1] & 0xf;
1045 *b2
= (insn
[2] >> 4) & 0xf;
1046 *d2
= ((insn
[2] & 0xf) << 8) | insn
[3];
1055 is_rxy (bfd_byte
*insn
, int op1
, int op2
,
1056 unsigned int *r1
, int *d2
, unsigned int *x2
, unsigned int *b2
)
1061 *r1
= (insn
[1] >> 4) & 0xf;
1062 *x2
= insn
[1] & 0xf;
1063 *b2
= (insn
[2] >> 4) & 0xf;
1064 /* The 'long displacement' is a 20-bit signed integer. */
1065 *d2
= ((((insn
[2] & 0xf) << 8) | insn
[3] | (insn
[4] << 12))
1066 ^ 0x80000) - 0x80000;
1074 /* Prologue analysis. */
1076 #define S390_NUM_GPRS 16
1077 #define S390_NUM_FPRS 16
1079 struct s390_prologue_data
{
1082 struct pv_area
*stack
;
1084 /* The size and byte-order of a GPR or FPR. */
1087 enum bfd_endian byte_order
;
1089 /* The general-purpose registers. */
1090 pv_t gpr
[S390_NUM_GPRS
];
1092 /* The floating-point registers. */
1093 pv_t fpr
[S390_NUM_FPRS
];
1095 /* The offset relative to the CFA where the incoming GPR N was saved
1096 by the function prologue. 0 if not saved or unknown. */
1097 int gpr_slot
[S390_NUM_GPRS
];
1099 /* Likewise for FPRs. */
1100 int fpr_slot
[S390_NUM_FPRS
];
1102 /* Nonzero if the backchain was saved. This is assumed to be the
1103 case when the incoming SP is saved at the current SP location. */
1104 int back_chain_saved_p
;
1107 /* Return the effective address for an X-style instruction, like:
1111 Here, X2 and B2 are registers, and D2 is a signed 20-bit
1112 constant; the effective address is the sum of all three. If either
1113 X2 or B2 are zero, then it doesn't contribute to the sum --- this
1114 means that r0 can't be used as either X2 or B2. */
1116 s390_addr (struct s390_prologue_data
*data
,
1117 int d2
, unsigned int x2
, unsigned int b2
)
1121 result
= pv_constant (d2
);
1123 result
= pv_add (result
, data
->gpr
[x2
]);
1125 result
= pv_add (result
, data
->gpr
[b2
]);
1130 /* Do a SIZE-byte store of VALUE to D2(X2,B2). */
1132 s390_store (struct s390_prologue_data
*data
,
1133 int d2
, unsigned int x2
, unsigned int b2
, CORE_ADDR size
,
1136 pv_t addr
= s390_addr (data
, d2
, x2
, b2
);
1139 /* Check whether we are storing the backchain. */
1140 offset
= pv_subtract (data
->gpr
[S390_SP_REGNUM
- S390_R0_REGNUM
], addr
);
1142 if (pv_is_constant (offset
) && offset
.k
== 0)
1143 if (size
== data
->gpr_size
1144 && pv_is_register_k (value
, S390_SP_REGNUM
, 0))
1146 data
->back_chain_saved_p
= 1;
1151 /* Check whether we are storing a register into the stack. */
1152 if (!pv_area_store_would_trash (data
->stack
, addr
))
1153 pv_area_store (data
->stack
, addr
, size
, value
);
1156 /* Note: If this is some store we cannot identify, you might think we
1157 should forget our cached values, as any of those might have been hit.
1159 However, we make the assumption that the register save areas are only
1160 ever stored to once in any given function, and we do recognize these
1161 stores. Thus every store we cannot recognize does not hit our data. */
1164 /* Do a SIZE-byte load from D2(X2,B2). */
1166 s390_load (struct s390_prologue_data
*data
,
1167 int d2
, unsigned int x2
, unsigned int b2
, CORE_ADDR size
)
1170 pv_t addr
= s390_addr (data
, d2
, x2
, b2
);
1172 /* If it's a load from an in-line constant pool, then we can
1173 simulate that, under the assumption that the code isn't
1174 going to change between the time the processor actually
1175 executed it creating the current frame, and the time when
1176 we're analyzing the code to unwind past that frame. */
1177 if (pv_is_constant (addr
))
1179 struct target_section
*secp
;
1180 secp
= target_section_by_addr (¤t_target
, addr
.k
);
1182 && (bfd_get_section_flags (secp
->the_bfd_section
->owner
,
1183 secp
->the_bfd_section
)
1185 return pv_constant (read_memory_integer (addr
.k
, size
,
1189 /* Check whether we are accessing one of our save slots. */
1190 return pv_area_fetch (data
->stack
, addr
, size
);
1193 /* Function for finding saved registers in a 'struct pv_area'; we pass
1194 this to pv_area_scan.
1196 If VALUE is a saved register, ADDR says it was saved at a constant
1197 offset from the frame base, and SIZE indicates that the whole
1198 register was saved, record its offset in the reg_offset table in
1199 PROLOGUE_UNTYPED. */
1201 s390_check_for_saved (void *data_untyped
, pv_t addr
,
1202 CORE_ADDR size
, pv_t value
)
1204 struct s390_prologue_data
*data
= data_untyped
;
1207 if (!pv_is_register (addr
, S390_SP_REGNUM
))
1210 offset
= 16 * data
->gpr_size
+ 32 - addr
.k
;
1212 /* If we are storing the original value of a register, we want to
1213 record the CFA offset. If the same register is stored multiple
1214 times, the stack slot with the highest address counts. */
1216 for (i
= 0; i
< S390_NUM_GPRS
; i
++)
1217 if (size
== data
->gpr_size
1218 && pv_is_register_k (value
, S390_R0_REGNUM
+ i
, 0))
1219 if (data
->gpr_slot
[i
] == 0
1220 || data
->gpr_slot
[i
] > offset
)
1222 data
->gpr_slot
[i
] = offset
;
1226 for (i
= 0; i
< S390_NUM_FPRS
; i
++)
1227 if (size
== data
->fpr_size
1228 && pv_is_register_k (value
, S390_F0_REGNUM
+ i
, 0))
1229 if (data
->fpr_slot
[i
] == 0
1230 || data
->fpr_slot
[i
] > offset
)
1232 data
->fpr_slot
[i
] = offset
;
1237 /* Analyze the prologue of the function starting at START_PC,
1238 continuing at most until CURRENT_PC. Initialize DATA to
1239 hold all information we find out about the state of the registers
1240 and stack slots. Return the address of the instruction after
1241 the last one that changed the SP, FP, or back chain; or zero
1244 s390_analyze_prologue (struct gdbarch
*gdbarch
,
1246 CORE_ADDR current_pc
,
1247 struct s390_prologue_data
*data
)
1249 int word_size
= gdbarch_ptr_bit (gdbarch
) / 8;
1251 /* Our return value:
1252 The address of the instruction after the last one that changed
1253 the SP, FP, or back chain; zero if we got an error trying to
1255 CORE_ADDR result
= start_pc
;
1257 /* The current PC for our abstract interpretation. */
1260 /* The address of the next instruction after that. */
1263 /* Set up everything's initial value. */
1267 data
->stack
= make_pv_area (S390_SP_REGNUM
, gdbarch_addr_bit (gdbarch
));
1269 /* For the purpose of prologue tracking, we consider the GPR size to
1270 be equal to the ABI word size, even if it is actually larger
1271 (i.e. when running a 32-bit binary under a 64-bit kernel). */
1272 data
->gpr_size
= word_size
;
1274 data
->byte_order
= gdbarch_byte_order (gdbarch
);
1276 for (i
= 0; i
< S390_NUM_GPRS
; i
++)
1277 data
->gpr
[i
] = pv_register (S390_R0_REGNUM
+ i
, 0);
1279 for (i
= 0; i
< S390_NUM_FPRS
; i
++)
1280 data
->fpr
[i
] = pv_register (S390_F0_REGNUM
+ i
, 0);
1282 for (i
= 0; i
< S390_NUM_GPRS
; i
++)
1283 data
->gpr_slot
[i
] = 0;
1285 for (i
= 0; i
< S390_NUM_FPRS
; i
++)
1286 data
->fpr_slot
[i
] = 0;
1288 data
->back_chain_saved_p
= 0;
1291 /* Start interpreting instructions, until we hit the frame's
1292 current PC or the first branch instruction. */
1293 for (pc
= start_pc
; pc
> 0 && pc
< current_pc
; pc
= next_pc
)
1295 bfd_byte insn
[S390_MAX_INSTR_SIZE
];
1296 int insn_len
= s390_readinstruction (insn
, pc
);
1298 bfd_byte dummy
[S390_MAX_INSTR_SIZE
] = { 0 };
1299 bfd_byte
*insn32
= word_size
== 4 ? insn
: dummy
;
1300 bfd_byte
*insn64
= word_size
== 8 ? insn
: dummy
;
1302 /* Fields for various kinds of instructions. */
1303 unsigned int b2
, r1
, r2
, x2
, r3
;
1306 /* The values of SP and FP before this instruction,
1307 for detecting instructions that change them. */
1308 pv_t pre_insn_sp
, pre_insn_fp
;
1309 /* Likewise for the flag whether the back chain was saved. */
1310 int pre_insn_back_chain_saved_p
;
1312 /* If we got an error trying to read the instruction, report it. */
1319 next_pc
= pc
+ insn_len
;
1321 pre_insn_sp
= data
->gpr
[S390_SP_REGNUM
- S390_R0_REGNUM
];
1322 pre_insn_fp
= data
->gpr
[S390_FRAME_REGNUM
- S390_R0_REGNUM
];
1323 pre_insn_back_chain_saved_p
= data
->back_chain_saved_p
;
1326 /* LHI r1, i2 --- load halfword immediate. */
1327 /* LGHI r1, i2 --- load halfword immediate (64-bit version). */
1328 /* LGFI r1, i2 --- load fullword immediate. */
1329 if (is_ri (insn32
, op1_lhi
, op2_lhi
, &r1
, &i2
)
1330 || is_ri (insn64
, op1_lghi
, op2_lghi
, &r1
, &i2
)
1331 || is_ril (insn
, op1_lgfi
, op2_lgfi
, &r1
, &i2
))
1332 data
->gpr
[r1
] = pv_constant (i2
);
1334 /* LR r1, r2 --- load from register. */
1335 /* LGR r1, r2 --- load from register (64-bit version). */
1336 else if (is_rr (insn32
, op_lr
, &r1
, &r2
)
1337 || is_rre (insn64
, op_lgr
, &r1
, &r2
))
1338 data
->gpr
[r1
] = data
->gpr
[r2
];
1340 /* L r1, d2(x2, b2) --- load. */
1341 /* LY r1, d2(x2, b2) --- load (long-displacement version). */
1342 /* LG r1, d2(x2, b2) --- load (64-bit version). */
1343 else if (is_rx (insn32
, op_l
, &r1
, &d2
, &x2
, &b2
)
1344 || is_rxy (insn32
, op1_ly
, op2_ly
, &r1
, &d2
, &x2
, &b2
)
1345 || is_rxy (insn64
, op1_lg
, op2_lg
, &r1
, &d2
, &x2
, &b2
))
1346 data
->gpr
[r1
] = s390_load (data
, d2
, x2
, b2
, data
->gpr_size
);
1348 /* ST r1, d2(x2, b2) --- store. */
1349 /* STY r1, d2(x2, b2) --- store (long-displacement version). */
1350 /* STG r1, d2(x2, b2) --- store (64-bit version). */
1351 else if (is_rx (insn32
, op_st
, &r1
, &d2
, &x2
, &b2
)
1352 || is_rxy (insn32
, op1_sty
, op2_sty
, &r1
, &d2
, &x2
, &b2
)
1353 || is_rxy (insn64
, op1_stg
, op2_stg
, &r1
, &d2
, &x2
, &b2
))
1354 s390_store (data
, d2
, x2
, b2
, data
->gpr_size
, data
->gpr
[r1
]);
1356 /* STD r1, d2(x2,b2) --- store floating-point register. */
1357 else if (is_rx (insn
, op_std
, &r1
, &d2
, &x2
, &b2
))
1358 s390_store (data
, d2
, x2
, b2
, data
->fpr_size
, data
->fpr
[r1
]);
1360 /* STM r1, r3, d2(b2) --- store multiple. */
1361 /* STMY r1, r3, d2(b2) --- store multiple (long-displacement
1363 /* STMG r1, r3, d2(b2) --- store multiple (64-bit version). */
1364 else if (is_rs (insn32
, op_stm
, &r1
, &r3
, &d2
, &b2
)
1365 || is_rsy (insn32
, op1_stmy
, op2_stmy
, &r1
, &r3
, &d2
, &b2
)
1366 || is_rsy (insn64
, op1_stmg
, op2_stmg
, &r1
, &r3
, &d2
, &b2
))
1368 for (; r1
<= r3
; r1
++, d2
+= data
->gpr_size
)
1369 s390_store (data
, d2
, 0, b2
, data
->gpr_size
, data
->gpr
[r1
]);
1372 /* AHI r1, i2 --- add halfword immediate. */
1373 /* AGHI r1, i2 --- add halfword immediate (64-bit version). */
1374 /* AFI r1, i2 --- add fullword immediate. */
1375 /* AGFI r1, i2 --- add fullword immediate (64-bit version). */
1376 else if (is_ri (insn32
, op1_ahi
, op2_ahi
, &r1
, &i2
)
1377 || is_ri (insn64
, op1_aghi
, op2_aghi
, &r1
, &i2
)
1378 || is_ril (insn32
, op1_afi
, op2_afi
, &r1
, &i2
)
1379 || is_ril (insn64
, op1_agfi
, op2_agfi
, &r1
, &i2
))
1380 data
->gpr
[r1
] = pv_add_constant (data
->gpr
[r1
], i2
);
1382 /* ALFI r1, i2 --- add logical immediate. */
1383 /* ALGFI r1, i2 --- add logical immediate (64-bit version). */
1384 else if (is_ril (insn32
, op1_alfi
, op2_alfi
, &r1
, &i2
)
1385 || is_ril (insn64
, op1_algfi
, op2_algfi
, &r1
, &i2
))
1386 data
->gpr
[r1
] = pv_add_constant (data
->gpr
[r1
],
1387 (CORE_ADDR
)i2
& 0xffffffff);
1389 /* AR r1, r2 -- add register. */
1390 /* AGR r1, r2 -- add register (64-bit version). */
1391 else if (is_rr (insn32
, op_ar
, &r1
, &r2
)
1392 || is_rre (insn64
, op_agr
, &r1
, &r2
))
1393 data
->gpr
[r1
] = pv_add (data
->gpr
[r1
], data
->gpr
[r2
]);
1395 /* A r1, d2(x2, b2) -- add. */
1396 /* AY r1, d2(x2, b2) -- add (long-displacement version). */
1397 /* AG r1, d2(x2, b2) -- add (64-bit version). */
1398 else if (is_rx (insn32
, op_a
, &r1
, &d2
, &x2
, &b2
)
1399 || is_rxy (insn32
, op1_ay
, op2_ay
, &r1
, &d2
, &x2
, &b2
)
1400 || is_rxy (insn64
, op1_ag
, op2_ag
, &r1
, &d2
, &x2
, &b2
))
1401 data
->gpr
[r1
] = pv_add (data
->gpr
[r1
],
1402 s390_load (data
, d2
, x2
, b2
, data
->gpr_size
));
1404 /* SLFI r1, i2 --- subtract logical immediate. */
1405 /* SLGFI r1, i2 --- subtract logical immediate (64-bit version). */
1406 else if (is_ril (insn32
, op1_slfi
, op2_slfi
, &r1
, &i2
)
1407 || is_ril (insn64
, op1_slgfi
, op2_slgfi
, &r1
, &i2
))
1408 data
->gpr
[r1
] = pv_add_constant (data
->gpr
[r1
],
1409 -((CORE_ADDR
)i2
& 0xffffffff));
1411 /* SR r1, r2 -- subtract register. */
1412 /* SGR r1, r2 -- subtract register (64-bit version). */
1413 else if (is_rr (insn32
, op_sr
, &r1
, &r2
)
1414 || is_rre (insn64
, op_sgr
, &r1
, &r2
))
1415 data
->gpr
[r1
] = pv_subtract (data
->gpr
[r1
], data
->gpr
[r2
]);
1417 /* S r1, d2(x2, b2) -- subtract. */
1418 /* SY r1, d2(x2, b2) -- subtract (long-displacement version). */
1419 /* SG r1, d2(x2, b2) -- subtract (64-bit version). */
1420 else if (is_rx (insn32
, op_s
, &r1
, &d2
, &x2
, &b2
)
1421 || is_rxy (insn32
, op1_sy
, op2_sy
, &r1
, &d2
, &x2
, &b2
)
1422 || is_rxy (insn64
, op1_sg
, op2_sg
, &r1
, &d2
, &x2
, &b2
))
1423 data
->gpr
[r1
] = pv_subtract (data
->gpr
[r1
],
1424 s390_load (data
, d2
, x2
, b2
, data
->gpr_size
));
1426 /* LA r1, d2(x2, b2) --- load address. */
1427 /* LAY r1, d2(x2, b2) --- load address (long-displacement version). */
1428 else if (is_rx (insn
, op_la
, &r1
, &d2
, &x2
, &b2
)
1429 || is_rxy (insn
, op1_lay
, op2_lay
, &r1
, &d2
, &x2
, &b2
))
1430 data
->gpr
[r1
] = s390_addr (data
, d2
, x2
, b2
);
1432 /* LARL r1, i2 --- load address relative long. */
1433 else if (is_ril (insn
, op1_larl
, op2_larl
, &r1
, &i2
))
1434 data
->gpr
[r1
] = pv_constant (pc
+ i2
* 2);
1436 /* BASR r1, 0 --- branch and save.
1437 Since r2 is zero, this saves the PC in r1, but doesn't branch. */
1438 else if (is_rr (insn
, op_basr
, &r1
, &r2
)
1440 data
->gpr
[r1
] = pv_constant (next_pc
);
1442 /* BRAS r1, i2 --- branch relative and save. */
1443 else if (is_ri (insn
, op1_bras
, op2_bras
, &r1
, &i2
))
1445 data
->gpr
[r1
] = pv_constant (next_pc
);
1446 next_pc
= pc
+ i2
* 2;
1448 /* We'd better not interpret any backward branches. We'll
1454 /* Terminate search when hitting any other branch instruction. */
1455 else if (is_rr (insn
, op_basr
, &r1
, &r2
)
1456 || is_rx (insn
, op_bas
, &r1
, &d2
, &x2
, &b2
)
1457 || is_rr (insn
, op_bcr
, &r1
, &r2
)
1458 || is_rx (insn
, op_bc
, &r1
, &d2
, &x2
, &b2
)
1459 || is_ri (insn
, op1_brc
, op2_brc
, &r1
, &i2
)
1460 || is_ril (insn
, op1_brcl
, op2_brcl
, &r1
, &i2
)
1461 || is_ril (insn
, op1_brasl
, op2_brasl
, &r2
, &i2
))
1466 /* An instruction we don't know how to simulate. The only
1467 safe thing to do would be to set every value we're tracking
1468 to 'unknown'. Instead, we'll be optimistic: we assume that
1469 we *can* interpret every instruction that the compiler uses
1470 to manipulate any of the data we're interested in here --
1471 then we can just ignore anything else. */
1474 /* Record the address after the last instruction that changed
1475 the FP, SP, or backlink. Ignore instructions that changed
1476 them back to their original values --- those are probably
1477 restore instructions. (The back chain is never restored,
1480 pv_t sp
= data
->gpr
[S390_SP_REGNUM
- S390_R0_REGNUM
];
1481 pv_t fp
= data
->gpr
[S390_FRAME_REGNUM
- S390_R0_REGNUM
];
1483 if ((! pv_is_identical (pre_insn_sp
, sp
)
1484 && ! pv_is_register_k (sp
, S390_SP_REGNUM
, 0)
1485 && sp
.kind
!= pvk_unknown
)
1486 || (! pv_is_identical (pre_insn_fp
, fp
)
1487 && ! pv_is_register_k (fp
, S390_FRAME_REGNUM
, 0)
1488 && fp
.kind
!= pvk_unknown
)
1489 || pre_insn_back_chain_saved_p
!= data
->back_chain_saved_p
)
1494 /* Record where all the registers were saved. */
1495 pv_area_scan (data
->stack
, s390_check_for_saved
, data
);
1497 free_pv_area (data
->stack
);
1503 /* Advance PC across any function entry prologue instructions to reach
1504 some "real" code. */
1506 s390_skip_prologue (struct gdbarch
*gdbarch
, CORE_ADDR pc
)
1508 struct s390_prologue_data data
;
1510 skip_pc
= s390_analyze_prologue (gdbarch
, pc
, (CORE_ADDR
)-1, &data
);
1511 return skip_pc
? skip_pc
: pc
;
1514 /* Return true if we are in the functin's epilogue, i.e. after the
1515 instruction that destroyed the function's stack frame. */
1517 s390_in_function_epilogue_p (struct gdbarch
*gdbarch
, CORE_ADDR pc
)
1519 int word_size
= gdbarch_ptr_bit (gdbarch
) / 8;
1521 /* In frameless functions, there's not frame to destroy and thus
1522 we don't care about the epilogue.
1524 In functions with frame, the epilogue sequence is a pair of
1525 a LM-type instruction that restores (amongst others) the
1526 return register %r14 and the stack pointer %r15, followed
1527 by a branch 'br %r14' --or equivalent-- that effects the
1530 In that situation, this function needs to return 'true' in
1531 exactly one case: when pc points to that branch instruction.
1533 Thus we try to disassemble the one instructions immediately
1534 preceding pc and check whether it is an LM-type instruction
1535 modifying the stack pointer.
1537 Note that disassembling backwards is not reliable, so there
1538 is a slight chance of false positives here ... */
1541 unsigned int r1
, r3
, b2
;
1545 && !target_read_memory (pc
- 4, insn
, 4)
1546 && is_rs (insn
, op_lm
, &r1
, &r3
, &d2
, &b2
)
1547 && r3
== S390_SP_REGNUM
- S390_R0_REGNUM
)
1551 && !target_read_memory (pc
- 6, insn
, 6)
1552 && is_rsy (insn
, op1_lmy
, op2_lmy
, &r1
, &r3
, &d2
, &b2
)
1553 && r3
== S390_SP_REGNUM
- S390_R0_REGNUM
)
1557 && !target_read_memory (pc
- 6, insn
, 6)
1558 && is_rsy (insn
, op1_lmg
, op2_lmg
, &r1
, &r3
, &d2
, &b2
)
1559 && r3
== S390_SP_REGNUM
- S390_R0_REGNUM
)
1565 /* Displaced stepping. */
1567 /* Fix up the state of registers and memory after having single-stepped
1568 a displaced instruction. */
1570 s390_displaced_step_fixup (struct gdbarch
*gdbarch
,
1571 struct displaced_step_closure
*closure
,
1572 CORE_ADDR from
, CORE_ADDR to
,
1573 struct regcache
*regs
)
1575 /* Since we use simple_displaced_step_copy_insn, our closure is a
1576 copy of the instruction. */
1577 gdb_byte
*insn
= (gdb_byte
*) closure
;
1578 static int s390_instrlen
[] = { 2, 4, 4, 6 };
1579 int insnlen
= s390_instrlen
[insn
[0] >> 6];
1581 /* Fields for various kinds of instructions. */
1582 unsigned int b2
, r1
, r2
, x2
, r3
;
1585 /* Get current PC and addressing mode bit. */
1586 CORE_ADDR pc
= regcache_read_pc (regs
);
1589 if (register_size (gdbarch
, S390_PSWA_REGNUM
) == 4)
1591 regcache_cooked_read_unsigned (regs
, S390_PSWA_REGNUM
, &amode
);
1592 amode
&= 0x80000000;
1595 if (debug_displaced
)
1596 fprintf_unfiltered (gdb_stdlog
,
1597 "displaced: (s390) fixup (%s, %s) pc %s len %d amode 0x%x\n",
1598 paddress (gdbarch
, from
), paddress (gdbarch
, to
),
1599 paddress (gdbarch
, pc
), insnlen
, (int) amode
);
1601 /* Handle absolute branch and save instructions. */
1602 if (is_rr (insn
, op_basr
, &r1
, &r2
)
1603 || is_rx (insn
, op_bas
, &r1
, &d2
, &x2
, &b2
))
1605 /* Recompute saved return address in R1. */
1606 regcache_cooked_write_unsigned (regs
, S390_R0_REGNUM
+ r1
,
1607 amode
| (from
+ insnlen
));
1610 /* Handle absolute branch instructions. */
1611 else if (is_rr (insn
, op_bcr
, &r1
, &r2
)
1612 || is_rx (insn
, op_bc
, &r1
, &d2
, &x2
, &b2
)
1613 || is_rr (insn
, op_bctr
, &r1
, &r2
)
1614 || is_rre (insn
, op_bctgr
, &r1
, &r2
)
1615 || is_rx (insn
, op_bct
, &r1
, &d2
, &x2
, &b2
)
1616 || is_rxy (insn
, op1_bctg
, op2_brctg
, &r1
, &d2
, &x2
, &b2
)
1617 || is_rs (insn
, op_bxh
, &r1
, &r3
, &d2
, &b2
)
1618 || is_rsy (insn
, op1_bxhg
, op2_bxhg
, &r1
, &r3
, &d2
, &b2
)
1619 || is_rs (insn
, op_bxle
, &r1
, &r3
, &d2
, &b2
)
1620 || is_rsy (insn
, op1_bxleg
, op2_bxleg
, &r1
, &r3
, &d2
, &b2
))
1622 /* Update PC iff branch was *not* taken. */
1623 if (pc
== to
+ insnlen
)
1624 regcache_write_pc (regs
, from
+ insnlen
);
1627 /* Handle PC-relative branch and save instructions. */
1628 else if (is_ri (insn
, op1_bras
, op2_bras
, &r1
, &i2
)
1629 || is_ril (insn
, op1_brasl
, op2_brasl
, &r1
, &i2
))
1632 regcache_write_pc (regs
, pc
- to
+ from
);
1633 /* Recompute saved return address in R1. */
1634 regcache_cooked_write_unsigned (regs
, S390_R0_REGNUM
+ r1
,
1635 amode
| (from
+ insnlen
));
1638 /* Handle PC-relative branch instructions. */
1639 else if (is_ri (insn
, op1_brc
, op2_brc
, &r1
, &i2
)
1640 || is_ril (insn
, op1_brcl
, op2_brcl
, &r1
, &i2
)
1641 || is_ri (insn
, op1_brct
, op2_brct
, &r1
, &i2
)
1642 || is_ri (insn
, op1_brctg
, op2_brctg
, &r1
, &i2
)
1643 || is_rsi (insn
, op_brxh
, &r1
, &r3
, &i2
)
1644 || is_rie (insn
, op1_brxhg
, op2_brxhg
, &r1
, &r3
, &i2
)
1645 || is_rsi (insn
, op_brxle
, &r1
, &r3
, &i2
)
1646 || is_rie (insn
, op1_brxlg
, op2_brxlg
, &r1
, &r3
, &i2
))
1649 regcache_write_pc (regs
, pc
- to
+ from
);
1652 /* Handle LOAD ADDRESS RELATIVE LONG. */
1653 else if (is_ril (insn
, op1_larl
, op2_larl
, &r1
, &i2
))
1656 regcache_write_pc (regs
, from
+ insnlen
);
1657 /* Recompute output address in R1. */
1658 regcache_cooked_write_unsigned (regs
, S390_R0_REGNUM
+ r1
,
1659 amode
| (from
+ i2
* 2));
1662 /* If we executed a breakpoint instruction, point PC right back at it. */
1663 else if (insn
[0] == 0x0 && insn
[1] == 0x1)
1664 regcache_write_pc (regs
, from
);
1666 /* For any other insn, PC points right after the original instruction. */
1668 regcache_write_pc (regs
, from
+ insnlen
);
1670 if (debug_displaced
)
1671 fprintf_unfiltered (gdb_stdlog
,
1672 "displaced: (s390) pc is now %s\n",
1673 paddress (gdbarch
, regcache_read_pc (regs
)));
1677 /* Helper routine to unwind pseudo registers. */
1679 static struct value
*
1680 s390_unwind_pseudo_register (struct frame_info
*this_frame
, int regnum
)
1682 struct gdbarch
*gdbarch
= get_frame_arch (this_frame
);
1683 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
1684 struct type
*type
= register_type (gdbarch
, regnum
);
1686 /* Unwind PC via PSW address. */
1687 if (regnum
== tdep
->pc_regnum
)
1691 val
= frame_unwind_register_value (this_frame
, S390_PSWA_REGNUM
);
1692 if (!value_optimized_out (val
))
1694 LONGEST pswa
= value_as_long (val
);
1696 if (TYPE_LENGTH (type
) == 4)
1697 return value_from_pointer (type
, pswa
& 0x7fffffff);
1699 return value_from_pointer (type
, pswa
);
1703 /* Unwind CC via PSW mask. */
1704 if (regnum
== tdep
->cc_regnum
)
1708 val
= frame_unwind_register_value (this_frame
, S390_PSWM_REGNUM
);
1709 if (!value_optimized_out (val
))
1711 LONGEST pswm
= value_as_long (val
);
1713 if (TYPE_LENGTH (type
) == 4)
1714 return value_from_longest (type
, (pswm
>> 12) & 3);
1716 return value_from_longest (type
, (pswm
>> 44) & 3);
1720 /* Unwind full GPRs to show at least the lower halves (as the
1721 upper halves are undefined). */
1722 if (tdep
->gpr_full_regnum
!= -1
1723 && regnum
>= tdep
->gpr_full_regnum
1724 && regnum
< tdep
->gpr_full_regnum
+ 16)
1726 int reg
= regnum
- tdep
->gpr_full_regnum
;
1729 val
= frame_unwind_register_value (this_frame
, S390_R0_REGNUM
+ reg
);
1730 if (!value_optimized_out (val
))
1731 return value_cast (type
, val
);
1734 return allocate_optimized_out_value (type
);
1737 static struct value
*
1738 s390_trad_frame_prev_register (struct frame_info
*this_frame
,
1739 struct trad_frame_saved_reg saved_regs
[],
1742 if (regnum
< S390_NUM_REGS
)
1743 return trad_frame_get_prev_register (this_frame
, saved_regs
, regnum
);
1745 return s390_unwind_pseudo_register (this_frame
, regnum
);
1749 /* Normal stack frames. */
1751 struct s390_unwind_cache
{
1754 CORE_ADDR frame_base
;
1755 CORE_ADDR local_base
;
1757 struct trad_frame_saved_reg
*saved_regs
;
1761 s390_prologue_frame_unwind_cache (struct frame_info
*this_frame
,
1762 struct s390_unwind_cache
*info
)
1764 struct gdbarch
*gdbarch
= get_frame_arch (this_frame
);
1765 int word_size
= gdbarch_ptr_bit (gdbarch
) / 8;
1766 struct s390_prologue_data data
;
1767 pv_t
*fp
= &data
.gpr
[S390_FRAME_REGNUM
- S390_R0_REGNUM
];
1768 pv_t
*sp
= &data
.gpr
[S390_SP_REGNUM
- S390_R0_REGNUM
];
1777 struct frame_info
*next_frame
;
1779 /* Try to find the function start address. If we can't find it, we don't
1780 bother searching for it -- with modern compilers this would be mostly
1781 pointless anyway. Trust that we'll either have valid DWARF-2 CFI data
1782 or else a valid backchain ... */
1783 func
= get_frame_func (this_frame
);
1787 /* Try to analyze the prologue. */
1788 result
= s390_analyze_prologue (gdbarch
, func
,
1789 get_frame_pc (this_frame
), &data
);
1793 /* If this was successful, we should have found the instruction that
1794 sets the stack pointer register to the previous value of the stack
1795 pointer minus the frame size. */
1796 if (!pv_is_register (*sp
, S390_SP_REGNUM
))
1799 /* A frame size of zero at this point can mean either a real
1800 frameless function, or else a failure to find the prologue.
1801 Perform some sanity checks to verify we really have a
1802 frameless function. */
1805 /* If the next frame is a NORMAL_FRAME, this frame *cannot* have frame
1806 size zero. This is only possible if the next frame is a sentinel
1807 frame, a dummy frame, or a signal trampoline frame. */
1808 /* FIXME: cagney/2004-05-01: This sanity check shouldn't be
1809 needed, instead the code should simpliy rely on its
1811 next_frame
= get_next_frame (this_frame
);
1812 while (next_frame
&& get_frame_type (next_frame
) == INLINE_FRAME
)
1813 next_frame
= get_next_frame (next_frame
);
1815 && get_frame_type (get_next_frame (this_frame
)) == NORMAL_FRAME
)
1818 /* If we really have a frameless function, %r14 must be valid
1819 -- in particular, it must point to a different function. */
1820 reg
= get_frame_register_unsigned (this_frame
, S390_RETADDR_REGNUM
);
1821 reg
= gdbarch_addr_bits_remove (gdbarch
, reg
) - 1;
1822 if (get_pc_function_start (reg
) == func
)
1824 /* However, there is one case where it *is* valid for %r14
1825 to point to the same function -- if this is a recursive
1826 call, and we have stopped in the prologue *before* the
1827 stack frame was allocated.
1829 Recognize this case by looking ahead a bit ... */
1831 struct s390_prologue_data data2
;
1832 pv_t
*sp
= &data2
.gpr
[S390_SP_REGNUM
- S390_R0_REGNUM
];
1834 if (!(s390_analyze_prologue (gdbarch
, func
, (CORE_ADDR
)-1, &data2
)
1835 && pv_is_register (*sp
, S390_SP_REGNUM
)
1842 /* OK, we've found valid prologue data. */
1845 /* If the frame pointer originally also holds the same value
1846 as the stack pointer, we're probably using it. If it holds
1847 some other value -- even a constant offset -- it is most
1848 likely used as temp register. */
1849 if (pv_is_identical (*sp
, *fp
))
1850 frame_pointer
= S390_FRAME_REGNUM
;
1852 frame_pointer
= S390_SP_REGNUM
;
1854 /* If we've detected a function with stack frame, we'll still have to
1855 treat it as frameless if we're currently within the function epilog
1856 code at a point where the frame pointer has already been restored.
1857 This can only happen in an innermost frame. */
1858 /* FIXME: cagney/2004-05-01: This sanity check shouldn't be needed,
1859 instead the code should simpliy rely on its analysis. */
1860 next_frame
= get_next_frame (this_frame
);
1861 while (next_frame
&& get_frame_type (next_frame
) == INLINE_FRAME
)
1862 next_frame
= get_next_frame (next_frame
);
1864 && (next_frame
== NULL
1865 || get_frame_type (get_next_frame (this_frame
)) != NORMAL_FRAME
))
1867 /* See the comment in s390_in_function_epilogue_p on why this is
1868 not completely reliable ... */
1869 if (s390_in_function_epilogue_p (gdbarch
, get_frame_pc (this_frame
)))
1871 memset (&data
, 0, sizeof (data
));
1873 frame_pointer
= S390_SP_REGNUM
;
1877 /* Once we know the frame register and the frame size, we can unwind
1878 the current value of the frame register from the next frame, and
1879 add back the frame size to arrive that the previous frame's
1880 stack pointer value. */
1881 prev_sp
= get_frame_register_unsigned (this_frame
, frame_pointer
) + size
;
1882 cfa
= prev_sp
+ 16*word_size
+ 32;
1884 /* Set up ABI call-saved/call-clobbered registers. */
1885 for (i
= 0; i
< S390_NUM_REGS
; i
++)
1886 if (!s390_register_call_saved (gdbarch
, i
))
1887 trad_frame_set_unknown (info
->saved_regs
, i
);
1889 /* CC is always call-clobbered. */
1890 trad_frame_set_unknown (info
->saved_regs
, S390_PSWM_REGNUM
);
1892 /* Record the addresses of all register spill slots the prologue parser
1893 has recognized. Consider only registers defined as call-saved by the
1894 ABI; for call-clobbered registers the parser may have recognized
1897 for (i
= 0; i
< 16; i
++)
1898 if (s390_register_call_saved (gdbarch
, S390_R0_REGNUM
+ i
)
1899 && data
.gpr_slot
[i
] != 0)
1900 info
->saved_regs
[S390_R0_REGNUM
+ i
].addr
= cfa
- data
.gpr_slot
[i
];
1902 for (i
= 0; i
< 16; i
++)
1903 if (s390_register_call_saved (gdbarch
, S390_F0_REGNUM
+ i
)
1904 && data
.fpr_slot
[i
] != 0)
1905 info
->saved_regs
[S390_F0_REGNUM
+ i
].addr
= cfa
- data
.fpr_slot
[i
];
1907 /* Function return will set PC to %r14. */
1908 info
->saved_regs
[S390_PSWA_REGNUM
] = info
->saved_regs
[S390_RETADDR_REGNUM
];
1910 /* In frameless functions, we unwind simply by moving the return
1911 address to the PC. However, if we actually stored to the
1912 save area, use that -- we might only think the function frameless
1913 because we're in the middle of the prologue ... */
1915 && !trad_frame_addr_p (info
->saved_regs
, S390_PSWA_REGNUM
))
1917 info
->saved_regs
[S390_PSWA_REGNUM
].realreg
= S390_RETADDR_REGNUM
;
1920 /* Another sanity check: unless this is a frameless function,
1921 we should have found spill slots for SP and PC.
1922 If not, we cannot unwind further -- this happens e.g. in
1923 libc's thread_start routine. */
1926 if (!trad_frame_addr_p (info
->saved_regs
, S390_SP_REGNUM
)
1927 || !trad_frame_addr_p (info
->saved_regs
, S390_PSWA_REGNUM
))
1931 /* We use the current value of the frame register as local_base,
1932 and the top of the register save area as frame_base. */
1935 info
->frame_base
= prev_sp
+ 16*word_size
+ 32;
1936 info
->local_base
= prev_sp
- size
;
1944 s390_backchain_frame_unwind_cache (struct frame_info
*this_frame
,
1945 struct s390_unwind_cache
*info
)
1947 struct gdbarch
*gdbarch
= get_frame_arch (this_frame
);
1948 int word_size
= gdbarch_ptr_bit (gdbarch
) / 8;
1949 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
1950 CORE_ADDR backchain
;
1955 /* Set up ABI call-saved/call-clobbered registers. */
1956 for (i
= 0; i
< S390_NUM_REGS
; i
++)
1957 if (!s390_register_call_saved (gdbarch
, i
))
1958 trad_frame_set_unknown (info
->saved_regs
, i
);
1960 /* CC is always call-clobbered. */
1961 trad_frame_set_unknown (info
->saved_regs
, S390_PSWM_REGNUM
);
1963 /* Get the backchain. */
1964 reg
= get_frame_register_unsigned (this_frame
, S390_SP_REGNUM
);
1965 backchain
= read_memory_unsigned_integer (reg
, word_size
, byte_order
);
1967 /* A zero backchain terminates the frame chain. As additional
1968 sanity check, let's verify that the spill slot for SP in the
1969 save area pointed to by the backchain in fact links back to
1972 && safe_read_memory_integer (backchain
+ 15*word_size
,
1973 word_size
, byte_order
, &sp
)
1974 && (CORE_ADDR
)sp
== backchain
)
1976 /* We don't know which registers were saved, but it will have
1977 to be at least %r14 and %r15. This will allow us to continue
1978 unwinding, but other prev-frame registers may be incorrect ... */
1979 info
->saved_regs
[S390_SP_REGNUM
].addr
= backchain
+ 15*word_size
;
1980 info
->saved_regs
[S390_RETADDR_REGNUM
].addr
= backchain
+ 14*word_size
;
1982 /* Function return will set PC to %r14. */
1983 info
->saved_regs
[S390_PSWA_REGNUM
]
1984 = info
->saved_regs
[S390_RETADDR_REGNUM
];
1986 /* We use the current value of the frame register as local_base,
1987 and the top of the register save area as frame_base. */
1988 info
->frame_base
= backchain
+ 16*word_size
+ 32;
1989 info
->local_base
= reg
;
1992 info
->func
= get_frame_pc (this_frame
);
1995 static struct s390_unwind_cache
*
1996 s390_frame_unwind_cache (struct frame_info
*this_frame
,
1997 void **this_prologue_cache
)
1999 struct s390_unwind_cache
*info
;
2000 if (*this_prologue_cache
)
2001 return *this_prologue_cache
;
2003 info
= FRAME_OBSTACK_ZALLOC (struct s390_unwind_cache
);
2004 *this_prologue_cache
= info
;
2005 info
->saved_regs
= trad_frame_alloc_saved_regs (this_frame
);
2007 info
->frame_base
= -1;
2008 info
->local_base
= -1;
2010 /* Try to use prologue analysis to fill the unwind cache.
2011 If this fails, fall back to reading the stack backchain. */
2012 if (!s390_prologue_frame_unwind_cache (this_frame
, info
))
2013 s390_backchain_frame_unwind_cache (this_frame
, info
);
2019 s390_frame_this_id (struct frame_info
*this_frame
,
2020 void **this_prologue_cache
,
2021 struct frame_id
*this_id
)
2023 struct s390_unwind_cache
*info
2024 = s390_frame_unwind_cache (this_frame
, this_prologue_cache
);
2026 if (info
->frame_base
== -1)
2029 *this_id
= frame_id_build (info
->frame_base
, info
->func
);
2032 static struct value
*
2033 s390_frame_prev_register (struct frame_info
*this_frame
,
2034 void **this_prologue_cache
, int regnum
)
2036 struct gdbarch
*gdbarch
= get_frame_arch (this_frame
);
2037 struct s390_unwind_cache
*info
2038 = s390_frame_unwind_cache (this_frame
, this_prologue_cache
);
2040 return s390_trad_frame_prev_register (this_frame
, info
->saved_regs
, regnum
);
2043 static const struct frame_unwind s390_frame_unwind
= {
2045 default_frame_unwind_stop_reason
,
2047 s390_frame_prev_register
,
2049 default_frame_sniffer
2053 /* Code stubs and their stack frames. For things like PLTs and NULL
2054 function calls (where there is no true frame and the return address
2055 is in the RETADDR register). */
2057 struct s390_stub_unwind_cache
2059 CORE_ADDR frame_base
;
2060 struct trad_frame_saved_reg
*saved_regs
;
2063 static struct s390_stub_unwind_cache
*
2064 s390_stub_frame_unwind_cache (struct frame_info
*this_frame
,
2065 void **this_prologue_cache
)
2067 struct gdbarch
*gdbarch
= get_frame_arch (this_frame
);
2068 int word_size
= gdbarch_ptr_bit (gdbarch
) / 8;
2069 struct s390_stub_unwind_cache
*info
;
2072 if (*this_prologue_cache
)
2073 return *this_prologue_cache
;
2075 info
= FRAME_OBSTACK_ZALLOC (struct s390_stub_unwind_cache
);
2076 *this_prologue_cache
= info
;
2077 info
->saved_regs
= trad_frame_alloc_saved_regs (this_frame
);
2079 /* The return address is in register %r14. */
2080 info
->saved_regs
[S390_PSWA_REGNUM
].realreg
= S390_RETADDR_REGNUM
;
2082 /* Retrieve stack pointer and determine our frame base. */
2083 reg
= get_frame_register_unsigned (this_frame
, S390_SP_REGNUM
);
2084 info
->frame_base
= reg
+ 16*word_size
+ 32;
2090 s390_stub_frame_this_id (struct frame_info
*this_frame
,
2091 void **this_prologue_cache
,
2092 struct frame_id
*this_id
)
2094 struct s390_stub_unwind_cache
*info
2095 = s390_stub_frame_unwind_cache (this_frame
, this_prologue_cache
);
2096 *this_id
= frame_id_build (info
->frame_base
, get_frame_pc (this_frame
));
2099 static struct value
*
2100 s390_stub_frame_prev_register (struct frame_info
*this_frame
,
2101 void **this_prologue_cache
, int regnum
)
2103 struct s390_stub_unwind_cache
*info
2104 = s390_stub_frame_unwind_cache (this_frame
, this_prologue_cache
);
2105 return s390_trad_frame_prev_register (this_frame
, info
->saved_regs
, regnum
);
2109 s390_stub_frame_sniffer (const struct frame_unwind
*self
,
2110 struct frame_info
*this_frame
,
2111 void **this_prologue_cache
)
2113 CORE_ADDR addr_in_block
;
2114 bfd_byte insn
[S390_MAX_INSTR_SIZE
];
2116 /* If the current PC points to non-readable memory, we assume we
2117 have trapped due to an invalid function pointer call. We handle
2118 the non-existing current function like a PLT stub. */
2119 addr_in_block
= get_frame_address_in_block (this_frame
);
2120 if (in_plt_section (addr_in_block
)
2121 || s390_readinstruction (insn
, get_frame_pc (this_frame
)) < 0)
2126 static const struct frame_unwind s390_stub_frame_unwind
= {
2128 default_frame_unwind_stop_reason
,
2129 s390_stub_frame_this_id
,
2130 s390_stub_frame_prev_register
,
2132 s390_stub_frame_sniffer
2136 /* Signal trampoline stack frames. */
2138 struct s390_sigtramp_unwind_cache
{
2139 CORE_ADDR frame_base
;
2140 struct trad_frame_saved_reg
*saved_regs
;
2143 static struct s390_sigtramp_unwind_cache
*
2144 s390_sigtramp_frame_unwind_cache (struct frame_info
*this_frame
,
2145 void **this_prologue_cache
)
2147 struct gdbarch
*gdbarch
= get_frame_arch (this_frame
);
2148 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
2149 int word_size
= gdbarch_ptr_bit (gdbarch
) / 8;
2150 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
2151 struct s390_sigtramp_unwind_cache
*info
;
2152 ULONGEST this_sp
, prev_sp
;
2153 CORE_ADDR next_ra
, next_cfa
, sigreg_ptr
, sigreg_high_off
;
2156 if (*this_prologue_cache
)
2157 return *this_prologue_cache
;
2159 info
= FRAME_OBSTACK_ZALLOC (struct s390_sigtramp_unwind_cache
);
2160 *this_prologue_cache
= info
;
2161 info
->saved_regs
= trad_frame_alloc_saved_regs (this_frame
);
2163 this_sp
= get_frame_register_unsigned (this_frame
, S390_SP_REGNUM
);
2164 next_ra
= get_frame_pc (this_frame
);
2165 next_cfa
= this_sp
+ 16*word_size
+ 32;
2167 /* New-style RT frame:
2168 retcode + alignment (8 bytes)
2170 ucontext (contains sigregs at offset 5 words). */
2171 if (next_ra
== next_cfa
)
2173 sigreg_ptr
= next_cfa
+ 8 + 128 + align_up (5*word_size
, 8);
2174 /* sigregs are followed by uc_sigmask (8 bytes), then by the
2175 upper GPR halves if present. */
2176 sigreg_high_off
= 8;
2179 /* Old-style RT frame and all non-RT frames:
2180 old signal mask (8 bytes)
2181 pointer to sigregs. */
2184 sigreg_ptr
= read_memory_unsigned_integer (next_cfa
+ 8,
2185 word_size
, byte_order
);
2186 /* sigregs are followed by signo (4 bytes), then by the
2187 upper GPR halves if present. */
2188 sigreg_high_off
= 4;
2191 /* The sigregs structure looks like this:
2200 /* PSW mask and address. */
2201 info
->saved_regs
[S390_PSWM_REGNUM
].addr
= sigreg_ptr
;
2202 sigreg_ptr
+= word_size
;
2203 info
->saved_regs
[S390_PSWA_REGNUM
].addr
= sigreg_ptr
;
2204 sigreg_ptr
+= word_size
;
2206 /* Then the GPRs. */
2207 for (i
= 0; i
< 16; i
++)
2209 info
->saved_regs
[S390_R0_REGNUM
+ i
].addr
= sigreg_ptr
;
2210 sigreg_ptr
+= word_size
;
2213 /* Then the ACRs. */
2214 for (i
= 0; i
< 16; i
++)
2216 info
->saved_regs
[S390_A0_REGNUM
+ i
].addr
= sigreg_ptr
;
2220 /* The floating-point control word. */
2221 info
->saved_regs
[S390_FPC_REGNUM
].addr
= sigreg_ptr
;
2224 /* And finally the FPRs. */
2225 for (i
= 0; i
< 16; i
++)
2227 info
->saved_regs
[S390_F0_REGNUM
+ i
].addr
= sigreg_ptr
;
2231 /* If we have them, the GPR upper halves are appended at the end. */
2232 sigreg_ptr
+= sigreg_high_off
;
2233 if (tdep
->gpr_full_regnum
!= -1)
2234 for (i
= 0; i
< 16; i
++)
2236 info
->saved_regs
[S390_R0_UPPER_REGNUM
+ i
].addr
= sigreg_ptr
;
2240 /* Restore the previous frame's SP. */
2241 prev_sp
= read_memory_unsigned_integer (
2242 info
->saved_regs
[S390_SP_REGNUM
].addr
,
2243 word_size
, byte_order
);
2245 /* Determine our frame base. */
2246 info
->frame_base
= prev_sp
+ 16*word_size
+ 32;
2252 s390_sigtramp_frame_this_id (struct frame_info
*this_frame
,
2253 void **this_prologue_cache
,
2254 struct frame_id
*this_id
)
2256 struct s390_sigtramp_unwind_cache
*info
2257 = s390_sigtramp_frame_unwind_cache (this_frame
, this_prologue_cache
);
2258 *this_id
= frame_id_build (info
->frame_base
, get_frame_pc (this_frame
));
2261 static struct value
*
2262 s390_sigtramp_frame_prev_register (struct frame_info
*this_frame
,
2263 void **this_prologue_cache
, int regnum
)
2265 struct s390_sigtramp_unwind_cache
*info
2266 = s390_sigtramp_frame_unwind_cache (this_frame
, this_prologue_cache
);
2267 return s390_trad_frame_prev_register (this_frame
, info
->saved_regs
, regnum
);
2271 s390_sigtramp_frame_sniffer (const struct frame_unwind
*self
,
2272 struct frame_info
*this_frame
,
2273 void **this_prologue_cache
)
2275 CORE_ADDR pc
= get_frame_pc (this_frame
);
2276 bfd_byte sigreturn
[2];
2278 if (target_read_memory (pc
, sigreturn
, 2))
2281 if (sigreturn
[0] != 0x0a /* svc */)
2284 if (sigreturn
[1] != 119 /* sigreturn */
2285 && sigreturn
[1] != 173 /* rt_sigreturn */)
2291 static const struct frame_unwind s390_sigtramp_frame_unwind
= {
2293 default_frame_unwind_stop_reason
,
2294 s390_sigtramp_frame_this_id
,
2295 s390_sigtramp_frame_prev_register
,
2297 s390_sigtramp_frame_sniffer
2301 /* Frame base handling. */
2304 s390_frame_base_address (struct frame_info
*this_frame
, void **this_cache
)
2306 struct s390_unwind_cache
*info
2307 = s390_frame_unwind_cache (this_frame
, this_cache
);
2308 return info
->frame_base
;
2312 s390_local_base_address (struct frame_info
*this_frame
, void **this_cache
)
2314 struct s390_unwind_cache
*info
2315 = s390_frame_unwind_cache (this_frame
, this_cache
);
2316 return info
->local_base
;
2319 static const struct frame_base s390_frame_base
= {
2321 s390_frame_base_address
,
2322 s390_local_base_address
,
2323 s390_local_base_address
2327 s390_unwind_pc (struct gdbarch
*gdbarch
, struct frame_info
*next_frame
)
2329 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
2331 pc
= frame_unwind_register_unsigned (next_frame
, tdep
->pc_regnum
);
2332 return gdbarch_addr_bits_remove (gdbarch
, pc
);
2336 s390_unwind_sp (struct gdbarch
*gdbarch
, struct frame_info
*next_frame
)
2339 sp
= frame_unwind_register_unsigned (next_frame
, S390_SP_REGNUM
);
2340 return gdbarch_addr_bits_remove (gdbarch
, sp
);
2344 /* DWARF-2 frame support. */
2346 static struct value
*
2347 s390_dwarf2_prev_register (struct frame_info
*this_frame
, void **this_cache
,
2350 return s390_unwind_pseudo_register (this_frame
, regnum
);
2354 s390_dwarf2_frame_init_reg (struct gdbarch
*gdbarch
, int regnum
,
2355 struct dwarf2_frame_state_reg
*reg
,
2356 struct frame_info
*this_frame
)
2358 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
2360 /* The condition code (and thus PSW mask) is call-clobbered. */
2361 if (regnum
== S390_PSWM_REGNUM
)
2362 reg
->how
= DWARF2_FRAME_REG_UNDEFINED
;
2364 /* The PSW address unwinds to the return address. */
2365 else if (regnum
== S390_PSWA_REGNUM
)
2366 reg
->how
= DWARF2_FRAME_REG_RA
;
2368 /* Fixed registers are call-saved or call-clobbered
2369 depending on the ABI in use. */
2370 else if (regnum
< S390_NUM_REGS
)
2372 if (s390_register_call_saved (gdbarch
, regnum
))
2373 reg
->how
= DWARF2_FRAME_REG_SAME_VALUE
;
2375 reg
->how
= DWARF2_FRAME_REG_UNDEFINED
;
2378 /* We install a special function to unwind pseudos. */
2381 reg
->how
= DWARF2_FRAME_REG_FN
;
2382 reg
->loc
.fn
= s390_dwarf2_prev_register
;
2387 /* Dummy function calls. */
2389 /* Return non-zero if TYPE is an integer-like type, zero otherwise.
2390 "Integer-like" types are those that should be passed the way
2391 integers are: integers, enums, ranges, characters, and booleans. */
2393 is_integer_like (struct type
*type
)
2395 enum type_code code
= TYPE_CODE (type
);
2397 return (code
== TYPE_CODE_INT
2398 || code
== TYPE_CODE_ENUM
2399 || code
== TYPE_CODE_RANGE
2400 || code
== TYPE_CODE_CHAR
2401 || code
== TYPE_CODE_BOOL
);
2404 /* Return non-zero if TYPE is a pointer-like type, zero otherwise.
2405 "Pointer-like" types are those that should be passed the way
2406 pointers are: pointers and references. */
2408 is_pointer_like (struct type
*type
)
2410 enum type_code code
= TYPE_CODE (type
);
2412 return (code
== TYPE_CODE_PTR
2413 || code
== TYPE_CODE_REF
);
2417 /* Return non-zero if TYPE is a `float singleton' or `double
2418 singleton', zero otherwise.
2420 A `T singleton' is a struct type with one member, whose type is
2421 either T or a `T singleton'. So, the following are all float
2425 struct { struct { float x; } x; };
2426 struct { struct { struct { float x; } x; } x; };
2430 All such structures are passed as if they were floats or doubles,
2431 as the (revised) ABI says. */
2433 is_float_singleton (struct type
*type
)
2435 if (TYPE_CODE (type
) == TYPE_CODE_STRUCT
&& TYPE_NFIELDS (type
) == 1)
2437 struct type
*singleton_type
= TYPE_FIELD_TYPE (type
, 0);
2438 CHECK_TYPEDEF (singleton_type
);
2440 return (TYPE_CODE (singleton_type
) == TYPE_CODE_FLT
2441 || TYPE_CODE (singleton_type
) == TYPE_CODE_DECFLOAT
2442 || is_float_singleton (singleton_type
));
2449 /* Return non-zero if TYPE is a struct-like type, zero otherwise.
2450 "Struct-like" types are those that should be passed as structs are:
2453 As an odd quirk, not mentioned in the ABI, GCC passes float and
2454 double singletons as if they were a plain float, double, etc. (The
2455 corresponding union types are handled normally.) So we exclude
2456 those types here. *shrug* */
2458 is_struct_like (struct type
*type
)
2460 enum type_code code
= TYPE_CODE (type
);
2462 return (code
== TYPE_CODE_UNION
2463 || (code
== TYPE_CODE_STRUCT
&& ! is_float_singleton (type
)));
2467 /* Return non-zero if TYPE is a float-like type, zero otherwise.
2468 "Float-like" types are those that should be passed as
2469 floating-point values are.
2471 You'd think this would just be floats, doubles, long doubles, etc.
2472 But as an odd quirk, not mentioned in the ABI, GCC passes float and
2473 double singletons as if they were a plain float, double, etc. (The
2474 corresponding union types are handled normally.) So we include
2475 those types here. *shrug* */
2477 is_float_like (struct type
*type
)
2479 return (TYPE_CODE (type
) == TYPE_CODE_FLT
2480 || TYPE_CODE (type
) == TYPE_CODE_DECFLOAT
2481 || is_float_singleton (type
));
2486 is_power_of_two (unsigned int n
)
2488 return ((n
& (n
- 1)) == 0);
2491 /* Return non-zero if TYPE should be passed as a pointer to a copy,
2494 s390_function_arg_pass_by_reference (struct type
*type
)
2496 if (TYPE_LENGTH (type
) > 8)
2499 return (is_struct_like (type
) && !is_power_of_two (TYPE_LENGTH (type
)))
2500 || TYPE_CODE (type
) == TYPE_CODE_COMPLEX
2501 || (TYPE_CODE (type
) == TYPE_CODE_ARRAY
&& TYPE_VECTOR (type
));
2504 /* Return non-zero if TYPE should be passed in a float register
2507 s390_function_arg_float (struct type
*type
)
2509 if (TYPE_LENGTH (type
) > 8)
2512 return is_float_like (type
);
2515 /* Return non-zero if TYPE should be passed in an integer register
2516 (or a pair of integer registers) if possible. */
2518 s390_function_arg_integer (struct type
*type
)
2520 if (TYPE_LENGTH (type
) > 8)
2523 return is_integer_like (type
)
2524 || is_pointer_like (type
)
2525 || (is_struct_like (type
) && is_power_of_two (TYPE_LENGTH (type
)));
2528 /* Return ARG, a `SIMPLE_ARG', sign-extended or zero-extended to a full
2529 word as required for the ABI. */
2531 extend_simple_arg (struct gdbarch
*gdbarch
, struct value
*arg
)
2533 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
2534 struct type
*type
= check_typedef (value_type (arg
));
2536 /* Even structs get passed in the least significant bits of the
2537 register / memory word. It's not really right to extract them as
2538 an integer, but it does take care of the extension. */
2539 if (TYPE_UNSIGNED (type
))
2540 return extract_unsigned_integer (value_contents (arg
),
2541 TYPE_LENGTH (type
), byte_order
);
2543 return extract_signed_integer (value_contents (arg
),
2544 TYPE_LENGTH (type
), byte_order
);
2548 /* Return the alignment required by TYPE. */
2550 alignment_of (struct type
*type
)
2554 if (is_integer_like (type
)
2555 || is_pointer_like (type
)
2556 || TYPE_CODE (type
) == TYPE_CODE_FLT
2557 || TYPE_CODE (type
) == TYPE_CODE_DECFLOAT
)
2558 alignment
= TYPE_LENGTH (type
);
2559 else if (TYPE_CODE (type
) == TYPE_CODE_STRUCT
2560 || TYPE_CODE (type
) == TYPE_CODE_UNION
)
2565 for (i
= 0; i
< TYPE_NFIELDS (type
); i
++)
2568 = alignment_of (check_typedef (TYPE_FIELD_TYPE (type
, i
)));
2570 if (field_alignment
> alignment
)
2571 alignment
= field_alignment
;
2577 /* Check that everything we ever return is a power of two. Lots of
2578 code doesn't want to deal with aligning things to arbitrary
2580 gdb_assert ((alignment
& (alignment
- 1)) == 0);
2586 /* Put the actual parameter values pointed to by ARGS[0..NARGS-1] in
2587 place to be passed to a function, as specified by the "GNU/Linux
2588 for S/390 ELF Application Binary Interface Supplement".
2590 SP is the current stack pointer. We must put arguments, links,
2591 padding, etc. whereever they belong, and return the new stack
2594 If STRUCT_RETURN is non-zero, then the function we're calling is
2595 going to return a structure by value; STRUCT_ADDR is the address of
2596 a block we've allocated for it on the stack.
2598 Our caller has taken care of any type promotions needed to satisfy
2599 prototypes or the old K&R argument-passing rules. */
2601 s390_push_dummy_call (struct gdbarch
*gdbarch
, struct value
*function
,
2602 struct regcache
*regcache
, CORE_ADDR bp_addr
,
2603 int nargs
, struct value
**args
, CORE_ADDR sp
,
2604 int struct_return
, CORE_ADDR struct_addr
)
2606 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
2607 int word_size
= gdbarch_ptr_bit (gdbarch
) / 8;
2608 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
2611 /* If the i'th argument is passed as a reference to a copy, then
2612 copy_addr[i] is the address of the copy we made. */
2613 CORE_ADDR
*copy_addr
= alloca (nargs
* sizeof (CORE_ADDR
));
2615 /* Reserve space for the reference-to-copy area. */
2616 for (i
= 0; i
< nargs
; i
++)
2618 struct value
*arg
= args
[i
];
2619 struct type
*type
= check_typedef (value_type (arg
));
2621 if (s390_function_arg_pass_by_reference (type
))
2623 sp
-= TYPE_LENGTH (type
);
2624 sp
= align_down (sp
, alignment_of (type
));
2629 /* Reserve space for the parameter area. As a conservative
2630 simplification, we assume that everything will be passed on the
2631 stack. Since every argument larger than 8 bytes will be
2632 passed by reference, we use this simple upper bound. */
2635 /* After all that, make sure it's still aligned on an eight-byte
2637 sp
= align_down (sp
, 8);
2639 /* Allocate the standard frame areas: the register save area, the
2640 word reserved for the compiler (which seems kind of meaningless),
2641 and the back chain pointer. */
2642 sp
-= 16*word_size
+ 32;
2644 /* Now we have the final SP value. Make sure we didn't underflow;
2645 on 31-bit, this would result in addresses with the high bit set,
2646 which causes confusion elsewhere. Note that if we error out
2647 here, stack and registers remain untouched. */
2648 if (gdbarch_addr_bits_remove (gdbarch
, sp
) != sp
)
2649 error (_("Stack overflow"));
2652 /* Finally, place the actual parameters, working from SP towards
2653 higher addresses. The code above is supposed to reserve enough
2658 CORE_ADDR starg
= sp
+ 16*word_size
+ 32;
2660 /* A struct is returned using general register 2. */
2663 regcache_cooked_write_unsigned (regcache
, S390_R0_REGNUM
+ gr
,
2668 for (i
= 0; i
< nargs
; i
++)
2670 struct value
*arg
= args
[i
];
2671 struct type
*type
= check_typedef (value_type (arg
));
2672 unsigned length
= TYPE_LENGTH (type
);
2674 if (s390_function_arg_pass_by_reference (type
))
2676 /* Actually copy the argument contents to the stack slot
2677 that was reserved above. */
2678 write_memory (copy_addr
[i
], value_contents (arg
), length
);
2682 regcache_cooked_write_unsigned (regcache
, S390_R0_REGNUM
+ gr
,
2688 write_memory_unsigned_integer (starg
, word_size
, byte_order
,
2693 else if (s390_function_arg_float (type
))
2695 /* The GNU/Linux for S/390 ABI uses FPRs 0 and 2 to pass arguments,
2696 the GNU/Linux for zSeries ABI uses 0, 2, 4, and 6. */
2697 if (fr
<= (tdep
->abi
== ABI_LINUX_S390
? 2 : 6))
2699 /* When we store a single-precision value in an FP register,
2700 it occupies the leftmost bits. */
2701 regcache_cooked_write_part (regcache
, S390_F0_REGNUM
+ fr
,
2702 0, length
, value_contents (arg
));
2707 /* When we store a single-precision value in a stack slot,
2708 it occupies the rightmost bits. */
2709 starg
= align_up (starg
+ length
, word_size
);
2710 write_memory (starg
- length
, value_contents (arg
), length
);
2713 else if (s390_function_arg_integer (type
) && length
<= word_size
)
2717 /* Integer arguments are always extended to word size. */
2718 regcache_cooked_write_signed (regcache
, S390_R0_REGNUM
+ gr
,
2719 extend_simple_arg (gdbarch
,
2725 /* Integer arguments are always extended to word size. */
2726 write_memory_signed_integer (starg
, word_size
, byte_order
,
2727 extend_simple_arg (gdbarch
, arg
));
2731 else if (s390_function_arg_integer (type
) && length
== 2*word_size
)
2735 regcache_cooked_write (regcache
, S390_R0_REGNUM
+ gr
,
2736 value_contents (arg
));
2737 regcache_cooked_write (regcache
, S390_R0_REGNUM
+ gr
+ 1,
2738 value_contents (arg
) + word_size
);
2743 /* If we skipped r6 because we couldn't fit a DOUBLE_ARG
2744 in it, then don't go back and use it again later. */
2747 write_memory (starg
, value_contents (arg
), length
);
2752 internal_error (__FILE__
, __LINE__
, _("unknown argument type"));
2756 /* Store return PSWA. In 31-bit mode, keep addressing mode bit. */
2760 regcache_cooked_read_unsigned (regcache
, S390_PSWA_REGNUM
, &pswa
);
2761 bp_addr
= (bp_addr
& 0x7fffffff) | (pswa
& 0x80000000);
2763 regcache_cooked_write_unsigned (regcache
, S390_RETADDR_REGNUM
, bp_addr
);
2765 /* Store updated stack pointer. */
2766 regcache_cooked_write_unsigned (regcache
, S390_SP_REGNUM
, sp
);
2768 /* We need to return the 'stack part' of the frame ID,
2769 which is actually the top of the register save area. */
2770 return sp
+ 16*word_size
+ 32;
2773 /* Assuming THIS_FRAME is a dummy, return the frame ID of that
2774 dummy frame. The frame ID's base needs to match the TOS value
2775 returned by push_dummy_call, and the PC match the dummy frame's
2777 static struct frame_id
2778 s390_dummy_id (struct gdbarch
*gdbarch
, struct frame_info
*this_frame
)
2780 int word_size
= gdbarch_ptr_bit (gdbarch
) / 8;
2781 CORE_ADDR sp
= get_frame_register_unsigned (this_frame
, S390_SP_REGNUM
);
2782 sp
= gdbarch_addr_bits_remove (gdbarch
, sp
);
2784 return frame_id_build (sp
+ 16*word_size
+ 32,
2785 get_frame_pc (this_frame
));
2789 s390_frame_align (struct gdbarch
*gdbarch
, CORE_ADDR addr
)
2791 /* Both the 32- and 64-bit ABI's say that the stack pointer should
2792 always be aligned on an eight-byte boundary. */
2797 /* Function return value access. */
2799 static enum return_value_convention
2800 s390_return_value_convention (struct gdbarch
*gdbarch
, struct type
*type
)
2802 if (TYPE_LENGTH (type
) > 8)
2803 return RETURN_VALUE_STRUCT_CONVENTION
;
2805 switch (TYPE_CODE (type
))
2807 case TYPE_CODE_STRUCT
:
2808 case TYPE_CODE_UNION
:
2809 case TYPE_CODE_ARRAY
:
2810 case TYPE_CODE_COMPLEX
:
2811 return RETURN_VALUE_STRUCT_CONVENTION
;
2814 return RETURN_VALUE_REGISTER_CONVENTION
;
2818 static enum return_value_convention
2819 s390_return_value (struct gdbarch
*gdbarch
, struct value
*function
,
2820 struct type
*type
, struct regcache
*regcache
,
2821 gdb_byte
*out
, const gdb_byte
*in
)
2823 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
2824 int word_size
= gdbarch_ptr_bit (gdbarch
) / 8;
2825 enum return_value_convention rvc
;
2828 type
= check_typedef (type
);
2829 rvc
= s390_return_value_convention (gdbarch
, type
);
2830 length
= TYPE_LENGTH (type
);
2836 case RETURN_VALUE_REGISTER_CONVENTION
:
2837 if (TYPE_CODE (type
) == TYPE_CODE_FLT
2838 || TYPE_CODE (type
) == TYPE_CODE_DECFLOAT
)
2840 /* When we store a single-precision value in an FP register,
2841 it occupies the leftmost bits. */
2842 regcache_cooked_write_part (regcache
, S390_F0_REGNUM
,
2845 else if (length
<= word_size
)
2847 /* Integer arguments are always extended to word size. */
2848 if (TYPE_UNSIGNED (type
))
2849 regcache_cooked_write_unsigned (regcache
, S390_R2_REGNUM
,
2850 extract_unsigned_integer (in
, length
, byte_order
));
2852 regcache_cooked_write_signed (regcache
, S390_R2_REGNUM
,
2853 extract_signed_integer (in
, length
, byte_order
));
2855 else if (length
== 2*word_size
)
2857 regcache_cooked_write (regcache
, S390_R2_REGNUM
, in
);
2858 regcache_cooked_write (regcache
, S390_R3_REGNUM
, in
+ word_size
);
2861 internal_error (__FILE__
, __LINE__
, _("invalid return type"));
2864 case RETURN_VALUE_STRUCT_CONVENTION
:
2865 error (_("Cannot set function return value."));
2873 case RETURN_VALUE_REGISTER_CONVENTION
:
2874 if (TYPE_CODE (type
) == TYPE_CODE_FLT
2875 || TYPE_CODE (type
) == TYPE_CODE_DECFLOAT
)
2877 /* When we store a single-precision value in an FP register,
2878 it occupies the leftmost bits. */
2879 regcache_cooked_read_part (regcache
, S390_F0_REGNUM
,
2882 else if (length
<= word_size
)
2884 /* Integer arguments occupy the rightmost bits. */
2885 regcache_cooked_read_part (regcache
, S390_R2_REGNUM
,
2886 word_size
- length
, length
, out
);
2888 else if (length
== 2*word_size
)
2890 regcache_cooked_read (regcache
, S390_R2_REGNUM
, out
);
2891 regcache_cooked_read (regcache
, S390_R3_REGNUM
, out
+ word_size
);
2894 internal_error (__FILE__
, __LINE__
, _("invalid return type"));
2897 case RETURN_VALUE_STRUCT_CONVENTION
:
2898 error (_("Function return value unknown."));
2909 static const gdb_byte
*
2910 s390_breakpoint_from_pc (struct gdbarch
*gdbarch
,
2911 CORE_ADDR
*pcptr
, int *lenptr
)
2913 static const gdb_byte breakpoint
[] = { 0x0, 0x1 };
2915 *lenptr
= sizeof (breakpoint
);
2920 /* Address handling. */
2923 s390_addr_bits_remove (struct gdbarch
*gdbarch
, CORE_ADDR addr
)
2925 return addr
& 0x7fffffff;
2929 s390_address_class_type_flags (int byte_size
, int dwarf2_addr_class
)
2932 return TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1
;
2938 s390_address_class_type_flags_to_name (struct gdbarch
*gdbarch
, int type_flags
)
2940 if (type_flags
& TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1
)
2947 s390_address_class_name_to_type_flags (struct gdbarch
*gdbarch
,
2949 int *type_flags_ptr
)
2951 if (strcmp (name
, "mode32") == 0)
2953 *type_flags_ptr
= TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1
;
2960 /* Implementation of `gdbarch_stap_is_single_operand', as defined in
2964 s390_stap_is_single_operand (struct gdbarch
*gdbarch
, const char *s
)
2966 return ((isdigit (*s
) && s
[1] == '(' && s
[2] == '%') /* Displacement
2968 || *s
== '%' /* Register access. */
2969 || isdigit (*s
)); /* Literal number. */
2972 /* Set up gdbarch struct. */
2974 static struct gdbarch
*
2975 s390_gdbarch_init (struct gdbarch_info info
, struct gdbarch_list
*arches
)
2977 const struct target_desc
*tdesc
= info
.target_desc
;
2978 struct tdesc_arch_data
*tdesc_data
= NULL
;
2979 struct gdbarch
*gdbarch
;
2980 struct gdbarch_tdep
*tdep
;
2983 int have_linux_v1
= 0;
2984 int have_linux_v2
= 0;
2985 int first_pseudo_reg
, last_pseudo_reg
;
2987 /* Default ABI and register size. */
2988 switch (info
.bfd_arch_info
->mach
)
2990 case bfd_mach_s390_31
:
2991 tdep_abi
= ABI_LINUX_S390
;
2994 case bfd_mach_s390_64
:
2995 tdep_abi
= ABI_LINUX_ZSERIES
;
3002 /* Use default target description if none provided by the target. */
3003 if (!tdesc_has_registers (tdesc
))
3005 if (tdep_abi
== ABI_LINUX_S390
)
3006 tdesc
= tdesc_s390_linux32
;
3008 tdesc
= tdesc_s390x_linux64
;
3011 /* Check any target description for validity. */
3012 if (tdesc_has_registers (tdesc
))
3014 static const char *const gprs
[] = {
3015 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
3016 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"
3018 static const char *const fprs
[] = {
3019 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7",
3020 "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15"
3022 static const char *const acrs
[] = {
3023 "acr0", "acr1", "acr2", "acr3", "acr4", "acr5", "acr6", "acr7",
3024 "acr8", "acr9", "acr10", "acr11", "acr12", "acr13", "acr14", "acr15"
3026 static const char *const gprs_lower
[] = {
3027 "r0l", "r1l", "r2l", "r3l", "r4l", "r5l", "r6l", "r7l",
3028 "r8l", "r9l", "r10l", "r11l", "r12l", "r13l", "r14l", "r15l"
3030 static const char *const gprs_upper
[] = {
3031 "r0h", "r1h", "r2h", "r3h", "r4h", "r5h", "r6h", "r7h",
3032 "r8h", "r9h", "r10h", "r11h", "r12h", "r13h", "r14h", "r15h"
3034 const struct tdesc_feature
*feature
;
3037 feature
= tdesc_find_feature (tdesc
, "org.gnu.gdb.s390.core");
3038 if (feature
== NULL
)
3041 tdesc_data
= tdesc_data_alloc ();
3043 valid_p
&= tdesc_numbered_register (feature
, tdesc_data
,
3044 S390_PSWM_REGNUM
, "pswm");
3045 valid_p
&= tdesc_numbered_register (feature
, tdesc_data
,
3046 S390_PSWA_REGNUM
, "pswa");
3048 if (tdesc_unnumbered_register (feature
, "r0"))
3050 for (i
= 0; i
< 16; i
++)
3051 valid_p
&= tdesc_numbered_register (feature
, tdesc_data
,
3052 S390_R0_REGNUM
+ i
, gprs
[i
]);
3058 for (i
= 0; i
< 16; i
++)
3059 valid_p
&= tdesc_numbered_register (feature
, tdesc_data
,
3062 for (i
= 0; i
< 16; i
++)
3063 valid_p
&= tdesc_numbered_register (feature
, tdesc_data
,
3064 S390_R0_UPPER_REGNUM
+ i
,
3068 feature
= tdesc_find_feature (tdesc
, "org.gnu.gdb.s390.fpr");
3069 if (feature
== NULL
)
3071 tdesc_data_cleanup (tdesc_data
);
3075 valid_p
&= tdesc_numbered_register (feature
, tdesc_data
,
3076 S390_FPC_REGNUM
, "fpc");
3077 for (i
= 0; i
< 16; i
++)
3078 valid_p
&= tdesc_numbered_register (feature
, tdesc_data
,
3079 S390_F0_REGNUM
+ i
, fprs
[i
]);
3081 feature
= tdesc_find_feature (tdesc
, "org.gnu.gdb.s390.acr");
3082 if (feature
== NULL
)
3084 tdesc_data_cleanup (tdesc_data
);
3088 for (i
= 0; i
< 16; i
++)
3089 valid_p
&= tdesc_numbered_register (feature
, tdesc_data
,
3090 S390_A0_REGNUM
+ i
, acrs
[i
]);
3092 /* Optional GNU/Linux-specific "registers". */
3093 feature
= tdesc_find_feature (tdesc
, "org.gnu.gdb.s390.linux");
3096 tdesc_numbered_register (feature
, tdesc_data
,
3097 S390_ORIG_R2_REGNUM
, "orig_r2");
3099 if (tdesc_numbered_register (feature
, tdesc_data
,
3100 S390_LAST_BREAK_REGNUM
, "last_break"))
3103 if (tdesc_numbered_register (feature
, tdesc_data
,
3104 S390_SYSTEM_CALL_REGNUM
, "system_call"))
3107 if (have_linux_v2
> have_linux_v1
)
3113 tdesc_data_cleanup (tdesc_data
);
3118 /* Find a candidate among extant architectures. */
3119 for (arches
= gdbarch_list_lookup_by_info (arches
, &info
);
3121 arches
= gdbarch_list_lookup_by_info (arches
->next
, &info
))
3123 tdep
= gdbarch_tdep (arches
->gdbarch
);
3126 if (tdep
->abi
!= tdep_abi
)
3128 if ((tdep
->gpr_full_regnum
!= -1) != have_upper
)
3130 if (tdesc_data
!= NULL
)
3131 tdesc_data_cleanup (tdesc_data
);
3132 return arches
->gdbarch
;
3135 /* Otherwise create a new gdbarch for the specified machine type. */
3136 tdep
= XCALLOC (1, struct gdbarch_tdep
);
3137 tdep
->abi
= tdep_abi
;
3138 gdbarch
= gdbarch_alloc (&info
, tdep
);
3140 set_gdbarch_believe_pcc_promotion (gdbarch
, 0);
3141 set_gdbarch_char_signed (gdbarch
, 0);
3143 /* S/390 GNU/Linux uses either 64-bit or 128-bit long doubles.
3144 We can safely let them default to 128-bit, since the debug info
3145 will give the size of type actually used in each case. */
3146 set_gdbarch_long_double_bit (gdbarch
, 128);
3147 set_gdbarch_long_double_format (gdbarch
, floatformats_ia64_quad
);
3149 /* Amount PC must be decremented by after a breakpoint. This is
3150 often the number of bytes returned by gdbarch_breakpoint_from_pc but not
3152 set_gdbarch_decr_pc_after_break (gdbarch
, 2);
3153 /* Stack grows downward. */
3154 set_gdbarch_inner_than (gdbarch
, core_addr_lessthan
);
3155 set_gdbarch_breakpoint_from_pc (gdbarch
, s390_breakpoint_from_pc
);
3156 set_gdbarch_skip_prologue (gdbarch
, s390_skip_prologue
);
3157 set_gdbarch_in_function_epilogue_p (gdbarch
, s390_in_function_epilogue_p
);
3159 set_gdbarch_num_regs (gdbarch
, S390_NUM_REGS
);
3160 set_gdbarch_sp_regnum (gdbarch
, S390_SP_REGNUM
);
3161 set_gdbarch_fp0_regnum (gdbarch
, S390_F0_REGNUM
);
3162 set_gdbarch_stab_reg_to_regnum (gdbarch
, s390_dwarf_reg_to_regnum
);
3163 set_gdbarch_dwarf2_reg_to_regnum (gdbarch
, s390_dwarf_reg_to_regnum
);
3164 set_gdbarch_value_from_register (gdbarch
, s390_value_from_register
);
3165 set_gdbarch_regset_from_core_section (gdbarch
,
3166 s390_regset_from_core_section
);
3167 set_gdbarch_core_read_description (gdbarch
, s390_core_read_description
);
3168 set_gdbarch_cannot_store_register (gdbarch
, s390_cannot_store_register
);
3169 set_gdbarch_write_pc (gdbarch
, s390_write_pc
);
3170 set_gdbarch_pseudo_register_read (gdbarch
, s390_pseudo_register_read
);
3171 set_gdbarch_pseudo_register_write (gdbarch
, s390_pseudo_register_write
);
3172 set_tdesc_pseudo_register_name (gdbarch
, s390_pseudo_register_name
);
3173 set_tdesc_pseudo_register_type (gdbarch
, s390_pseudo_register_type
);
3174 set_tdesc_pseudo_register_reggroup_p (gdbarch
,
3175 s390_pseudo_register_reggroup_p
);
3176 tdesc_use_registers (gdbarch
, tdesc
, tdesc_data
);
3178 /* Assign pseudo register numbers. */
3179 first_pseudo_reg
= gdbarch_num_regs (gdbarch
);
3180 last_pseudo_reg
= first_pseudo_reg
;
3181 tdep
->gpr_full_regnum
= -1;
3184 tdep
->gpr_full_regnum
= last_pseudo_reg
;
3185 last_pseudo_reg
+= 16;
3187 tdep
->pc_regnum
= last_pseudo_reg
++;
3188 tdep
->cc_regnum
= last_pseudo_reg
++;
3189 set_gdbarch_pc_regnum (gdbarch
, tdep
->pc_regnum
);
3190 set_gdbarch_num_pseudo_regs (gdbarch
, last_pseudo_reg
- first_pseudo_reg
);
3192 /* Inferior function calls. */
3193 set_gdbarch_push_dummy_call (gdbarch
, s390_push_dummy_call
);
3194 set_gdbarch_dummy_id (gdbarch
, s390_dummy_id
);
3195 set_gdbarch_frame_align (gdbarch
, s390_frame_align
);
3196 set_gdbarch_return_value (gdbarch
, s390_return_value
);
3198 /* Frame handling. */
3199 dwarf2_frame_set_init_reg (gdbarch
, s390_dwarf2_frame_init_reg
);
3200 dwarf2_frame_set_adjust_regnum (gdbarch
, s390_adjust_frame_regnum
);
3201 dwarf2_append_unwinders (gdbarch
);
3202 frame_base_append_sniffer (gdbarch
, dwarf2_frame_base_sniffer
);
3203 frame_unwind_append_unwinder (gdbarch
, &s390_stub_frame_unwind
);
3204 frame_unwind_append_unwinder (gdbarch
, &s390_sigtramp_frame_unwind
);
3205 frame_unwind_append_unwinder (gdbarch
, &s390_frame_unwind
);
3206 frame_base_set_default (gdbarch
, &s390_frame_base
);
3207 set_gdbarch_unwind_pc (gdbarch
, s390_unwind_pc
);
3208 set_gdbarch_unwind_sp (gdbarch
, s390_unwind_sp
);
3210 /* Displaced stepping. */
3211 set_gdbarch_displaced_step_copy_insn (gdbarch
,
3212 simple_displaced_step_copy_insn
);
3213 set_gdbarch_displaced_step_fixup (gdbarch
, s390_displaced_step_fixup
);
3214 set_gdbarch_displaced_step_free_closure (gdbarch
,
3215 simple_displaced_step_free_closure
);
3216 set_gdbarch_displaced_step_location (gdbarch
,
3217 displaced_step_at_entry_point
);
3218 set_gdbarch_max_insn_length (gdbarch
, S390_MAX_INSTR_SIZE
);
3220 /* Note that GNU/Linux is the only OS supported on this
3222 linux_init_abi (info
, gdbarch
);
3226 case ABI_LINUX_S390
:
3227 tdep
->gregset
= &s390_gregset
;
3228 tdep
->sizeof_gregset
= s390_sizeof_gregset
;
3229 tdep
->fpregset
= &s390_fpregset
;
3230 tdep
->sizeof_fpregset
= s390_sizeof_fpregset
;
3232 set_gdbarch_addr_bits_remove (gdbarch
, s390_addr_bits_remove
);
3233 set_solib_svr4_fetch_link_map_offsets
3234 (gdbarch
, svr4_ilp32_fetch_link_map_offsets
);
3239 set_gdbarch_core_regset_sections (gdbarch
,
3240 s390_linux64v2_regset_sections
);
3241 else if (have_linux_v1
)
3242 set_gdbarch_core_regset_sections (gdbarch
,
3243 s390_linux64v1_regset_sections
);
3245 set_gdbarch_core_regset_sections (gdbarch
,
3246 s390_linux64_regset_sections
);
3251 set_gdbarch_core_regset_sections (gdbarch
,
3252 s390_linux32v2_regset_sections
);
3253 else if (have_linux_v1
)
3254 set_gdbarch_core_regset_sections (gdbarch
,
3255 s390_linux32v1_regset_sections
);
3257 set_gdbarch_core_regset_sections (gdbarch
,
3258 s390_linux32_regset_sections
);
3262 case ABI_LINUX_ZSERIES
:
3263 tdep
->gregset
= &s390x_gregset
;
3264 tdep
->sizeof_gregset
= s390x_sizeof_gregset
;
3265 tdep
->fpregset
= &s390_fpregset
;
3266 tdep
->sizeof_fpregset
= s390_sizeof_fpregset
;
3268 set_gdbarch_long_bit (gdbarch
, 64);
3269 set_gdbarch_long_long_bit (gdbarch
, 64);
3270 set_gdbarch_ptr_bit (gdbarch
, 64);
3271 set_solib_svr4_fetch_link_map_offsets
3272 (gdbarch
, svr4_lp64_fetch_link_map_offsets
);
3273 set_gdbarch_address_class_type_flags (gdbarch
,
3274 s390_address_class_type_flags
);
3275 set_gdbarch_address_class_type_flags_to_name (gdbarch
,
3276 s390_address_class_type_flags_to_name
);
3277 set_gdbarch_address_class_name_to_type_flags (gdbarch
,
3278 s390_address_class_name_to_type_flags
);
3281 set_gdbarch_core_regset_sections (gdbarch
,
3282 s390x_linux64v2_regset_sections
);
3283 else if (have_linux_v1
)
3284 set_gdbarch_core_regset_sections (gdbarch
,
3285 s390x_linux64v1_regset_sections
);
3287 set_gdbarch_core_regset_sections (gdbarch
,
3288 s390x_linux64_regset_sections
);
3292 set_gdbarch_print_insn (gdbarch
, print_insn_s390
);
3294 set_gdbarch_skip_trampoline_code (gdbarch
, find_solib_trampoline_target
);
3296 /* Enable TLS support. */
3297 set_gdbarch_fetch_tls_load_module_address (gdbarch
,
3298 svr4_fetch_objfile_link_map
);
3300 set_gdbarch_get_siginfo_type (gdbarch
, linux_get_siginfo_type
);
3302 /* SystemTap functions. */
3303 set_gdbarch_stap_register_prefix (gdbarch
, "%");
3304 set_gdbarch_stap_register_indirection_prefix (gdbarch
, "(");
3305 set_gdbarch_stap_register_indirection_suffix (gdbarch
, ")");
3306 set_gdbarch_stap_is_single_operand (gdbarch
, s390_stap_is_single_operand
);
3312 extern initialize_file_ftype _initialize_s390_tdep
; /* -Wmissing-prototypes */
3315 _initialize_s390_tdep (void)
3317 /* Hook us into the gdbarch mechanism. */
3318 register_gdbarch_init (bfd_arch_s390
, s390_gdbarch_init
);
3320 /* Initialize the GNU/Linux target descriptions. */
3321 initialize_tdesc_s390_linux32 ();
3322 initialize_tdesc_s390_linux32v1 ();
3323 initialize_tdesc_s390_linux32v2 ();
3324 initialize_tdesc_s390_linux64 ();
3325 initialize_tdesc_s390_linux64v1 ();
3326 initialize_tdesc_s390_linux64v2 ();
3327 initialize_tdesc_s390x_linux64 ();
3328 initialize_tdesc_s390x_linux64v1 ();
3329 initialize_tdesc_s390x_linux64v2 ();