gdb/testsuite: gdb.base/args.exp: add KFAIL for native-extended-gdbserver
[binutils-gdb.git] / gdb / s390-tdep.c
index 247adcd6e2749901bc6ca4e436f330452df78470..4905bcab36e450e14f1d4e476fb9c7c8e9d7b4ad 100644 (file)
@@ -1,6 +1,6 @@
 /* Target-dependent code for s390.
 
-   Copyright (C) 2001-2020 Free Software Foundation, Inc.
+   Copyright (C) 2001-2021 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -39,6 +39,7 @@
 #include "target-descriptions.h"
 #include "trad-frame.h"
 #include "value.h"
+#include "inferior.h"
 
 #include "features/s390-linux32.c"
 #include "features/s390x-linux64.c"
@@ -421,18 +422,19 @@ is_non_branch_ril (gdb_byte *insn)
   return 0;
 }
 
-typedef buf_displaced_step_closure s390_displaced_step_closure;
+typedef buf_displaced_step_copy_insn_closure
+  s390_displaced_step_copy_insn_closure;
 
 /* Implementation of gdbarch_displaced_step_copy_insn.  */
 
-static displaced_step_closure_up
+static displaced_step_copy_insn_closure_up
 s390_displaced_step_copy_insn (struct gdbarch *gdbarch,
                               CORE_ADDR from, CORE_ADDR to,
                               struct regcache *regs)
 {
   size_t len = gdbarch_max_insn_length (gdbarch);
-  std::unique_ptr<s390_displaced_step_closure> closure
-    (new s390_displaced_step_closure (len));
+  std::unique_ptr<s390_displaced_step_copy_insn_closure> closure
+    (new s390_displaced_step_copy_insn_closure (len));
   gdb_byte *buf = closure->buf.data ();
 
   read_memory (from, buf, len);
@@ -470,7 +472,7 @@ s390_displaced_step_copy_insn (struct gdbarch *gdbarch,
                          displaced_step_dump_bytes (buf, len).c_str ());
 
   /* This is a work around for a problem with g++ 4.8.  */
-  return displaced_step_closure_up (closure.release ());
+  return displaced_step_copy_insn_closure_up (closure.release ());
 }
 
 /* Fix up the state of registers and memory after having single-stepped
@@ -478,13 +480,13 @@ s390_displaced_step_copy_insn (struct gdbarch *gdbarch,
 
 static void
 s390_displaced_step_fixup (struct gdbarch *gdbarch,
-                          struct displaced_step_closure *closure_,
+                          displaced_step_copy_insn_closure *closure_,
                           CORE_ADDR from, CORE_ADDR to,
                           struct regcache *regs)
 {
   /* Our closure is a copy of the instruction.  */
-  s390_displaced_step_closure *closure
-    = (s390_displaced_step_closure *) closure_;
+  s390_displaced_step_copy_insn_closure *closure
+    = (s390_displaced_step_copy_insn_closure *) closure_;
   gdb_byte *insn = closure->buf.data ();
   static int s390_instrlen[] = { 2, 4, 4, 6 };
   int insnlen = s390_instrlen[insn[0] >> 6];
@@ -683,8 +685,8 @@ s390_load (struct s390_prologue_data *data,
      we're analyzing the code to unwind past that frame.  */
   if (pv_is_constant (addr))
     {
-      struct target_section *secp;
-      secp = target_section_by_addr (current_top_target (), addr.k);
+      const struct target_section *secp
+       = target_section_by_addr (current_inferior ()->top_target (), addr.k);
       if (secp != NULL
          && (bfd_section_flags (secp->the_bfd_section) & SEC_READONLY))
        return pv_constant (read_memory_integer (addr.k, size,
@@ -2298,7 +2300,7 @@ s390_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
 
 struct value *
 s390_trad_frame_prev_register (struct frame_info *this_frame,
-                              struct trad_frame_saved_reg saved_regs[],
+                              trad_frame_saved_reg saved_regs[],
                               int regnum)
 {
   if (regnum < S390_NUM_REGS)
@@ -2315,7 +2317,7 @@ struct s390_unwind_cache {
   CORE_ADDR frame_base;
   CORE_ADDR local_base;
 
-  struct trad_frame_saved_reg *saved_regs;
+  trad_frame_saved_reg *saved_regs;
 };
 
 /* Unwind THIS_FRAME and write the information into unwind cache INFO using
@@ -2450,10 +2452,10 @@ s390_prologue_frame_unwind_cache (struct frame_info *this_frame,
   /* Set up ABI call-saved/call-clobbered registers.  */
   for (i = 0; i < S390_NUM_REGS; i++)
     if (!s390_register_call_saved (gdbarch, i))
-      trad_frame_set_unknown (info->saved_regs, i);
+      info->saved_regs[i].set_unknown ();
 
   /* CC is always call-clobbered.  */
-  trad_frame_set_unknown (info->saved_regs, S390_PSWM_REGNUM);
+  info->saved_regs[S390_PSWM_REGNUM].set_unknown ();
 
   /* Record the addresses of all register spill slots the prologue parser
      has recognized.  Consider only registers defined as call-saved by the
@@ -2463,12 +2465,12 @@ s390_prologue_frame_unwind_cache (struct frame_info *this_frame,
   for (i = 0; i < 16; i++)
     if (s390_register_call_saved (gdbarch, S390_R0_REGNUM + i)
        && data.gpr_slot[i] != 0)
-      info->saved_regs[S390_R0_REGNUM + i].addr = cfa - data.gpr_slot[i];
+      info->saved_regs[S390_R0_REGNUM + i].set_addr (cfa - data.gpr_slot[i]);
 
   for (i = 0; i < 16; i++)
     if (s390_register_call_saved (gdbarch, S390_F0_REGNUM + i)
        && data.fpr_slot[i] != 0)
-      info->saved_regs[S390_F0_REGNUM + i].addr = cfa - data.fpr_slot[i];
+      info->saved_regs[S390_F0_REGNUM + i].set_addr (cfa - data.fpr_slot[i]);
 
   /* Function return will set PC to %r14.  */
   info->saved_regs[S390_PSWA_REGNUM] = info->saved_regs[S390_RETADDR_REGNUM];
@@ -2478,9 +2480,9 @@ s390_prologue_frame_unwind_cache (struct frame_info *this_frame,
      save area, use that -- we might only think the function frameless
      because we're in the middle of the prologue ...  */
   if (size == 0
-      && !trad_frame_addr_p (info->saved_regs, S390_PSWA_REGNUM))
+      && !info->saved_regs[S390_PSWA_REGNUM].is_addr ())
     {
-      info->saved_regs[S390_PSWA_REGNUM].realreg = S390_RETADDR_REGNUM;
+      info->saved_regs[S390_PSWA_REGNUM].set_realreg (S390_RETADDR_REGNUM);
     }
 
   /* Another sanity check: unless this is a frameless function,
@@ -2489,8 +2491,8 @@ s390_prologue_frame_unwind_cache (struct frame_info *this_frame,
      libc's thread_start routine.  */
   if (size > 0)
     {
-      if (!trad_frame_addr_p (info->saved_regs, S390_SP_REGNUM)
-         || !trad_frame_addr_p (info->saved_regs, S390_PSWA_REGNUM))
+      if (!info->saved_regs[S390_SP_REGNUM].is_addr ()
+         || !info->saved_regs[S390_PSWA_REGNUM].is_addr ())
        prev_sp = -1;
     }
 
@@ -2523,10 +2525,10 @@ s390_backchain_frame_unwind_cache (struct frame_info *this_frame,
   /* Set up ABI call-saved/call-clobbered registers.  */
   for (i = 0; i < S390_NUM_REGS; i++)
     if (!s390_register_call_saved (gdbarch, i))
-      trad_frame_set_unknown (info->saved_regs, i);
+      info->saved_regs[i].set_unknown ();
 
   /* CC is always call-clobbered.  */
-  trad_frame_set_unknown (info->saved_regs, S390_PSWM_REGNUM);
+  info->saved_regs[S390_PSWM_REGNUM].set_unknown ();
 
   /* Get the backchain.  */
   reg = get_frame_register_unsigned (this_frame, S390_SP_REGNUM);
@@ -2546,8 +2548,8 @@ s390_backchain_frame_unwind_cache (struct frame_info *this_frame,
       /* We don't know which registers were saved, but it will have
         to be at least %r14 and %r15.  This will allow us to continue
         unwinding, but other prev-frame registers may be incorrect ...  */
-      info->saved_regs[S390_SP_REGNUM].addr = backchain + 15*word_size;
-      info->saved_regs[S390_RETADDR_REGNUM].addr = backchain + 14*word_size;
+      info->saved_regs[S390_SP_REGNUM].set_addr (backchain + 15*word_size);
+      info->saved_regs[S390_RETADDR_REGNUM].set_addr (backchain + 14*word_size);
 
       /* Function return will set PC to %r14.  */
       info->saved_regs[S390_PSWA_REGNUM]
@@ -2647,7 +2649,7 @@ static const struct frame_unwind s390_frame_unwind = {
 struct s390_stub_unwind_cache
 {
   CORE_ADDR frame_base;
-  struct trad_frame_saved_reg *saved_regs;
+  trad_frame_saved_reg *saved_regs;
 };
 
 /* Unwind THIS_FRAME and return the corresponding unwind cache for
@@ -2670,7 +2672,7 @@ s390_stub_frame_unwind_cache (struct frame_info *this_frame,
   info->saved_regs = trad_frame_alloc_saved_regs (this_frame);
 
   /* The return address is in register %r14.  */
-  info->saved_regs[S390_PSWA_REGNUM].realreg = S390_RETADDR_REGNUM;
+  info->saved_regs[S390_PSWA_REGNUM].set_realreg (S390_RETADDR_REGNUM);
 
   /* Retrieve stack pointer and determine our frame base.  */
   reg = get_frame_register_unsigned (this_frame, S390_SP_REGNUM);
@@ -7046,7 +7048,10 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_displaced_step_copy_insn (gdbarch,
                                        s390_displaced_step_copy_insn);
   set_gdbarch_displaced_step_fixup (gdbarch, s390_displaced_step_fixup);
-  set_gdbarch_displaced_step_location (gdbarch, linux_displaced_step_location);
+  set_gdbarch_displaced_step_prepare (gdbarch, linux_displaced_step_prepare);
+  set_gdbarch_displaced_step_finish (gdbarch, linux_displaced_step_finish);
+  set_gdbarch_displaced_step_restore_all_in_ptid
+    (gdbarch, linux_displaced_step_restore_all_in_ptid);
   set_gdbarch_displaced_step_hw_singlestep (gdbarch, s390_displaced_step_hw_singlestep);
   set_gdbarch_software_single_step (gdbarch, s390_software_single_step);
   set_gdbarch_max_insn_length (gdbarch, S390_MAX_INSTR_SIZE);
@@ -7138,12 +7143,12 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
      cause GDB to crash with an internal error when the user tries to set
      an unsupported OSABI.  */
   if (!tdesc_has_registers (tdesc))
-  {
-    if (info.bfd_arch_info->mach == bfd_mach_s390_31)
-      tdesc = tdesc_s390_linux32;
-    else
-      tdesc = tdesc_s390x_linux64;
-  }
+    {
+      if (info.bfd_arch_info->mach == bfd_mach_s390_31)
+       tdesc = tdesc_s390_linux32;
+      else
+       tdesc = tdesc_s390x_linux64;
+    }
   tdep->tdesc = tdesc;
 
   /* Check any target description for validity.  */