1 /* Target-dependent code for GDB, the GNU debugger.
3 Copyright (C) 2001-2015 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"
33 #include "floatformat.h"
35 #include "trad-frame.h"
36 #include "frame-base.h"
37 #include "frame-unwind.h"
38 #include "dwarf2-frame.h"
39 #include "reggroups.h"
43 #include "solib-svr4.h"
44 #include "prologue-value.h"
45 #include "linux-tdep.h"
46 #include "s390-linux-tdep.h"
48 #include "xml-syscall.h"
50 #include "stap-probe.h"
53 #include "user-regs.h"
54 #include "cli/cli-utils.h"
56 #include "elf/common.h"
60 #include "features/s390-linux32.c"
61 #include "features/s390-linux32v1.c"
62 #include "features/s390-linux32v2.c"
63 #include "features/s390-linux64.c"
64 #include "features/s390-linux64v1.c"
65 #include "features/s390-linux64v2.c"
66 #include "features/s390-te-linux64.c"
67 #include "features/s390-vx-linux64.c"
68 #include "features/s390-tevx-linux64.c"
69 #include "features/s390x-linux64.c"
70 #include "features/s390x-linux64v1.c"
71 #include "features/s390x-linux64v2.c"
72 #include "features/s390x-te-linux64.c"
73 #include "features/s390x-vx-linux64.c"
74 #include "features/s390x-tevx-linux64.c"
76 #define XML_SYSCALL_FILENAME_S390 "syscalls/s390-linux.xml"
77 #define XML_SYSCALL_FILENAME_S390X "syscalls/s390x-linux.xml"
85 enum s390_vector_abi_kind
91 /* The tdep structure. */
96 enum s390_abi_kind abi
;
99 enum s390_vector_abi_kind vector_abi
;
101 /* Pseudo register numbers. */
113 /* ABI call-saved register information. */
116 s390_register_call_saved (struct gdbarch
*gdbarch
, int regnum
)
118 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
123 if ((regnum
>= S390_R6_REGNUM
&& regnum
<= S390_R15_REGNUM
)
124 || regnum
== S390_F4_REGNUM
|| regnum
== S390_F6_REGNUM
125 || regnum
== S390_A0_REGNUM
)
130 case ABI_LINUX_ZSERIES
:
131 if ((regnum
>= S390_R6_REGNUM
&& regnum
<= S390_R15_REGNUM
)
132 || (regnum
>= S390_F8_REGNUM
&& regnum
<= S390_F15_REGNUM
)
133 || (regnum
>= S390_A0_REGNUM
&& regnum
<= S390_A1_REGNUM
))
143 s390_cannot_store_register (struct gdbarch
*gdbarch
, int regnum
)
145 /* The last-break address is read-only. */
146 return regnum
== S390_LAST_BREAK_REGNUM
;
150 s390_write_pc (struct regcache
*regcache
, CORE_ADDR pc
)
152 struct gdbarch
*gdbarch
= get_regcache_arch (regcache
);
153 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
155 regcache_cooked_write_unsigned (regcache
, tdep
->pc_regnum
, pc
);
157 /* Set special SYSTEM_CALL register to 0 to prevent the kernel from
158 messing with the PC we just installed, if we happen to be within
159 an interrupted system call that the kernel wants to restart.
161 Note that after we return from the dummy call, the SYSTEM_CALL and
162 ORIG_R2 registers will be automatically restored, and the kernel
163 continues to restart the system call at this point. */
164 if (register_size (gdbarch
, S390_SYSTEM_CALL_REGNUM
) > 0)
165 regcache_cooked_write_unsigned (regcache
, S390_SYSTEM_CALL_REGNUM
, 0);
169 /* DWARF Register Mapping. */
171 static const short s390_dwarf_regmap
[] =
173 /* 0-15: General Purpose Registers. */
174 S390_R0_REGNUM
, S390_R1_REGNUM
, S390_R2_REGNUM
, S390_R3_REGNUM
,
175 S390_R4_REGNUM
, S390_R5_REGNUM
, S390_R6_REGNUM
, S390_R7_REGNUM
,
176 S390_R8_REGNUM
, S390_R9_REGNUM
, S390_R10_REGNUM
, S390_R11_REGNUM
,
177 S390_R12_REGNUM
, S390_R13_REGNUM
, S390_R14_REGNUM
, S390_R15_REGNUM
,
179 /* 16-31: Floating Point Registers / Vector Registers 0-15. */
180 S390_F0_REGNUM
, S390_F2_REGNUM
, S390_F4_REGNUM
, S390_F6_REGNUM
,
181 S390_F1_REGNUM
, S390_F3_REGNUM
, S390_F5_REGNUM
, S390_F7_REGNUM
,
182 S390_F8_REGNUM
, S390_F10_REGNUM
, S390_F12_REGNUM
, S390_F14_REGNUM
,
183 S390_F9_REGNUM
, S390_F11_REGNUM
, S390_F13_REGNUM
, S390_F15_REGNUM
,
185 /* 32-47: Control Registers (not mapped). */
186 -1, -1, -1, -1, -1, -1, -1, -1,
187 -1, -1, -1, -1, -1, -1, -1, -1,
189 /* 48-63: Access Registers. */
190 S390_A0_REGNUM
, S390_A1_REGNUM
, S390_A2_REGNUM
, S390_A3_REGNUM
,
191 S390_A4_REGNUM
, S390_A5_REGNUM
, S390_A6_REGNUM
, S390_A7_REGNUM
,
192 S390_A8_REGNUM
, S390_A9_REGNUM
, S390_A10_REGNUM
, S390_A11_REGNUM
,
193 S390_A12_REGNUM
, S390_A13_REGNUM
, S390_A14_REGNUM
, S390_A15_REGNUM
,
195 /* 64-65: Program Status Word. */
199 /* 66-67: Reserved. */
202 /* 68-83: Vector Registers 16-31. */
203 S390_V16_REGNUM
, S390_V18_REGNUM
, S390_V20_REGNUM
, S390_V22_REGNUM
,
204 S390_V17_REGNUM
, S390_V19_REGNUM
, S390_V21_REGNUM
, S390_V23_REGNUM
,
205 S390_V24_REGNUM
, S390_V26_REGNUM
, S390_V28_REGNUM
, S390_V30_REGNUM
,
206 S390_V25_REGNUM
, S390_V27_REGNUM
, S390_V29_REGNUM
, S390_V31_REGNUM
,
208 /* End of "official" DWARF registers. The remainder of the map is
209 for GDB internal use only. */
211 /* GPR Lower Half Access. */
212 S390_R0_REGNUM
, S390_R1_REGNUM
, S390_R2_REGNUM
, S390_R3_REGNUM
,
213 S390_R4_REGNUM
, S390_R5_REGNUM
, S390_R6_REGNUM
, S390_R7_REGNUM
,
214 S390_R8_REGNUM
, S390_R9_REGNUM
, S390_R10_REGNUM
, S390_R11_REGNUM
,
215 S390_R12_REGNUM
, S390_R13_REGNUM
, S390_R14_REGNUM
, S390_R15_REGNUM
,
218 enum { s390_dwarf_reg_r0l
= ARRAY_SIZE (s390_dwarf_regmap
) - 16 };
220 /* Convert DWARF register number REG to the appropriate register
221 number used by GDB. */
223 s390_dwarf_reg_to_regnum (struct gdbarch
*gdbarch
, int reg
)
225 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
228 /* In a 32-on-64 debug scenario, debug info refers to the full
229 64-bit GPRs. Note that call frame information still refers to
230 the 32-bit lower halves, because s390_adjust_frame_regnum uses
231 special register numbers to access GPRs. */
232 if (tdep
->gpr_full_regnum
!= -1 && reg
>= 0 && reg
< 16)
233 return tdep
->gpr_full_regnum
+ reg
;
235 if (reg
>= 0 && reg
< ARRAY_SIZE (s390_dwarf_regmap
))
236 gdb_reg
= s390_dwarf_regmap
[reg
];
238 if (tdep
->v0_full_regnum
== -1)
240 if (gdb_reg
>= S390_V16_REGNUM
&& gdb_reg
<= S390_V31_REGNUM
)
245 if (gdb_reg
>= S390_F0_REGNUM
&& gdb_reg
<= S390_F15_REGNUM
)
246 gdb_reg
= gdb_reg
- S390_F0_REGNUM
+ tdep
->v0_full_regnum
;
252 /* Translate a .eh_frame register to DWARF register, or adjust a
253 .debug_frame register. */
255 s390_adjust_frame_regnum (struct gdbarch
*gdbarch
, int num
, int eh_frame_p
)
257 /* See s390_dwarf_reg_to_regnum for comments. */
258 return (num
>= 0 && num
< 16) ? num
+ s390_dwarf_reg_r0l
: num
;
262 /* Pseudo registers. */
265 regnum_is_gpr_full (struct gdbarch_tdep
*tdep
, int regnum
)
267 return (tdep
->gpr_full_regnum
!= -1
268 && regnum
>= tdep
->gpr_full_regnum
269 && regnum
<= tdep
->gpr_full_regnum
+ 15);
272 /* Check whether REGNUM indicates a full vector register (v0-v15).
273 These pseudo-registers are composed of f0-f15 and v0l-v15l. */
276 regnum_is_vxr_full (struct gdbarch_tdep
*tdep
, int regnum
)
278 return (tdep
->v0_full_regnum
!= -1
279 && regnum
>= tdep
->v0_full_regnum
280 && regnum
<= tdep
->v0_full_regnum
+ 15);
283 /* Return the name of register REGNO. Return the empty string for
284 registers that shouldn't be visible. */
287 s390_register_name (struct gdbarch
*gdbarch
, int regnum
)
289 if (regnum
>= S390_V0_LOWER_REGNUM
290 && regnum
<= S390_V15_LOWER_REGNUM
)
292 return tdesc_register_name (gdbarch
, regnum
);
296 s390_pseudo_register_name (struct gdbarch
*gdbarch
, int regnum
)
298 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
300 if (regnum
== tdep
->pc_regnum
)
303 if (regnum
== tdep
->cc_regnum
)
306 if (regnum_is_gpr_full (tdep
, regnum
))
308 static const char *full_name
[] = {
309 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
310 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"
312 return full_name
[regnum
- tdep
->gpr_full_regnum
];
315 if (regnum_is_vxr_full (tdep
, regnum
))
317 static const char *full_name
[] = {
318 "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7",
319 "v8", "v9", "v10", "v11", "v12", "v13", "v14", "v15"
321 return full_name
[regnum
- tdep
->v0_full_regnum
];
324 internal_error (__FILE__
, __LINE__
, _("invalid regnum"));
328 s390_pseudo_register_type (struct gdbarch
*gdbarch
, int regnum
)
330 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
332 if (regnum
== tdep
->pc_regnum
)
333 return builtin_type (gdbarch
)->builtin_func_ptr
;
335 if (regnum
== tdep
->cc_regnum
)
336 return builtin_type (gdbarch
)->builtin_int
;
338 if (regnum_is_gpr_full (tdep
, regnum
))
339 return builtin_type (gdbarch
)->builtin_uint64
;
341 if (regnum_is_vxr_full (tdep
, regnum
))
342 return tdesc_find_type (gdbarch
, "vec128");
344 internal_error (__FILE__
, __LINE__
, _("invalid regnum"));
347 static enum register_status
348 s390_pseudo_register_read (struct gdbarch
*gdbarch
, struct regcache
*regcache
,
349 int regnum
, gdb_byte
*buf
)
351 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
352 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
353 int regsize
= register_size (gdbarch
, regnum
);
356 if (regnum
== tdep
->pc_regnum
)
358 enum register_status status
;
360 status
= regcache_raw_read_unsigned (regcache
, S390_PSWA_REGNUM
, &val
);
361 if (status
== REG_VALID
)
363 if (register_size (gdbarch
, S390_PSWA_REGNUM
) == 4)
365 store_unsigned_integer (buf
, regsize
, byte_order
, val
);
370 if (regnum
== tdep
->cc_regnum
)
372 enum register_status status
;
374 status
= regcache_raw_read_unsigned (regcache
, S390_PSWM_REGNUM
, &val
);
375 if (status
== REG_VALID
)
377 if (register_size (gdbarch
, S390_PSWA_REGNUM
) == 4)
378 val
= (val
>> 12) & 3;
380 val
= (val
>> 44) & 3;
381 store_unsigned_integer (buf
, regsize
, byte_order
, val
);
386 if (regnum_is_gpr_full (tdep
, regnum
))
388 enum register_status status
;
391 regnum
-= tdep
->gpr_full_regnum
;
393 status
= regcache_raw_read_unsigned (regcache
, S390_R0_REGNUM
+ regnum
, &val
);
394 if (status
== REG_VALID
)
395 status
= regcache_raw_read_unsigned (regcache
, S390_R0_UPPER_REGNUM
+ regnum
,
397 if (status
== REG_VALID
)
399 val
|= val_upper
<< 32;
400 store_unsigned_integer (buf
, regsize
, byte_order
, val
);
405 if (regnum_is_vxr_full (tdep
, regnum
))
407 enum register_status status
;
409 regnum
-= tdep
->v0_full_regnum
;
411 status
= regcache_raw_read (regcache
, S390_F0_REGNUM
+ regnum
, buf
);
412 if (status
== REG_VALID
)
413 status
= regcache_raw_read (regcache
,
414 S390_V0_LOWER_REGNUM
+ regnum
, buf
+ 8);
418 internal_error (__FILE__
, __LINE__
, _("invalid regnum"));
422 s390_pseudo_register_write (struct gdbarch
*gdbarch
, struct regcache
*regcache
,
423 int regnum
, const gdb_byte
*buf
)
425 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
426 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
427 int regsize
= register_size (gdbarch
, regnum
);
430 if (regnum
== tdep
->pc_regnum
)
432 val
= extract_unsigned_integer (buf
, regsize
, byte_order
);
433 if (register_size (gdbarch
, S390_PSWA_REGNUM
) == 4)
435 regcache_raw_read_unsigned (regcache
, S390_PSWA_REGNUM
, &psw
);
436 val
= (psw
& 0x80000000) | (val
& 0x7fffffff);
438 regcache_raw_write_unsigned (regcache
, S390_PSWA_REGNUM
, val
);
442 if (regnum
== tdep
->cc_regnum
)
444 val
= extract_unsigned_integer (buf
, regsize
, byte_order
);
445 regcache_raw_read_unsigned (regcache
, S390_PSWM_REGNUM
, &psw
);
446 if (register_size (gdbarch
, S390_PSWA_REGNUM
) == 4)
447 val
= (psw
& ~((ULONGEST
)3 << 12)) | ((val
& 3) << 12);
449 val
= (psw
& ~((ULONGEST
)3 << 44)) | ((val
& 3) << 44);
450 regcache_raw_write_unsigned (regcache
, S390_PSWM_REGNUM
, val
);
454 if (regnum_is_gpr_full (tdep
, regnum
))
456 regnum
-= tdep
->gpr_full_regnum
;
457 val
= extract_unsigned_integer (buf
, regsize
, byte_order
);
458 regcache_raw_write_unsigned (regcache
, S390_R0_REGNUM
+ regnum
,
460 regcache_raw_write_unsigned (regcache
, S390_R0_UPPER_REGNUM
+ regnum
,
465 if (regnum_is_vxr_full (tdep
, regnum
))
467 regnum
-= tdep
->v0_full_regnum
;
468 regcache_raw_write (regcache
, S390_F0_REGNUM
+ regnum
, buf
);
469 regcache_raw_write (regcache
, S390_V0_LOWER_REGNUM
+ regnum
, buf
+ 8);
473 internal_error (__FILE__
, __LINE__
, _("invalid regnum"));
476 /* 'float' values are stored in the upper half of floating-point
477 registers, even though we are otherwise a big-endian platform. The
478 same applies to a 'float' value within a vector. */
480 static struct value
*
481 s390_value_from_register (struct gdbarch
*gdbarch
, struct type
*type
,
482 int regnum
, struct frame_id frame_id
)
484 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
485 struct value
*value
= default_value_from_register (gdbarch
, type
,
487 check_typedef (type
);
489 if ((regnum
>= S390_F0_REGNUM
&& regnum
<= S390_F15_REGNUM
490 && TYPE_LENGTH (type
) < 8)
491 || regnum_is_vxr_full (tdep
, regnum
)
492 || (regnum
>= S390_V16_REGNUM
&& regnum
<= S390_V31_REGNUM
))
493 set_value_offset (value
, 0);
498 /* Register groups. */
501 s390_pseudo_register_reggroup_p (struct gdbarch
*gdbarch
, int regnum
,
502 struct reggroup
*group
)
504 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
506 /* We usually save/restore the whole PSW, which includes PC and CC.
507 However, some older gdbservers may not support saving/restoring
508 the whole PSW yet, and will return an XML register description
509 excluding those from the save/restore register groups. In those
510 cases, we still need to explicitly save/restore PC and CC in order
511 to push or pop frames. Since this doesn't hurt anything if we
512 already save/restore the whole PSW (it's just redundant), we add
513 PC and CC at this point unconditionally. */
514 if (group
== save_reggroup
|| group
== restore_reggroup
)
515 return regnum
== tdep
->pc_regnum
|| regnum
== tdep
->cc_regnum
;
517 if (group
== vector_reggroup
)
518 return regnum_is_vxr_full (tdep
, regnum
);
520 if (group
== general_reggroup
&& regnum_is_vxr_full (tdep
, regnum
))
523 return default_register_reggroup_p (gdbarch
, regnum
, group
);
527 /* Maps for register sets. */
529 static const struct regcache_map_entry s390_gregmap
[] =
531 { 1, S390_PSWM_REGNUM
},
532 { 1, S390_PSWA_REGNUM
},
533 { 16, S390_R0_REGNUM
},
534 { 16, S390_A0_REGNUM
},
535 { 1, S390_ORIG_R2_REGNUM
},
539 static const struct regcache_map_entry s390_fpregmap
[] =
541 { 1, S390_FPC_REGNUM
, 8 },
542 { 16, S390_F0_REGNUM
, 8 },
546 static const struct regcache_map_entry s390_regmap_upper
[] =
548 { 16, S390_R0_UPPER_REGNUM
, 4 },
552 static const struct regcache_map_entry s390_regmap_last_break
[] =
554 { 1, REGCACHE_MAP_SKIP
, 4 },
555 { 1, S390_LAST_BREAK_REGNUM
, 4 },
559 static const struct regcache_map_entry s390x_regmap_last_break
[] =
561 { 1, S390_LAST_BREAK_REGNUM
, 8 },
565 static const struct regcache_map_entry s390_regmap_system_call
[] =
567 { 1, S390_SYSTEM_CALL_REGNUM
, 4 },
571 static const struct regcache_map_entry s390_regmap_tdb
[] =
573 { 1, S390_TDB_DWORD0_REGNUM
, 8 },
574 { 1, S390_TDB_ABORT_CODE_REGNUM
, 8 },
575 { 1, S390_TDB_CONFLICT_TOKEN_REGNUM
, 8 },
576 { 1, S390_TDB_ATIA_REGNUM
, 8 },
577 { 12, REGCACHE_MAP_SKIP
, 8 },
578 { 16, S390_TDB_R0_REGNUM
, 8 },
582 static const struct regcache_map_entry s390_regmap_vxrs_low
[] =
584 { 16, S390_V0_LOWER_REGNUM
, 8 },
588 static const struct regcache_map_entry s390_regmap_vxrs_high
[] =
590 { 16, S390_V16_REGNUM
, 16 },
595 /* Supply the TDB regset. Like regcache_supply_regset, but invalidate
596 the TDB registers unless the TDB format field is valid. */
599 s390_supply_tdb_regset (const struct regset
*regset
, struct regcache
*regcache
,
600 int regnum
, const void *regs
, size_t len
)
603 enum register_status ret
;
606 regcache_supply_regset (regset
, regcache
, regnum
, regs
, len
);
607 ret
= regcache_cooked_read_unsigned (regcache
, S390_TDB_DWORD0_REGNUM
, &tdw
);
608 if (ret
!= REG_VALID
|| (tdw
>> 56) != 1)
609 regcache_supply_regset (regset
, regcache
, regnum
, NULL
, len
);
612 const struct regset s390_gregset
= {
614 regcache_supply_regset
,
615 regcache_collect_regset
618 const struct regset s390_fpregset
= {
620 regcache_supply_regset
,
621 regcache_collect_regset
624 static const struct regset s390_upper_regset
= {
626 regcache_supply_regset
,
627 regcache_collect_regset
630 const struct regset s390_last_break_regset
= {
631 s390_regmap_last_break
,
632 regcache_supply_regset
,
633 regcache_collect_regset
636 const struct regset s390x_last_break_regset
= {
637 s390x_regmap_last_break
,
638 regcache_supply_regset
,
639 regcache_collect_regset
642 const struct regset s390_system_call_regset
= {
643 s390_regmap_system_call
,
644 regcache_supply_regset
,
645 regcache_collect_regset
648 const struct regset s390_tdb_regset
= {
650 s390_supply_tdb_regset
,
651 regcache_collect_regset
654 const struct regset s390_vxrs_low_regset
= {
655 s390_regmap_vxrs_low
,
656 regcache_supply_regset
,
657 regcache_collect_regset
660 const struct regset s390_vxrs_high_regset
= {
661 s390_regmap_vxrs_high
,
662 regcache_supply_regset
,
663 regcache_collect_regset
666 /* Iterate over supported core file register note sections. */
669 s390_iterate_over_regset_sections (struct gdbarch
*gdbarch
,
670 iterate_over_regset_sections_cb
*cb
,
672 const struct regcache
*regcache
)
674 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
675 const int gregset_size
= (tdep
->abi
== ABI_LINUX_S390
?
676 s390_sizeof_gregset
: s390x_sizeof_gregset
);
678 cb (".reg", gregset_size
, &s390_gregset
, NULL
, cb_data
);
679 cb (".reg2", s390_sizeof_fpregset
, &s390_fpregset
, NULL
, cb_data
);
681 if (tdep
->abi
== ABI_LINUX_S390
&& tdep
->gpr_full_regnum
!= -1)
682 cb (".reg-s390-high-gprs", 16 * 4, &s390_upper_regset
,
683 "s390 GPR upper halves", cb_data
);
685 if (tdep
->have_linux_v1
)
686 cb (".reg-s390-last-break", 8,
687 (gdbarch_ptr_bit (gdbarch
) == 32
688 ? &s390_last_break_regset
: &s390x_last_break_regset
),
689 "s930 last-break address", cb_data
);
691 if (tdep
->have_linux_v2
)
692 cb (".reg-s390-system-call", 4, &s390_system_call_regset
,
693 "s390 system-call", cb_data
);
695 /* If regcache is set, we are in "write" (gcore) mode. In this
696 case, don't iterate over the TDB unless its registers are
700 || REG_VALID
== regcache_register_status (regcache
,
701 S390_TDB_DWORD0_REGNUM
)))
702 cb (".reg-s390-tdb", s390_sizeof_tdbregset
, &s390_tdb_regset
,
703 "s390 TDB", cb_data
);
705 if (tdep
->v0_full_regnum
!= -1)
707 cb (".reg-s390-vxrs-low", 16 * 8, &s390_vxrs_low_regset
,
708 "s390 vector registers 0-15 lower half", cb_data
);
709 cb (".reg-s390-vxrs-high", 16 * 16, &s390_vxrs_high_regset
,
710 "s390 vector registers 16-31", cb_data
);
714 static const struct target_desc
*
715 s390_core_read_description (struct gdbarch
*gdbarch
,
716 struct target_ops
*target
, bfd
*abfd
)
718 asection
*section
= bfd_get_section_by_name (abfd
, ".reg");
720 int high_gprs
, v1
, v2
, te
, vx
;
722 target_auxv_search (target
, AT_HWCAP
, &hwcap
);
726 high_gprs
= (bfd_get_section_by_name (abfd
, ".reg-s390-high-gprs")
728 v1
= (bfd_get_section_by_name (abfd
, ".reg-s390-last-break") != NULL
);
729 v2
= (bfd_get_section_by_name (abfd
, ".reg-s390-system-call") != NULL
);
730 vx
= (hwcap
& HWCAP_S390_VX
);
731 te
= (hwcap
& HWCAP_S390_TE
);
733 switch (bfd_section_size (abfd
, section
))
735 case s390_sizeof_gregset
:
737 return (te
&& vx
? tdesc_s390_tevx_linux64
:
738 vx
? tdesc_s390_vx_linux64
:
739 te
? tdesc_s390_te_linux64
:
740 v2
? tdesc_s390_linux64v2
:
741 v1
? tdesc_s390_linux64v1
: tdesc_s390_linux64
);
743 return (v2
? tdesc_s390_linux32v2
:
744 v1
? tdesc_s390_linux32v1
: tdesc_s390_linux32
);
746 case s390x_sizeof_gregset
:
747 return (te
&& vx
? tdesc_s390x_tevx_linux64
:
748 vx
? tdesc_s390x_vx_linux64
:
749 te
? tdesc_s390x_te_linux64
:
750 v2
? tdesc_s390x_linux64v2
:
751 v1
? tdesc_s390x_linux64v1
: tdesc_s390x_linux64
);
759 /* Decoding S/390 instructions. */
761 /* Named opcode values for the S/390 instructions we recognize. Some
762 instructions have their opcode split across two fields; those are the
763 op1_* and op2_* enums. */
766 op1_lhi
= 0xa7, op2_lhi
= 0x08,
767 op1_lghi
= 0xa7, op2_lghi
= 0x09,
768 op1_lgfi
= 0xc0, op2_lgfi
= 0x01,
772 op1_ly
= 0xe3, op2_ly
= 0x58,
773 op1_lg
= 0xe3, op2_lg
= 0x04,
775 op1_lmy
= 0xeb, op2_lmy
= 0x98,
776 op1_lmg
= 0xeb, op2_lmg
= 0x04,
778 op1_sty
= 0xe3, op2_sty
= 0x50,
779 op1_stg
= 0xe3, op2_stg
= 0x24,
782 op1_stmy
= 0xeb, op2_stmy
= 0x90,
783 op1_stmg
= 0xeb, op2_stmg
= 0x24,
784 op1_aghi
= 0xa7, op2_aghi
= 0x0b,
785 op1_ahi
= 0xa7, op2_ahi
= 0x0a,
786 op1_agfi
= 0xc2, op2_agfi
= 0x08,
787 op1_afi
= 0xc2, op2_afi
= 0x09,
788 op1_algfi
= 0xc2, op2_algfi
= 0x0a,
789 op1_alfi
= 0xc2, op2_alfi
= 0x0b,
793 op1_ay
= 0xe3, op2_ay
= 0x5a,
794 op1_ag
= 0xe3, op2_ag
= 0x08,
795 op1_slgfi
= 0xc2, op2_slgfi
= 0x04,
796 op1_slfi
= 0xc2, op2_slfi
= 0x05,
800 op1_sy
= 0xe3, op2_sy
= 0x5b,
801 op1_sg
= 0xe3, op2_sg
= 0x09,
805 op1_lay
= 0xe3, op2_lay
= 0x71,
806 op1_larl
= 0xc0, op2_larl
= 0x00,
814 op1_bctg
= 0xe3, op2_bctg
= 0x46,
816 op1_bxhg
= 0xeb, op2_bxhg
= 0x44,
818 op1_bxleg
= 0xeb, op2_bxleg
= 0x45,
819 op1_bras
= 0xa7, op2_bras
= 0x05,
820 op1_brasl
= 0xc0, op2_brasl
= 0x05,
821 op1_brc
= 0xa7, op2_brc
= 0x04,
822 op1_brcl
= 0xc0, op2_brcl
= 0x04,
823 op1_brct
= 0xa7, op2_brct
= 0x06,
824 op1_brctg
= 0xa7, op2_brctg
= 0x07,
826 op1_brxhg
= 0xec, op2_brxhg
= 0x44,
828 op1_brxlg
= 0xec, op2_brxlg
= 0x45,
833 /* Read a single instruction from address AT. */
835 #define S390_MAX_INSTR_SIZE 6
837 s390_readinstruction (bfd_byte instr
[], CORE_ADDR at
)
839 static int s390_instrlen
[] = { 2, 4, 4, 6 };
842 if (target_read_memory (at
, &instr
[0], 2))
844 instrlen
= s390_instrlen
[instr
[0] >> 6];
847 if (target_read_memory (at
+ 2, &instr
[2], instrlen
- 2))
854 /* The functions below are for recognizing and decoding S/390
855 instructions of various formats. Each of them checks whether INSN
856 is an instruction of the given format, with the specified opcodes.
857 If it is, it sets the remaining arguments to the values of the
858 instruction's fields, and returns a non-zero value; otherwise, it
861 These functions' arguments appear in the order they appear in the
862 instruction, not in the machine-language form. So, opcodes always
863 come first, even though they're sometimes scattered around the
864 instructions. And displacements appear before base and extension
865 registers, as they do in the assembly syntax, not at the end, as
866 they do in the machine language. */
868 is_ri (bfd_byte
*insn
, int op1
, int op2
, unsigned int *r1
, int *i2
)
870 if (insn
[0] == op1
&& (insn
[1] & 0xf) == op2
)
872 *r1
= (insn
[1] >> 4) & 0xf;
873 /* i2 is a 16-bit signed quantity. */
874 *i2
= (((insn
[2] << 8) | insn
[3]) ^ 0x8000) - 0x8000;
883 is_ril (bfd_byte
*insn
, int op1
, int op2
,
884 unsigned int *r1
, int *i2
)
886 if (insn
[0] == op1
&& (insn
[1] & 0xf) == op2
)
888 *r1
= (insn
[1] >> 4) & 0xf;
889 /* i2 is a signed quantity. If the host 'int' is 32 bits long,
890 no sign extension is necessary, but we don't want to assume
892 *i2
= (((insn
[2] << 24)
895 | (insn
[5])) ^ 0x80000000) - 0x80000000;
904 is_rr (bfd_byte
*insn
, int op
, unsigned int *r1
, unsigned int *r2
)
908 *r1
= (insn
[1] >> 4) & 0xf;
918 is_rre (bfd_byte
*insn
, int op
, unsigned int *r1
, unsigned int *r2
)
920 if (((insn
[0] << 8) | insn
[1]) == op
)
922 /* Yes, insn[3]. insn[2] is unused in RRE format. */
923 *r1
= (insn
[3] >> 4) & 0xf;
933 is_rs (bfd_byte
*insn
, int op
,
934 unsigned int *r1
, unsigned int *r3
, int *d2
, unsigned int *b2
)
938 *r1
= (insn
[1] >> 4) & 0xf;
940 *b2
= (insn
[2] >> 4) & 0xf;
941 *d2
= ((insn
[2] & 0xf) << 8) | insn
[3];
950 is_rsy (bfd_byte
*insn
, int op1
, int op2
,
951 unsigned int *r1
, unsigned int *r3
, int *d2
, unsigned int *b2
)
956 *r1
= (insn
[1] >> 4) & 0xf;
958 *b2
= (insn
[2] >> 4) & 0xf;
959 /* The 'long displacement' is a 20-bit signed integer. */
960 *d2
= ((((insn
[2] & 0xf) << 8) | insn
[3] | (insn
[4] << 12))
961 ^ 0x80000) - 0x80000;
970 is_rsi (bfd_byte
*insn
, int op
,
971 unsigned int *r1
, unsigned int *r3
, int *i2
)
975 *r1
= (insn
[1] >> 4) & 0xf;
977 /* i2 is a 16-bit signed quantity. */
978 *i2
= (((insn
[2] << 8) | insn
[3]) ^ 0x8000) - 0x8000;
987 is_rie (bfd_byte
*insn
, int op1
, int op2
,
988 unsigned int *r1
, unsigned int *r3
, int *i2
)
993 *r1
= (insn
[1] >> 4) & 0xf;
995 /* i2 is a 16-bit signed quantity. */
996 *i2
= (((insn
[2] << 8) | insn
[3]) ^ 0x8000) - 0x8000;
1005 is_rx (bfd_byte
*insn
, int op
,
1006 unsigned int *r1
, int *d2
, unsigned int *x2
, unsigned int *b2
)
1010 *r1
= (insn
[1] >> 4) & 0xf;
1011 *x2
= insn
[1] & 0xf;
1012 *b2
= (insn
[2] >> 4) & 0xf;
1013 *d2
= ((insn
[2] & 0xf) << 8) | insn
[3];
1022 is_rxy (bfd_byte
*insn
, int op1
, int op2
,
1023 unsigned int *r1
, int *d2
, unsigned int *x2
, unsigned int *b2
)
1028 *r1
= (insn
[1] >> 4) & 0xf;
1029 *x2
= insn
[1] & 0xf;
1030 *b2
= (insn
[2] >> 4) & 0xf;
1031 /* The 'long displacement' is a 20-bit signed integer. */
1032 *d2
= ((((insn
[2] & 0xf) << 8) | insn
[3] | (insn
[4] << 12))
1033 ^ 0x80000) - 0x80000;
1041 /* Prologue analysis. */
1043 #define S390_NUM_GPRS 16
1044 #define S390_NUM_FPRS 16
1046 struct s390_prologue_data
{
1049 struct pv_area
*stack
;
1051 /* The size and byte-order of a GPR or FPR. */
1054 enum bfd_endian byte_order
;
1056 /* The general-purpose registers. */
1057 pv_t gpr
[S390_NUM_GPRS
];
1059 /* The floating-point registers. */
1060 pv_t fpr
[S390_NUM_FPRS
];
1062 /* The offset relative to the CFA where the incoming GPR N was saved
1063 by the function prologue. 0 if not saved or unknown. */
1064 int gpr_slot
[S390_NUM_GPRS
];
1066 /* Likewise for FPRs. */
1067 int fpr_slot
[S390_NUM_FPRS
];
1069 /* Nonzero if the backchain was saved. This is assumed to be the
1070 case when the incoming SP is saved at the current SP location. */
1071 int back_chain_saved_p
;
1074 /* Return the effective address for an X-style instruction, like:
1078 Here, X2 and B2 are registers, and D2 is a signed 20-bit
1079 constant; the effective address is the sum of all three. If either
1080 X2 or B2 are zero, then it doesn't contribute to the sum --- this
1081 means that r0 can't be used as either X2 or B2. */
1083 s390_addr (struct s390_prologue_data
*data
,
1084 int d2
, unsigned int x2
, unsigned int b2
)
1088 result
= pv_constant (d2
);
1090 result
= pv_add (result
, data
->gpr
[x2
]);
1092 result
= pv_add (result
, data
->gpr
[b2
]);
1097 /* Do a SIZE-byte store of VALUE to D2(X2,B2). */
1099 s390_store (struct s390_prologue_data
*data
,
1100 int d2
, unsigned int x2
, unsigned int b2
, CORE_ADDR size
,
1103 pv_t addr
= s390_addr (data
, d2
, x2
, b2
);
1106 /* Check whether we are storing the backchain. */
1107 offset
= pv_subtract (data
->gpr
[S390_SP_REGNUM
- S390_R0_REGNUM
], addr
);
1109 if (pv_is_constant (offset
) && offset
.k
== 0)
1110 if (size
== data
->gpr_size
1111 && pv_is_register_k (value
, S390_SP_REGNUM
, 0))
1113 data
->back_chain_saved_p
= 1;
1118 /* Check whether we are storing a register into the stack. */
1119 if (!pv_area_store_would_trash (data
->stack
, addr
))
1120 pv_area_store (data
->stack
, addr
, size
, value
);
1123 /* Note: If this is some store we cannot identify, you might think we
1124 should forget our cached values, as any of those might have been hit.
1126 However, we make the assumption that the register save areas are only
1127 ever stored to once in any given function, and we do recognize these
1128 stores. Thus every store we cannot recognize does not hit our data. */
1131 /* Do a SIZE-byte load from D2(X2,B2). */
1133 s390_load (struct s390_prologue_data
*data
,
1134 int d2
, unsigned int x2
, unsigned int b2
, CORE_ADDR size
)
1137 pv_t addr
= s390_addr (data
, d2
, x2
, b2
);
1139 /* If it's a load from an in-line constant pool, then we can
1140 simulate that, under the assumption that the code isn't
1141 going to change between the time the processor actually
1142 executed it creating the current frame, and the time when
1143 we're analyzing the code to unwind past that frame. */
1144 if (pv_is_constant (addr
))
1146 struct target_section
*secp
;
1147 secp
= target_section_by_addr (¤t_target
, addr
.k
);
1149 && (bfd_get_section_flags (secp
->the_bfd_section
->owner
,
1150 secp
->the_bfd_section
)
1152 return pv_constant (read_memory_integer (addr
.k
, size
,
1156 /* Check whether we are accessing one of our save slots. */
1157 return pv_area_fetch (data
->stack
, addr
, size
);
1160 /* Function for finding saved registers in a 'struct pv_area'; we pass
1161 this to pv_area_scan.
1163 If VALUE is a saved register, ADDR says it was saved at a constant
1164 offset from the frame base, and SIZE indicates that the whole
1165 register was saved, record its offset in the reg_offset table in
1166 PROLOGUE_UNTYPED. */
1168 s390_check_for_saved (void *data_untyped
, pv_t addr
,
1169 CORE_ADDR size
, pv_t value
)
1171 struct s390_prologue_data
*data
= (struct s390_prologue_data
*) data_untyped
;
1174 if (!pv_is_register (addr
, S390_SP_REGNUM
))
1177 offset
= 16 * data
->gpr_size
+ 32 - addr
.k
;
1179 /* If we are storing the original value of a register, we want to
1180 record the CFA offset. If the same register is stored multiple
1181 times, the stack slot with the highest address counts. */
1183 for (i
= 0; i
< S390_NUM_GPRS
; i
++)
1184 if (size
== data
->gpr_size
1185 && pv_is_register_k (value
, S390_R0_REGNUM
+ i
, 0))
1186 if (data
->gpr_slot
[i
] == 0
1187 || data
->gpr_slot
[i
] > offset
)
1189 data
->gpr_slot
[i
] = offset
;
1193 for (i
= 0; i
< S390_NUM_FPRS
; i
++)
1194 if (size
== data
->fpr_size
1195 && pv_is_register_k (value
, S390_F0_REGNUM
+ i
, 0))
1196 if (data
->fpr_slot
[i
] == 0
1197 || data
->fpr_slot
[i
] > offset
)
1199 data
->fpr_slot
[i
] = offset
;
1204 /* Analyze the prologue of the function starting at START_PC,
1205 continuing at most until CURRENT_PC. Initialize DATA to
1206 hold all information we find out about the state of the registers
1207 and stack slots. Return the address of the instruction after
1208 the last one that changed the SP, FP, or back chain; or zero
1211 s390_analyze_prologue (struct gdbarch
*gdbarch
,
1213 CORE_ADDR current_pc
,
1214 struct s390_prologue_data
*data
)
1216 int word_size
= gdbarch_ptr_bit (gdbarch
) / 8;
1218 /* Our return value:
1219 The address of the instruction after the last one that changed
1220 the SP, FP, or back chain; zero if we got an error trying to
1222 CORE_ADDR result
= start_pc
;
1224 /* The current PC for our abstract interpretation. */
1227 /* The address of the next instruction after that. */
1230 /* Set up everything's initial value. */
1234 data
->stack
= make_pv_area (S390_SP_REGNUM
, gdbarch_addr_bit (gdbarch
));
1236 /* For the purpose of prologue tracking, we consider the GPR size to
1237 be equal to the ABI word size, even if it is actually larger
1238 (i.e. when running a 32-bit binary under a 64-bit kernel). */
1239 data
->gpr_size
= word_size
;
1241 data
->byte_order
= gdbarch_byte_order (gdbarch
);
1243 for (i
= 0; i
< S390_NUM_GPRS
; i
++)
1244 data
->gpr
[i
] = pv_register (S390_R0_REGNUM
+ i
, 0);
1246 for (i
= 0; i
< S390_NUM_FPRS
; i
++)
1247 data
->fpr
[i
] = pv_register (S390_F0_REGNUM
+ i
, 0);
1249 for (i
= 0; i
< S390_NUM_GPRS
; i
++)
1250 data
->gpr_slot
[i
] = 0;
1252 for (i
= 0; i
< S390_NUM_FPRS
; i
++)
1253 data
->fpr_slot
[i
] = 0;
1255 data
->back_chain_saved_p
= 0;
1258 /* Start interpreting instructions, until we hit the frame's
1259 current PC or the first branch instruction. */
1260 for (pc
= start_pc
; pc
> 0 && pc
< current_pc
; pc
= next_pc
)
1262 bfd_byte insn
[S390_MAX_INSTR_SIZE
];
1263 int insn_len
= s390_readinstruction (insn
, pc
);
1265 bfd_byte dummy
[S390_MAX_INSTR_SIZE
] = { 0 };
1266 bfd_byte
*insn32
= word_size
== 4 ? insn
: dummy
;
1267 bfd_byte
*insn64
= word_size
== 8 ? insn
: dummy
;
1269 /* Fields for various kinds of instructions. */
1270 unsigned int b2
, r1
, r2
, x2
, r3
;
1273 /* The values of SP and FP before this instruction,
1274 for detecting instructions that change them. */
1275 pv_t pre_insn_sp
, pre_insn_fp
;
1276 /* Likewise for the flag whether the back chain was saved. */
1277 int pre_insn_back_chain_saved_p
;
1279 /* If we got an error trying to read the instruction, report it. */
1286 next_pc
= pc
+ insn_len
;
1288 pre_insn_sp
= data
->gpr
[S390_SP_REGNUM
- S390_R0_REGNUM
];
1289 pre_insn_fp
= data
->gpr
[S390_FRAME_REGNUM
- S390_R0_REGNUM
];
1290 pre_insn_back_chain_saved_p
= data
->back_chain_saved_p
;
1293 /* LHI r1, i2 --- load halfword immediate. */
1294 /* LGHI r1, i2 --- load halfword immediate (64-bit version). */
1295 /* LGFI r1, i2 --- load fullword immediate. */
1296 if (is_ri (insn32
, op1_lhi
, op2_lhi
, &r1
, &i2
)
1297 || is_ri (insn64
, op1_lghi
, op2_lghi
, &r1
, &i2
)
1298 || is_ril (insn
, op1_lgfi
, op2_lgfi
, &r1
, &i2
))
1299 data
->gpr
[r1
] = pv_constant (i2
);
1301 /* LR r1, r2 --- load from register. */
1302 /* LGR r1, r2 --- load from register (64-bit version). */
1303 else if (is_rr (insn32
, op_lr
, &r1
, &r2
)
1304 || is_rre (insn64
, op_lgr
, &r1
, &r2
))
1305 data
->gpr
[r1
] = data
->gpr
[r2
];
1307 /* L r1, d2(x2, b2) --- load. */
1308 /* LY r1, d2(x2, b2) --- load (long-displacement version). */
1309 /* LG r1, d2(x2, b2) --- load (64-bit version). */
1310 else if (is_rx (insn32
, op_l
, &r1
, &d2
, &x2
, &b2
)
1311 || is_rxy (insn32
, op1_ly
, op2_ly
, &r1
, &d2
, &x2
, &b2
)
1312 || is_rxy (insn64
, op1_lg
, op2_lg
, &r1
, &d2
, &x2
, &b2
))
1313 data
->gpr
[r1
] = s390_load (data
, d2
, x2
, b2
, data
->gpr_size
);
1315 /* ST r1, d2(x2, b2) --- store. */
1316 /* STY r1, d2(x2, b2) --- store (long-displacement version). */
1317 /* STG r1, d2(x2, b2) --- store (64-bit version). */
1318 else if (is_rx (insn32
, op_st
, &r1
, &d2
, &x2
, &b2
)
1319 || is_rxy (insn32
, op1_sty
, op2_sty
, &r1
, &d2
, &x2
, &b2
)
1320 || is_rxy (insn64
, op1_stg
, op2_stg
, &r1
, &d2
, &x2
, &b2
))
1321 s390_store (data
, d2
, x2
, b2
, data
->gpr_size
, data
->gpr
[r1
]);
1323 /* STD r1, d2(x2,b2) --- store floating-point register. */
1324 else if (is_rx (insn
, op_std
, &r1
, &d2
, &x2
, &b2
))
1325 s390_store (data
, d2
, x2
, b2
, data
->fpr_size
, data
->fpr
[r1
]);
1327 /* STM r1, r3, d2(b2) --- store multiple. */
1328 /* STMY r1, r3, d2(b2) --- store multiple (long-displacement
1330 /* STMG r1, r3, d2(b2) --- store multiple (64-bit version). */
1331 else if (is_rs (insn32
, op_stm
, &r1
, &r3
, &d2
, &b2
)
1332 || is_rsy (insn32
, op1_stmy
, op2_stmy
, &r1
, &r3
, &d2
, &b2
)
1333 || is_rsy (insn64
, op1_stmg
, op2_stmg
, &r1
, &r3
, &d2
, &b2
))
1335 for (; r1
<= r3
; r1
++, d2
+= data
->gpr_size
)
1336 s390_store (data
, d2
, 0, b2
, data
->gpr_size
, data
->gpr
[r1
]);
1339 /* AHI r1, i2 --- add halfword immediate. */
1340 /* AGHI r1, i2 --- add halfword immediate (64-bit version). */
1341 /* AFI r1, i2 --- add fullword immediate. */
1342 /* AGFI r1, i2 --- add fullword immediate (64-bit version). */
1343 else if (is_ri (insn32
, op1_ahi
, op2_ahi
, &r1
, &i2
)
1344 || is_ri (insn64
, op1_aghi
, op2_aghi
, &r1
, &i2
)
1345 || is_ril (insn32
, op1_afi
, op2_afi
, &r1
, &i2
)
1346 || is_ril (insn64
, op1_agfi
, op2_agfi
, &r1
, &i2
))
1347 data
->gpr
[r1
] = pv_add_constant (data
->gpr
[r1
], i2
);
1349 /* ALFI r1, i2 --- add logical immediate. */
1350 /* ALGFI r1, i2 --- add logical immediate (64-bit version). */
1351 else if (is_ril (insn32
, op1_alfi
, op2_alfi
, &r1
, &i2
)
1352 || is_ril (insn64
, op1_algfi
, op2_algfi
, &r1
, &i2
))
1353 data
->gpr
[r1
] = pv_add_constant (data
->gpr
[r1
],
1354 (CORE_ADDR
)i2
& 0xffffffff);
1356 /* AR r1, r2 -- add register. */
1357 /* AGR r1, r2 -- add register (64-bit version). */
1358 else if (is_rr (insn32
, op_ar
, &r1
, &r2
)
1359 || is_rre (insn64
, op_agr
, &r1
, &r2
))
1360 data
->gpr
[r1
] = pv_add (data
->gpr
[r1
], data
->gpr
[r2
]);
1362 /* A r1, d2(x2, b2) -- add. */
1363 /* AY r1, d2(x2, b2) -- add (long-displacement version). */
1364 /* AG r1, d2(x2, b2) -- add (64-bit version). */
1365 else if (is_rx (insn32
, op_a
, &r1
, &d2
, &x2
, &b2
)
1366 || is_rxy (insn32
, op1_ay
, op2_ay
, &r1
, &d2
, &x2
, &b2
)
1367 || is_rxy (insn64
, op1_ag
, op2_ag
, &r1
, &d2
, &x2
, &b2
))
1368 data
->gpr
[r1
] = pv_add (data
->gpr
[r1
],
1369 s390_load (data
, d2
, x2
, b2
, data
->gpr_size
));
1371 /* SLFI r1, i2 --- subtract logical immediate. */
1372 /* SLGFI r1, i2 --- subtract logical immediate (64-bit version). */
1373 else if (is_ril (insn32
, op1_slfi
, op2_slfi
, &r1
, &i2
)
1374 || is_ril (insn64
, op1_slgfi
, op2_slgfi
, &r1
, &i2
))
1375 data
->gpr
[r1
] = pv_add_constant (data
->gpr
[r1
],
1376 -((CORE_ADDR
)i2
& 0xffffffff));
1378 /* SR r1, r2 -- subtract register. */
1379 /* SGR r1, r2 -- subtract register (64-bit version). */
1380 else if (is_rr (insn32
, op_sr
, &r1
, &r2
)
1381 || is_rre (insn64
, op_sgr
, &r1
, &r2
))
1382 data
->gpr
[r1
] = pv_subtract (data
->gpr
[r1
], data
->gpr
[r2
]);
1384 /* S r1, d2(x2, b2) -- subtract. */
1385 /* SY r1, d2(x2, b2) -- subtract (long-displacement version). */
1386 /* SG r1, d2(x2, b2) -- subtract (64-bit version). */
1387 else if (is_rx (insn32
, op_s
, &r1
, &d2
, &x2
, &b2
)
1388 || is_rxy (insn32
, op1_sy
, op2_sy
, &r1
, &d2
, &x2
, &b2
)
1389 || is_rxy (insn64
, op1_sg
, op2_sg
, &r1
, &d2
, &x2
, &b2
))
1390 data
->gpr
[r1
] = pv_subtract (data
->gpr
[r1
],
1391 s390_load (data
, d2
, x2
, b2
, data
->gpr_size
));
1393 /* LA r1, d2(x2, b2) --- load address. */
1394 /* LAY r1, d2(x2, b2) --- load address (long-displacement version). */
1395 else if (is_rx (insn
, op_la
, &r1
, &d2
, &x2
, &b2
)
1396 || is_rxy (insn
, op1_lay
, op2_lay
, &r1
, &d2
, &x2
, &b2
))
1397 data
->gpr
[r1
] = s390_addr (data
, d2
, x2
, b2
);
1399 /* LARL r1, i2 --- load address relative long. */
1400 else if (is_ril (insn
, op1_larl
, op2_larl
, &r1
, &i2
))
1401 data
->gpr
[r1
] = pv_constant (pc
+ i2
* 2);
1403 /* BASR r1, 0 --- branch and save.
1404 Since r2 is zero, this saves the PC in r1, but doesn't branch. */
1405 else if (is_rr (insn
, op_basr
, &r1
, &r2
)
1407 data
->gpr
[r1
] = pv_constant (next_pc
);
1409 /* BRAS r1, i2 --- branch relative and save. */
1410 else if (is_ri (insn
, op1_bras
, op2_bras
, &r1
, &i2
))
1412 data
->gpr
[r1
] = pv_constant (next_pc
);
1413 next_pc
= pc
+ i2
* 2;
1415 /* We'd better not interpret any backward branches. We'll
1421 /* Terminate search when hitting any other branch instruction. */
1422 else if (is_rr (insn
, op_basr
, &r1
, &r2
)
1423 || is_rx (insn
, op_bas
, &r1
, &d2
, &x2
, &b2
)
1424 || is_rr (insn
, op_bcr
, &r1
, &r2
)
1425 || is_rx (insn
, op_bc
, &r1
, &d2
, &x2
, &b2
)
1426 || is_ri (insn
, op1_brc
, op2_brc
, &r1
, &i2
)
1427 || is_ril (insn
, op1_brcl
, op2_brcl
, &r1
, &i2
)
1428 || is_ril (insn
, op1_brasl
, op2_brasl
, &r2
, &i2
))
1433 /* An instruction we don't know how to simulate. The only
1434 safe thing to do would be to set every value we're tracking
1435 to 'unknown'. Instead, we'll be optimistic: we assume that
1436 we *can* interpret every instruction that the compiler uses
1437 to manipulate any of the data we're interested in here --
1438 then we can just ignore anything else. */
1441 /* Record the address after the last instruction that changed
1442 the FP, SP, or backlink. Ignore instructions that changed
1443 them back to their original values --- those are probably
1444 restore instructions. (The back chain is never restored,
1447 pv_t sp
= data
->gpr
[S390_SP_REGNUM
- S390_R0_REGNUM
];
1448 pv_t fp
= data
->gpr
[S390_FRAME_REGNUM
- S390_R0_REGNUM
];
1450 if ((! pv_is_identical (pre_insn_sp
, sp
)
1451 && ! pv_is_register_k (sp
, S390_SP_REGNUM
, 0)
1452 && sp
.kind
!= pvk_unknown
)
1453 || (! pv_is_identical (pre_insn_fp
, fp
)
1454 && ! pv_is_register_k (fp
, S390_FRAME_REGNUM
, 0)
1455 && fp
.kind
!= pvk_unknown
)
1456 || pre_insn_back_chain_saved_p
!= data
->back_chain_saved_p
)
1461 /* Record where all the registers were saved. */
1462 pv_area_scan (data
->stack
, s390_check_for_saved
, data
);
1464 free_pv_area (data
->stack
);
1470 /* Advance PC across any function entry prologue instructions to reach
1471 some "real" code. */
1473 s390_skip_prologue (struct gdbarch
*gdbarch
, CORE_ADDR pc
)
1475 struct s390_prologue_data data
;
1476 CORE_ADDR skip_pc
, func_addr
;
1478 if (find_pc_partial_function (pc
, NULL
, &func_addr
, NULL
))
1480 CORE_ADDR post_prologue_pc
1481 = skip_prologue_using_sal (gdbarch
, func_addr
);
1482 if (post_prologue_pc
!= 0)
1483 return max (pc
, post_prologue_pc
);
1486 skip_pc
= s390_analyze_prologue (gdbarch
, pc
, (CORE_ADDR
)-1, &data
);
1487 return skip_pc
? skip_pc
: pc
;
1490 /* Implmement the stack_frame_destroyed_p gdbarch method. */
1492 s390_stack_frame_destroyed_p (struct gdbarch
*gdbarch
, CORE_ADDR pc
)
1494 int word_size
= gdbarch_ptr_bit (gdbarch
) / 8;
1496 /* In frameless functions, there's not frame to destroy and thus
1497 we don't care about the epilogue.
1499 In functions with frame, the epilogue sequence is a pair of
1500 a LM-type instruction that restores (amongst others) the
1501 return register %r14 and the stack pointer %r15, followed
1502 by a branch 'br %r14' --or equivalent-- that effects the
1505 In that situation, this function needs to return 'true' in
1506 exactly one case: when pc points to that branch instruction.
1508 Thus we try to disassemble the one instructions immediately
1509 preceding pc and check whether it is an LM-type instruction
1510 modifying the stack pointer.
1512 Note that disassembling backwards is not reliable, so there
1513 is a slight chance of false positives here ... */
1516 unsigned int r1
, r3
, b2
;
1520 && !target_read_memory (pc
- 4, insn
, 4)
1521 && is_rs (insn
, op_lm
, &r1
, &r3
, &d2
, &b2
)
1522 && r3
== S390_SP_REGNUM
- S390_R0_REGNUM
)
1526 && !target_read_memory (pc
- 6, insn
, 6)
1527 && is_rsy (insn
, op1_lmy
, op2_lmy
, &r1
, &r3
, &d2
, &b2
)
1528 && r3
== S390_SP_REGNUM
- S390_R0_REGNUM
)
1532 && !target_read_memory (pc
- 6, insn
, 6)
1533 && is_rsy (insn
, op1_lmg
, op2_lmg
, &r1
, &r3
, &d2
, &b2
)
1534 && r3
== S390_SP_REGNUM
- S390_R0_REGNUM
)
1540 /* Displaced stepping. */
1542 /* Return true if INSN is a non-branch RIL-b or RIL-c format
1546 is_non_branch_ril (gdb_byte
*insn
)
1548 gdb_byte op1
= insn
[0];
1552 gdb_byte op2
= insn
[1] & 0x0f;
1556 case 0x02: /* llhrl */
1557 case 0x04: /* lghrl */
1558 case 0x05: /* lhrl */
1559 case 0x06: /* llghrl */
1560 case 0x07: /* sthrl */
1561 case 0x08: /* lgrl */
1562 case 0x0b: /* stgrl */
1563 case 0x0c: /* lgfrl */
1564 case 0x0d: /* lrl */
1565 case 0x0e: /* llgfrl */
1566 case 0x0f: /* strl */
1570 else if (op1
== 0xc6)
1572 gdb_byte op2
= insn
[1] & 0x0f;
1576 case 0x00: /* exrl */
1577 case 0x02: /* pfdrl */
1578 case 0x04: /* cghrl */
1579 case 0x05: /* chrl */
1580 case 0x06: /* clghrl */
1581 case 0x07: /* clhrl */
1582 case 0x08: /* cgrl */
1583 case 0x0a: /* clgrl */
1584 case 0x0c: /* cgfrl */
1585 case 0x0d: /* crl */
1586 case 0x0e: /* clgfrl */
1587 case 0x0f: /* clrl */
1595 /* Implementation of gdbarch_displaced_step_copy_insn. */
1597 static struct displaced_step_closure
*
1598 s390_displaced_step_copy_insn (struct gdbarch
*gdbarch
,
1599 CORE_ADDR from
, CORE_ADDR to
,
1600 struct regcache
*regs
)
1602 size_t len
= gdbarch_max_insn_length (gdbarch
);
1603 gdb_byte
*buf
= (gdb_byte
*) xmalloc (len
);
1604 struct cleanup
*old_chain
= make_cleanup (xfree
, buf
);
1606 read_memory (from
, buf
, len
);
1608 /* Adjust the displacement field of PC-relative RIL instructions,
1609 except branches. The latter are handled in the fixup hook. */
1610 if (is_non_branch_ril (buf
))
1614 offset
= extract_signed_integer (buf
+ 2, 4, BFD_ENDIAN_BIG
);
1615 offset
= (from
- to
+ offset
* 2) / 2;
1617 /* If the instruction is too far from the jump pad, punt. This
1618 will usually happen with instructions in shared libraries.
1619 We could probably support these by rewriting them to be
1620 absolute or fully emulating them. */
1621 if (offset
< INT32_MIN
|| offset
> INT32_MAX
)
1623 /* Let the core fall back to stepping over the breakpoint
1625 if (debug_displaced
)
1627 fprintf_unfiltered (gdb_stdlog
,
1628 "displaced: can't displaced step "
1629 "RIL instruction: offset %s out of range\n",
1632 do_cleanups (old_chain
);
1636 store_signed_integer (buf
+ 2, 4, BFD_ENDIAN_BIG
, offset
);
1639 write_memory (to
, buf
, len
);
1641 if (debug_displaced
)
1643 fprintf_unfiltered (gdb_stdlog
, "displaced: copy %s->%s: ",
1644 paddress (gdbarch
, from
), paddress (gdbarch
, to
));
1645 displaced_step_dump_bytes (gdb_stdlog
, buf
, len
);
1648 discard_cleanups (old_chain
);
1649 return (struct displaced_step_closure
*) buf
;
1652 /* Fix up the state of registers and memory after having single-stepped
1653 a displaced instruction. */
1655 s390_displaced_step_fixup (struct gdbarch
*gdbarch
,
1656 struct displaced_step_closure
*closure
,
1657 CORE_ADDR from
, CORE_ADDR to
,
1658 struct regcache
*regs
)
1660 /* Our closure is a copy of the instruction. */
1661 gdb_byte
*insn
= (gdb_byte
*) closure
;
1662 static int s390_instrlen
[] = { 2, 4, 4, 6 };
1663 int insnlen
= s390_instrlen
[insn
[0] >> 6];
1665 /* Fields for various kinds of instructions. */
1666 unsigned int b2
, r1
, r2
, x2
, r3
;
1669 /* Get current PC and addressing mode bit. */
1670 CORE_ADDR pc
= regcache_read_pc (regs
);
1673 if (register_size (gdbarch
, S390_PSWA_REGNUM
) == 4)
1675 regcache_cooked_read_unsigned (regs
, S390_PSWA_REGNUM
, &amode
);
1676 amode
&= 0x80000000;
1679 if (debug_displaced
)
1680 fprintf_unfiltered (gdb_stdlog
,
1681 "displaced: (s390) fixup (%s, %s) pc %s len %d amode 0x%x\n",
1682 paddress (gdbarch
, from
), paddress (gdbarch
, to
),
1683 paddress (gdbarch
, pc
), insnlen
, (int) amode
);
1685 /* Handle absolute branch and save instructions. */
1686 if (is_rr (insn
, op_basr
, &r1
, &r2
)
1687 || is_rx (insn
, op_bas
, &r1
, &d2
, &x2
, &b2
))
1689 /* Recompute saved return address in R1. */
1690 regcache_cooked_write_unsigned (regs
, S390_R0_REGNUM
+ r1
,
1691 amode
| (from
+ insnlen
));
1694 /* Handle absolute branch instructions. */
1695 else if (is_rr (insn
, op_bcr
, &r1
, &r2
)
1696 || is_rx (insn
, op_bc
, &r1
, &d2
, &x2
, &b2
)
1697 || is_rr (insn
, op_bctr
, &r1
, &r2
)
1698 || is_rre (insn
, op_bctgr
, &r1
, &r2
)
1699 || is_rx (insn
, op_bct
, &r1
, &d2
, &x2
, &b2
)
1700 || is_rxy (insn
, op1_bctg
, op2_brctg
, &r1
, &d2
, &x2
, &b2
)
1701 || is_rs (insn
, op_bxh
, &r1
, &r3
, &d2
, &b2
)
1702 || is_rsy (insn
, op1_bxhg
, op2_bxhg
, &r1
, &r3
, &d2
, &b2
)
1703 || is_rs (insn
, op_bxle
, &r1
, &r3
, &d2
, &b2
)
1704 || is_rsy (insn
, op1_bxleg
, op2_bxleg
, &r1
, &r3
, &d2
, &b2
))
1706 /* Update PC iff branch was *not* taken. */
1707 if (pc
== to
+ insnlen
)
1708 regcache_write_pc (regs
, from
+ insnlen
);
1711 /* Handle PC-relative branch and save instructions. */
1712 else if (is_ri (insn
, op1_bras
, op2_bras
, &r1
, &i2
)
1713 || is_ril (insn
, op1_brasl
, op2_brasl
, &r1
, &i2
))
1716 regcache_write_pc (regs
, pc
- to
+ from
);
1717 /* Recompute saved return address in R1. */
1718 regcache_cooked_write_unsigned (regs
, S390_R0_REGNUM
+ r1
,
1719 amode
| (from
+ insnlen
));
1722 /* Handle PC-relative branch instructions. */
1723 else if (is_ri (insn
, op1_brc
, op2_brc
, &r1
, &i2
)
1724 || is_ril (insn
, op1_brcl
, op2_brcl
, &r1
, &i2
)
1725 || is_ri (insn
, op1_brct
, op2_brct
, &r1
, &i2
)
1726 || is_ri (insn
, op1_brctg
, op2_brctg
, &r1
, &i2
)
1727 || is_rsi (insn
, op_brxh
, &r1
, &r3
, &i2
)
1728 || is_rie (insn
, op1_brxhg
, op2_brxhg
, &r1
, &r3
, &i2
)
1729 || is_rsi (insn
, op_brxle
, &r1
, &r3
, &i2
)
1730 || is_rie (insn
, op1_brxlg
, op2_brxlg
, &r1
, &r3
, &i2
))
1733 regcache_write_pc (regs
, pc
- to
+ from
);
1736 /* Handle LOAD ADDRESS RELATIVE LONG. */
1737 else if (is_ril (insn
, op1_larl
, op2_larl
, &r1
, &i2
))
1740 regcache_write_pc (regs
, from
+ insnlen
);
1741 /* Recompute output address in R1. */
1742 regcache_cooked_write_unsigned (regs
, S390_R0_REGNUM
+ r1
,
1743 amode
| (from
+ i2
* 2));
1746 /* If we executed a breakpoint instruction, point PC right back at it. */
1747 else if (insn
[0] == 0x0 && insn
[1] == 0x1)
1748 regcache_write_pc (regs
, from
);
1750 /* For any other insn, PC points right after the original instruction. */
1752 regcache_write_pc (regs
, from
+ insnlen
);
1754 if (debug_displaced
)
1755 fprintf_unfiltered (gdb_stdlog
,
1756 "displaced: (s390) pc is now %s\n",
1757 paddress (gdbarch
, regcache_read_pc (regs
)));
1761 /* Helper routine to unwind pseudo registers. */
1763 static struct value
*
1764 s390_unwind_pseudo_register (struct frame_info
*this_frame
, int regnum
)
1766 struct gdbarch
*gdbarch
= get_frame_arch (this_frame
);
1767 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
1768 struct type
*type
= register_type (gdbarch
, regnum
);
1770 /* Unwind PC via PSW address. */
1771 if (regnum
== tdep
->pc_regnum
)
1775 val
= frame_unwind_register_value (this_frame
, S390_PSWA_REGNUM
);
1776 if (!value_optimized_out (val
))
1778 LONGEST pswa
= value_as_long (val
);
1780 if (TYPE_LENGTH (type
) == 4)
1781 return value_from_pointer (type
, pswa
& 0x7fffffff);
1783 return value_from_pointer (type
, pswa
);
1787 /* Unwind CC via PSW mask. */
1788 if (regnum
== tdep
->cc_regnum
)
1792 val
= frame_unwind_register_value (this_frame
, S390_PSWM_REGNUM
);
1793 if (!value_optimized_out (val
))
1795 LONGEST pswm
= value_as_long (val
);
1797 if (TYPE_LENGTH (type
) == 4)
1798 return value_from_longest (type
, (pswm
>> 12) & 3);
1800 return value_from_longest (type
, (pswm
>> 44) & 3);
1804 /* Unwind full GPRs to show at least the lower halves (as the
1805 upper halves are undefined). */
1806 if (regnum_is_gpr_full (tdep
, regnum
))
1808 int reg
= regnum
- tdep
->gpr_full_regnum
;
1811 val
= frame_unwind_register_value (this_frame
, S390_R0_REGNUM
+ reg
);
1812 if (!value_optimized_out (val
))
1813 return value_cast (type
, val
);
1816 return allocate_optimized_out_value (type
);
1819 static struct value
*
1820 s390_trad_frame_prev_register (struct frame_info
*this_frame
,
1821 struct trad_frame_saved_reg saved_regs
[],
1824 if (regnum
< S390_NUM_REGS
)
1825 return trad_frame_get_prev_register (this_frame
, saved_regs
, regnum
);
1827 return s390_unwind_pseudo_register (this_frame
, regnum
);
1831 /* Normal stack frames. */
1833 struct s390_unwind_cache
{
1836 CORE_ADDR frame_base
;
1837 CORE_ADDR local_base
;
1839 struct trad_frame_saved_reg
*saved_regs
;
1843 s390_prologue_frame_unwind_cache (struct frame_info
*this_frame
,
1844 struct s390_unwind_cache
*info
)
1846 struct gdbarch
*gdbarch
= get_frame_arch (this_frame
);
1847 int word_size
= gdbarch_ptr_bit (gdbarch
) / 8;
1848 struct s390_prologue_data data
;
1849 pv_t
*fp
= &data
.gpr
[S390_FRAME_REGNUM
- S390_R0_REGNUM
];
1850 pv_t
*sp
= &data
.gpr
[S390_SP_REGNUM
- S390_R0_REGNUM
];
1859 struct frame_info
*next_frame
;
1861 /* Try to find the function start address. If we can't find it, we don't
1862 bother searching for it -- with modern compilers this would be mostly
1863 pointless anyway. Trust that we'll either have valid DWARF-2 CFI data
1864 or else a valid backchain ... */
1865 func
= get_frame_func (this_frame
);
1869 /* Try to analyze the prologue. */
1870 result
= s390_analyze_prologue (gdbarch
, func
,
1871 get_frame_pc (this_frame
), &data
);
1875 /* If this was successful, we should have found the instruction that
1876 sets the stack pointer register to the previous value of the stack
1877 pointer minus the frame size. */
1878 if (!pv_is_register (*sp
, S390_SP_REGNUM
))
1881 /* A frame size of zero at this point can mean either a real
1882 frameless function, or else a failure to find the prologue.
1883 Perform some sanity checks to verify we really have a
1884 frameless function. */
1887 /* If the next frame is a NORMAL_FRAME, this frame *cannot* have frame
1888 size zero. This is only possible if the next frame is a sentinel
1889 frame, a dummy frame, or a signal trampoline frame. */
1890 /* FIXME: cagney/2004-05-01: This sanity check shouldn't be
1891 needed, instead the code should simpliy rely on its
1893 next_frame
= get_next_frame (this_frame
);
1894 while (next_frame
&& get_frame_type (next_frame
) == INLINE_FRAME
)
1895 next_frame
= get_next_frame (next_frame
);
1897 && get_frame_type (get_next_frame (this_frame
)) == NORMAL_FRAME
)
1900 /* If we really have a frameless function, %r14 must be valid
1901 -- in particular, it must point to a different function. */
1902 reg
= get_frame_register_unsigned (this_frame
, S390_RETADDR_REGNUM
);
1903 reg
= gdbarch_addr_bits_remove (gdbarch
, reg
) - 1;
1904 if (get_pc_function_start (reg
) == func
)
1906 /* However, there is one case where it *is* valid for %r14
1907 to point to the same function -- if this is a recursive
1908 call, and we have stopped in the prologue *before* the
1909 stack frame was allocated.
1911 Recognize this case by looking ahead a bit ... */
1913 struct s390_prologue_data data2
;
1914 pv_t
*sp
= &data2
.gpr
[S390_SP_REGNUM
- S390_R0_REGNUM
];
1916 if (!(s390_analyze_prologue (gdbarch
, func
, (CORE_ADDR
)-1, &data2
)
1917 && pv_is_register (*sp
, S390_SP_REGNUM
)
1924 /* OK, we've found valid prologue data. */
1927 /* If the frame pointer originally also holds the same value
1928 as the stack pointer, we're probably using it. If it holds
1929 some other value -- even a constant offset -- it is most
1930 likely used as temp register. */
1931 if (pv_is_identical (*sp
, *fp
))
1932 frame_pointer
= S390_FRAME_REGNUM
;
1934 frame_pointer
= S390_SP_REGNUM
;
1936 /* If we've detected a function with stack frame, we'll still have to
1937 treat it as frameless if we're currently within the function epilog
1938 code at a point where the frame pointer has already been restored.
1939 This can only happen in an innermost frame. */
1940 /* FIXME: cagney/2004-05-01: This sanity check shouldn't be needed,
1941 instead the code should simpliy rely on its analysis. */
1942 next_frame
= get_next_frame (this_frame
);
1943 while (next_frame
&& get_frame_type (next_frame
) == INLINE_FRAME
)
1944 next_frame
= get_next_frame (next_frame
);
1946 && (next_frame
== NULL
1947 || get_frame_type (get_next_frame (this_frame
)) != NORMAL_FRAME
))
1949 /* See the comment in s390_stack_frame_destroyed_p on why this is
1950 not completely reliable ... */
1951 if (s390_stack_frame_destroyed_p (gdbarch
, get_frame_pc (this_frame
)))
1953 memset (&data
, 0, sizeof (data
));
1955 frame_pointer
= S390_SP_REGNUM
;
1959 /* Once we know the frame register and the frame size, we can unwind
1960 the current value of the frame register from the next frame, and
1961 add back the frame size to arrive that the previous frame's
1962 stack pointer value. */
1963 prev_sp
= get_frame_register_unsigned (this_frame
, frame_pointer
) + size
;
1964 cfa
= prev_sp
+ 16*word_size
+ 32;
1966 /* Set up ABI call-saved/call-clobbered registers. */
1967 for (i
= 0; i
< S390_NUM_REGS
; i
++)
1968 if (!s390_register_call_saved (gdbarch
, i
))
1969 trad_frame_set_unknown (info
->saved_regs
, i
);
1971 /* CC is always call-clobbered. */
1972 trad_frame_set_unknown (info
->saved_regs
, S390_PSWM_REGNUM
);
1974 /* Record the addresses of all register spill slots the prologue parser
1975 has recognized. Consider only registers defined as call-saved by the
1976 ABI; for call-clobbered registers the parser may have recognized
1979 for (i
= 0; i
< 16; i
++)
1980 if (s390_register_call_saved (gdbarch
, S390_R0_REGNUM
+ i
)
1981 && data
.gpr_slot
[i
] != 0)
1982 info
->saved_regs
[S390_R0_REGNUM
+ i
].addr
= cfa
- data
.gpr_slot
[i
];
1984 for (i
= 0; i
< 16; i
++)
1985 if (s390_register_call_saved (gdbarch
, S390_F0_REGNUM
+ i
)
1986 && data
.fpr_slot
[i
] != 0)
1987 info
->saved_regs
[S390_F0_REGNUM
+ i
].addr
= cfa
- data
.fpr_slot
[i
];
1989 /* Function return will set PC to %r14. */
1990 info
->saved_regs
[S390_PSWA_REGNUM
] = info
->saved_regs
[S390_RETADDR_REGNUM
];
1992 /* In frameless functions, we unwind simply by moving the return
1993 address to the PC. However, if we actually stored to the
1994 save area, use that -- we might only think the function frameless
1995 because we're in the middle of the prologue ... */
1997 && !trad_frame_addr_p (info
->saved_regs
, S390_PSWA_REGNUM
))
1999 info
->saved_regs
[S390_PSWA_REGNUM
].realreg
= S390_RETADDR_REGNUM
;
2002 /* Another sanity check: unless this is a frameless function,
2003 we should have found spill slots for SP and PC.
2004 If not, we cannot unwind further -- this happens e.g. in
2005 libc's thread_start routine. */
2008 if (!trad_frame_addr_p (info
->saved_regs
, S390_SP_REGNUM
)
2009 || !trad_frame_addr_p (info
->saved_regs
, S390_PSWA_REGNUM
))
2013 /* We use the current value of the frame register as local_base,
2014 and the top of the register save area as frame_base. */
2017 info
->frame_base
= prev_sp
+ 16*word_size
+ 32;
2018 info
->local_base
= prev_sp
- size
;
2026 s390_backchain_frame_unwind_cache (struct frame_info
*this_frame
,
2027 struct s390_unwind_cache
*info
)
2029 struct gdbarch
*gdbarch
= get_frame_arch (this_frame
);
2030 int word_size
= gdbarch_ptr_bit (gdbarch
) / 8;
2031 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
2032 CORE_ADDR backchain
;
2037 /* Set up ABI call-saved/call-clobbered registers. */
2038 for (i
= 0; i
< S390_NUM_REGS
; i
++)
2039 if (!s390_register_call_saved (gdbarch
, i
))
2040 trad_frame_set_unknown (info
->saved_regs
, i
);
2042 /* CC is always call-clobbered. */
2043 trad_frame_set_unknown (info
->saved_regs
, S390_PSWM_REGNUM
);
2045 /* Get the backchain. */
2046 reg
= get_frame_register_unsigned (this_frame
, S390_SP_REGNUM
);
2047 backchain
= read_memory_unsigned_integer (reg
, word_size
, byte_order
);
2049 /* A zero backchain terminates the frame chain. As additional
2050 sanity check, let's verify that the spill slot for SP in the
2051 save area pointed to by the backchain in fact links back to
2054 && safe_read_memory_integer (backchain
+ 15*word_size
,
2055 word_size
, byte_order
, &sp
)
2056 && (CORE_ADDR
)sp
== backchain
)
2058 /* We don't know which registers were saved, but it will have
2059 to be at least %r14 and %r15. This will allow us to continue
2060 unwinding, but other prev-frame registers may be incorrect ... */
2061 info
->saved_regs
[S390_SP_REGNUM
].addr
= backchain
+ 15*word_size
;
2062 info
->saved_regs
[S390_RETADDR_REGNUM
].addr
= backchain
+ 14*word_size
;
2064 /* Function return will set PC to %r14. */
2065 info
->saved_regs
[S390_PSWA_REGNUM
]
2066 = info
->saved_regs
[S390_RETADDR_REGNUM
];
2068 /* We use the current value of the frame register as local_base,
2069 and the top of the register save area as frame_base. */
2070 info
->frame_base
= backchain
+ 16*word_size
+ 32;
2071 info
->local_base
= reg
;
2074 info
->func
= get_frame_pc (this_frame
);
2077 static struct s390_unwind_cache
*
2078 s390_frame_unwind_cache (struct frame_info
*this_frame
,
2079 void **this_prologue_cache
)
2081 struct s390_unwind_cache
*info
;
2083 if (*this_prologue_cache
)
2084 return (struct s390_unwind_cache
*) *this_prologue_cache
;
2086 info
= FRAME_OBSTACK_ZALLOC (struct s390_unwind_cache
);
2087 *this_prologue_cache
= info
;
2088 info
->saved_regs
= trad_frame_alloc_saved_regs (this_frame
);
2090 info
->frame_base
= -1;
2091 info
->local_base
= -1;
2095 /* Try to use prologue analysis to fill the unwind cache.
2096 If this fails, fall back to reading the stack backchain. */
2097 if (!s390_prologue_frame_unwind_cache (this_frame
, info
))
2098 s390_backchain_frame_unwind_cache (this_frame
, info
);
2100 CATCH (ex
, RETURN_MASK_ERROR
)
2102 if (ex
.error
!= NOT_AVAILABLE_ERROR
)
2103 throw_exception (ex
);
2111 s390_frame_this_id (struct frame_info
*this_frame
,
2112 void **this_prologue_cache
,
2113 struct frame_id
*this_id
)
2115 struct s390_unwind_cache
*info
2116 = s390_frame_unwind_cache (this_frame
, this_prologue_cache
);
2118 if (info
->frame_base
== -1)
2121 *this_id
= frame_id_build (info
->frame_base
, info
->func
);
2124 static struct value
*
2125 s390_frame_prev_register (struct frame_info
*this_frame
,
2126 void **this_prologue_cache
, int regnum
)
2128 struct gdbarch
*gdbarch
= get_frame_arch (this_frame
);
2129 struct s390_unwind_cache
*info
2130 = s390_frame_unwind_cache (this_frame
, this_prologue_cache
);
2132 return s390_trad_frame_prev_register (this_frame
, info
->saved_regs
, regnum
);
2135 static const struct frame_unwind s390_frame_unwind
= {
2137 default_frame_unwind_stop_reason
,
2139 s390_frame_prev_register
,
2141 default_frame_sniffer
2145 /* Code stubs and their stack frames. For things like PLTs and NULL
2146 function calls (where there is no true frame and the return address
2147 is in the RETADDR register). */
2149 struct s390_stub_unwind_cache
2151 CORE_ADDR frame_base
;
2152 struct trad_frame_saved_reg
*saved_regs
;
2155 static struct s390_stub_unwind_cache
*
2156 s390_stub_frame_unwind_cache (struct frame_info
*this_frame
,
2157 void **this_prologue_cache
)
2159 struct gdbarch
*gdbarch
= get_frame_arch (this_frame
);
2160 int word_size
= gdbarch_ptr_bit (gdbarch
) / 8;
2161 struct s390_stub_unwind_cache
*info
;
2164 if (*this_prologue_cache
)
2165 return (struct s390_stub_unwind_cache
*) *this_prologue_cache
;
2167 info
= FRAME_OBSTACK_ZALLOC (struct s390_stub_unwind_cache
);
2168 *this_prologue_cache
= info
;
2169 info
->saved_regs
= trad_frame_alloc_saved_regs (this_frame
);
2171 /* The return address is in register %r14. */
2172 info
->saved_regs
[S390_PSWA_REGNUM
].realreg
= S390_RETADDR_REGNUM
;
2174 /* Retrieve stack pointer and determine our frame base. */
2175 reg
= get_frame_register_unsigned (this_frame
, S390_SP_REGNUM
);
2176 info
->frame_base
= reg
+ 16*word_size
+ 32;
2182 s390_stub_frame_this_id (struct frame_info
*this_frame
,
2183 void **this_prologue_cache
,
2184 struct frame_id
*this_id
)
2186 struct s390_stub_unwind_cache
*info
2187 = s390_stub_frame_unwind_cache (this_frame
, this_prologue_cache
);
2188 *this_id
= frame_id_build (info
->frame_base
, get_frame_pc (this_frame
));
2191 static struct value
*
2192 s390_stub_frame_prev_register (struct frame_info
*this_frame
,
2193 void **this_prologue_cache
, int regnum
)
2195 struct s390_stub_unwind_cache
*info
2196 = s390_stub_frame_unwind_cache (this_frame
, this_prologue_cache
);
2197 return s390_trad_frame_prev_register (this_frame
, info
->saved_regs
, regnum
);
2201 s390_stub_frame_sniffer (const struct frame_unwind
*self
,
2202 struct frame_info
*this_frame
,
2203 void **this_prologue_cache
)
2205 CORE_ADDR addr_in_block
;
2206 bfd_byte insn
[S390_MAX_INSTR_SIZE
];
2208 /* If the current PC points to non-readable memory, we assume we
2209 have trapped due to an invalid function pointer call. We handle
2210 the non-existing current function like a PLT stub. */
2211 addr_in_block
= get_frame_address_in_block (this_frame
);
2212 if (in_plt_section (addr_in_block
)
2213 || s390_readinstruction (insn
, get_frame_pc (this_frame
)) < 0)
2218 static const struct frame_unwind s390_stub_frame_unwind
= {
2220 default_frame_unwind_stop_reason
,
2221 s390_stub_frame_this_id
,
2222 s390_stub_frame_prev_register
,
2224 s390_stub_frame_sniffer
2228 /* Signal trampoline stack frames. */
2230 struct s390_sigtramp_unwind_cache
{
2231 CORE_ADDR frame_base
;
2232 struct trad_frame_saved_reg
*saved_regs
;
2235 static struct s390_sigtramp_unwind_cache
*
2236 s390_sigtramp_frame_unwind_cache (struct frame_info
*this_frame
,
2237 void **this_prologue_cache
)
2239 struct gdbarch
*gdbarch
= get_frame_arch (this_frame
);
2240 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
2241 int word_size
= gdbarch_ptr_bit (gdbarch
) / 8;
2242 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
2243 struct s390_sigtramp_unwind_cache
*info
;
2244 ULONGEST this_sp
, prev_sp
;
2245 CORE_ADDR next_ra
, next_cfa
, sigreg_ptr
, sigreg_high_off
;
2248 if (*this_prologue_cache
)
2249 return (struct s390_sigtramp_unwind_cache
*) *this_prologue_cache
;
2251 info
= FRAME_OBSTACK_ZALLOC (struct s390_sigtramp_unwind_cache
);
2252 *this_prologue_cache
= info
;
2253 info
->saved_regs
= trad_frame_alloc_saved_regs (this_frame
);
2255 this_sp
= get_frame_register_unsigned (this_frame
, S390_SP_REGNUM
);
2256 next_ra
= get_frame_pc (this_frame
);
2257 next_cfa
= this_sp
+ 16*word_size
+ 32;
2259 /* New-style RT frame:
2260 retcode + alignment (8 bytes)
2262 ucontext (contains sigregs at offset 5 words). */
2263 if (next_ra
== next_cfa
)
2265 sigreg_ptr
= next_cfa
+ 8 + 128 + align_up (5*word_size
, 8);
2266 /* sigregs are followed by uc_sigmask (8 bytes), then by the
2267 upper GPR halves if present. */
2268 sigreg_high_off
= 8;
2271 /* Old-style RT frame and all non-RT frames:
2272 old signal mask (8 bytes)
2273 pointer to sigregs. */
2276 sigreg_ptr
= read_memory_unsigned_integer (next_cfa
+ 8,
2277 word_size
, byte_order
);
2278 /* sigregs are followed by signo (4 bytes), then by the
2279 upper GPR halves if present. */
2280 sigreg_high_off
= 4;
2283 /* The sigregs structure looks like this:
2292 /* PSW mask and address. */
2293 info
->saved_regs
[S390_PSWM_REGNUM
].addr
= sigreg_ptr
;
2294 sigreg_ptr
+= word_size
;
2295 info
->saved_regs
[S390_PSWA_REGNUM
].addr
= sigreg_ptr
;
2296 sigreg_ptr
+= word_size
;
2298 /* Then the GPRs. */
2299 for (i
= 0; i
< 16; i
++)
2301 info
->saved_regs
[S390_R0_REGNUM
+ i
].addr
= sigreg_ptr
;
2302 sigreg_ptr
+= word_size
;
2305 /* Then the ACRs. */
2306 for (i
= 0; i
< 16; i
++)
2308 info
->saved_regs
[S390_A0_REGNUM
+ i
].addr
= sigreg_ptr
;
2312 /* The floating-point control word. */
2313 info
->saved_regs
[S390_FPC_REGNUM
].addr
= sigreg_ptr
;
2316 /* And finally the FPRs. */
2317 for (i
= 0; i
< 16; i
++)
2319 info
->saved_regs
[S390_F0_REGNUM
+ i
].addr
= sigreg_ptr
;
2323 /* If we have them, the GPR upper halves are appended at the end. */
2324 sigreg_ptr
+= sigreg_high_off
;
2325 if (tdep
->gpr_full_regnum
!= -1)
2326 for (i
= 0; i
< 16; i
++)
2328 info
->saved_regs
[S390_R0_UPPER_REGNUM
+ i
].addr
= sigreg_ptr
;
2332 /* Restore the previous frame's SP. */
2333 prev_sp
= read_memory_unsigned_integer (
2334 info
->saved_regs
[S390_SP_REGNUM
].addr
,
2335 word_size
, byte_order
);
2337 /* Determine our frame base. */
2338 info
->frame_base
= prev_sp
+ 16*word_size
+ 32;
2344 s390_sigtramp_frame_this_id (struct frame_info
*this_frame
,
2345 void **this_prologue_cache
,
2346 struct frame_id
*this_id
)
2348 struct s390_sigtramp_unwind_cache
*info
2349 = s390_sigtramp_frame_unwind_cache (this_frame
, this_prologue_cache
);
2350 *this_id
= frame_id_build (info
->frame_base
, get_frame_pc (this_frame
));
2353 static struct value
*
2354 s390_sigtramp_frame_prev_register (struct frame_info
*this_frame
,
2355 void **this_prologue_cache
, int regnum
)
2357 struct s390_sigtramp_unwind_cache
*info
2358 = s390_sigtramp_frame_unwind_cache (this_frame
, this_prologue_cache
);
2359 return s390_trad_frame_prev_register (this_frame
, info
->saved_regs
, regnum
);
2363 s390_sigtramp_frame_sniffer (const struct frame_unwind
*self
,
2364 struct frame_info
*this_frame
,
2365 void **this_prologue_cache
)
2367 CORE_ADDR pc
= get_frame_pc (this_frame
);
2368 bfd_byte sigreturn
[2];
2370 if (target_read_memory (pc
, sigreturn
, 2))
2373 if (sigreturn
[0] != op_svc
)
2376 if (sigreturn
[1] != 119 /* sigreturn */
2377 && sigreturn
[1] != 173 /* rt_sigreturn */)
2383 static const struct frame_unwind s390_sigtramp_frame_unwind
= {
2385 default_frame_unwind_stop_reason
,
2386 s390_sigtramp_frame_this_id
,
2387 s390_sigtramp_frame_prev_register
,
2389 s390_sigtramp_frame_sniffer
2392 /* Retrieve the syscall number at a ptrace syscall-stop. Return -1
2396 s390_linux_get_syscall_number (struct gdbarch
*gdbarch
,
2399 struct regcache
*regs
= get_thread_regcache (ptid
);
2400 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
2401 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
2403 ULONGEST svc_number
= -1;
2406 /* Assume that the PC points after the 2-byte SVC instruction. We
2407 don't currently support SVC via EXECUTE. */
2408 regcache_cooked_read_unsigned (regs
, tdep
->pc_regnum
, &pc
);
2410 opcode
= read_memory_unsigned_integer ((CORE_ADDR
) pc
, 1, byte_order
);
2411 if (opcode
!= op_svc
)
2414 svc_number
= read_memory_unsigned_integer ((CORE_ADDR
) pc
+ 1, 1,
2416 if (svc_number
== 0)
2417 regcache_cooked_read_unsigned (regs
, S390_R1_REGNUM
, &svc_number
);
2423 /* Frame base handling. */
2426 s390_frame_base_address (struct frame_info
*this_frame
, void **this_cache
)
2428 struct s390_unwind_cache
*info
2429 = s390_frame_unwind_cache (this_frame
, this_cache
);
2430 return info
->frame_base
;
2434 s390_local_base_address (struct frame_info
*this_frame
, void **this_cache
)
2436 struct s390_unwind_cache
*info
2437 = s390_frame_unwind_cache (this_frame
, this_cache
);
2438 return info
->local_base
;
2441 static const struct frame_base s390_frame_base
= {
2443 s390_frame_base_address
,
2444 s390_local_base_address
,
2445 s390_local_base_address
2449 s390_unwind_pc (struct gdbarch
*gdbarch
, struct frame_info
*next_frame
)
2451 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
2453 pc
= frame_unwind_register_unsigned (next_frame
, tdep
->pc_regnum
);
2454 return gdbarch_addr_bits_remove (gdbarch
, pc
);
2458 s390_unwind_sp (struct gdbarch
*gdbarch
, struct frame_info
*next_frame
)
2461 sp
= frame_unwind_register_unsigned (next_frame
, S390_SP_REGNUM
);
2462 return gdbarch_addr_bits_remove (gdbarch
, sp
);
2466 /* DWARF-2 frame support. */
2468 static struct value
*
2469 s390_dwarf2_prev_register (struct frame_info
*this_frame
, void **this_cache
,
2472 return s390_unwind_pseudo_register (this_frame
, regnum
);
2476 s390_dwarf2_frame_init_reg (struct gdbarch
*gdbarch
, int regnum
,
2477 struct dwarf2_frame_state_reg
*reg
,
2478 struct frame_info
*this_frame
)
2480 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
2482 /* The condition code (and thus PSW mask) is call-clobbered. */
2483 if (regnum
== S390_PSWM_REGNUM
)
2484 reg
->how
= DWARF2_FRAME_REG_UNDEFINED
;
2486 /* The PSW address unwinds to the return address. */
2487 else if (regnum
== S390_PSWA_REGNUM
)
2488 reg
->how
= DWARF2_FRAME_REG_RA
;
2490 /* Fixed registers are call-saved or call-clobbered
2491 depending on the ABI in use. */
2492 else if (regnum
< S390_NUM_REGS
)
2494 if (s390_register_call_saved (gdbarch
, regnum
))
2495 reg
->how
= DWARF2_FRAME_REG_SAME_VALUE
;
2497 reg
->how
= DWARF2_FRAME_REG_UNDEFINED
;
2500 /* We install a special function to unwind pseudos. */
2503 reg
->how
= DWARF2_FRAME_REG_FN
;
2504 reg
->loc
.fn
= s390_dwarf2_prev_register
;
2509 /* Dummy function calls. */
2511 /* Unwrap any single-field structs in TYPE and return the effective
2512 "inner" type. E.g., yield "float" for all these cases:
2516 struct { struct { float x; } x; };
2517 struct { struct { struct { float x; } x; } x; };
2519 However, if an inner type is smaller than MIN_SIZE, abort the
2522 static struct type
*
2523 s390_effective_inner_type (struct type
*type
, unsigned int min_size
)
2525 while (TYPE_CODE (type
) == TYPE_CODE_STRUCT
2526 && TYPE_NFIELDS (type
) == 1)
2528 struct type
*inner
= check_typedef (TYPE_FIELD_TYPE (type
, 0));
2530 if (TYPE_LENGTH (inner
) < min_size
)
2538 /* Return non-zero if TYPE should be passed like "float" or
2542 s390_function_arg_float (struct type
*type
)
2544 /* Note that long double as well as complex types are intentionally
2546 if (TYPE_LENGTH (type
) > 8)
2549 /* A struct containing just a float or double is passed like a float
2551 type
= s390_effective_inner_type (type
, 0);
2553 return (TYPE_CODE (type
) == TYPE_CODE_FLT
2554 || TYPE_CODE (type
) == TYPE_CODE_DECFLOAT
);
2557 /* Return non-zero if TYPE should be passed like a vector. */
2560 s390_function_arg_vector (struct type
*type
)
2562 if (TYPE_LENGTH (type
) > 16)
2565 /* Structs containing just a vector are passed like a vector. */
2566 type
= s390_effective_inner_type (type
, TYPE_LENGTH (type
));
2568 return TYPE_CODE (type
) == TYPE_CODE_ARRAY
&& TYPE_VECTOR (type
);
2571 /* Determine whether N is a power of two. */
2574 is_power_of_two (unsigned int n
)
2576 return n
&& ((n
& (n
- 1)) == 0);
2579 /* For an argument whose type is TYPE and which is not passed like a
2580 float or vector, return non-zero if it should be passed like "int"
2584 s390_function_arg_integer (struct type
*type
)
2586 enum type_code code
= TYPE_CODE (type
);
2588 if (TYPE_LENGTH (type
) > 8)
2591 if (code
== TYPE_CODE_INT
2592 || code
== TYPE_CODE_ENUM
2593 || code
== TYPE_CODE_RANGE
2594 || code
== TYPE_CODE_CHAR
2595 || code
== TYPE_CODE_BOOL
2596 || code
== TYPE_CODE_PTR
2597 || code
== TYPE_CODE_REF
)
2600 return ((code
== TYPE_CODE_UNION
|| code
== TYPE_CODE_STRUCT
)
2601 && is_power_of_two (TYPE_LENGTH (type
)));
2604 /* Argument passing state: Internal data structure passed to helper
2605 routines of s390_push_dummy_call. */
2607 struct s390_arg_state
2609 /* Register cache, or NULL, if we are in "preparation mode". */
2610 struct regcache
*regcache
;
2611 /* Next available general/floating-point/vector register for
2612 argument passing. */
2614 /* Current pointer to copy area (grows downwards). */
2616 /* Current pointer to parameter area (grows upwards). */
2620 /* Prepare one argument ARG for a dummy call and update the argument
2621 passing state AS accordingly. If the regcache field in AS is set,
2622 operate in "write mode" and write ARG into the inferior. Otherwise
2623 run "preparation mode" and skip all updates to the inferior. */
2626 s390_handle_arg (struct s390_arg_state
*as
, struct value
*arg
,
2627 struct gdbarch_tdep
*tdep
, int word_size
,
2628 enum bfd_endian byte_order
, int is_unnamed
)
2630 struct type
*type
= check_typedef (value_type (arg
));
2631 unsigned int length
= TYPE_LENGTH (type
);
2632 int write_mode
= as
->regcache
!= NULL
;
2634 if (s390_function_arg_float (type
))
2636 /* The GNU/Linux for S/390 ABI uses FPRs 0 and 2 to pass
2637 arguments. The GNU/Linux for zSeries ABI uses 0, 2, 4, and
2639 if (as
->fr
<= (tdep
->abi
== ABI_LINUX_S390
? 2 : 6))
2641 /* When we store a single-precision value in an FP register,
2642 it occupies the leftmost bits. */
2644 regcache_cooked_write_part (as
->regcache
,
2645 S390_F0_REGNUM
+ as
->fr
,
2647 value_contents (arg
));
2652 /* When we store a single-precision value in a stack slot,
2653 it occupies the rightmost bits. */
2654 as
->argp
= align_up (as
->argp
+ length
, word_size
);
2656 write_memory (as
->argp
- length
, value_contents (arg
),
2660 else if (tdep
->vector_abi
== S390_VECTOR_ABI_128
2661 && s390_function_arg_vector (type
))
2663 static const char use_vr
[] = {24, 26, 28, 30, 25, 27, 29, 31};
2665 if (!is_unnamed
&& as
->vr
< ARRAY_SIZE (use_vr
))
2667 int regnum
= S390_V24_REGNUM
+ use_vr
[as
->vr
] - 24;
2670 regcache_cooked_write_part (as
->regcache
, regnum
,
2672 value_contents (arg
));
2678 write_memory (as
->argp
, value_contents (arg
), length
);
2679 as
->argp
= align_up (as
->argp
+ length
, word_size
);
2682 else if (s390_function_arg_integer (type
) && length
<= word_size
)
2684 /* Initialize it just to avoid a GCC false warning. */
2689 /* Place value in least significant bits of the register or
2690 memory word and sign- or zero-extend to full word size.
2691 This also applies to a struct or union. */
2692 val
= TYPE_UNSIGNED (type
)
2693 ? extract_unsigned_integer (value_contents (arg
),
2695 : extract_signed_integer (value_contents (arg
),
2696 length
, byte_order
);
2702 regcache_cooked_write_unsigned (as
->regcache
,
2703 S390_R0_REGNUM
+ as
->gr
,
2710 write_memory_unsigned_integer (as
->argp
, word_size
,
2712 as
->argp
+= word_size
;
2715 else if (s390_function_arg_integer (type
) && length
== 8)
2721 regcache_cooked_write (as
->regcache
,
2722 S390_R0_REGNUM
+ as
->gr
,
2723 value_contents (arg
));
2724 regcache_cooked_write (as
->regcache
,
2725 S390_R0_REGNUM
+ as
->gr
+ 1,
2726 value_contents (arg
) + word_size
);
2732 /* If we skipped r6 because we couldn't fit a DOUBLE_ARG
2733 in it, then don't go back and use it again later. */
2737 write_memory (as
->argp
, value_contents (arg
), length
);
2743 /* This argument type is never passed in registers. Place the
2744 value in the copy area and pass a pointer to it. Use 8-byte
2745 alignment as a conservative assumption. */
2746 as
->copy
= align_down (as
->copy
- length
, 8);
2748 write_memory (as
->copy
, value_contents (arg
), length
);
2753 regcache_cooked_write_unsigned (as
->regcache
,
2754 S390_R0_REGNUM
+ as
->gr
,
2761 write_memory_unsigned_integer (as
->argp
, word_size
,
2762 byte_order
, as
->copy
);
2763 as
->argp
+= word_size
;
2768 /* Put the actual parameter values pointed to by ARGS[0..NARGS-1] in
2769 place to be passed to a function, as specified by the "GNU/Linux
2770 for S/390 ELF Application Binary Interface Supplement".
2772 SP is the current stack pointer. We must put arguments, links,
2773 padding, etc. whereever they belong, and return the new stack
2776 If STRUCT_RETURN is non-zero, then the function we're calling is
2777 going to return a structure by value; STRUCT_ADDR is the address of
2778 a block we've allocated for it on the stack.
2780 Our caller has taken care of any type promotions needed to satisfy
2781 prototypes or the old K&R argument-passing rules. */
2784 s390_push_dummy_call (struct gdbarch
*gdbarch
, struct value
*function
,
2785 struct regcache
*regcache
, CORE_ADDR bp_addr
,
2786 int nargs
, struct value
**args
, CORE_ADDR sp
,
2787 int struct_return
, CORE_ADDR struct_addr
)
2789 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
2790 int word_size
= gdbarch_ptr_bit (gdbarch
) / 8;
2791 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
2793 struct s390_arg_state arg_state
, arg_prep
;
2794 CORE_ADDR param_area_start
, new_sp
;
2795 struct type
*ftype
= check_typedef (value_type (function
));
2797 if (TYPE_CODE (ftype
) == TYPE_CODE_PTR
)
2798 ftype
= check_typedef (TYPE_TARGET_TYPE (ftype
));
2801 arg_prep
.gr
= struct_return
? 3 : 2;
2805 arg_prep
.regcache
= NULL
;
2807 /* Initialize arg_state for "preparation mode". */
2808 arg_state
= arg_prep
;
2810 /* Update arg_state.copy with the start of the reference-to-copy area
2811 and arg_state.argp with the size of the parameter area. */
2812 for (i
= 0; i
< nargs
; i
++)
2813 s390_handle_arg (&arg_state
, args
[i
], tdep
, word_size
, byte_order
,
2814 TYPE_VARARGS (ftype
) && i
>= TYPE_NFIELDS (ftype
));
2816 param_area_start
= align_down (arg_state
.copy
- arg_state
.argp
, 8);
2818 /* Allocate the standard frame areas: the register save area, the
2819 word reserved for the compiler, and the back chain pointer. */
2820 new_sp
= param_area_start
- (16 * word_size
+ 32);
2822 /* Now we have the final stack pointer. Make sure we didn't
2823 underflow; on 31-bit, this would result in addresses with the
2824 high bit set, which causes confusion elsewhere. Note that if we
2825 error out here, stack and registers remain untouched. */
2826 if (gdbarch_addr_bits_remove (gdbarch
, new_sp
) != new_sp
)
2827 error (_("Stack overflow"));
2829 /* Pass the structure return address in general register 2. */
2831 regcache_cooked_write_unsigned (regcache
, S390_R2_REGNUM
, struct_addr
);
2833 /* Initialize arg_state for "write mode". */
2834 arg_state
= arg_prep
;
2835 arg_state
.argp
= param_area_start
;
2836 arg_state
.regcache
= regcache
;
2838 /* Write all parameters. */
2839 for (i
= 0; i
< nargs
; i
++)
2840 s390_handle_arg (&arg_state
, args
[i
], tdep
, word_size
, byte_order
,
2841 TYPE_VARARGS (ftype
) && i
>= TYPE_NFIELDS (ftype
));
2843 /* Store return PSWA. In 31-bit mode, keep addressing mode bit. */
2847 regcache_cooked_read_unsigned (regcache
, S390_PSWA_REGNUM
, &pswa
);
2848 bp_addr
= (bp_addr
& 0x7fffffff) | (pswa
& 0x80000000);
2850 regcache_cooked_write_unsigned (regcache
, S390_RETADDR_REGNUM
, bp_addr
);
2852 /* Store updated stack pointer. */
2853 regcache_cooked_write_unsigned (regcache
, S390_SP_REGNUM
, new_sp
);
2855 /* We need to return the 'stack part' of the frame ID,
2856 which is actually the top of the register save area. */
2857 return param_area_start
;
2860 /* Assuming THIS_FRAME is a dummy, return the frame ID of that
2861 dummy frame. The frame ID's base needs to match the TOS value
2862 returned by push_dummy_call, and the PC match the dummy frame's
2864 static struct frame_id
2865 s390_dummy_id (struct gdbarch
*gdbarch
, struct frame_info
*this_frame
)
2867 int word_size
= gdbarch_ptr_bit (gdbarch
) / 8;
2868 CORE_ADDR sp
= get_frame_register_unsigned (this_frame
, S390_SP_REGNUM
);
2869 sp
= gdbarch_addr_bits_remove (gdbarch
, sp
);
2871 return frame_id_build (sp
+ 16*word_size
+ 32,
2872 get_frame_pc (this_frame
));
2876 s390_frame_align (struct gdbarch
*gdbarch
, CORE_ADDR addr
)
2878 /* Both the 32- and 64-bit ABI's say that the stack pointer should
2879 always be aligned on an eight-byte boundary. */
2884 /* Helper for s390_return_value: Set or retrieve a function return
2885 value if it resides in a register. */
2888 s390_register_return_value (struct gdbarch
*gdbarch
, struct type
*type
,
2889 struct regcache
*regcache
,
2890 gdb_byte
*out
, const gdb_byte
*in
)
2892 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
2893 int word_size
= gdbarch_ptr_bit (gdbarch
) / 8;
2894 int length
= TYPE_LENGTH (type
);
2895 int code
= TYPE_CODE (type
);
2897 if (code
== TYPE_CODE_FLT
|| code
== TYPE_CODE_DECFLOAT
)
2899 /* Float-like value: left-aligned in f0. */
2901 regcache_cooked_write_part (regcache
, S390_F0_REGNUM
,
2904 regcache_cooked_read_part (regcache
, S390_F0_REGNUM
,
2907 else if (code
== TYPE_CODE_ARRAY
)
2909 /* Vector: left-aligned in v24. */
2911 regcache_cooked_write_part (regcache
, S390_V24_REGNUM
,
2914 regcache_cooked_read_part (regcache
, S390_V24_REGNUM
,
2917 else if (length
<= word_size
)
2919 /* Integer: zero- or sign-extended in r2. */
2921 regcache_cooked_read_part (regcache
, S390_R2_REGNUM
,
2922 word_size
- length
, length
, out
);
2923 else if (TYPE_UNSIGNED (type
))
2924 regcache_cooked_write_unsigned
2925 (regcache
, S390_R2_REGNUM
,
2926 extract_unsigned_integer (in
, length
, byte_order
));
2928 regcache_cooked_write_signed
2929 (regcache
, S390_R2_REGNUM
,
2930 extract_signed_integer (in
, length
, byte_order
));
2932 else if (length
== 2 * word_size
)
2934 /* Double word: in r2 and r3. */
2937 regcache_cooked_write (regcache
, S390_R2_REGNUM
, in
);
2938 regcache_cooked_write (regcache
, S390_R3_REGNUM
,
2943 regcache_cooked_read (regcache
, S390_R2_REGNUM
, out
);
2944 regcache_cooked_read (regcache
, S390_R3_REGNUM
,
2949 internal_error (__FILE__
, __LINE__
, _("invalid return type"));
2953 /* Implement the 'return_value' gdbarch method. */
2955 static enum return_value_convention
2956 s390_return_value (struct gdbarch
*gdbarch
, struct value
*function
,
2957 struct type
*type
, struct regcache
*regcache
,
2958 gdb_byte
*out
, const gdb_byte
*in
)
2960 enum return_value_convention rvc
;
2962 type
= check_typedef (type
);
2964 switch (TYPE_CODE (type
))
2966 case TYPE_CODE_STRUCT
:
2967 case TYPE_CODE_UNION
:
2968 case TYPE_CODE_COMPLEX
:
2969 rvc
= RETURN_VALUE_STRUCT_CONVENTION
;
2971 case TYPE_CODE_ARRAY
:
2972 rvc
= (gdbarch_tdep (gdbarch
)->vector_abi
== S390_VECTOR_ABI_128
2973 && TYPE_LENGTH (type
) <= 16 && TYPE_VECTOR (type
))
2974 ? RETURN_VALUE_REGISTER_CONVENTION
2975 : RETURN_VALUE_STRUCT_CONVENTION
;
2978 rvc
= TYPE_LENGTH (type
) <= 8
2979 ? RETURN_VALUE_REGISTER_CONVENTION
2980 : RETURN_VALUE_STRUCT_CONVENTION
;
2983 if (in
!= NULL
|| out
!= NULL
)
2985 if (rvc
== RETURN_VALUE_REGISTER_CONVENTION
)
2986 s390_register_return_value (gdbarch
, type
, regcache
, out
, in
);
2987 else if (in
!= NULL
)
2988 error (_("Cannot set function return value."));
2990 error (_("Function return value unknown."));
2999 static const gdb_byte
*
3000 s390_breakpoint_from_pc (struct gdbarch
*gdbarch
,
3001 CORE_ADDR
*pcptr
, int *lenptr
)
3003 static const gdb_byte breakpoint
[] = { 0x0, 0x1 };
3005 *lenptr
= sizeof (breakpoint
);
3010 /* Address handling. */
3013 s390_addr_bits_remove (struct gdbarch
*gdbarch
, CORE_ADDR addr
)
3015 return addr
& 0x7fffffff;
3019 s390_address_class_type_flags (int byte_size
, int dwarf2_addr_class
)
3022 return TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1
;
3028 s390_address_class_type_flags_to_name (struct gdbarch
*gdbarch
, int type_flags
)
3030 if (type_flags
& TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1
)
3037 s390_address_class_name_to_type_flags (struct gdbarch
*gdbarch
,
3039 int *type_flags_ptr
)
3041 if (strcmp (name
, "mode32") == 0)
3043 *type_flags_ptr
= TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1
;
3050 /* Implement gdbarch_gcc_target_options. GCC does not know "-m32" or
3051 "-mcmodel=large". */
3054 s390_gcc_target_options (struct gdbarch
*gdbarch
)
3056 return xstrdup (gdbarch_ptr_bit (gdbarch
) == 64 ? "-m64" : "-m31");
3059 /* Implement gdbarch_gnu_triplet_regexp. Target triplets are "s390-*"
3060 for 31-bit and "s390x-*" for 64-bit, while the BFD arch name is
3061 always "s390". Note that an s390x compiler supports "-m31" as
3065 s390_gnu_triplet_regexp (struct gdbarch
*gdbarch
)
3070 /* Implementation of `gdbarch_stap_is_single_operand', as defined in
3074 s390_stap_is_single_operand (struct gdbarch
*gdbarch
, const char *s
)
3076 return ((isdigit (*s
) && s
[1] == '(' && s
[2] == '%') /* Displacement
3078 || *s
== '%' /* Register access. */
3079 || isdigit (*s
)); /* Literal number. */
3082 /* Set up gdbarch struct. */
3084 static struct gdbarch
*
3085 s390_gdbarch_init (struct gdbarch_info info
, struct gdbarch_list
*arches
)
3087 const struct target_desc
*tdesc
= info
.target_desc
;
3088 struct tdesc_arch_data
*tdesc_data
= NULL
;
3089 struct gdbarch
*gdbarch
;
3090 struct gdbarch_tdep
*tdep
;
3091 enum s390_abi_kind tdep_abi
;
3092 enum s390_vector_abi_kind vector_abi
;
3094 int have_linux_v1
= 0;
3095 int have_linux_v2
= 0;
3098 int first_pseudo_reg
, last_pseudo_reg
;
3099 static const char *const stap_register_prefixes
[] = { "%", NULL
};
3100 static const char *const stap_register_indirection_prefixes
[] = { "(",
3102 static const char *const stap_register_indirection_suffixes
[] = { ")",
3105 /* Default ABI and register size. */
3106 switch (info
.bfd_arch_info
->mach
)
3108 case bfd_mach_s390_31
:
3109 tdep_abi
= ABI_LINUX_S390
;
3112 case bfd_mach_s390_64
:
3113 tdep_abi
= ABI_LINUX_ZSERIES
;
3120 /* Use default target description if none provided by the target. */
3121 if (!tdesc_has_registers (tdesc
))
3123 if (tdep_abi
== ABI_LINUX_S390
)
3124 tdesc
= tdesc_s390_linux32
;
3126 tdesc
= tdesc_s390x_linux64
;
3129 /* Check any target description for validity. */
3130 if (tdesc_has_registers (tdesc
))
3132 static const char *const gprs
[] = {
3133 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
3134 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"
3136 static const char *const fprs
[] = {
3137 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7",
3138 "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15"
3140 static const char *const acrs
[] = {
3141 "acr0", "acr1", "acr2", "acr3", "acr4", "acr5", "acr6", "acr7",
3142 "acr8", "acr9", "acr10", "acr11", "acr12", "acr13", "acr14", "acr15"
3144 static const char *const gprs_lower
[] = {
3145 "r0l", "r1l", "r2l", "r3l", "r4l", "r5l", "r6l", "r7l",
3146 "r8l", "r9l", "r10l", "r11l", "r12l", "r13l", "r14l", "r15l"
3148 static const char *const gprs_upper
[] = {
3149 "r0h", "r1h", "r2h", "r3h", "r4h", "r5h", "r6h", "r7h",
3150 "r8h", "r9h", "r10h", "r11h", "r12h", "r13h", "r14h", "r15h"
3152 static const char *const tdb_regs
[] = {
3153 "tdb0", "tac", "tct", "atia",
3154 "tr0", "tr1", "tr2", "tr3", "tr4", "tr5", "tr6", "tr7",
3155 "tr8", "tr9", "tr10", "tr11", "tr12", "tr13", "tr14", "tr15"
3157 static const char *const vxrs_low
[] = {
3158 "v0l", "v1l", "v2l", "v3l", "v4l", "v5l", "v6l", "v7l", "v8l",
3159 "v9l", "v10l", "v11l", "v12l", "v13l", "v14l", "v15l",
3161 static const char *const vxrs_high
[] = {
3162 "v16", "v17", "v18", "v19", "v20", "v21", "v22", "v23", "v24",
3163 "v25", "v26", "v27", "v28", "v29", "v30", "v31",
3165 const struct tdesc_feature
*feature
;
3168 feature
= tdesc_find_feature (tdesc
, "org.gnu.gdb.s390.core");
3169 if (feature
== NULL
)
3172 tdesc_data
= tdesc_data_alloc ();
3174 valid_p
&= tdesc_numbered_register (feature
, tdesc_data
,
3175 S390_PSWM_REGNUM
, "pswm");
3176 valid_p
&= tdesc_numbered_register (feature
, tdesc_data
,
3177 S390_PSWA_REGNUM
, "pswa");
3179 if (tdesc_unnumbered_register (feature
, "r0"))
3181 for (i
= 0; i
< 16; i
++)
3182 valid_p
&= tdesc_numbered_register (feature
, tdesc_data
,
3183 S390_R0_REGNUM
+ i
, gprs
[i
]);
3189 for (i
= 0; i
< 16; i
++)
3190 valid_p
&= tdesc_numbered_register (feature
, tdesc_data
,
3193 for (i
= 0; i
< 16; i
++)
3194 valid_p
&= tdesc_numbered_register (feature
, tdesc_data
,
3195 S390_R0_UPPER_REGNUM
+ i
,
3199 feature
= tdesc_find_feature (tdesc
, "org.gnu.gdb.s390.fpr");
3200 if (feature
== NULL
)
3202 tdesc_data_cleanup (tdesc_data
);
3206 valid_p
&= tdesc_numbered_register (feature
, tdesc_data
,
3207 S390_FPC_REGNUM
, "fpc");
3208 for (i
= 0; i
< 16; i
++)
3209 valid_p
&= tdesc_numbered_register (feature
, tdesc_data
,
3210 S390_F0_REGNUM
+ i
, fprs
[i
]);
3212 feature
= tdesc_find_feature (tdesc
, "org.gnu.gdb.s390.acr");
3213 if (feature
== NULL
)
3215 tdesc_data_cleanup (tdesc_data
);
3219 for (i
= 0; i
< 16; i
++)
3220 valid_p
&= tdesc_numbered_register (feature
, tdesc_data
,
3221 S390_A0_REGNUM
+ i
, acrs
[i
]);
3223 /* Optional GNU/Linux-specific "registers". */
3224 feature
= tdesc_find_feature (tdesc
, "org.gnu.gdb.s390.linux");
3227 tdesc_numbered_register (feature
, tdesc_data
,
3228 S390_ORIG_R2_REGNUM
, "orig_r2");
3230 if (tdesc_numbered_register (feature
, tdesc_data
,
3231 S390_LAST_BREAK_REGNUM
, "last_break"))
3234 if (tdesc_numbered_register (feature
, tdesc_data
,
3235 S390_SYSTEM_CALL_REGNUM
, "system_call"))
3238 if (have_linux_v2
> have_linux_v1
)
3242 /* Transaction diagnostic block. */
3243 feature
= tdesc_find_feature (tdesc
, "org.gnu.gdb.s390.tdb");
3246 for (i
= 0; i
< ARRAY_SIZE (tdb_regs
); i
++)
3247 valid_p
&= tdesc_numbered_register (feature
, tdesc_data
,
3248 S390_TDB_DWORD0_REGNUM
+ i
,
3253 /* Vector registers. */
3254 feature
= tdesc_find_feature (tdesc
, "org.gnu.gdb.s390.vx");
3257 for (i
= 0; i
< 16; i
++)
3258 valid_p
&= tdesc_numbered_register (feature
, tdesc_data
,
3259 S390_V0_LOWER_REGNUM
+ i
,
3261 for (i
= 0; i
< 16; i
++)
3262 valid_p
&= tdesc_numbered_register (feature
, tdesc_data
,
3263 S390_V16_REGNUM
+ i
,
3270 tdesc_data_cleanup (tdesc_data
);
3275 /* Determine vector ABI. */
3276 vector_abi
= S390_VECTOR_ABI_NONE
;
3279 && info
.abfd
!= NULL
3280 && info
.abfd
->format
== bfd_object
3281 && bfd_get_flavour (info
.abfd
) == bfd_target_elf_flavour
3282 && bfd_elf_get_obj_attr_int (info
.abfd
, OBJ_ATTR_GNU
,
3283 Tag_GNU_S390_ABI_Vector
) == 2)
3284 vector_abi
= S390_VECTOR_ABI_128
;
3287 /* Find a candidate among extant architectures. */
3288 for (arches
= gdbarch_list_lookup_by_info (arches
, &info
);
3290 arches
= gdbarch_list_lookup_by_info (arches
->next
, &info
))
3292 tdep
= gdbarch_tdep (arches
->gdbarch
);
3295 if (tdep
->abi
!= tdep_abi
)
3297 if (tdep
->vector_abi
!= vector_abi
)
3299 if ((tdep
->gpr_full_regnum
!= -1) != have_upper
)
3301 if (tdesc_data
!= NULL
)
3302 tdesc_data_cleanup (tdesc_data
);
3303 return arches
->gdbarch
;
3306 /* Otherwise create a new gdbarch for the specified machine type. */
3307 tdep
= XCNEW (struct gdbarch_tdep
);
3308 tdep
->abi
= tdep_abi
;
3309 tdep
->vector_abi
= vector_abi
;
3310 tdep
->have_linux_v1
= have_linux_v1
;
3311 tdep
->have_linux_v2
= have_linux_v2
;
3312 tdep
->have_tdb
= have_tdb
;
3313 gdbarch
= gdbarch_alloc (&info
, tdep
);
3315 set_gdbarch_believe_pcc_promotion (gdbarch
, 0);
3316 set_gdbarch_char_signed (gdbarch
, 0);
3318 /* S/390 GNU/Linux uses either 64-bit or 128-bit long doubles.
3319 We can safely let them default to 128-bit, since the debug info
3320 will give the size of type actually used in each case. */
3321 set_gdbarch_long_double_bit (gdbarch
, 128);
3322 set_gdbarch_long_double_format (gdbarch
, floatformats_ia64_quad
);
3324 /* Amount PC must be decremented by after a breakpoint. This is
3325 often the number of bytes returned by gdbarch_breakpoint_from_pc but not
3327 set_gdbarch_decr_pc_after_break (gdbarch
, 2);
3328 /* Stack grows downward. */
3329 set_gdbarch_inner_than (gdbarch
, core_addr_lessthan
);
3330 set_gdbarch_breakpoint_from_pc (gdbarch
, s390_breakpoint_from_pc
);
3331 set_gdbarch_skip_prologue (gdbarch
, s390_skip_prologue
);
3332 set_gdbarch_stack_frame_destroyed_p (gdbarch
, s390_stack_frame_destroyed_p
);
3334 set_gdbarch_num_regs (gdbarch
, S390_NUM_REGS
);
3335 set_gdbarch_sp_regnum (gdbarch
, S390_SP_REGNUM
);
3336 set_gdbarch_fp0_regnum (gdbarch
, S390_F0_REGNUM
);
3337 set_gdbarch_stab_reg_to_regnum (gdbarch
, s390_dwarf_reg_to_regnum
);
3338 set_gdbarch_dwarf2_reg_to_regnum (gdbarch
, s390_dwarf_reg_to_regnum
);
3339 set_gdbarch_value_from_register (gdbarch
, s390_value_from_register
);
3340 set_gdbarch_core_read_description (gdbarch
, s390_core_read_description
);
3341 set_gdbarch_iterate_over_regset_sections (gdbarch
,
3342 s390_iterate_over_regset_sections
);
3343 set_gdbarch_cannot_store_register (gdbarch
, s390_cannot_store_register
);
3344 set_gdbarch_write_pc (gdbarch
, s390_write_pc
);
3345 set_gdbarch_pseudo_register_read (gdbarch
, s390_pseudo_register_read
);
3346 set_gdbarch_pseudo_register_write (gdbarch
, s390_pseudo_register_write
);
3347 set_tdesc_pseudo_register_name (gdbarch
, s390_pseudo_register_name
);
3348 set_tdesc_pseudo_register_type (gdbarch
, s390_pseudo_register_type
);
3349 set_tdesc_pseudo_register_reggroup_p (gdbarch
,
3350 s390_pseudo_register_reggroup_p
);
3351 tdesc_use_registers (gdbarch
, tdesc
, tdesc_data
);
3352 set_gdbarch_register_name (gdbarch
, s390_register_name
);
3354 /* Assign pseudo register numbers. */
3355 first_pseudo_reg
= gdbarch_num_regs (gdbarch
);
3356 last_pseudo_reg
= first_pseudo_reg
;
3357 tdep
->gpr_full_regnum
= -1;
3360 tdep
->gpr_full_regnum
= last_pseudo_reg
;
3361 last_pseudo_reg
+= 16;
3363 tdep
->v0_full_regnum
= -1;
3366 tdep
->v0_full_regnum
= last_pseudo_reg
;
3367 last_pseudo_reg
+= 16;
3369 tdep
->pc_regnum
= last_pseudo_reg
++;
3370 tdep
->cc_regnum
= last_pseudo_reg
++;
3371 set_gdbarch_pc_regnum (gdbarch
, tdep
->pc_regnum
);
3372 set_gdbarch_num_pseudo_regs (gdbarch
, last_pseudo_reg
- first_pseudo_reg
);
3374 /* Inferior function calls. */
3375 set_gdbarch_push_dummy_call (gdbarch
, s390_push_dummy_call
);
3376 set_gdbarch_dummy_id (gdbarch
, s390_dummy_id
);
3377 set_gdbarch_frame_align (gdbarch
, s390_frame_align
);
3378 set_gdbarch_return_value (gdbarch
, s390_return_value
);
3380 /* Syscall handling. */
3381 set_gdbarch_get_syscall_number (gdbarch
, s390_linux_get_syscall_number
);
3383 /* Frame handling. */
3384 dwarf2_frame_set_init_reg (gdbarch
, s390_dwarf2_frame_init_reg
);
3385 dwarf2_frame_set_adjust_regnum (gdbarch
, s390_adjust_frame_regnum
);
3386 dwarf2_append_unwinders (gdbarch
);
3387 frame_base_append_sniffer (gdbarch
, dwarf2_frame_base_sniffer
);
3388 frame_unwind_append_unwinder (gdbarch
, &s390_stub_frame_unwind
);
3389 frame_unwind_append_unwinder (gdbarch
, &s390_sigtramp_frame_unwind
);
3390 frame_unwind_append_unwinder (gdbarch
, &s390_frame_unwind
);
3391 frame_base_set_default (gdbarch
, &s390_frame_base
);
3392 set_gdbarch_unwind_pc (gdbarch
, s390_unwind_pc
);
3393 set_gdbarch_unwind_sp (gdbarch
, s390_unwind_sp
);
3395 /* Displaced stepping. */
3396 set_gdbarch_displaced_step_copy_insn (gdbarch
,
3397 s390_displaced_step_copy_insn
);
3398 set_gdbarch_displaced_step_fixup (gdbarch
, s390_displaced_step_fixup
);
3399 set_gdbarch_displaced_step_free_closure (gdbarch
,
3400 simple_displaced_step_free_closure
);
3401 set_gdbarch_displaced_step_location (gdbarch
, linux_displaced_step_location
);
3402 set_gdbarch_max_insn_length (gdbarch
, S390_MAX_INSTR_SIZE
);
3404 /* Note that GNU/Linux is the only OS supported on this
3406 linux_init_abi (info
, gdbarch
);
3410 case ABI_LINUX_S390
:
3411 set_gdbarch_addr_bits_remove (gdbarch
, s390_addr_bits_remove
);
3412 set_solib_svr4_fetch_link_map_offsets
3413 (gdbarch
, svr4_ilp32_fetch_link_map_offsets
);
3415 set_xml_syscall_file_name (gdbarch
, XML_SYSCALL_FILENAME_S390
);
3418 case ABI_LINUX_ZSERIES
:
3419 set_gdbarch_long_bit (gdbarch
, 64);
3420 set_gdbarch_long_long_bit (gdbarch
, 64);
3421 set_gdbarch_ptr_bit (gdbarch
, 64);
3422 set_solib_svr4_fetch_link_map_offsets
3423 (gdbarch
, svr4_lp64_fetch_link_map_offsets
);
3424 set_gdbarch_address_class_type_flags (gdbarch
,
3425 s390_address_class_type_flags
);
3426 set_gdbarch_address_class_type_flags_to_name (gdbarch
,
3427 s390_address_class_type_flags_to_name
);
3428 set_gdbarch_address_class_name_to_type_flags (gdbarch
,
3429 s390_address_class_name_to_type_flags
);
3430 set_xml_syscall_file_name (gdbarch
, XML_SYSCALL_FILENAME_S390X
);
3434 set_gdbarch_print_insn (gdbarch
, print_insn_s390
);
3436 set_gdbarch_skip_trampoline_code (gdbarch
, find_solib_trampoline_target
);
3438 /* Enable TLS support. */
3439 set_gdbarch_fetch_tls_load_module_address (gdbarch
,
3440 svr4_fetch_objfile_link_map
);
3442 /* SystemTap functions. */
3443 set_gdbarch_stap_register_prefixes (gdbarch
, stap_register_prefixes
);
3444 set_gdbarch_stap_register_indirection_prefixes (gdbarch
,
3445 stap_register_indirection_prefixes
);
3446 set_gdbarch_stap_register_indirection_suffixes (gdbarch
,
3447 stap_register_indirection_suffixes
);
3448 set_gdbarch_stap_is_single_operand (gdbarch
, s390_stap_is_single_operand
);
3449 set_gdbarch_gcc_target_options (gdbarch
, s390_gcc_target_options
);
3450 set_gdbarch_gnu_triplet_regexp (gdbarch
, s390_gnu_triplet_regexp
);
3456 extern initialize_file_ftype _initialize_s390_tdep
; /* -Wmissing-prototypes */
3459 _initialize_s390_tdep (void)
3461 /* Hook us into the gdbarch mechanism. */
3462 register_gdbarch_init (bfd_arch_s390
, s390_gdbarch_init
);
3464 /* Initialize the GNU/Linux target descriptions. */
3465 initialize_tdesc_s390_linux32 ();
3466 initialize_tdesc_s390_linux32v1 ();
3467 initialize_tdesc_s390_linux32v2 ();
3468 initialize_tdesc_s390_linux64 ();
3469 initialize_tdesc_s390_linux64v1 ();
3470 initialize_tdesc_s390_linux64v2 ();
3471 initialize_tdesc_s390_te_linux64 ();
3472 initialize_tdesc_s390_vx_linux64 ();
3473 initialize_tdesc_s390_tevx_linux64 ();
3474 initialize_tdesc_s390x_linux64 ();
3475 initialize_tdesc_s390x_linux64v1 ();
3476 initialize_tdesc_s390x_linux64v2 ();
3477 initialize_tdesc_s390x_te_linux64 ();
3478 initialize_tdesc_s390x_vx_linux64 ();
3479 initialize_tdesc_s390x_tevx_linux64 ();