[gdb/testsuite] Fix gdb.dwarf2/locexpr-data-member-location.exp with nopie
[binutils-gdb.git] / gdb / ia64-linux-nat.c
index 49ae702682b0a6864fed5e6ba74a74ce97325839..316e08fb6161ddaa7799c0b80ab742089597fd02 100644 (file)
@@ -1,7 +1,7 @@
 /* Functions specific to running gdb native on IA-64 running
    GNU/Linux.
 
-   Copyright (C) 1999-2018 Free Software Foundation, Inc.
+   Copyright (C) 1999-2022 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -21,6 +21,7 @@
 #include "defs.h"
 #include "inferior.h"
 #include "target.h"
+#include "gdbarch.h"
 #include "gdbcore.h"
 #include "regcache.h"
 #include "ia64-tdep.h"
@@ -28,7 +29,7 @@
 
 #include <signal.h>
 #include "nat/gdb_ptrace.h"
-#include "gdb_wait.h"
+#include "gdbsupport/gdb_wait.h"
 #ifdef HAVE_SYS_REG_H
 #include <sys/reg.h>
 #endif
@@ -57,8 +58,6 @@ public:
                                        ULONGEST offset, ULONGEST len,
                                        ULONGEST *xfered_len) override;
 
-  const struct target_desc *read_description () override;
-
   /* Override watchpoint routines.  */
 
   /* The IA-64 architecture can step over a watch point (without
@@ -70,7 +69,7 @@ public:
      has determined that a hardware watchpoint has indeed been hit.
      The CPU will then be able to execute one instruction without
      triggering a watchpoint.  */
-  bool have_steppable_watchpoint () { return 1; }
+  bool have_steppable_watchpoint () override { return true; }
 
   int can_use_hw_breakpoint (enum bptype, int, int) override;
   bool stopped_by_watchpoint () override;
@@ -82,6 +81,8 @@ public:
   /* Override linux_nat_target low methods.  */
   void low_new_thread (struct lwp_info *lp) override;
   bool low_status_is_event (int status) override;
+
+  void enable_watchpoints_in_psr (ptid_t ptid);
 };
 
 static ia64_linux_nat_target the_ia64_linux_nat_target;
@@ -403,7 +404,7 @@ ia64_cannot_store_register (struct gdbarch *gdbarch, int regno)
   return regno < 0
         || regno >= gdbarch_num_regs (gdbarch)
         || u_offsets[regno] == -1
-         || regno == IA64_BSPSTORE_REGNUM;
+        || regno == IA64_BSPSTORE_REGNUM;
 }
 
 void
@@ -531,17 +532,17 @@ fill_fpregset (const struct regcache *regcache,
 #define IA64_PSR_DB (1UL << 24)
 #define IA64_PSR_DD (1UL << 39)
 
-static void
-enable_watchpoints_in_psr (ptid_t ptid)
+void
+ia64_linux_nat_target::enable_watchpoints_in_psr (ptid_t ptid)
 {
-  struct regcache *regcache = get_thread_regcache (ptid);
+  struct regcache *regcache = get_thread_regcache (this, ptid);
   ULONGEST psr;
 
   regcache_cooked_read_unsigned (regcache, IA64_PSR_REGNUM, &psr);
   if (!(psr & IA64_PSR_DB))
     {
       psr |= IA64_PSR_DB;      /* Set the db bit - this enables hardware
-                                  watchpoints and breakpoints.  */
+                                  watchpoints and breakpoints.  */
       regcache_cooked_write_unsigned (regcache, IA64_PSR_REGNUM, psr);
     }
 }
@@ -553,7 +554,7 @@ store_debug_register (ptid_t ptid, int idx, long val)
 {
   int tid;
 
-  tid = ptid_get_lwp (ptid);
+  tid = ptid.lwp ();
   if (tid == 0)
     tid = ptid.pid ();
 
@@ -588,7 +589,6 @@ ia64_linux_nat_target::insert_watchpoint (CORE_ADDR addr, int len,
                                          enum target_hw_bp_type type,
                                          struct expression *cond)
 {
-  struct lwp_info *lp;
   int idx;
   long dbr_addr, dbr_mask;
   int max_watchpoints = 4;
@@ -629,7 +629,8 @@ ia64_linux_nat_target::insert_watchpoint (CORE_ADDR addr, int len,
 
   debug_registers[2 * idx] = dbr_addr;
   debug_registers[2 * idx + 1] = dbr_mask;
-  ALL_LWPS (lp)
+
+  for (const lwp_info *lp : all_lwps ())
     {
       store_debug_register_pair (lp->ptid, idx, &dbr_addr, &dbr_mask);
       enable_watchpoints_in_psr (lp->ptid);
@@ -656,14 +657,12 @@ ia64_linux_nat_target::remove_watchpoint (CORE_ADDR addr, int len,
       dbr_mask = debug_registers[2 * idx + 1];
       if ((dbr_mask & (0x3UL << 62)) && addr == (CORE_ADDR) dbr_addr)
        {
-         struct lwp_info *lp;
-
          debug_registers[2 * idx] = 0;
          debug_registers[2 * idx + 1] = 0;
          dbr_addr = 0;
          dbr_mask = 0;
 
-         ALL_LWPS (lp)
+         for (const lwp_info *lp : all_lwps ())
            store_debug_register_pair (lp->ptid, idx, &dbr_addr, &dbr_mask);
 
          return 0;
@@ -672,8 +671,8 @@ ia64_linux_nat_target::remove_watchpoint (CORE_ADDR addr, int len,
   return -1;
 }
 
-static void
-ia64_linux_new_thread (struct lwp_info *lp)
+void
+ia64_linux_nat_target::low_new_thread (struct lwp_info *lp)
 {
   int i, any;
 
@@ -705,7 +704,7 @@ ia64_linux_nat_target::stopped_data_address (CORE_ADDR *addr_p)
 
   regcache_cooked_read_unsigned (regcache, IA64_PSR_REGNUM, &psr);
   psr |= IA64_PSR_DD;  /* Set the dd bit - this will disable the watchpoint
-                           for the next instruction.  */
+                          for the next instruction.  */
   regcache_cooked_write_unsigned (regcache, IA64_PSR_REGNUM, psr);
 
   *addr_p = (CORE_ADDR) siginfo.si_addr;
@@ -719,10 +718,9 @@ ia64_linux_nat_target::stopped_by_watchpoint ()
   return stopped_data_address (&addr);
 }
 
-static int
-ia64_linux_can_use_hw_breakpoint (struct target_ops *self,
-                                 enum bptype type,
-                                 int cnt, int othertype)
+int
+ia64_linux_nat_target::can_use_hw_breakpoint (enum bptype type,
+                                             int cnt, int othertype)
 {
   return 1;
 }
@@ -887,7 +885,7 @@ ia64_linux_nat_target::xfer_partial (enum target_object object,
 
       /* Probe for the table size once.  */
       if (gate_table_size == 0)
-        gate_table_size = syscall (__NR_getunwind, NULL, 0);
+       gate_table_size = syscall (__NR_getunwind, NULL, 0);
       if (gate_table_size < 0)
        return TARGET_XFER_E_IO;
 
@@ -924,8 +922,9 @@ ia64_linux_nat_target::low_status_is_event (int status)
                                 || WSTOPSIG (status) == SIGILL);
 }
 
+void _initialize_ia64_linux_nat ();
 void
-_initialize_ia64_linux_nat (void)
+_initialize_ia64_linux_nat ()
 {
   /* Register the target.  */
   linux_target = &the_ia64_linux_nat_target;