Include ld-lib.exp from ctf-lib.exp
[binutils-gdb.git] / gdbserver / linux-ppc-low.cc
index e0310856c2098903173815fe605adbc987a99863..db9a88219ea2891c0ecb5236ea690336e02d039d 100644 (file)
@@ -1,6 +1,6 @@
 /* GNU/Linux/PowerPC specific low level interface, for the remote server for
    GDB.
-   Copyright (C) 1995-2020 Free Software Foundation, Inc.
+   Copyright (C) 1995-2021 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -62,6 +62,25 @@ public:
 
   void low_supply_ptrace_register (regcache *regcache, int regno,
                                   const char *buf) override;
+
+  bool supports_tracepoints () override;
+
+  bool supports_fast_tracepoints () override;
+
+  int install_fast_tracepoint_jump_pad
+    (CORE_ADDR tpoint, CORE_ADDR tpaddr, CORE_ADDR collector,
+     CORE_ADDR lockaddr, ULONGEST orig_size, CORE_ADDR *jump_entry,
+     CORE_ADDR *trampoline, ULONGEST *trampoline_size,
+     unsigned char *jjump_pad_insn, ULONGEST *jjump_pad_insn_size,
+     CORE_ADDR *adjusted_insn_addr, CORE_ADDR *adjusted_insn_addr_end,
+     char *err) override;
+
+  int get_min_fast_tracepoint_insn_len () override;
+
+  struct emit_ops *emit_ops () override;
+
+  int get_ipa_tdesc_idx () override;
+
 protected:
 
   void low_arch_setup () override;
@@ -83,6 +102,8 @@ protected:
 
   int low_remove_point (raw_bkpt_type type, CORE_ADDR addr,
                        int size, raw_breakpoint *bp) override;
+
+  int low_get_thread_area (int lwpid, CORE_ADDR *addrp) override;
 };
 
 /* The singleton target ops object.  */
@@ -228,8 +249,8 @@ ppc_target::low_collect_ptrace_register (regcache *regcache, int regno,
   else if (__BYTE_ORDER == __BIG_ENDIAN)
     {
       /* Big-endian values sit at the right end of the buffer.  In case of
-         registers whose sizes are smaller than sizeof (long), we must use a
-         padding to access them correctly.  */
+        registers whose sizes are smaller than sizeof (long), we must use a
+        padding to access them correctly.  */
       int size = register_size (regcache->tdesc, regno);
 
       if (size < sizeof (long))
@@ -253,8 +274,8 @@ ppc_target::low_supply_ptrace_register (regcache *regcache, int regno,
   else if (__BYTE_ORDER == __BIG_ENDIAN)
     {
       /* Big-endian values sit at the right end of the buffer.  In case of
-         registers whose sizes are smaller than sizeof (long), we must use a
-         padding to access them correctly.  */
+        registers whose sizes are smaller than sizeof (long), we must use a
+        padding to access them correctly.  */
       int size = register_size (regcache->tdesc, regno);
 
       if (size < sizeof (long))
@@ -786,14 +807,6 @@ ppc_store_evrregset (struct regcache *regcache, const void *buf)
   supply_register_by_name (regcache, "spefscr", &regset->spefscr);
 }
 
-/* Support for hardware single step.  */
-
-static int
-ppc_supports_hardware_single_step (void)
-{
-  return 1;
-}
-
 static struct regset_info ppc_regsets[] = {
   /* List the extra register sets before GENERAL_REGS.  That way we will
      fetch them every time, but still fall back to PTRACE_PEEKUSER for the
@@ -1024,12 +1037,12 @@ ppc_target::low_arch_setup ()
       }
 }
 
-/* Implementation of linux_target_ops method "supports_tracepoints".  */
+/* Implementation of target ops method "supports_tracepoints".  */
 
-static int
-ppc_supports_tracepoints (void)
+bool
+ppc_target::supports_tracepoints ()
 {
-  return 1;
+  return true;
 }
 
 /* Get the thread area address.  This is used to recognize which
@@ -1037,8 +1050,8 @@ ppc_supports_tracepoints (void)
    don't read anything from the address, and treat it as opaque; it's
    the address itself that we assume is unique per-thread.  */
 
-static int
-ppc_get_thread_area (int lwpid, CORE_ADDR *addr)
+int
+ppc_target::low_get_thread_area (int lwpid, CORE_ADDR *addr)
 {
   struct lwp_info *lwp = find_lwp_pid (ptid_t (lwpid));
   struct thread_info *thr = get_lwp_thread (lwp);
@@ -1354,12 +1367,12 @@ gen_limm (uint32_t *buf, int reg, uint64_t imm, int is_64)
         ori    reg, reg, <imm[15:0]> */
       p += GEN_LIS (p, reg, ((imm >> 48) & 0xffff));
       if (((imm >> 32) & 0xffff) != 0)
-        p += GEN_ORI (p, reg, reg, ((imm >> 32) & 0xffff));
+       p += GEN_ORI (p, reg, reg, ((imm >> 32) & 0xffff));
       p += GEN_RLDICR (p, reg, reg, 32, 31);
       if (((imm >> 16) & 0xffff) != 0)
-        p += GEN_ORIS (p, reg, reg, ((imm >> 16) & 0xffff));
+       p += GEN_ORIS (p, reg, reg, ((imm >> 16) & 0xffff));
       if ((imm & 0xffff) != 0)
-        p += GEN_ORI (p, reg, reg, (imm & 0xffff));
+       p += GEN_ORI (p, reg, reg, (imm & 0xffff));
     }
 
   return p - buf;
@@ -1565,22 +1578,29 @@ ppc_relocate_instruction (CORE_ADDR *to, CORE_ADDR oldloc)
   *to += 4;
 }
 
+bool
+ppc_target::supports_fast_tracepoints ()
+{
+  return true;
+}
+
 /* Implement install_fast_tracepoint_jump_pad of target_ops.
    See target.h for details.  */
 
-static int
-ppc_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint, CORE_ADDR tpaddr,
-                                     CORE_ADDR collector,
-                                     CORE_ADDR lockaddr,
-                                     ULONGEST orig_size,
-                                     CORE_ADDR *jump_entry,
-                                     CORE_ADDR *trampoline,
-                                     ULONGEST *trampoline_size,
-                                     unsigned char *jjump_pad_insn,
-                                     ULONGEST *jjump_pad_insn_size,
-                                     CORE_ADDR *adjusted_insn_addr,
-                                     CORE_ADDR *adjusted_insn_addr_end,
-                                     char *err)
+int
+ppc_target::install_fast_tracepoint_jump_pad (CORE_ADDR tpoint,
+                                             CORE_ADDR tpaddr,
+                                             CORE_ADDR collector,
+                                             CORE_ADDR lockaddr,
+                                             ULONGEST orig_size,
+                                             CORE_ADDR *jump_entry,
+                                             CORE_ADDR *trampoline,
+                                             ULONGEST *trampoline_size,
+                                             unsigned char *jjump_pad_insn,
+                                             ULONGEST *jjump_pad_insn_size,
+                                             CORE_ADDR *adjusted_insn_addr,
+                                             CORE_ADDR *adjusted_insn_addr_end,
+                                             char *err)
 {
   uint32_t buf[256];
   uint32_t *p = buf;
@@ -1774,8 +1794,8 @@ ppc_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint, CORE_ADDR tpaddr,
 
 /* Returns the minimum instruction length for installing a tracepoint.  */
 
-static int
-ppc_get_min_fast_tracepoint_insn_len (void)
+int
+ppc_target::get_min_fast_tracepoint_insn_len ()
 {
   return 4;
 }
@@ -1824,8 +1844,8 @@ emit_insns (uint32_t *buf, int n)
        |  Expand stack as needed.
        |
        +-
-        |  Some padding for minimum stack frame and 16-byte alignment.
-        |  16 bytes.
+       |  Some padding for minimum stack frame and 16-byte alignment.
+       |  16 bytes.
  SP     +- Back-chain (SP')
 
   initial frame size
@@ -2640,8 +2660,8 @@ static struct emit_ops ppc_emit_ops_impl =
        |  Expand stack as needed.
        |
        +-
-        |  Some padding for minimum stack frame.
-        |  112 for ELFv1.
+       |  Some padding for minimum stack frame.
+       |  112 for ELFv1.
  SP     +- Back-chain (SP')
 
   initial frame size
@@ -2733,7 +2753,7 @@ ppc64_emit_epilogue (void)
            /* Restore registers.  */
            "ld    31, -8(1)    \n"
            "ld    30, -16(1)   \n"
-            /* Restore LR.  */
+           /* Restore LR.  */
            "ld    0, 16(1)     \n"
            /* Return 0 for no-error.  */
            "li    3, 0         \n"
@@ -3355,10 +3375,10 @@ static struct emit_ops ppc64v2_emit_ops_impl =
 
 #endif
 
-/* Implementation of linux_target_ops method "emit_ops".  */
+/* Implementation of target ops method "emit_ops".  */
 
-static struct emit_ops *
-ppc_emit_ops (void)
+emit_ops *
+ppc_target::emit_ops ()
 {
 #ifdef __powerpc64__
   struct regcache *regcache = get_thread_regcache (current_thread, 0);
@@ -3366,18 +3386,18 @@ ppc_emit_ops (void)
   if (register_size (regcache->tdesc, 0) == 8)
     {
       if (is_elfv2_inferior ())
-        return &ppc64v2_emit_ops_impl;
+       return &ppc64v2_emit_ops_impl;
       else
-        return &ppc64v1_emit_ops_impl;
+       return &ppc64v1_emit_ops_impl;
     }
 #endif
   return &ppc_emit_ops_impl;
 }
 
-/* Implementation of linux_target_ops method "get_ipa_tdesc_idx".  */
+/* Implementation of target ops method "get_ipa_tdesc_idx".  */
 
-static int
-ppc_get_ipa_tdesc_idx (void)
+int
+ppc_target::get_ipa_tdesc_idx ()
 {
   struct regcache *regcache = get_thread_regcache (current_thread, 0);
   const struct target_desc *tdesc = regcache->tdesc;
@@ -3427,26 +3447,6 @@ ppc_get_ipa_tdesc_idx (void)
   return 0;
 }
 
-struct linux_target_ops the_low_target = {
-  NULL, /* siginfo_fixup */
-  NULL, /* new_process */
-  NULL, /* delete_process */
-  NULL, /* new_thread */
-  NULL, /* delete_thread */
-  NULL, /* new_fork */
-  NULL, /* prepare_to_resume */
-  NULL, /* process_qsupported */
-  ppc_supports_tracepoints,
-  ppc_get_thread_area,
-  ppc_install_fast_tracepoint_jump_pad,
-  ppc_emit_ops,
-  ppc_get_min_fast_tracepoint_insn_len,
-  NULL, /* supports_range_stepping */
-  ppc_supports_hardware_single_step,
-  NULL, /* get_syscall_trapinfo */
-  ppc_get_ipa_tdesc_idx,
-};
-
 /* The linux target ops object.  */
 
 linux_process_target *the_linux_target = &the_ppc_target;