* gdb.base/corefile.exp: Recognize the message saying that GDB
[deliverable/binutils-gdb.git] / gdb / s390-tdep.c
index f91b6963454ac543d81e121228a4793fc62e0240..ddeacadd7fe51af0b8016cb941de00e8720af398 100644 (file)
@@ -180,6 +180,14 @@ s390_stab_reg_to_regnum (int regno)
 }
 
 
+/* Return true if REGIDX is the number of a register used to pass
+     arguments, false otherwise.  */
+static int
+is_arg_reg (int regidx)
+{
+  return 2 <= regidx && regidx <= 6;
+}
+
 
 /* s390_get_frame_info based on Hartmuts
    prologue definition in
@@ -208,15 +216,45 @@ s390_get_frame_info (CORE_ADDR pc, struct frame_extra_info *fextra_info,
   int gprs_saved[S390_NUM_GPRS];
   int fprs_saved[S390_NUM_FPRS];
   int regidx, instrlen;
-  int save_link_regidx, subtract_sp_regidx;
-  int const_pool_state, save_link_state;
-  int frame_pointer_found, varargs_state;
+  int const_pool_state;
+  int varargs_state;
   int loop_cnt, gdb_gpr_store, gdb_fpr_store;
-  int frame_pointer_regidx = 0xf;
   int offset, expected_offset;
   int err = 0;
   disassemble_info info;
 
+  /* Have we seen an instruction initializing the frame pointer yet?
+     If we've seen an `lr %r11, %r15', then frame_pointer_found is
+     non-zero, and frame_pointer_regidx == 11.  Otherwise,
+     frame_pointer_found is zero and frame_pointer_regidx is 15,
+     indicating that we're using the stack pointer as our frame
+     pointer.  */
+  int frame_pointer_found = 0;
+  int frame_pointer_regidx = 0xf;
+
+  /* What we've seen so far regarding saving the back chain link:
+     0 -- nothing yet; sp still has the same value it had at the entry
+          point.  Since not all functions allocate frames, this is a
+          valid state for the prologue to finish in.
+     1 -- We've saved the original sp in some register other than the
+          frame pointer (hard-coded to be %r11, yuck).
+          save_link_regidx is the register we saved it in.
+     2 -- We've seen the initial `bras' instruction of the sequence for
+          reserving more than 32k of stack:
+                bras %rX, .+8
+                .long N
+                s %r15, 0(%rX)
+          where %rX is not the constant pool register.
+          subtract_sp_regidx is %rX, and fextra_info->stack_bought is N.
+     3 -- We've reserved space for a new stack frame.  This means we
+          either saw a simple `ahi %r15,-N' in state 1, or the final
+          `s %r15, ...' in state 2.
+     4 -- The frame and link are now fully initialized.  We've
+          reserved space for the new stack frame, and stored the old
+          stack pointer captured in the back chain pointer field.  */
+  int save_link_state = 0;
+  int save_link_regidx, subtract_sp_regidx;
+
   /* What we've seen so far regarding r12 --- the GOT (Global Offset
      Table) pointer.  We expect to see `l %r12, N(%r13)', which loads
      r12 with the offset from the constant pool to the GOT, and then
@@ -228,11 +266,11 @@ s390_get_frame_info (CORE_ADDR pc, struct frame_extra_info *fextra_info,
      When got_state is 1, then got_load_addr is the address of the
      load instruction, and got_load_len is the length of that
      instruction.  */
-  int got_state;
+  int got_state= 0;
   CORE_ADDR got_load_addr = 0, got_load_len = 0;
 
-  const_pool_state = save_link_state = got_state = varargs_state = 0;
-  frame_pointer_found = 0;
+  const_pool_state = varargs_state = 0;
+
   memset (gprs_saved, 0, sizeof (gprs_saved));
   memset (fprs_saved, 0, sizeof (fprs_saved));
   info.read_memory_func = dis_asm_read_memory;
@@ -375,6 +413,28 @@ s390_get_frame_info (CORE_ADDR pc, struct frame_extra_info *fextra_info,
          continue;
        }
 
+      /* Check for an fp-relative STG, ST, or STM.  This is probably
+          spilling an argument from a register out into a stack slot.
+          This could be a user instruction, but if we haven't included
+          any other suspicious instructions in the prologue, this
+          could only be an initializing store, which isn't too bad to
+          skip.  The consequences of not including arg-to-stack spills
+          are more serious, though --- you don't see the proper values
+          of the arguments.  */
+      if ((save_link_state == 3 || save_link_state == 4)
+          && ((instr[0] == 0x50      /* st %rA, D(%rX,%rB) */
+               && (instr[1] & 0xf) == 0 /* %rX is zero, no index reg */
+               && is_arg_reg ((instr[1] >> 4) & 0xf)
+               && ((instr[2] >> 4) & 0xf) == frame_pointer_regidx)
+              || (instr[0] == 0x90 /* stm %rA, %rB, D(%rC) */
+                  && is_arg_reg ((instr[1] >> 4) & 0xf)
+                  && is_arg_reg (instr[1] & 0xf)
+                  && ((instr[2] >> 4) & 0xf) == frame_pointer_regidx)))
+        {
+          valid_prologue = 1;
+          continue;
+        }
+
       /* check for STD */
       if (instr[0] == 0x60 && (instr[2] >> 4) == 0xf)
        {
@@ -493,7 +553,8 @@ s390_get_frame_info (CORE_ADDR pc, struct frame_extra_info *fextra_info,
       /* Alternatively check for the complex construction for
          buying more than 32k of stack
          BRAS gprx,.+8
-         long vals    %r15,0(%gprx)  gprx currently r1 */
+         long val
+         s    %r15,0(%gprx)  gprx currently r1 */
       if ((save_link_state == 1) && (instr[0] == 0xa7)
          && ((instr[1] & 0xf) == 0x5) && (instr[2] == 0)
          && (instr[3] == 0x4) && ((instr[1] >> 4) != CONST_POOL_REGIDX))
@@ -1083,12 +1144,13 @@ s390_store_return_value (struct type *valtype, char *valbuf)
 
   if (TYPE_CODE (valtype) == TYPE_CODE_FLT)
     {
-      DOUBLEST tempfloat = extract_floating (valbuf, TYPE_LENGTH (valtype));
-
-      floatformat_from_doublest (&floatformat_ieee_double_big, &tempfloat,
-                                reg_buff);
-      write_register_bytes (REGISTER_BYTE (S390_FP0_REGNUM), reg_buff,
-                           S390_FPR_SIZE);
+      if (TYPE_LENGTH (valtype) == 4
+          || TYPE_LENGTH (valtype) == 8)
+        write_register_bytes (REGISTER_BYTE (S390_FP0_REGNUM), valbuf,
+                              TYPE_LENGTH (valtype));
+      else
+        error ("GDB is unable to return `long double' values "
+               "on this architecture.");
     }
   else
     {
This page took 0.029781 seconds and 4 git commands to generate.