* gdbarch.sh (TARGET_CHAR_SIGNED): New macro.
[deliverable/binutils-gdb.git] / gdb / s390-tdep.c
CommitLineData
5769d3cd
AC
1/* Target-dependent code for GDB, the GNU debugger.
2 Copyright 2001 Free Software Foundation, Inc.
3 Contributed by D.J. Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com)
4 for IBM Deutschland Entwicklung GmbH, IBM Corporation.
5
6 This file is part of GDB.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21 02111-1307, USA. */
22
23#define S390_TDEP /* for special macros in tm-s390.h */
24#include <defs.h>
25#include "arch-utils.h"
26#include "frame.h"
27#include "inferior.h"
28#include "symtab.h"
29#include "target.h"
30#include "gdbcore.h"
31#include "gdbcmd.h"
32#include "symfile.h"
33#include "objfiles.h"
34#include "tm.h"
35#include "../bfd/bfd.h"
36#include "floatformat.h"
37#include "regcache.h"
fd0407d6 38#include "value.h"
78f8b424 39#include "gdb_assert.h"
5769d3cd
AC
40
41
42
60e6cc42 43
5769d3cd 44/* Number of bytes of storage in the actual machine representation
23b7362f 45 for register N. */
5769d3cd
AC
46int
47s390_register_raw_size (int reg_nr)
48{
23b7362f
JB
49 if (S390_FP0_REGNUM <= reg_nr
50 && reg_nr < S390_FP0_REGNUM + S390_NUM_FPRS)
51 return S390_FPR_SIZE;
52 else
53 return 4;
5769d3cd
AC
54}
55
56int
57s390x_register_raw_size (int reg_nr)
58{
59 return (reg_nr == S390_FPC_REGNUM)
60 || (reg_nr >= S390_FIRST_ACR && reg_nr <= S390_LAST_ACR) ? 4 : 8;
61}
62
63int
64s390_cannot_fetch_register (int regno)
65{
66 return (regno >= S390_FIRST_CR && regno < (S390_FIRST_CR + 9)) ||
67 (regno >= (S390_FIRST_CR + 12) && regno <= S390_LAST_CR);
68}
69
70int
71s390_register_byte (int reg_nr)
72{
73 if (reg_nr <= S390_GP_LAST_REGNUM)
74 return reg_nr * S390_GPR_SIZE;
75 if (reg_nr <= S390_LAST_ACR)
76 return S390_ACR0_OFFSET + (((reg_nr) - S390_FIRST_ACR) * S390_ACR_SIZE);
77 if (reg_nr <= S390_LAST_CR)
78 return S390_CR0_OFFSET + (((reg_nr) - S390_FIRST_CR) * S390_CR_SIZE);
79 if (reg_nr == S390_FPC_REGNUM)
80 return S390_FPC_OFFSET;
81 else
82 return S390_FP0_OFFSET + (((reg_nr) - S390_FP0_REGNUM) * S390_FPR_SIZE);
83}
84
85#ifndef GDBSERVER
86#define S390_MAX_INSTR_SIZE (6)
87#define S390_SYSCALL_OPCODE (0x0a)
88#define S390_SYSCALL_SIZE (2)
89#define S390_SIGCONTEXT_SREGS_OFFSET (8)
90#define S390X_SIGCONTEXT_SREGS_OFFSET (8)
91#define S390_SIGREGS_FP0_OFFSET (144)
92#define S390X_SIGREGS_FP0_OFFSET (216)
93#define S390_UC_MCONTEXT_OFFSET (256)
94#define S390X_UC_MCONTEXT_OFFSET (344)
95#define S390_STACK_FRAME_OVERHEAD (GDB_TARGET_IS_ESAME ? 160:96)
96#define S390_SIGNAL_FRAMESIZE (GDB_TARGET_IS_ESAME ? 160:96)
97#define s390_NR_sigreturn 119
98#define s390_NR_rt_sigreturn 173
99
100
101
102struct frame_extra_info
103{
104 int initialised;
105 int good_prologue;
106 CORE_ADDR function_start;
107 CORE_ADDR skip_prologue_function_start;
108 CORE_ADDR saved_pc_valid;
109 CORE_ADDR saved_pc;
110 CORE_ADDR sig_fixed_saved_pc_valid;
111 CORE_ADDR sig_fixed_saved_pc;
112 CORE_ADDR frame_pointer_saved_pc; /* frame pointer needed for alloca */
113 CORE_ADDR stack_bought; /* amount we decrement the stack pointer by */
114 CORE_ADDR sigcontext;
115};
116
117
118static CORE_ADDR s390_frame_saved_pc_nofix (struct frame_info *fi);
119
120int
121s390_readinstruction (bfd_byte instr[], CORE_ADDR at,
122 struct disassemble_info *info)
123{
124 int instrlen;
125
126 static int s390_instrlen[] = {
127 2,
128 4,
129 4,
130 6
131 };
132 if ((*info->read_memory_func) (at, &instr[0], 2, info))
133 return -1;
134 instrlen = s390_instrlen[instr[0] >> 6];
135 if ((*info->read_memory_func) (at + 2, &instr[2], instrlen - 2, info))
136 return -1;
137 return instrlen;
138}
139
140static void
141s390_memset_extra_info (struct frame_extra_info *fextra_info)
142{
143 memset (fextra_info, 0, sizeof (struct frame_extra_info));
144}
145
146
147
148char *
149s390_register_name (int reg_nr)
150{
151 static char *register_names[] = {
152 "pswm", "pswa",
4ed90530
JB
153 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
154 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
5769d3cd
AC
155 "acr0", "acr1", "acr2", "acr3", "acr4", "acr5", "acr6", "acr7",
156 "acr8", "acr9", "acr10", "acr11", "acr12", "acr13", "acr14", "acr15",
157 "cr0", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7",
158 "cr8", "cr9", "cr10", "cr11", "cr12", "cr13", "cr14", "cr15",
159 "fpc",
4ed90530
JB
160 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7",
161 "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15"
5769d3cd
AC
162 };
163
b09677dc
JB
164 if (reg_nr <= S390_LAST_REGNUM)
165 return register_names[reg_nr];
166 else
5769d3cd 167 return NULL;
5769d3cd
AC
168}
169
170
171
172
173int
174s390_stab_reg_to_regnum (int regno)
175{
176 return regno >= 64 ? S390_PSWM_REGNUM - 64 :
177 regno >= 48 ? S390_FIRST_ACR - 48 :
178 regno >= 32 ? S390_FIRST_CR - 32 :
179 regno <= 15 ? (regno + 2) :
180 S390_FP0_REGNUM + ((regno - 16) & 8) + (((regno - 16) & 3) << 1) +
181 (((regno - 16) & 4) >> 2);
182}
183
184
12bffad7
JB
185/* Return true if REGIDX is the number of a register used to pass
186 arguments, false otherwise. */
187static int
188is_arg_reg (int regidx)
189{
190 return 2 <= regidx && regidx <= 6;
191}
192
5769d3cd
AC
193
194/* s390_get_frame_info based on Hartmuts
195 prologue definition in
196 gcc-2.8.1/config/l390/linux.c
197
198 It reads one instruction at a time & based on whether
199 it looks like prologue code or not it makes a decision on
200 whether the prologue is over, there are various state machines
201 in the code to determine if the prologue code is possilby valid.
202
203 This is done to hopefully allow the code survive minor revs of
204 calling conventions.
205
206 */
207
208int
209s390_get_frame_info (CORE_ADDR pc, struct frame_extra_info *fextra_info,
210 struct frame_info *fi, int init_extra_info)
211{
212#define CONST_POOL_REGIDX 13
213#define GOT_REGIDX 12
214 bfd_byte instr[S390_MAX_INSTR_SIZE];
215 CORE_ADDR test_pc = pc, test_pc2;
216 CORE_ADDR orig_sp = 0, save_reg_addr = 0, *saved_regs = NULL;
217 int valid_prologue, good_prologue = 0;
218 int gprs_saved[S390_NUM_GPRS];
219 int fprs_saved[S390_NUM_FPRS];
220 int regidx, instrlen;
6df29de2 221 int const_pool_state;
7286245e 222 int varargs_state;
5769d3cd 223 int loop_cnt, gdb_gpr_store, gdb_fpr_store;
5769d3cd
AC
224 int offset, expected_offset;
225 int err = 0;
226 disassemble_info info;
8ac0e65a 227
7286245e
JB
228 /* Have we seen an instruction initializing the frame pointer yet?
229 If we've seen an `lr %r11, %r15', then frame_pointer_found is
230 non-zero, and frame_pointer_regidx == 11. Otherwise,
231 frame_pointer_found is zero and frame_pointer_regidx is 15,
232 indicating that we're using the stack pointer as our frame
233 pointer. */
234 int frame_pointer_found = 0;
235 int frame_pointer_regidx = 0xf;
236
6df29de2
JB
237 /* What we've seen so far regarding saving the back chain link:
238 0 -- nothing yet; sp still has the same value it had at the entry
239 point. Since not all functions allocate frames, this is a
240 valid state for the prologue to finish in.
241 1 -- We've saved the original sp in some register other than the
242 frame pointer (hard-coded to be %r11, yuck).
243 save_link_regidx is the register we saved it in.
244 2 -- We've seen the initial `bras' instruction of the sequence for
245 reserving more than 32k of stack:
246 bras %rX, .+8
247 .long N
248 s %r15, 0(%rX)
249 where %rX is not the constant pool register.
250 subtract_sp_regidx is %rX, and fextra_info->stack_bought is N.
251 3 -- We've reserved space for a new stack frame. This means we
252 either saw a simple `ahi %r15,-N' in state 1, or the final
253 `s %r15, ...' in state 2.
254 4 -- The frame and link are now fully initialized. We've
255 reserved space for the new stack frame, and stored the old
256 stack pointer captured in the back chain pointer field. */
7286245e 257 int save_link_state = 0;
6df29de2
JB
258 int save_link_regidx, subtract_sp_regidx;
259
8ac0e65a
JB
260 /* What we've seen so far regarding r12 --- the GOT (Global Offset
261 Table) pointer. We expect to see `l %r12, N(%r13)', which loads
262 r12 with the offset from the constant pool to the GOT, and then
263 an `ar %r12, %r13', which adds the constant pool address,
264 yielding the GOT's address. Here's what got_state means:
265 0 -- seen nothing
266 1 -- seen `l %r12, N(%r13)', but no `ar'
267 2 -- seen load and add, so GOT pointer is totally initialized
268 When got_state is 1, then got_load_addr is the address of the
269 load instruction, and got_load_len is the length of that
270 instruction. */
7286245e 271 int got_state= 0;
64f9bb98 272 CORE_ADDR got_load_addr = 0, got_load_len = 0;
8ac0e65a 273
7286245e
JB
274 const_pool_state = varargs_state = 0;
275
5769d3cd
AC
276 memset (gprs_saved, 0, sizeof (gprs_saved));
277 memset (fprs_saved, 0, sizeof (fprs_saved));
278 info.read_memory_func = dis_asm_read_memory;
279
280 save_link_regidx = subtract_sp_regidx = 0;
281 if (fextra_info)
282 {
283 if (fi && fi->frame)
284 {
386e4208
JB
285 if (! init_extra_info && fextra_info->initialised)
286 orig_sp = fi->frame + fextra_info->stack_bought;
5769d3cd
AC
287 saved_regs = fi->saved_regs;
288 }
289 if (init_extra_info || !fextra_info->initialised)
290 {
291 s390_memset_extra_info (fextra_info);
292 fextra_info->function_start = pc;
293 fextra_info->initialised = 1;
294 }
295 }
296 instrlen = 0;
297 do
298 {
299 valid_prologue = 0;
300 test_pc += instrlen;
301 /* add the previous instruction len */
302 instrlen = s390_readinstruction (instr, test_pc, &info);
303 if (instrlen < 0)
304 {
305 good_prologue = 0;
306 err = -1;
307 break;
308 }
309 /* We probably are in a glibc syscall */
310 if (instr[0] == S390_SYSCALL_OPCODE && test_pc == pc)
311 {
312 good_prologue = 1;
313 if (saved_regs && fextra_info && fi->next && fi->next->extra_info
314 && fi->next->extra_info->sigcontext)
315 {
316 /* We are backtracing from a signal handler */
317 save_reg_addr = fi->next->extra_info->sigcontext +
318 REGISTER_BYTE (S390_GP0_REGNUM);
319 for (regidx = 0; regidx < S390_NUM_GPRS; regidx++)
320 {
321 saved_regs[S390_GP0_REGNUM + regidx] = save_reg_addr;
322 save_reg_addr += S390_GPR_SIZE;
323 }
324 save_reg_addr = fi->next->extra_info->sigcontext +
325 (GDB_TARGET_IS_ESAME ? S390X_SIGREGS_FP0_OFFSET :
326 S390_SIGREGS_FP0_OFFSET);
327 for (regidx = 0; regidx < S390_NUM_FPRS; regidx++)
328 {
329 saved_regs[S390_FP0_REGNUM + regidx] = save_reg_addr;
330 save_reg_addr += S390_FPR_SIZE;
331 }
332 }
333 break;
334 }
335 if (save_link_state == 0)
336 {
337 /* check for a stack relative STMG or STM */
338 if (((GDB_TARGET_IS_ESAME &&
339 ((instr[0] == 0xeb) && (instr[5] == 0x24))) ||
340 (instr[0] == 0x90)) && ((instr[2] >> 4) == 0xf))
341 {
342 regidx = (instr[1] >> 4);
343 if (regidx < 6)
344 varargs_state = 1;
345 offset = ((instr[2] & 0xf) << 8) + instr[3];
346 expected_offset =
347 S390_GPR6_STACK_OFFSET + (S390_GPR_SIZE * (regidx - 6));
348 if (offset != expected_offset)
349 {
350 good_prologue = 0;
351 break;
352 }
353 if (saved_regs)
354 save_reg_addr = orig_sp + offset;
355 for (; regidx <= (instr[1] & 0xf); regidx++)
356 {
357 if (gprs_saved[regidx])
358 {
359 good_prologue = 0;
360 break;
361 }
362 good_prologue = 1;
363 gprs_saved[regidx] = 1;
364 if (saved_regs)
365 {
366 saved_regs[S390_GP0_REGNUM + regidx] = save_reg_addr;
367 save_reg_addr += S390_GPR_SIZE;
368 }
369 }
370 valid_prologue = 1;
371 continue;
372 }
373 }
374 /* check for a stack relative STG or ST */
375 if ((save_link_state == 0 || save_link_state == 3) &&
376 ((GDB_TARGET_IS_ESAME &&
377 ((instr[0] == 0xe3) && (instr[5] == 0x24))) ||
378 (instr[0] == 0x50)) && ((instr[2] >> 4) == 0xf))
379 {
380 regidx = instr[1] >> 4;
381 offset = ((instr[2] & 0xf) << 8) + instr[3];
382 if (offset == 0)
383 {
384 if (save_link_state == 3 && regidx == save_link_regidx)
385 {
386 save_link_state = 4;
387 valid_prologue = 1;
388 continue;
389 }
390 else
391 break;
392 }
393 if (regidx < 6)
394 varargs_state = 1;
395 expected_offset =
396 S390_GPR6_STACK_OFFSET + (S390_GPR_SIZE * (regidx - 6));
397 if (offset != expected_offset)
398 {
399 good_prologue = 0;
400 break;
401 }
402 if (gprs_saved[regidx])
403 {
404 good_prologue = 0;
405 break;
406 }
407 good_prologue = 1;
408 gprs_saved[regidx] = 1;
409 if (saved_regs)
410 {
411 save_reg_addr = orig_sp + offset;
412 saved_regs[S390_GP0_REGNUM + regidx] = save_reg_addr;
413 }
414 valid_prologue = 1;
415 continue;
416 }
417
12bffad7 418 /* Check for an fp-relative STG, ST, or STM. This is probably
7666f43c
JB
419 spilling an argument from a register out into a stack slot.
420 This could be a user instruction, but if we haven't included
421 any other suspicious instructions in the prologue, this
422 could only be an initializing store, which isn't too bad to
423 skip. The consequences of not including arg-to-stack spills
424 are more serious, though --- you don't see the proper values
425 of the arguments. */
426 if ((save_link_state == 3 || save_link_state == 4)
12bffad7
JB
427 && ((instr[0] == 0x50 /* st %rA, D(%rX,%rB) */
428 && (instr[1] & 0xf) == 0 /* %rX is zero, no index reg */
429 && is_arg_reg ((instr[1] >> 4) & 0xf)
430 && ((instr[2] >> 4) & 0xf) == frame_pointer_regidx)
431 || (instr[0] == 0x90 /* stm %rA, %rB, D(%rC) */
432 && is_arg_reg ((instr[1] >> 4) & 0xf)
433 && is_arg_reg (instr[1] & 0xf)
434 && ((instr[2] >> 4) & 0xf) == frame_pointer_regidx)))
7666f43c
JB
435 {
436 valid_prologue = 1;
437 continue;
438 }
439
5769d3cd
AC
440 /* check for STD */
441 if (instr[0] == 0x60 && (instr[2] >> 4) == 0xf)
442 {
443 regidx = instr[1] >> 4;
444 if (regidx == 0 || regidx == 2)
445 varargs_state = 1;
446 if (fprs_saved[regidx])
447 {
448 good_prologue = 0;
449 break;
450 }
451 fprs_saved[regidx] = 1;
452 if (saved_regs)
453 {
454 save_reg_addr = orig_sp + (((instr[2] & 0xf) << 8) + instr[3]);
455 saved_regs[S390_FP0_REGNUM + regidx] = save_reg_addr;
456 }
457 valid_prologue = 1;
458 continue;
459 }
460
461
462 if (const_pool_state == 0)
463 {
464
465 if (GDB_TARGET_IS_ESAME)
466 {
467 /* Check for larl CONST_POOL_REGIDX,offset on ESAME */
468 if ((instr[0] == 0xc0)
469 && (instr[1] == (CONST_POOL_REGIDX << 4)))
470 {
471 const_pool_state = 2;
472 valid_prologue = 1;
473 continue;
474 }
475 }
476 else
477 {
478 /* Check for BASR gpr13,gpr0 used to load constant pool pointer to r13 in old compiler */
479 if (instr[0] == 0xd && (instr[1] & 0xf) == 0
480 && ((instr[1] >> 4) == CONST_POOL_REGIDX))
481 {
482 const_pool_state = 1;
483 valid_prologue = 1;
484 continue;
485 }
486 }
487 /* Check for new fangled bras %r13,newpc to load new constant pool */
488 /* embedded in code, older pre abi compilers also emitted this stuff. */
489 if ((instr[0] == 0xa7) && ((instr[1] & 0xf) == 0x5) &&
490 ((instr[1] >> 4) == CONST_POOL_REGIDX)
491 && ((instr[2] & 0x80) == 0))
492 {
493 const_pool_state = 2;
494 test_pc +=
495 (((((instr[2] & 0xf) << 8) + instr[3]) << 1) - instrlen);
496 valid_prologue = 1;
497 continue;
498 }
499 }
500 /* Check for AGHI or AHI CONST_POOL_REGIDX,val */
501 if (const_pool_state == 1 && (instr[0] == 0xa7) &&
502 ((GDB_TARGET_IS_ESAME &&
503 (instr[1] == ((CONST_POOL_REGIDX << 4) | 0xb))) ||
504 (instr[1] == ((CONST_POOL_REGIDX << 4) | 0xa))))
505 {
506 const_pool_state = 2;
507 valid_prologue = 1;
508 continue;
509 }
510 /* Check for LGR or LR gprx,15 */
511 if ((GDB_TARGET_IS_ESAME &&
512 instr[0] == 0xb9 && instr[1] == 0x04 && (instr[3] & 0xf) == 0xf) ||
513 (instr[0] == 0x18 && (instr[1] & 0xf) == 0xf))
514 {
515 if (GDB_TARGET_IS_ESAME)
516 regidx = instr[3] >> 4;
517 else
518 regidx = instr[1] >> 4;
519 if (save_link_state == 0 && regidx != 0xb)
520 {
521 /* Almost defintely code for
522 decrementing the stack pointer
523 ( i.e. a non leaf function
524 or else leaf with locals ) */
525 save_link_regidx = regidx;
526 save_link_state = 1;
527 valid_prologue = 1;
528 continue;
529 }
530 /* We use this frame pointer for alloca
531 unfortunately we need to assume its gpr11
532 otherwise we would need a smarter prologue
533 walker. */
534 if (!frame_pointer_found && regidx == 0xb)
535 {
536 frame_pointer_regidx = 0xb;
537 frame_pointer_found = 1;
538 if (fextra_info)
539 fextra_info->frame_pointer_saved_pc = test_pc;
540 valid_prologue = 1;
541 continue;
542 }
543 }
544 /* Check for AHI or AGHI gpr15,val */
545 if (save_link_state == 1 && (instr[0] == 0xa7) &&
546 ((GDB_TARGET_IS_ESAME && (instr[1] == 0xfb)) || (instr[1] == 0xfa)))
547 {
548 if (fextra_info)
549 fextra_info->stack_bought =
550 -extract_signed_integer (&instr[2], 2);
551 save_link_state = 3;
552 valid_prologue = 1;
553 continue;
554 }
555 /* Alternatively check for the complex construction for
556 buying more than 32k of stack
557 BRAS gprx,.+8
6df29de2
JB
558 long val
559 s %r15,0(%gprx) gprx currently r1 */
5769d3cd
AC
560 if ((save_link_state == 1) && (instr[0] == 0xa7)
561 && ((instr[1] & 0xf) == 0x5) && (instr[2] == 0)
562 && (instr[3] == 0x4) && ((instr[1] >> 4) != CONST_POOL_REGIDX))
563 {
564 subtract_sp_regidx = instr[1] >> 4;
565 save_link_state = 2;
566 if (fextra_info)
567 target_read_memory (test_pc + instrlen,
568 (char *) &fextra_info->stack_bought,
569 sizeof (fextra_info->stack_bought));
570 test_pc += 4;
571 valid_prologue = 1;
572 continue;
573 }
574 if (save_link_state == 2 && instr[0] == 0x5b
575 && instr[1] == 0xf0 &&
576 instr[2] == (subtract_sp_regidx << 4) && instr[3] == 0)
577 {
578 save_link_state = 3;
579 valid_prologue = 1;
580 continue;
581 }
582 /* check for LA gprx,offset(15) used for varargs */
583 if ((instr[0] == 0x41) && ((instr[2] >> 4) == 0xf) &&
584 ((instr[1] & 0xf) == 0))
585 {
586 /* some code uses gpr7 to point to outgoing args */
587 if (((instr[1] >> 4) == 7) && (save_link_state == 0) &&
588 ((instr[2] & 0xf) == 0)
589 && (instr[3] == S390_STACK_FRAME_OVERHEAD))
590 {
591 valid_prologue = 1;
592 continue;
593 }
594 if (varargs_state == 1)
595 {
596 varargs_state = 2;
597 valid_prologue = 1;
598 continue;
599 }
600 }
601 /* Check for a GOT load */
602
603 if (GDB_TARGET_IS_ESAME)
604 {
605 /* Check for larl GOT_REGIDX, on ESAME */
606 if ((got_state == 0) && (instr[0] == 0xc0)
607 && (instr[1] == (GOT_REGIDX << 4)))
608 {
609 got_state = 2;
610 valid_prologue = 1;
611 continue;
612 }
613 }
614 else
615 {
616 /* check for l GOT_REGIDX,x(CONST_POOL_REGIDX) */
617 if (got_state == 0 && const_pool_state == 2 && instr[0] == 0x58
618 && (instr[2] == (CONST_POOL_REGIDX << 4))
619 && ((instr[1] >> 4) == GOT_REGIDX))
620 {
8ac0e65a
JB
621 got_state = 1;
622 got_load_addr = test_pc;
623 got_load_len = instrlen;
5769d3cd
AC
624 valid_prologue = 1;
625 continue;
626 }
627 /* Check for subsequent ar got_regidx,basr_regidx */
628 if (got_state == 1 && instr[0] == 0x1a &&
629 instr[1] == ((GOT_REGIDX << 4) | CONST_POOL_REGIDX))
630 {
631 got_state = 2;
632 valid_prologue = 1;
633 continue;
634 }
635 }
636 }
637 while (valid_prologue && good_prologue);
638 if (good_prologue)
639 {
8ac0e65a
JB
640 /* If this function doesn't reference the global offset table,
641 then the compiler may use r12 for other things. If the last
642 instruction we saw was a load of r12 from the constant pool,
643 with no subsequent add to make the address PC-relative, then
644 the load was probably a genuine body instruction; don't treat
645 it as part of the prologue. */
646 if (got_state == 1
647 && got_load_addr + got_load_len == test_pc)
648 {
649 test_pc = got_load_addr;
650 instrlen = got_load_len;
651 }
652
653 good_prologue = (((const_pool_state == 0) || (const_pool_state == 2)) &&
5769d3cd
AC
654 ((save_link_state == 0) || (save_link_state == 4)) &&
655 ((varargs_state == 0) || (varargs_state == 2)));
656 }
657 if (fextra_info)
658 {
659 fextra_info->good_prologue = good_prologue;
660 fextra_info->skip_prologue_function_start =
661 (good_prologue ? test_pc : pc);
662 }
09025237
JB
663 if (saved_regs)
664 /* The SP's element of the saved_regs array holds the old SP,
665 not the address at which it is saved. */
666 saved_regs[S390_SP_REGNUM] = orig_sp;
5769d3cd
AC
667 return err;
668}
669
670
671int
672s390_check_function_end (CORE_ADDR pc)
673{
674 bfd_byte instr[S390_MAX_INSTR_SIZE];
675 disassemble_info info;
676 int regidx, instrlen;
677
678 info.read_memory_func = dis_asm_read_memory;
679 instrlen = s390_readinstruction (instr, pc, &info);
680 if (instrlen < 0)
681 return -1;
682 /* check for BR */
683 if (instrlen != 2 || instr[0] != 07 || (instr[1] >> 4) != 0xf)
684 return 0;
685 regidx = instr[1] & 0xf;
686 /* Check for LMG or LG */
687 instrlen =
688 s390_readinstruction (instr, pc - (GDB_TARGET_IS_ESAME ? 6 : 4), &info);
689 if (instrlen < 0)
690 return -1;
691 if (GDB_TARGET_IS_ESAME)
692 {
693
694 if (instrlen != 6 || instr[0] != 0xeb || instr[5] != 0x4)
695 return 0;
696 }
697 else if (instrlen != 4 || instr[0] != 0x98)
698 {
699 return 0;
700 }
701 if ((instr[2] >> 4) != 0xf)
702 return 0;
703 if (regidx == 14)
704 return 1;
705 instrlen = s390_readinstruction (instr, pc - (GDB_TARGET_IS_ESAME ? 12 : 8),
706 &info);
707 if (instrlen < 0)
708 return -1;
709 if (GDB_TARGET_IS_ESAME)
710 {
711 /* Check for LG */
712 if (instrlen != 6 || instr[0] != 0xe3 || instr[5] != 0x4)
713 return 0;
714 }
715 else
716 {
717 /* Check for L */
718 if (instrlen != 4 || instr[0] != 0x58)
719 return 0;
720 }
721 if (instr[2] >> 4 != 0xf)
722 return 0;
723 if (instr[1] >> 4 != regidx)
724 return 0;
725 return 1;
726}
727
728static CORE_ADDR
729s390_sniff_pc_function_start (CORE_ADDR pc, struct frame_info *fi)
730{
731 CORE_ADDR function_start, test_function_start;
732 int loop_cnt, err, function_end;
733 struct frame_extra_info fextra_info;
734 function_start = get_pc_function_start (pc);
735
736 if (function_start == 0)
737 {
738 test_function_start = pc;
739 if (test_function_start & 1)
740 return 0; /* This has to be bogus */
741 loop_cnt = 0;
742 do
743 {
744
745 err =
746 s390_get_frame_info (test_function_start, &fextra_info, fi, 1);
747 loop_cnt++;
748 test_function_start -= 2;
749 function_end = s390_check_function_end (test_function_start);
750 }
751 while (!(function_end == 1 || err || loop_cnt >= 4096 ||
752 (fextra_info.good_prologue)));
753 if (fextra_info.good_prologue)
754 function_start = fextra_info.function_start;
755 else if (function_end == 1)
756 function_start = test_function_start;
757 }
758 return function_start;
759}
760
761
762
763CORE_ADDR
764s390_function_start (struct frame_info *fi)
765{
766 CORE_ADDR function_start = 0;
767
768 if (fi->extra_info && fi->extra_info->initialised)
769 function_start = fi->extra_info->function_start;
770 else if (fi->pc)
771 function_start = get_pc_function_start (fi->pc);
772 return function_start;
773}
774
775
776
777
778int
779s390_frameless_function_invocation (struct frame_info *fi)
780{
781 struct frame_extra_info fextra_info, *fextra_info_ptr;
782 int frameless = 0;
783
784 if (fi->next == NULL) /* no may be frameless */
785 {
786 if (fi->extra_info)
787 fextra_info_ptr = fi->extra_info;
788 else
789 {
790 fextra_info_ptr = &fextra_info;
791 s390_get_frame_info (s390_sniff_pc_function_start (fi->pc, fi),
792 fextra_info_ptr, fi, 1);
793 }
794 frameless = ((fextra_info_ptr->stack_bought == 0));
795 }
796 return frameless;
797
798}
799
800
801static int
802s390_is_sigreturn (CORE_ADDR pc, struct frame_info *sighandler_fi,
803 CORE_ADDR *sregs, CORE_ADDR *sigcaller_pc)
804{
805 bfd_byte instr[S390_MAX_INSTR_SIZE];
806 disassemble_info info;
807 int instrlen;
808 CORE_ADDR scontext;
809 int retval = 0;
810 CORE_ADDR orig_sp;
811 CORE_ADDR temp_sregs;
812
813 scontext = temp_sregs = 0;
814
815 info.read_memory_func = dis_asm_read_memory;
816 instrlen = s390_readinstruction (instr, pc, &info);
817 if (sigcaller_pc)
818 *sigcaller_pc = 0;
819 if (((instrlen == S390_SYSCALL_SIZE) &&
820 (instr[0] == S390_SYSCALL_OPCODE)) &&
821 ((instr[1] == s390_NR_sigreturn) || (instr[1] == s390_NR_rt_sigreturn)))
822 {
823 if (sighandler_fi)
824 {
825 if (s390_frameless_function_invocation (sighandler_fi))
826 orig_sp = sighandler_fi->frame;
827 else
828 orig_sp = ADDR_BITS_REMOVE ((CORE_ADDR)
829 read_memory_integer (sighandler_fi->
830 frame,
831 S390_GPR_SIZE));
832 if (orig_sp && sigcaller_pc)
833 {
834 scontext = orig_sp + S390_SIGNAL_FRAMESIZE;
835 if (pc == scontext && instr[1] == s390_NR_rt_sigreturn)
836 {
837 /* We got a new style rt_signal */
838 /* get address of read ucontext->uc_mcontext */
839 temp_sregs = orig_sp + (GDB_TARGET_IS_ESAME ?
840 S390X_UC_MCONTEXT_OFFSET :
841 S390_UC_MCONTEXT_OFFSET);
842 }
843 else
844 {
845 /* read sigcontext->sregs */
846 temp_sregs = ADDR_BITS_REMOVE ((CORE_ADDR)
847 read_memory_integer (scontext
848 +
849 (GDB_TARGET_IS_ESAME
850 ?
851 S390X_SIGCONTEXT_SREGS_OFFSET
852 :
853 S390_SIGCONTEXT_SREGS_OFFSET),
854 S390_GPR_SIZE));
855
856 }
857 /* read sigregs->psw.addr */
858 *sigcaller_pc =
859 ADDR_BITS_REMOVE ((CORE_ADDR)
860 read_memory_integer (temp_sregs +
861 REGISTER_BYTE
862 (S390_PC_REGNUM),
863 S390_PSW_ADDR_SIZE));
864 }
865 }
866 retval = 1;
867 }
868 if (sregs)
869 *sregs = temp_sregs;
870 return retval;
871}
872
873/*
874 We need to do something better here but this will keep us out of trouble
875 for the moment.
876 For some reason the blockframe.c calls us with fi->next->fromleaf
877 so this seems of little use to us. */
878void
879s390_init_frame_pc_first (int next_fromleaf, struct frame_info *fi)
880{
881 CORE_ADDR sigcaller_pc;
882
883 fi->pc = 0;
884 if (next_fromleaf)
885 {
886 fi->pc = ADDR_BITS_REMOVE (read_register (S390_RETADDR_REGNUM));
887 /* fix signal handlers */
888 }
889 else if (fi->next && fi->next->pc)
890 fi->pc = s390_frame_saved_pc_nofix (fi->next);
891 if (fi->pc && fi->next && fi->next->frame &&
892 s390_is_sigreturn (fi->pc, fi->next, NULL, &sigcaller_pc))
893 {
894 fi->pc = sigcaller_pc;
895 }
896
897}
898
899void
900s390_init_extra_frame_info (int fromleaf, struct frame_info *fi)
901{
902 fi->extra_info = frame_obstack_alloc (sizeof (struct frame_extra_info));
903 if (fi->pc)
904 s390_get_frame_info (s390_sniff_pc_function_start (fi->pc, fi),
905 fi->extra_info, fi, 1);
906 else
907 s390_memset_extra_info (fi->extra_info);
908}
909
910/* If saved registers of frame FI are not known yet, read and cache them.
911 &FEXTRA_INFOP contains struct frame_extra_info; TDATAP can be NULL,
912 in which case the framedata are read. */
913
914void
915s390_frame_init_saved_regs (struct frame_info *fi)
916{
917
918 int quick;
919
920 if (fi->saved_regs == NULL)
921 {
922 /* zalloc memsets the saved regs */
923 frame_saved_regs_zalloc (fi);
924 if (fi->pc)
925 {
926 quick = (fi->extra_info && fi->extra_info->initialised
927 && fi->extra_info->good_prologue);
928 s390_get_frame_info (quick ? fi->extra_info->function_start :
929 s390_sniff_pc_function_start (fi->pc, fi),
930 fi->extra_info, fi, !quick);
931 }
932 }
933}
934
935
936
937CORE_ADDR
938s390_frame_args_address (struct frame_info *fi)
939{
940
941 /* Apparently gdb already knows gdb_args_offset itself */
942 return fi->frame;
943}
944
945
946static CORE_ADDR
947s390_frame_saved_pc_nofix (struct frame_info *fi)
948{
949 if (fi->extra_info && fi->extra_info->saved_pc_valid)
950 return fi->extra_info->saved_pc;
5c3cf190
JB
951
952 if (generic_find_dummy_frame (fi->pc, fi->frame))
953 return generic_read_register_dummy (fi->pc, fi->frame, S390_PC_REGNUM);
954
5769d3cd
AC
955 s390_frame_init_saved_regs (fi);
956 if (fi->extra_info)
957 {
958 fi->extra_info->saved_pc_valid = 1;
959 if (fi->extra_info->good_prologue)
960 {
961 if (fi->saved_regs[S390_RETADDR_REGNUM])
962 {
963 return (fi->extra_info->saved_pc =
964 ADDR_BITS_REMOVE (read_memory_integer
965 (fi->saved_regs[S390_RETADDR_REGNUM],
966 S390_GPR_SIZE)));
967 }
d0ad30c9
JB
968 else
969 return read_register (S390_RETADDR_REGNUM);
5769d3cd
AC
970 }
971 }
972 return 0;
973}
974
975CORE_ADDR
976s390_frame_saved_pc (struct frame_info *fi)
977{
978 CORE_ADDR saved_pc = 0, sig_pc;
979
980 if (fi->extra_info && fi->extra_info->sig_fixed_saved_pc_valid)
981 return fi->extra_info->sig_fixed_saved_pc;
982 saved_pc = s390_frame_saved_pc_nofix (fi);
983
984 if (fi->extra_info)
985 {
986 fi->extra_info->sig_fixed_saved_pc_valid = 1;
987 if (saved_pc)
988 {
989 if (s390_is_sigreturn (saved_pc, fi, NULL, &sig_pc))
990 saved_pc = sig_pc;
991 }
992 fi->extra_info->sig_fixed_saved_pc = saved_pc;
993 }
994 return saved_pc;
995}
996
997
998
999
1000/* We want backtraces out of signal handlers so we don't
1001 set thisframe->signal_handler_caller to 1 */
1002
1003CORE_ADDR
1004s390_frame_chain (struct frame_info *thisframe)
1005{
1006 CORE_ADDR prev_fp = 0;
1007
1008 if (thisframe->prev && thisframe->prev->frame)
1009 prev_fp = thisframe->prev->frame;
5c3cf190
JB
1010 else if (generic_find_dummy_frame (thisframe->pc, thisframe->frame))
1011 return generic_read_register_dummy (thisframe->pc, thisframe->frame,
1012 S390_SP_REGNUM);
5769d3cd
AC
1013 else
1014 {
1015 int sigreturn = 0;
1016 CORE_ADDR sregs = 0;
1017 struct frame_extra_info prev_fextra_info;
1018
1019 memset (&prev_fextra_info, 0, sizeof (prev_fextra_info));
1020 if (thisframe->pc)
1021 {
1022 CORE_ADDR saved_pc, sig_pc;
1023
1024 saved_pc = s390_frame_saved_pc_nofix (thisframe);
1025 if (saved_pc)
1026 {
1027 if ((sigreturn =
1028 s390_is_sigreturn (saved_pc, thisframe, &sregs, &sig_pc)))
1029 saved_pc = sig_pc;
1030 s390_get_frame_info (s390_sniff_pc_function_start
1031 (saved_pc, NULL), &prev_fextra_info, NULL,
1032 1);
1033 }
1034 }
1035 if (sigreturn)
1036 {
1037 /* read sigregs,regs.gprs[11 or 15] */
1038 prev_fp = read_memory_integer (sregs +
1039 REGISTER_BYTE (S390_GP0_REGNUM +
1040 (prev_fextra_info.
1041 frame_pointer_saved_pc
1042 ? 11 : 15)),
1043 S390_GPR_SIZE);
1044 thisframe->extra_info->sigcontext = sregs;
1045 }
1046 else
1047 {
1048 if (thisframe->saved_regs)
1049 {
5769d3cd
AC
1050 int regno;
1051
31c4d430
JB
1052 if (prev_fextra_info.frame_pointer_saved_pc
1053 && thisframe->saved_regs[S390_FRAME_REGNUM])
1054 regno = S390_FRAME_REGNUM;
1055 else
1056 regno = S390_SP_REGNUM;
1057
5769d3cd 1058 if (thisframe->saved_regs[regno])
31c4d430
JB
1059 {
1060 /* The SP's entry of `saved_regs' is special. */
1061 if (regno == S390_SP_REGNUM)
1062 prev_fp = thisframe->saved_regs[regno];
1063 else
1064 prev_fp =
1065 read_memory_integer (thisframe->saved_regs[regno],
1066 S390_GPR_SIZE);
1067 }
5769d3cd
AC
1068 }
1069 }
1070 }
1071 return ADDR_BITS_REMOVE (prev_fp);
1072}
1073
1074/*
1075 Whether struct frame_extra_info is actually needed I'll have to figure
1076 out as our frames are similar to rs6000 there is a possibility
1077 i386 dosen't need it. */
1078
1079
1080
1081/* a given return value in `regbuf' with a type `valtype', extract and copy its
1082 value into `valbuf' */
1083void
1084s390_extract_return_value (struct type *valtype, char *regbuf, char *valbuf)
1085{
1086 /* floats and doubles are returned in fpr0. fpr's have a size of 8 bytes.
1087 We need to truncate the return value into float size (4 byte) if
1088 necessary. */
1089 int len = TYPE_LENGTH (valtype);
1090
1091 if (TYPE_CODE (valtype) == TYPE_CODE_FLT)
f2c6cfba 1092 memcpy (valbuf, &regbuf[REGISTER_BYTE (S390_FP0_REGNUM)], len);
5769d3cd
AC
1093 else
1094 {
1095 int offset = 0;
1096 /* return value is copied starting from r2. */
1097 if (TYPE_LENGTH (valtype) < S390_GPR_SIZE)
1098 offset = S390_GPR_SIZE - TYPE_LENGTH (valtype);
1099 memcpy (valbuf,
1100 regbuf + REGISTER_BYTE (S390_GP0_REGNUM + 2) + offset,
1101 TYPE_LENGTH (valtype));
1102 }
1103}
1104
1105
1106static char *
1107s390_promote_integer_argument (struct type *valtype, char *valbuf,
1108 char *reg_buff, int *arglen)
1109{
1110 char *value = valbuf;
1111 int len = TYPE_LENGTH (valtype);
1112
1113 if (len < S390_GPR_SIZE)
1114 {
1115 /* We need to upgrade this value to a register to pass it correctly */
1116 int idx, diff = S390_GPR_SIZE - len, negative =
1117 (!TYPE_UNSIGNED (valtype) && value[0] & 0x80);
1118 for (idx = 0; idx < S390_GPR_SIZE; idx++)
1119 {
1120 reg_buff[idx] = (idx < diff ? (negative ? 0xff : 0x0) :
1121 value[idx - diff]);
1122 }
1123 value = reg_buff;
1124 *arglen = S390_GPR_SIZE;
1125 }
1126 else
1127 {
1128 if (len & (S390_GPR_SIZE - 1))
1129 {
1130 fprintf_unfiltered (gdb_stderr,
1131 "s390_promote_integer_argument detected an argument not "
1132 "a multiple of S390_GPR_SIZE & greater than S390_GPR_SIZE "
1133 "we might not deal with this correctly.\n");
1134 }
1135 *arglen = len;
1136 }
1137
1138 return (value);
1139}
1140
1141void
1142s390_store_return_value (struct type *valtype, char *valbuf)
1143{
1144 int arglen;
1145 char *reg_buff = alloca (max (S390_FPR_SIZE, REGISTER_SIZE)), *value;
1146
1147 if (TYPE_CODE (valtype) == TYPE_CODE_FLT)
1148 {
03a013f4
JB
1149 if (TYPE_LENGTH (valtype) == 4
1150 || TYPE_LENGTH (valtype) == 8)
1151 write_register_bytes (REGISTER_BYTE (S390_FP0_REGNUM), valbuf,
1152 TYPE_LENGTH (valtype));
1153 else
1154 error ("GDB is unable to return `long double' values "
1155 "on this architecture.");
5769d3cd
AC
1156 }
1157 else
1158 {
1159 value =
1160 s390_promote_integer_argument (valtype, valbuf, reg_buff, &arglen);
1161 /* Everything else is returned in GPR2 and up. */
1162 write_register_bytes (REGISTER_BYTE (S390_GP0_REGNUM + 2), value,
1163 arglen);
1164 }
1165}
1166static int
1167gdb_print_insn_s390 (bfd_vma memaddr, disassemble_info * info)
1168{
1169 bfd_byte instrbuff[S390_MAX_INSTR_SIZE];
1170 int instrlen, cnt;
1171
1172 instrlen = s390_readinstruction (instrbuff, (CORE_ADDR) memaddr, info);
1173 if (instrlen < 0)
1174 {
1175 (*info->memory_error_func) (instrlen, memaddr, info);
1176 return -1;
1177 }
1178 for (cnt = 0; cnt < instrlen; cnt++)
1179 info->fprintf_func (info->stream, "%02X ", instrbuff[cnt]);
1180 for (cnt = instrlen; cnt < S390_MAX_INSTR_SIZE; cnt++)
1181 info->fprintf_func (info->stream, " ");
1182 instrlen = print_insn_s390 (memaddr, info);
1183 return instrlen;
1184}
1185
1186
1187
1188/* Not the most efficent code in the world */
1189int
1190s390_fp_regnum ()
1191{
1192 int regno = S390_SP_REGNUM;
1193 struct frame_extra_info fextra_info;
1194
1195 CORE_ADDR pc = ADDR_BITS_REMOVE (read_register (S390_PC_REGNUM));
1196
1197 s390_get_frame_info (s390_sniff_pc_function_start (pc, NULL), &fextra_info,
1198 NULL, 1);
1199 if (fextra_info.frame_pointer_saved_pc)
1200 regno = S390_FRAME_REGNUM;
1201 return regno;
1202}
1203
1204CORE_ADDR
1205s390_read_fp ()
1206{
1207 return read_register (s390_fp_regnum ());
1208}
1209
1210
1211void
1212s390_write_fp (CORE_ADDR val)
1213{
1214 write_register (s390_fp_regnum (), val);
1215}
1216
1217
4c8287ac
JB
1218static void
1219s390_pop_frame_regular (struct frame_info *frame)
5769d3cd 1220{
4c8287ac
JB
1221 int regnum;
1222
1223 write_register (S390_PC_REGNUM, FRAME_SAVED_PC (frame));
1224
1225 /* Restore any saved registers. */
1226 for (regnum = 0; regnum < NUM_REGS; regnum++)
1227 if (frame->saved_regs[regnum] != 0)
1228 {
1229 ULONGEST value;
1230
1231 value = read_memory_unsigned_integer (frame->saved_regs[regnum],
1232 REGISTER_RAW_SIZE (regnum));
1233 write_register (regnum, value);
1234 }
5769d3cd 1235
9a1befc9
JB
1236 /* Actually cut back the stack. Remember that the SP's element of
1237 saved_regs is the old SP itself, not the address at which it is
1238 saved. */
1239 write_register (S390_SP_REGNUM, frame->saved_regs[S390_SP_REGNUM]);
5769d3cd 1240
4c8287ac
JB
1241 /* Throw away any cached frame information. */
1242 flush_cached_frames ();
5769d3cd
AC
1243}
1244
4c8287ac
JB
1245
1246/* Destroy the innermost (Top-Of-Stack) stack frame, restoring the
1247 machine state that was in effect before the frame was created.
1248 Used in the contexts of the "return" command, and of
1249 target function calls from the debugger. */
1250void
1251s390_pop_frame ()
1252{
1253 /* This function checks for and handles generic dummy frames, and
1254 calls back to our function for ordinary frames. */
1255 generic_pop_current_frame (s390_pop_frame_regular);
1256}
1257
1258
78f8b424
JB
1259/* Return non-zero if TYPE is an integer-like type, zero otherwise.
1260 "Integer-like" types are those that should be passed the way
1261 integers are: integers, enums, ranges, characters, and booleans. */
1262static int
1263is_integer_like (struct type *type)
1264{
1265 enum type_code code = TYPE_CODE (type);
1266
1267 return (code == TYPE_CODE_INT
1268 || code == TYPE_CODE_ENUM
1269 || code == TYPE_CODE_RANGE
1270 || code == TYPE_CODE_CHAR
1271 || code == TYPE_CODE_BOOL);
1272}
1273
1274
1275/* Return non-zero if TYPE is a pointer-like type, zero otherwise.
1276 "Pointer-like" types are those that should be passed the way
1277 pointers are: pointers and references. */
1278static int
1279is_pointer_like (struct type *type)
1280{
1281 enum type_code code = TYPE_CODE (type);
1282
1283 return (code == TYPE_CODE_PTR
1284 || code == TYPE_CODE_REF);
1285}
1286
1287
20a940cc
JB
1288/* Return non-zero if TYPE is a `float singleton' or `double
1289 singleton', zero otherwise.
1290
1291 A `T singleton' is a struct type with one member, whose type is
1292 either T or a `T singleton'. So, the following are all float
1293 singletons:
1294
1295 struct { float x };
1296 struct { struct { float x; } x; };
1297 struct { struct { struct { float x; } x; } x; };
1298
1299 ... and so on.
1300
1301 WHY THE HECK DO WE CARE ABOUT THIS??? Well, it turns out that GCC
1302 passes all float singletons and double singletons as if they were
1303 simply floats or doubles. This is *not* what the ABI says it
1304 should do. */
1305static int
1306is_float_singleton (struct type *type)
1307{
1308 return (TYPE_CODE (type) == TYPE_CODE_STRUCT
1309 && TYPE_NFIELDS (type) == 1
1310 && (TYPE_CODE (TYPE_FIELD_TYPE (type, 0)) == TYPE_CODE_FLT
1311 || is_float_singleton (TYPE_FIELD_TYPE (type, 0))));
1312}
1313
1314
1315/* Return non-zero if TYPE is a struct-like type, zero otherwise.
1316 "Struct-like" types are those that should be passed as structs are:
1317 structs and unions.
1318
1319 As an odd quirk, not mentioned in the ABI, GCC passes float and
1320 double singletons as if they were a plain float, double, etc. (The
1321 corresponding union types are handled normally.) So we exclude
1322 those types here. *shrug* */
1323static int
1324is_struct_like (struct type *type)
1325{
1326 enum type_code code = TYPE_CODE (type);
1327
1328 return (code == TYPE_CODE_UNION
1329 || (code == TYPE_CODE_STRUCT && ! is_float_singleton (type)));
1330}
1331
1332
1333/* Return non-zero if TYPE is a float-like type, zero otherwise.
1334 "Float-like" types are those that should be passed as
1335 floating-point values are.
1336
1337 You'd think this would just be floats, doubles, long doubles, etc.
1338 But as an odd quirk, not mentioned in the ABI, GCC passes float and
1339 double singletons as if they were a plain float, double, etc. (The
1340 corresponding union types are handled normally.) So we exclude
1341 those types here. *shrug* */
1342static int
1343is_float_like (struct type *type)
1344{
1345 return (TYPE_CODE (type) == TYPE_CODE_FLT
1346 || is_float_singleton (type));
1347}
1348
1349
78f8b424
JB
1350/* Return non-zero if TYPE is considered a `DOUBLE_OR_FLOAT', as
1351 defined by the parameter passing conventions described in the
1352 "Linux for S/390 ELF Application Binary Interface Supplement".
1353 Otherwise, return zero. */
1354static int
1355is_double_or_float (struct type *type)
1356{
20a940cc 1357 return (is_float_like (type)
78f8b424
JB
1358 && (TYPE_LENGTH (type) == 4
1359 || TYPE_LENGTH (type) == 8));
1360}
1361
5769d3cd 1362
78f8b424
JB
1363/* Return non-zero if TYPE is considered a `SIMPLE_ARG', as defined by
1364 the parameter passing conventions described in the "Linux for S/390
1365 ELF Application Binary Interface Supplement". Return zero otherwise. */
1366static int
1367is_simple_arg (struct type *type)
1368{
78f8b424
JB
1369 unsigned length = TYPE_LENGTH (type);
1370
a1677dfb
JB
1371 /* This is almost a direct translation of the ABI's language, except
1372 that we have to exclude 8-byte structs; those are DOUBLE_ARGs. */
78f8b424
JB
1373 return ((is_integer_like (type) && length <= 4)
1374 || is_pointer_like (type)
20a940cc
JB
1375 || (is_struct_like (type) && length != 8)
1376 || (is_float_like (type) && length == 16));
78f8b424
JB
1377}
1378
1379
1380/* Return non-zero if TYPE should be passed as a pointer to a copy,
1381 zero otherwise. TYPE must be a SIMPLE_ARG, as recognized by
1382 `is_simple_arg'. */
1383static int
1384pass_by_copy_ref (struct type *type)
1385{
78f8b424
JB
1386 unsigned length = TYPE_LENGTH (type);
1387
20a940cc
JB
1388 return ((is_struct_like (type) && length != 1 && length != 2 && length != 4)
1389 || (is_float_like (type) && length == 16));
78f8b424
JB
1390}
1391
1392
1393/* Return ARG, a `SIMPLE_ARG', sign-extended or zero-extended to a full
1394 word as required for the ABI. */
1395static LONGEST
1396extend_simple_arg (struct value *arg)
1397{
1398 struct type *type = VALUE_TYPE (arg);
1399
1400 /* Even structs get passed in the least significant bits of the
1401 register / memory word. It's not really right to extract them as
1402 an integer, but it does take care of the extension. */
1403 if (TYPE_UNSIGNED (type))
1404 return extract_unsigned_integer (VALUE_CONTENTS (arg),
1405 TYPE_LENGTH (type));
1406 else
1407 return extract_signed_integer (VALUE_CONTENTS (arg),
1408 TYPE_LENGTH (type));
1409}
1410
1411
1412/* Return non-zero if TYPE is a `DOUBLE_ARG', as defined by the
1413 parameter passing conventions described in the "Linux for S/390 ELF
1414 Application Binary Interface Supplement". Return zero otherwise. */
1415static int
1416is_double_arg (struct type *type)
1417{
78f8b424
JB
1418 unsigned length = TYPE_LENGTH (type);
1419
1420 return ((is_integer_like (type)
20a940cc 1421 || is_struct_like (type))
78f8b424
JB
1422 && length == 8);
1423}
1424
1425
1426/* Round ADDR up to the next N-byte boundary. N must be a power of
1427 two. */
1428static CORE_ADDR
1429round_up (CORE_ADDR addr, int n)
1430{
1431 /* Check that N is really a power of two. */
1432 gdb_assert (n && (n & (n-1)) == 0);
1433 return ((addr + n - 1) & -n);
1434}
1435
1436
1437/* Round ADDR down to the next N-byte boundary. N must be a power of
1438 two. */
1439static CORE_ADDR
1440round_down (CORE_ADDR addr, int n)
1441{
1442 /* Check that N is really a power of two. */
1443 gdb_assert (n && (n & (n-1)) == 0);
1444 return (addr & -n);
1445}
1446
1447
1448/* Return the alignment required by TYPE. */
1449static int
1450alignment_of (struct type *type)
1451{
1452 int alignment;
1453
1454 if (is_integer_like (type)
1455 || is_pointer_like (type)
1456 || TYPE_CODE (type) == TYPE_CODE_FLT)
1457 alignment = TYPE_LENGTH (type);
1458 else if (TYPE_CODE (type) == TYPE_CODE_STRUCT
1459 || TYPE_CODE (type) == TYPE_CODE_UNION)
1460 {
1461 int i;
1462
1463 alignment = 1;
1464 for (i = 0; i < TYPE_NFIELDS (type); i++)
1465 {
1466 int field_alignment = alignment_of (TYPE_FIELD_TYPE (type, i));
1467
1468 if (field_alignment > alignment)
1469 alignment = field_alignment;
1470 }
1471 }
1472 else
1473 alignment = 1;
1474
1475 /* Check that everything we ever return is a power of two. Lots of
1476 code doesn't want to deal with aligning things to arbitrary
1477 boundaries. */
1478 gdb_assert ((alignment & (alignment - 1)) == 0);
1479
1480 return alignment;
1481}
1482
1483
1484/* Put the actual parameter values pointed to by ARGS[0..NARGS-1] in
1485 place to be passed to a function, as specified by the "Linux for
1486 S/390 ELF Application Binary Interface Supplement".
1487
1488 SP is the current stack pointer. We must put arguments, links,
1489 padding, etc. whereever they belong, and return the new stack
1490 pointer value.
1491
1492 If STRUCT_RETURN is non-zero, then the function we're calling is
1493 going to return a structure by value; STRUCT_ADDR is the address of
1494 a block we've allocated for it on the stack.
1495
1496 Our caller has taken care of any type promotions needed to satisfy
1497 prototypes or the old K&R argument-passing rules. */
5769d3cd 1498CORE_ADDR
d45fc520 1499s390_push_arguments (int nargs, struct value **args, CORE_ADDR sp,
5769d3cd
AC
1500 int struct_return, CORE_ADDR struct_addr)
1501{
78f8b424
JB
1502 int i;
1503 int pointer_size = (TARGET_PTR_BIT / TARGET_CHAR_BIT);
5769d3cd 1504
78f8b424
JB
1505 /* The number of arguments passed by reference-to-copy. */
1506 int num_copies;
5769d3cd 1507
78f8b424
JB
1508 /* If the i'th argument is passed as a reference to a copy, then
1509 copy_addr[i] is the address of the copy we made. */
1510 CORE_ADDR *copy_addr = alloca (nargs * sizeof (CORE_ADDR));
5769d3cd 1511
78f8b424
JB
1512 /* Build the reference-to-copy area. */
1513 num_copies = 0;
1514 for (i = 0; i < nargs; i++)
1515 {
1516 struct value *arg = args[i];
1517 struct type *type = VALUE_TYPE (arg);
1518 unsigned length = TYPE_LENGTH (type);
5769d3cd 1519
78f8b424
JB
1520 if (is_simple_arg (type)
1521 && pass_by_copy_ref (type))
01c464e9 1522 {
78f8b424
JB
1523 sp -= length;
1524 sp = round_down (sp, alignment_of (type));
1525 write_memory (sp, VALUE_CONTENTS (arg), length);
1526 copy_addr[i] = sp;
1527 num_copies++;
01c464e9 1528 }
5769d3cd 1529 }
5769d3cd 1530
78f8b424
JB
1531 /* Reserve space for the parameter area. As a conservative
1532 simplification, we assume that everything will be passed on the
1533 stack. */
1534 {
1535 int i;
1536
1537 for (i = 0; i < nargs; i++)
1538 {
1539 struct value *arg = args[i];
1540 struct type *type = VALUE_TYPE (arg);
1541 int length = TYPE_LENGTH (type);
1542
1543 sp = round_down (sp, alignment_of (type));
1544
1545 /* SIMPLE_ARG values get extended to 32 bits. Assume every
1546 argument is. */
1547 if (length < 4) length = 4;
1548 sp -= length;
1549 }
1550 }
1551
1552 /* Include space for any reference-to-copy pointers. */
1553 sp = round_down (sp, pointer_size);
1554 sp -= num_copies * pointer_size;
1555
1556 /* After all that, make sure it's still aligned on an eight-byte
1557 boundary. */
1558 sp = round_down (sp, 8);
1559
1560 /* Finally, place the actual parameters, working from SP towards
1561 higher addresses. The code above is supposed to reserve enough
1562 space for this. */
1563 {
1564 int fr = 0;
1565 int gr = 2;
1566 CORE_ADDR starg = sp;
1567
1568 for (i = 0; i < nargs; i++)
1569 {
1570 struct value *arg = args[i];
1571 struct type *type = VALUE_TYPE (arg);
1572
1573 if (is_double_or_float (type)
1574 && fr <= 2)
1575 {
1576 /* When we store a single-precision value in an FP register,
1577 it occupies the leftmost bits. */
1578 write_register_bytes (REGISTER_BYTE (S390_FP0_REGNUM + fr),
1579 VALUE_CONTENTS (arg),
1580 TYPE_LENGTH (type));
1581 fr += 2;
1582 }
1583 else if (is_simple_arg (type)
1584 && gr <= 6)
1585 {
1586 /* Do we need to pass a pointer to our copy of this
1587 argument? */
1588 if (pass_by_copy_ref (type))
1589 write_register (S390_GP0_REGNUM + gr, copy_addr[i]);
1590 else
1591 write_register (S390_GP0_REGNUM + gr, extend_simple_arg (arg));
1592
1593 gr++;
1594 }
1595 else if (is_double_arg (type)
1596 && gr <= 5)
1597 {
1598 write_register_gen (S390_GP0_REGNUM + gr,
1599 VALUE_CONTENTS (arg));
1600 write_register_gen (S390_GP0_REGNUM + gr + 1,
1601 VALUE_CONTENTS (arg) + 4);
1602 gr += 2;
1603 }
1604 else
1605 {
1606 /* The `OTHER' case. */
1607 enum type_code code = TYPE_CODE (type);
1608 unsigned length = TYPE_LENGTH (type);
1609
1610 /* If we skipped r6 because we couldn't fit a DOUBLE_ARG
1611 in it, then don't go back and use it again later. */
1612 if (is_double_arg (type) && gr == 6)
1613 gr = 7;
1614
1615 if (is_simple_arg (type))
1616 {
1617 /* Simple args are always either extended to 32 bits,
1618 or pointers. */
1619 starg = round_up (starg, 4);
1620
1621 /* Do we need to pass a pointer to our copy of this
1622 argument? */
1623 if (pass_by_copy_ref (type))
1624 write_memory_signed_integer (starg, pointer_size,
1625 copy_addr[i]);
1626 else
1627 /* Simple args are always extended to 32 bits. */
1628 write_memory_signed_integer (starg, 4,
1629 extend_simple_arg (arg));
1630 starg += 4;
1631 }
1632 else
1633 {
20a940cc
JB
1634 /* You'd think we should say:
1635 starg = round_up (starg, alignment_of (type));
1636 Unfortunately, GCC seems to simply align the stack on
1637 a four-byte boundary, even when passing doubles. */
1638 starg = round_up (starg, 4);
78f8b424
JB
1639 write_memory (starg, VALUE_CONTENTS (arg), length);
1640 starg += length;
1641 }
1642 }
1643 }
1644 }
1645
1646 /* Allocate the standard frame areas: the register save area, the
1647 word reserved for the compiler (which seems kind of meaningless),
1648 and the back chain pointer. */
1649 sp -= 96;
1650
1651 /* Write the back chain pointer into the first word of the stack
1652 frame. This will help us get backtraces from within functions
1653 called from GDB. */
1654 write_memory_unsigned_integer (sp, (TARGET_PTR_BIT / TARGET_CHAR_BIT),
1655 read_fp ());
1656
1657 return sp;
5769d3cd
AC
1658}
1659
c8f9d51c
JB
1660
1661static int
1662s390_use_struct_convention (int gcc_p, struct type *value_type)
1663{
1664 enum type_code code = TYPE_CODE (value_type);
1665
1666 return (code == TYPE_CODE_STRUCT
1667 || code == TYPE_CODE_UNION);
1668}
1669
1670
5769d3cd
AC
1671/* Return the GDB type object for the "standard" data type
1672 of data in register N. */
1673struct type *
1674s390_register_virtual_type (int regno)
1675{
b09677dc
JB
1676 if (S390_FP0_REGNUM <= regno && regno < S390_FP0_REGNUM + S390_NUM_FPRS)
1677 return builtin_type_double;
1678 else
1679 return builtin_type_int;
5769d3cd
AC
1680}
1681
1682
1683struct type *
1684s390x_register_virtual_type (int regno)
1685{
1686 return (regno == S390_FPC_REGNUM) ||
1687 (regno >= S390_FIRST_ACR && regno <= S390_LAST_ACR) ? builtin_type_int :
1688 (regno >= S390_FP0_REGNUM) ? builtin_type_double : builtin_type_long;
1689}
1690
1691
1692
1693void
1694s390_store_struct_return (CORE_ADDR addr, CORE_ADDR sp)
1695{
1696 write_register (S390_GP0_REGNUM + 2, addr);
1697}
1698
1699
1700
1701static unsigned char *
1702s390_breakpoint_from_pc (CORE_ADDR *pcptr, int *lenptr)
1703{
1704 static unsigned char breakpoint[] = { 0x0, 0x1 };
1705
1706 *lenptr = sizeof (breakpoint);
1707 return breakpoint;
1708}
1709
1710/* Advance PC across any function entry prologue instructions to reach some
1711 "real" code. */
1712CORE_ADDR
1713s390_skip_prologue (CORE_ADDR pc)
1714{
1715 struct frame_extra_info fextra_info;
1716
1717 s390_get_frame_info (pc, &fextra_info, NULL, 1);
1718 return fextra_info.skip_prologue_function_start;
1719}
1720
5769d3cd
AC
1721/* Immediately after a function call, return the saved pc.
1722 Can't go through the frames for this because on some machines
1723 the new frame is not set up until the new function executes
1724 some instructions. */
1725CORE_ADDR
1726s390_saved_pc_after_call (struct frame_info *frame)
1727{
1728 return ADDR_BITS_REMOVE (read_register (S390_RETADDR_REGNUM));
1729}
1730
1731static CORE_ADDR
1732s390_addr_bits_remove (CORE_ADDR addr)
1733{
1734 return (addr) & 0x7fffffff;
1735}
1736
1737
1738static CORE_ADDR
1739s390_push_return_address (CORE_ADDR pc, CORE_ADDR sp)
1740{
d4d0c21e 1741 write_register (S390_RETADDR_REGNUM, CALL_DUMMY_ADDRESS ());
5769d3cd
AC
1742 return sp;
1743}
1744
1745struct gdbarch *
1746s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
1747{
d4d0c21e 1748 static LONGEST s390_call_dummy_words[] = { 0 };
5769d3cd
AC
1749 struct gdbarch *gdbarch;
1750 struct gdbarch_tdep *tdep;
1751 int elf_flags;
1752
1753 /* First see if there is already a gdbarch that can satisfy the request. */
1754 arches = gdbarch_list_lookup_by_info (arches, &info);
1755 if (arches != NULL)
1756 return arches->gdbarch;
1757
1758 /* None found: is the request for a s390 architecture? */
1759 if (info.bfd_arch_info->arch != bfd_arch_s390)
1760 return NULL; /* No; then it's not for us. */
1761
1762 /* Yes: create a new gdbarch for the specified machine type. */
1763 gdbarch = gdbarch_alloc (&info, NULL);
1764
1765 set_gdbarch_believe_pcc_promotion (gdbarch, 0);
4e409299 1766 set_gdbarch_char_signed (gdbarch, 0);
5769d3cd 1767
5769d3cd
AC
1768 set_gdbarch_frame_args_skip (gdbarch, 0);
1769 set_gdbarch_frame_args_address (gdbarch, s390_frame_args_address);
1770 set_gdbarch_frame_chain (gdbarch, s390_frame_chain);
1771 set_gdbarch_frame_init_saved_regs (gdbarch, s390_frame_init_saved_regs);
1772 set_gdbarch_frame_locals_address (gdbarch, s390_frame_args_address);
1773 /* We can't do this */
1774 set_gdbarch_frame_num_args (gdbarch, frame_num_args_unknown);
1775 set_gdbarch_store_struct_return (gdbarch, s390_store_struct_return);
1776 set_gdbarch_extract_return_value (gdbarch, s390_extract_return_value);
1777 set_gdbarch_store_return_value (gdbarch, s390_store_return_value);
1778 /* Amount PC must be decremented by after a breakpoint.
1779 This is often the number of bytes in BREAKPOINT
1780 but not always. */
1781 set_gdbarch_decr_pc_after_break (gdbarch, 2);
1782 set_gdbarch_pop_frame (gdbarch, s390_pop_frame);
5769d3cd
AC
1783 set_gdbarch_ieee_float (gdbarch, 1);
1784 /* Stack grows downward. */
1785 set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
1786 /* Offset from address of function to start of its code.
1787 Zero on most machines. */
1788 set_gdbarch_function_start_offset (gdbarch, 0);
1789 set_gdbarch_max_register_raw_size (gdbarch, 8);
1790 set_gdbarch_max_register_virtual_size (gdbarch, 8);
1791 set_gdbarch_breakpoint_from_pc (gdbarch, s390_breakpoint_from_pc);
1792 set_gdbarch_skip_prologue (gdbarch, s390_skip_prologue);
1793 set_gdbarch_init_extra_frame_info (gdbarch, s390_init_extra_frame_info);
1794 set_gdbarch_init_frame_pc_first (gdbarch, s390_init_frame_pc_first);
1795 set_gdbarch_read_fp (gdbarch, s390_read_fp);
1796 set_gdbarch_write_fp (gdbarch, s390_write_fp);
1797 /* This function that tells us whether the function invocation represented
1798 by FI does not have a frame on the stack associated with it. If it
1799 does not, FRAMELESS is set to 1, else 0. */
1800 set_gdbarch_frameless_function_invocation (gdbarch,
1801 s390_frameless_function_invocation);
1802 /* Return saved PC from a frame */
1803 set_gdbarch_frame_saved_pc (gdbarch, s390_frame_saved_pc);
1804 /* FRAME_CHAIN takes a frame's nominal address
1805 and produces the frame's chain-pointer. */
1806 set_gdbarch_frame_chain (gdbarch, s390_frame_chain);
1807 set_gdbarch_saved_pc_after_call (gdbarch, s390_saved_pc_after_call);
1808 set_gdbarch_register_byte (gdbarch, s390_register_byte);
1809 set_gdbarch_pc_regnum (gdbarch, S390_PC_REGNUM);
1810 set_gdbarch_sp_regnum (gdbarch, S390_SP_REGNUM);
1811 set_gdbarch_fp_regnum (gdbarch, S390_FP_REGNUM);
1812 set_gdbarch_fp0_regnum (gdbarch, S390_FP0_REGNUM);
1813 set_gdbarch_num_regs (gdbarch, S390_NUM_REGS);
1814 set_gdbarch_cannot_fetch_register (gdbarch, s390_cannot_fetch_register);
1815 set_gdbarch_cannot_store_register (gdbarch, s390_cannot_fetch_register);
1816 set_gdbarch_get_saved_register (gdbarch, generic_get_saved_register);
c8f9d51c 1817 set_gdbarch_use_struct_convention (gdbarch, s390_use_struct_convention);
8001d1e4 1818 set_gdbarch_frame_chain_valid (gdbarch, func_frame_chain_valid);
5769d3cd
AC
1819 set_gdbarch_register_name (gdbarch, s390_register_name);
1820 set_gdbarch_stab_reg_to_regnum (gdbarch, s390_stab_reg_to_regnum);
1821 set_gdbarch_dwarf_reg_to_regnum (gdbarch, s390_stab_reg_to_regnum);
1822 set_gdbarch_dwarf2_reg_to_regnum (gdbarch, s390_stab_reg_to_regnum);
c8f9d51c
JB
1823 set_gdbarch_extract_struct_value_address
1824 (gdbarch, generic_cannot_extract_struct_value_address);
5769d3cd 1825
d4d0c21e 1826 /* Parameters for inferior function calls. */
5769d3cd 1827 set_gdbarch_call_dummy_p (gdbarch, 1);
d4d0c21e
JB
1828 set_gdbarch_use_generic_dummy_frames (gdbarch, 1);
1829 set_gdbarch_call_dummy_length (gdbarch, 0);
1830 set_gdbarch_call_dummy_location (gdbarch, AT_ENTRY_POINT);
1831 set_gdbarch_call_dummy_address (gdbarch, entry_point_address);
1832 set_gdbarch_call_dummy_start_offset (gdbarch, 0);
1833 set_gdbarch_pc_in_call_dummy (gdbarch, pc_in_call_dummy_at_entry_point);
1834 set_gdbarch_push_dummy_frame (gdbarch, generic_push_dummy_frame);
1835 set_gdbarch_push_arguments (gdbarch, s390_push_arguments);
5c3cf190 1836 set_gdbarch_save_dummy_frame_tos (gdbarch, generic_save_dummy_frame_tos);
d4d0c21e
JB
1837 set_gdbarch_call_dummy_breakpoint_offset_p (gdbarch, 1);
1838 set_gdbarch_call_dummy_breakpoint_offset (gdbarch, 0);
5769d3cd 1839 set_gdbarch_call_dummy_stack_adjust_p (gdbarch, 0);
d4d0c21e 1840 set_gdbarch_fix_call_dummy (gdbarch, generic_fix_call_dummy);
5769d3cd 1841 set_gdbarch_push_return_address (gdbarch, s390_push_return_address);
d4d0c21e
JB
1842 set_gdbarch_sizeof_call_dummy_words (gdbarch,
1843 sizeof (s390_call_dummy_words));
1844 set_gdbarch_call_dummy_words (gdbarch, s390_call_dummy_words);
0adb2aba
JB
1845 set_gdbarch_coerce_float_to_double (gdbarch,
1846 standard_coerce_float_to_double);
5769d3cd
AC
1847
1848 switch (info.bfd_arch_info->mach)
1849 {
1850 case bfd_mach_s390_esa:
1851 set_gdbarch_register_size (gdbarch, 4);
5769d3cd
AC
1852 set_gdbarch_register_raw_size (gdbarch, s390_register_raw_size);
1853 set_gdbarch_register_virtual_size (gdbarch, s390_register_raw_size);
1854 set_gdbarch_register_virtual_type (gdbarch, s390_register_virtual_type);
1855
1856 set_gdbarch_addr_bits_remove (gdbarch, s390_addr_bits_remove);
5769d3cd
AC
1857 set_gdbarch_register_bytes (gdbarch, S390_REGISTER_BYTES);
1858 break;
1859 case bfd_mach_s390_esame:
1860 set_gdbarch_register_size (gdbarch, 8);
5769d3cd
AC
1861 set_gdbarch_register_raw_size (gdbarch, s390x_register_raw_size);
1862 set_gdbarch_register_virtual_size (gdbarch, s390x_register_raw_size);
1863 set_gdbarch_register_virtual_type (gdbarch,
1864 s390x_register_virtual_type);
1865
1866 set_gdbarch_long_bit (gdbarch, 64);
1867 set_gdbarch_long_long_bit (gdbarch, 64);
1868 set_gdbarch_ptr_bit (gdbarch, 64);
5769d3cd
AC
1869 set_gdbarch_register_bytes (gdbarch, S390X_REGISTER_BYTES);
1870 break;
1871 }
1872
1873 return gdbarch;
1874}
1875
1876
1877
1878void
1879_initialize_s390_tdep ()
1880{
1881
1882 /* Hook us into the gdbarch mechanism. */
1883 register_gdbarch_init (bfd_arch_s390, s390_gdbarch_init);
1884 if (!tm_print_insn) /* Someone may have already set it */
1885 tm_print_insn = gdb_print_insn_s390;
1886}
1887
1888#endif /* GDBSERVER */
This page took 0.169135 seconds and 4 git commands to generate.