[gdb/testsuite] Fix gdb.dwarf2/locexpr-data-member-location.exp with nopie
[binutils-gdb.git] / gdb / ia64-linux-nat.c
index 361fc6ae375f44dd7b8c85b06b39ee95d83c6fef..316e08fb6161ddaa7799c0b80ab742089597fd02 100644 (file)
@@ -1,7 +1,7 @@
 /* Functions specific to running gdb native on IA-64 running
    GNU/Linux.
 
-   Copyright (C) 1999-2020 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"
@@ -80,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;
@@ -401,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
@@ -529,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);
     }
 }
@@ -586,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;
@@ -627,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);
@@ -654,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;
@@ -703,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;
@@ -884,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;
 
@@ -921,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;