* gdb.base/maint.exp: Only dump symbols from one source file
[deliverable/binutils-gdb.git] / gdb / s390-tdep.c
index ba8c9a3e31457ec41c7cbccff359f2d63542aa9f..622f285073802204d2a921c47de92585337800ab 100644 (file)
@@ -1,5 +1,7 @@
 /* Target-dependent code for GDB, the GNU debugger.
-   Copyright 2001 Free Software Foundation, Inc.
+
+   Copyright 2001, 2002 Free Software Foundation, Inc.
+
    Contributed by D.J. Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com)
    for IBM Deutschland Entwicklung GmbH, IBM Corporation.
 
@@ -132,8 +134,11 @@ s390_readinstruction (bfd_byte instr[], CORE_ADDR at,
   if ((*info->read_memory_func) (at, &instr[0], 2, info))
     return -1;
   instrlen = s390_instrlen[instr[0] >> 6];
-  if ((*info->read_memory_func) (at + 2, &instr[2], instrlen - 2, info))
-    return -1;
+  if (instrlen > 2)
+    {
+      if ((*info->read_memory_func) (at + 2, &instr[2], instrlen - 2, info))
+        return -1;
+    }
   return instrlen;
 }
 
@@ -145,7 +150,7 @@ s390_memset_extra_info (struct frame_extra_info *fextra_info)
 
 
 
-char *
+const char *
 s390_register_name (int reg_nr)
 {
   static char *register_names[] = {
@@ -161,9 +166,10 @@ s390_register_name (int reg_nr)
     "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15"
   };
 
-  if (reg_nr >= S390_LAST_REGNUM)
+  if (reg_nr <= S390_LAST_REGNUM)
+    return register_names[reg_nr];
+  else
     return NULL;
-  return register_names[reg_nr];
 }
 
 
@@ -281,8 +287,9 @@ s390_get_frame_info (CORE_ADDR pc, struct frame_extra_info *fextra_info,
     {
       if (fi && fi->frame)
        {
+          orig_sp = fi->frame;
           if (! init_extra_info && fextra_info->initialised)
-            orig_sp = fi->frame + fextra_info->stack_bought;
+            orig_sp += fextra_info->stack_bought;
          saved_regs = fi->saved_regs;
        }
       if (init_extra_info || !fextra_info->initialised)
@@ -948,25 +955,23 @@ s390_frame_saved_pc_nofix (struct frame_info *fi)
   if (fi->extra_info && fi->extra_info->saved_pc_valid)
     return fi->extra_info->saved_pc;
 
-  if (generic_find_dummy_frame (fi->pc, fi->frame))
-    return generic_read_register_dummy (fi->pc, fi->frame, S390_PC_REGNUM);
+  if (deprecated_generic_find_dummy_frame (fi->pc, fi->frame))
+    return deprecated_read_register_dummy (fi->pc, fi->frame, S390_PC_REGNUM);
 
   s390_frame_init_saved_regs (fi);
   if (fi->extra_info)
     {
       fi->extra_info->saved_pc_valid = 1;
-      if (fi->extra_info->good_prologue)
-       {
-         if (fi->saved_regs[S390_RETADDR_REGNUM])
-           {
-             return (fi->extra_info->saved_pc =
-                     ADDR_BITS_REMOVE (read_memory_integer
-                                       (fi->saved_regs[S390_RETADDR_REGNUM],
-                                        S390_GPR_SIZE)));
-           }
-          else
-            return read_register (S390_RETADDR_REGNUM);
-       }
+      if (fi->extra_info->good_prologue
+          && fi->saved_regs[S390_RETADDR_REGNUM])
+        fi->extra_info->saved_pc
+          = ADDR_BITS_REMOVE (read_memory_integer
+                              (fi->saved_regs[S390_RETADDR_REGNUM],
+                               S390_GPR_SIZE));
+      else
+        fi->extra_info->saved_pc
+          = ADDR_BITS_REMOVE (read_register (S390_RETADDR_REGNUM));
+      return fi->extra_info->saved_pc;
     }
   return 0;
 }
@@ -996,19 +1001,17 @@ s390_frame_saved_pc (struct frame_info *fi)
 
 
 
-/* We want backtraces out of signal handlers so we don't
-   set thisframe->signal_handler_caller to 1 */
+/* We want backtraces out of signal handlers so we don't set
+   (get_frame_type (thisframe) == SIGTRAMP_FRAME) to 1 */
 
 CORE_ADDR
 s390_frame_chain (struct frame_info *thisframe)
 {
   CORE_ADDR prev_fp = 0;
 
-  if (thisframe->prev && thisframe->prev->frame)
-    prev_fp = thisframe->prev->frame;
-  else if (generic_find_dummy_frame (thisframe->pc, thisframe->frame))
-    return generic_read_register_dummy (thisframe->pc, thisframe->frame,
-                                        S390_SP_REGNUM);
+  if (deprecated_generic_find_dummy_frame (thisframe->pc, thisframe->frame))
+    return deprecated_read_register_dummy (thisframe->pc, thisframe->frame,
+                                          S390_SP_REGNUM);
   else
     {
       int sigreturn = 0;
@@ -1147,8 +1150,8 @@ s390_store_return_value (struct type *valtype, char *valbuf)
     {
       if (TYPE_LENGTH (valtype) == 4
           || TYPE_LENGTH (valtype) == 8)
-        write_register_bytes (REGISTER_BYTE (S390_FP0_REGNUM), valbuf,
-                              TYPE_LENGTH (valtype));
+        deprecated_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.");
@@ -1158,8 +1161,8 @@ s390_store_return_value (struct type *valtype, char *valbuf)
       value =
        s390_promote_integer_argument (valtype, valbuf, reg_buff, &arglen);
       /* Everything else is returned in GPR2 and up. */
-      write_register_bytes (REGISTER_BYTE (S390_GP0_REGNUM + 2), value,
-                           arglen);
+      deprecated_write_register_bytes (REGISTER_BYTE (S390_GP0_REGNUM + 2),
+                                      value, arglen);
     }
 }
 static int
@@ -1186,7 +1189,7 @@ gdb_print_insn_s390 (bfd_vma memaddr, disassemble_info * info)
 
 /* Not the most efficent code in the world */
 int
-s390_fp_regnum ()
+s390_fp_regnum (void)
 {
   int regno = S390_SP_REGNUM;
   struct frame_extra_info fextra_info;
@@ -1201,19 +1204,12 @@ s390_fp_regnum ()
 }
 
 CORE_ADDR
-s390_read_fp ()
+s390_read_fp (void)
 {
   return read_register (s390_fp_regnum ());
 }
 
 
-void
-s390_write_fp (CORE_ADDR val)
-{
-  write_register (s390_fp_regnum (), val);
-}
-
-
 static void
 s390_pop_frame_regular (struct frame_info *frame)
 {
@@ -1222,20 +1218,23 @@ s390_pop_frame_regular (struct frame_info *frame)
   write_register (S390_PC_REGNUM, FRAME_SAVED_PC (frame));
 
   /* Restore any saved registers.  */
-  for (regnum = 0; regnum < NUM_REGS; regnum++)
-    if (frame->saved_regs[regnum] != 0)
-      {
-        ULONGEST value;
-
-        value = read_memory_unsigned_integer (frame->saved_regs[regnum],
-                                              REGISTER_RAW_SIZE (regnum));
-        write_register (regnum, value);
-      }
+  if (frame->saved_regs)
+    {
+      for (regnum = 0; regnum < NUM_REGS; regnum++)
+        if (frame->saved_regs[regnum] != 0)
+          {
+            ULONGEST value;
+            
+            value = read_memory_unsigned_integer (frame->saved_regs[regnum],
+                                                  REGISTER_RAW_SIZE (regnum));
+            write_register (regnum, value);
+          }
 
-  /* Actually cut back the stack.  Remember that the SP's element of
-     saved_regs is the old SP itself, not the address at which it is
-     saved.  */
-  write_register (S390_SP_REGNUM, frame->saved_regs[S390_SP_REGNUM]);
+      /* Actually cut back the stack.  Remember that the SP's element of
+         saved_regs is the old SP itself, not the address at which it is
+         saved.  */
+      write_register (S390_SP_REGNUM, frame->saved_regs[S390_SP_REGNUM]);
+    }
 
   /* Throw away any cached frame information.  */
   flush_cached_frames ();
@@ -1247,7 +1246,7 @@ s390_pop_frame_regular (struct frame_info *frame)
    Used in the contexts of the "return" command, and of 
    target function calls from the debugger.  */
 void
-s390_pop_frame ()
+s390_pop_frame (void)
 {
   /* This function checks for and handles generic dummy frames, and
      calls back to our function for ordinary frames.  */
@@ -1348,7 +1347,7 @@ is_float_like (struct type *type)
 
 /* Return non-zero if TYPE is considered a `DOUBLE_OR_FLOAT', as
    defined by the parameter passing conventions described in the
-   "Linux for S/390 ELF Application Binary Interface Supplement".
+   "GNU/Linux for S/390 ELF Application Binary Interface Supplement".
    Otherwise, return zero.  */
 static int
 is_double_or_float (struct type *type)
@@ -1360,8 +1359,9 @@ is_double_or_float (struct type *type)
 
 
 /* Return non-zero if TYPE is considered a `SIMPLE_ARG', as defined by
-   the parameter passing conventions described in the "Linux for S/390
-   ELF Application Binary Interface Supplement".  Return zero otherwise.  */
+   the parameter passing conventions described in the "GNU/Linux for
+   S/390 ELF Application Binary Interface Supplement".  Return zero
+   otherwise.  */
 static int
 is_simple_arg (struct type *type)
 {
@@ -1409,8 +1409,9 @@ extend_simple_arg (struct value *arg)
 
 
 /* Return non-zero if TYPE is a `DOUBLE_ARG', as defined by the
-   parameter passing conventions described in the "Linux for S/390 ELF
-   Application Binary Interface Supplement".  Return zero otherwise.  */
+   parameter passing conventions described in the "GNU/Linux for S/390
+   ELF Application Binary Interface Supplement".  Return zero
+   otherwise.  */
 static int
 is_double_arg (struct type *type)
 {
@@ -1481,8 +1482,8 @@ alignment_of (struct type *type)
 
 
 /* Put the actual parameter values pointed to by ARGS[0..NARGS-1] in
-   place to be passed to a function, as specified by the "Linux for
-   S/390 ELF Application Binary Interface Supplement".
+   place to be passed to a function, as specified by the "GNU/Linux
+   for S/390 ELF Application Binary Interface Supplement".
 
    SP is the current stack pointer.  We must put arguments, links,
    padding, etc. whereever they belong, and return the new stack
@@ -1574,9 +1575,9 @@ s390_push_arguments (int nargs, struct value **args, CORE_ADDR sp,
           {
             /* When we store a single-precision value in an FP register,
                it occupies the leftmost bits.  */
-            write_register_bytes (REGISTER_BYTE (S390_FP0_REGNUM + fr),
-                                  VALUE_CONTENTS (arg),
-                                  TYPE_LENGTH (type));
+            deprecated_write_register_bytes (REGISTER_BYTE (S390_FP0_REGNUM + fr),
+                                            VALUE_CONTENTS (arg),
+                                            TYPE_LENGTH (type));
             fr += 2;
           }
         else if (is_simple_arg (type)
@@ -1594,10 +1595,10 @@ s390_push_arguments (int nargs, struct value **args, CORE_ADDR sp,
         else if (is_double_arg (type)
                  && gr <= 5)
           {
-            write_register_gen (S390_GP0_REGNUM + gr,
-                                VALUE_CONTENTS (arg));
-            write_register_gen (S390_GP0_REGNUM + gr + 1,
-                                VALUE_CONTENTS (arg) + 4);
+            deprecated_write_register_gen (S390_GP0_REGNUM + gr,
+                                          VALUE_CONTENTS (arg));
+            deprecated_write_register_gen (S390_GP0_REGNUM + gr + 1,
+                                          VALUE_CONTENTS (arg) + 4);
             gr += 2;
           }
         else
@@ -1672,8 +1673,10 @@ s390_use_struct_convention (int gcc_p, struct type *value_type)
 struct type *
 s390_register_virtual_type (int regno)
 {
-  return ((unsigned) regno - S390_FPC_REGNUM) <
-    S390_NUM_FPRS ? builtin_type_double : builtin_type_int;
+  if (S390_FP0_REGNUM <= regno && regno < S390_FP0_REGNUM + S390_NUM_FPRS)
+    return builtin_type_double;
+  else
+    return builtin_type_int;
 }
 
 
@@ -1695,7 +1698,7 @@ s390_store_struct_return (CORE_ADDR addr, CORE_ADDR sp)
 
 
 
-static unsigned char *
+const static unsigned char *
 s390_breakpoint_from_pc (CORE_ADDR *pcptr, int *lenptr)
 {
   static unsigned char breakpoint[] = { 0x0, 0x1 };
@@ -1770,14 +1773,13 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   /* We can't do this */
   set_gdbarch_frame_num_args (gdbarch, frame_num_args_unknown);
   set_gdbarch_store_struct_return (gdbarch, s390_store_struct_return);
-  set_gdbarch_extract_return_value (gdbarch, s390_extract_return_value);
-  set_gdbarch_store_return_value (gdbarch, s390_store_return_value);
+  set_gdbarch_deprecated_extract_return_value (gdbarch, s390_extract_return_value);
+  set_gdbarch_deprecated_store_return_value (gdbarch, s390_store_return_value);
   /* Amount PC must be decremented by after a breakpoint.
      This is often the number of bytes in BREAKPOINT
      but not always.  */
   set_gdbarch_decr_pc_after_break (gdbarch, 2);
   set_gdbarch_pop_frame (gdbarch, s390_pop_frame);
-  set_gdbarch_ieee_float (gdbarch, 1);
   /* Stack grows downward.  */
   set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
   /* Offset from address of function to start of its code.
@@ -1790,7 +1792,6 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_init_extra_frame_info (gdbarch, s390_init_extra_frame_info);
   set_gdbarch_init_frame_pc_first (gdbarch, s390_init_frame_pc_first);
   set_gdbarch_read_fp (gdbarch, s390_read_fp);
-  set_gdbarch_write_fp (gdbarch, s390_write_fp);
   /* This function that tells us whether the function invocation represented
      by FI does not have a frame on the stack associated with it.  If it
      does not, FRAMELESS is set to 1, else 0.  */
@@ -1810,24 +1811,21 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_num_regs (gdbarch, S390_NUM_REGS);
   set_gdbarch_cannot_fetch_register (gdbarch, s390_cannot_fetch_register);
   set_gdbarch_cannot_store_register (gdbarch, s390_cannot_fetch_register);
-  set_gdbarch_get_saved_register (gdbarch, generic_get_saved_register);
   set_gdbarch_use_struct_convention (gdbarch, s390_use_struct_convention);
   set_gdbarch_frame_chain_valid (gdbarch, func_frame_chain_valid);
   set_gdbarch_register_name (gdbarch, s390_register_name);
   set_gdbarch_stab_reg_to_regnum (gdbarch, s390_stab_reg_to_regnum);
   set_gdbarch_dwarf_reg_to_regnum (gdbarch, s390_stab_reg_to_regnum);
   set_gdbarch_dwarf2_reg_to_regnum (gdbarch, s390_stab_reg_to_regnum);
-  set_gdbarch_extract_struct_value_address
+  set_gdbarch_deprecated_extract_struct_value_address
     (gdbarch, generic_cannot_extract_struct_value_address);
 
   /* Parameters for inferior function calls.  */
   set_gdbarch_call_dummy_p (gdbarch, 1);
-  set_gdbarch_use_generic_dummy_frames (gdbarch, 1);
   set_gdbarch_call_dummy_length (gdbarch, 0);
-  set_gdbarch_call_dummy_location (gdbarch, AT_ENTRY_POINT);
   set_gdbarch_call_dummy_address (gdbarch, entry_point_address);
   set_gdbarch_call_dummy_start_offset (gdbarch, 0);
-  set_gdbarch_pc_in_call_dummy (gdbarch, pc_in_call_dummy_at_entry_point);
+  set_gdbarch_deprecated_pc_in_call_dummy (gdbarch, deprecated_pc_in_call_dummy_at_entry_point);
   set_gdbarch_push_dummy_frame (gdbarch, generic_push_dummy_frame);
   set_gdbarch_push_arguments (gdbarch, s390_push_arguments);
   set_gdbarch_save_dummy_frame_tos (gdbarch, generic_save_dummy_frame_tos);
@@ -1844,7 +1842,7 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   switch (info.bfd_arch_info->mach)
     {
-    case bfd_mach_s390_esa:
+    case bfd_mach_s390_31:
       set_gdbarch_register_size (gdbarch, 4);
       set_gdbarch_register_raw_size (gdbarch, s390_register_raw_size);
       set_gdbarch_register_virtual_size (gdbarch, s390_register_raw_size);
@@ -1853,7 +1851,7 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
       set_gdbarch_addr_bits_remove (gdbarch, s390_addr_bits_remove);
       set_gdbarch_register_bytes (gdbarch, S390_REGISTER_BYTES);
       break;
-    case bfd_mach_s390_esame:
+    case bfd_mach_s390_64:
       set_gdbarch_register_size (gdbarch, 8);
       set_gdbarch_register_raw_size (gdbarch, s390x_register_raw_size);
       set_gdbarch_register_virtual_size (gdbarch, s390x_register_raw_size);
@@ -1873,7 +1871,7 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
 
 void
-_initialize_s390_tdep ()
+_initialize_s390_tdep (void)
 {
 
   /* Hook us into the gdbarch mechanism.  */
This page took 0.040146 seconds and 4 git commands to generate.