Remove some uses of "object_files"
[deliverable/binutils-gdb.git] / gdb / aarch64-linux-nat.c
index 1e7db2920b9119dc925bc5fcf4642def85748446..6d43eb7070f17768f324fe950bc7a0f278d190d8 100644 (file)
@@ -1,6 +1,6 @@
 /* Native-dependent code for GNU/Linux AArch64.
 
-   Copyright (C) 2011-2018 Free Software Foundation, Inc.
+   Copyright (C) 2011-2019 Free Software Foundation, Inc.
    Contributed by ARM Ltd.
 
    This file is part of GDB.
@@ -42,6 +42,7 @@
 #include <asm/ptrace.h>
 
 #include "gregset.h"
+#include "linux-tdep.h"
 
 /* Defines ps_err_e, struct ps_prochandle.  */
 #include "gdb_proc_service.h"
@@ -77,6 +78,9 @@ public:
   /* Override the GNU/Linux inferior startup hook.  */
   void post_startup_inferior (ptid_t) override;
 
+  /* Override the GNU/Linux post attach hook.  */
+  void post_attach (int pid) override;
+
   /* These three defer to common nat/ code.  */
   void low_new_thread (struct lwp_info *lp) override
   { aarch64_linux_new_thread (lp); }
@@ -209,7 +213,7 @@ fetch_gregs_from_thread (struct regcache *regcache)
      and arm.  */
   gdb_static_assert (sizeof (regs) >= 18 * 4);
 
-  tid = ptid_get_lwp (regcache->ptid ());
+  tid = regcache->ptid ().lwp ();
 
   iovec.iov_base = &regs;
   if (gdbarch_bfd_arch_info (gdbarch)->bits_per_word == 32)
@@ -246,7 +250,7 @@ store_gregs_to_thread (const struct regcache *regcache)
   /* Make sure REGS can hold all registers contents on both aarch64
      and arm.  */
   gdb_static_assert (sizeof (regs) >= 18 * 4);
-  tid = ptid_get_lwp (regcache->ptid ());
+  tid = regcache->ptid ().lwp ();
 
   iovec.iov_base = &regs;
   if (gdbarch_bfd_arch_info (gdbarch)->bits_per_word == 32)
@@ -289,7 +293,7 @@ fetch_fpregs_from_thread (struct regcache *regcache)
      and arm.  */
   gdb_static_assert (sizeof regs >= VFP_REGS_SIZE);
 
-  tid = ptid_get_lwp (regcache->ptid ());
+  tid = regcache->ptid ().lwp ();
 
   iovec.iov_base = &regs;
 
@@ -335,7 +339,7 @@ store_fpregs_to_thread (const struct regcache *regcache)
   /* Make sure REGS can hold all VFP registers contents on both aarch64
      and arm.  */
   gdb_static_assert (sizeof regs >= VFP_REGS_SIZE);
-  tid = ptid_get_lwp (regcache->ptid ());
+  tid = regcache->ptid ().lwp ();
 
   iovec.iov_base = &regs;
 
@@ -391,7 +395,7 @@ static void
 fetch_sveregs_from_thread (struct regcache *regcache)
 {
   std::unique_ptr<gdb_byte[]> base
-    = aarch64_sve_get_sveregs (ptid_get_lwp (regcache->ptid ()));
+    = aarch64_sve_get_sveregs (regcache->ptid ().lwp ());
   aarch64_sve_regs_copy_to_reg_buf (regcache, base.get ());
 }
 
@@ -403,7 +407,7 @@ store_sveregs_to_thread (struct regcache *regcache)
 {
   int ret;
   struct iovec iovec;
-  int tid = ptid_get_lwp (regcache->ptid ());
+  int tid = regcache->ptid ().lwp ();
 
   /* Obtain a dump of SVE registers from ptrace.  */
   std::unique_ptr<gdb_byte[]> base = aarch64_sve_get_sveregs (tid);
@@ -420,6 +424,31 @@ store_sveregs_to_thread (struct regcache *regcache)
     perror_with_name (_("Unable to store sve registers"));
 }
 
+/* Fill GDB's register array with the pointer authentication mask values from
+   the current thread.  */
+
+static void
+fetch_pauth_masks_from_thread (struct regcache *regcache)
+{
+  struct gdbarch_tdep *tdep = gdbarch_tdep (regcache->arch ());
+  int ret;
+  struct iovec iovec;
+  uint64_t pauth_regset[2] = {0, 0};
+  int tid = regcache->ptid ().lwp ();
+
+  iovec.iov_base = &pauth_regset;
+  iovec.iov_len = sizeof (pauth_regset);
+
+  ret = ptrace (PTRACE_GETREGSET, tid, NT_ARM_PAC_MASK, &iovec);
+  if (ret != 0)
+    perror_with_name (_("unable to fetch pauth registers."));
+
+  regcache->raw_supply (AARCH64_PAUTH_DMASK_REGNUM (tdep->pauth_reg_base),
+                       &pauth_regset[0]);
+  regcache->raw_supply (AARCH64_PAUTH_CMASK_REGNUM (tdep->pauth_reg_base),
+                       &pauth_regset[1]);
+}
+
 /* Implement the "fetch_registers" target_ops method.  */
 
 void
@@ -435,6 +464,9 @@ aarch64_linux_nat_target::fetch_registers (struct regcache *regcache,
        fetch_sveregs_from_thread (regcache);
       else
        fetch_fpregs_from_thread (regcache);
+
+      if (tdep->has_pauth ())
+       fetch_pauth_masks_from_thread (regcache);
     }
   else if (regno < AARCH64_V0_REGNUM)
     fetch_gregs_from_thread (regcache);
@@ -442,6 +474,13 @@ aarch64_linux_nat_target::fetch_registers (struct regcache *regcache,
     fetch_sveregs_from_thread (regcache);
   else
     fetch_fpregs_from_thread (regcache);
+
+  if (tdep->has_pauth ())
+    {
+      if (regno == AARCH64_PAUTH_DMASK_REGNUM (tdep->pauth_reg_base)
+         || regno == AARCH64_PAUTH_CMASK_REGNUM (tdep->pauth_reg_base))
+       fetch_pauth_masks_from_thread (regcache);
+    }
 }
 
 /* Implement the "store_registers" target_ops method.  */
@@ -537,7 +576,7 @@ aarch64_linux_nat_target::low_new_fork (struct lwp_info *parent,
      new process so that all breakpoints and watchpoints can be
      removed together.  */
 
-  parent_pid = ptid_get_pid (parent->ptid);
+  parent_pid = parent->ptid.pid ();
   parent_state = aarch64_get_debug_reg_state (parent_pid);
   child_state = aarch64_get_debug_reg_state (child_pid);
   *child_state = *parent_state;
@@ -563,11 +602,26 @@ ps_get_thread_area (struct ps_prochandle *ph,
 void
 aarch64_linux_nat_target::post_startup_inferior (ptid_t ptid)
 {
-  low_forget_process (ptid_get_pid (ptid));
-  aarch64_linux_get_debug_reg_capacity (ptid_get_pid (ptid));
+  low_forget_process (ptid.pid ());
+  aarch64_linux_get_debug_reg_capacity (ptid.pid ());
   linux_nat_target::post_startup_inferior (ptid);
 }
 
+/* Implement the "post_attach" target_ops method.  */
+
+void
+aarch64_linux_nat_target::post_attach (int pid)
+{
+  low_forget_process (pid);
+  /* Set the hardware debug register capacity.  If
+     aarch64_linux_get_debug_reg_capacity is not called
+     (as it is in aarch64_linux_child_post_startup_inferior) then
+     software watchpoints will be used instead of hardware
+     watchpoints when attaching to a target.  */
+  aarch64_linux_get_debug_reg_capacity (pid);
+  linux_nat_target::post_attach (pid);
+}
+
 extern struct target_desc *tdesc_arm_with_neon;
 
 /* Implement the "read_description" target_ops method.  */
@@ -579,7 +633,7 @@ aarch64_linux_nat_target::read_description ()
   gdb_byte regbuf[VFP_REGS_SIZE];
   struct iovec iovec;
 
-  tid = ptid_get_lwp (inferior_ptid);
+  tid = inferior_ptid.lwp ();
 
   iovec.iov_base = regbuf;
   iovec.iov_len = VFP_REGS_SIZE;
@@ -587,8 +641,11 @@ aarch64_linux_nat_target::read_description ()
   ret = ptrace (PTRACE_GETREGSET, tid, NT_ARM_VFP, &iovec);
   if (ret == 0)
     return tdesc_arm_with_neon;
-  else
-    return aarch64_read_description (aarch64_sve_get_vq (tid));
+
+  CORE_ADDR hwcap = linux_get_hwcap (this);
+
+  return aarch64_read_description (aarch64_sve_get_vq (tid),
+                                  hwcap & AARCH64_HWCAP_PACA);
 }
 
 /* Convert a native/host siginfo object, into/from the siginfo in the
@@ -669,7 +726,7 @@ aarch64_linux_nat_target::insert_hw_breakpoint (struct gdbarch *gdbarch,
   int len;
   const enum target_hw_bp_type type = hw_execute;
   struct aarch64_debug_reg_state *state
-    = aarch64_get_debug_reg_state (ptid_get_pid (inferior_ptid));
+    = aarch64_get_debug_reg_state (inferior_ptid.pid ());
 
   gdbarch_breakpoint_from_pc (gdbarch, &addr, &len);
 
@@ -702,7 +759,7 @@ aarch64_linux_nat_target::remove_hw_breakpoint (struct gdbarch *gdbarch,
   int len = 4;
   const enum target_hw_bp_type type = hw_execute;
   struct aarch64_debug_reg_state *state
-    = aarch64_get_debug_reg_state (ptid_get_pid (inferior_ptid));
+    = aarch64_get_debug_reg_state (inferior_ptid.pid ());
 
   gdbarch_breakpoint_from_pc (gdbarch, &addr, &len);
 
@@ -735,7 +792,7 @@ aarch64_linux_nat_target::insert_watchpoint (CORE_ADDR addr, int len,
 {
   int ret;
   struct aarch64_debug_reg_state *state
-    = aarch64_get_debug_reg_state (ptid_get_pid (inferior_ptid));
+    = aarch64_get_debug_reg_state (inferior_ptid.pid ());
 
   if (show_debug_regs)
     fprintf_unfiltered (gdb_stdlog,
@@ -767,7 +824,7 @@ aarch64_linux_nat_target::remove_watchpoint (CORE_ADDR addr, int len,
 {
   int ret;
   struct aarch64_debug_reg_state *state
-    = aarch64_get_debug_reg_state (ptid_get_pid (inferior_ptid));
+    = aarch64_get_debug_reg_state (inferior_ptid.pid ());
 
   if (show_debug_regs)
     fprintf_unfiltered (gdb_stdlog,
@@ -801,7 +858,7 @@ bool
 aarch64_linux_nat_target::stopped_data_address (CORE_ADDR *addr_p)
 {
   siginfo_t siginfo;
-  int i, tid;
+  int i;
   struct aarch64_debug_reg_state *state;
 
   if (!linux_nat_get_siginfo (inferior_ptid, &siginfo))
@@ -813,7 +870,7 @@ aarch64_linux_nat_target::stopped_data_address (CORE_ADDR *addr_p)
     return false;
 
   /* Check if the address matches any watched address.  */
-  state = aarch64_get_debug_reg_state (ptid_get_pid (inferior_ptid));
+  state = aarch64_get_debug_reg_state (inferior_ptid.pid ());
   for (i = aarch64_num_wp_regs - 1; i >= 0; --i)
     {
       const unsigned int offset
This page took 0.026949 seconds and 4 git commands to generate.