]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/ppc-linux-nat.c
2.41 Release sources
[thirdparty/binutils-gdb.git] / gdb / ppc-linux-nat.c
index b089fcc8a5f5a662b161d816c05b519a2bd007de..d14aba694e539d182438207f1141ea799d8dc9b4 100644 (file)
@@ -1,6 +1,6 @@
 /* PPC GNU/Linux native support.
 
-   Copyright (C) 1988-2022 Free Software Foundation, Inc.
+   Copyright (C) 1988-2023 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -178,7 +178,6 @@ struct ppc_hw_breakpoint
 
    The layout is like this (where x is the actual value of the vscr reg): */
 
-/* *INDENT-OFF* */
 /*
 Big-Endian:
    |.|.|.|.|.....|.|.|.|.||.|.|.|x||.|
@@ -189,7 +188,6 @@ Little-Endian:
    <------->     <-------><-------><->
      VR0           VR31     VSCR    VRSAVE
 */
-/* *INDENT-ON* */
 
 typedef char gdb_vrregset_t[PPC_LINUX_SIZEOF_VRREGSET];
 
@@ -335,7 +333,7 @@ public:
 
   /* One and only one of these three functions returns true, indicating
      whether the corresponding interface is the one we detected.  The
-     interface must already have been detected as a precontidion.  */
+     interface must already have been detected as a precondition.  */
 
   bool hwdebug_p ()
   {
@@ -456,7 +454,7 @@ private:
 
      UNAVAILABLE can indicate that the kernel doesn't support any of the
      two sets of requests or that there was an error when we tried to
-     detect wich interface is available.  */
+     detect which interface is available.  */
 
   enum debug_reg_interface
     {
@@ -530,8 +528,8 @@ struct ppc_linux_nat_target final : public linux_nat_target
 
   const struct target_desc *read_description ()  override;
 
-  int auxv_parse (gdb_byte **readptr,
-                 gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
+  int auxv_parse (const gdb_byte **readptr,
+                 const gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
     override;
 
   /* Override linux_nat_target low methods.  */
@@ -628,7 +626,6 @@ private:
 
 static ppc_linux_nat_target the_ppc_linux_nat_target;
 
-/* *INDENT-OFF* */
 /* registers layout, as presented by the ptrace interface:
 PT_R0, PT_R1, PT_R2, PT_R3, PT_R4, PT_R5, PT_R6, PT_R7,
 PT_R8, PT_R9, PT_R10, PT_R11, PT_R12, PT_R13, PT_R14, PT_R15,
@@ -643,7 +640,6 @@ PT_FPR0 + 40, PT_FPR0 + 42, PT_FPR0 + 44, PT_FPR0 + 46,
 PT_FPR0 + 48, PT_FPR0 + 50, PT_FPR0 + 52, PT_FPR0 + 54,
 PT_FPR0 + 56, PT_FPR0 + 58, PT_FPR0 + 60, PT_FPR0 + 62,
 PT_NIP, PT_MSR, PT_CCR, PT_LNK, PT_CTR, PT_XER, PT_MQ */
-/* *INDENT_ON * */
 
 static int
 ppc_register_u_addr (struct gdbarch *gdbarch, int regno)
@@ -1113,8 +1109,7 @@ fetch_register (struct regcache *regcache, int tid, int regno)
       regcache->raw_supply (regno, buf + padding);
     }
   else 
-    internal_error (__FILE__, __LINE__,
-                   _("fetch_register: unexpected byte order: %d"),
+    internal_error (_("fetch_register: unexpected byte order: %d"),
                    gdbarch_byte_order (gdbarch));
 }
 
@@ -1915,8 +1910,8 @@ fill_fpregset (const struct regcache *regcache,
 }
 
 int
-ppc_linux_nat_target::auxv_parse (gdb_byte **readptr,
-                                 gdb_byte *endptr, CORE_ADDR *typep,
+ppc_linux_nat_target::auxv_parse (const gdb_byte **readptr,
+                                 const gdb_byte *endptr, CORE_ADDR *typep,
                                  CORE_ADDR *valp)
 {
   int tid = inferior_ptid.lwp ();
@@ -1926,7 +1921,7 @@ ppc_linux_nat_target::auxv_parse (gdb_byte **readptr,
   int sizeof_auxv_field = ppc_linux_target_wordsize (tid);
 
   enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
-  gdb_byte *ptr = *readptr;
+  const gdb_byte *ptr = *readptr;
 
   if (endptr == ptr)
     return 0;
@@ -1946,6 +1941,9 @@ ppc_linux_nat_target::auxv_parse (gdb_byte **readptr,
 const struct target_desc *
 ppc_linux_nat_target::read_description ()
 {
+  if (inferior_ptid == null_ptid)
+    return this->beneath ()->read_description ();
+
   int tid = inferior_ptid.pid ();
 
   if (have_ptrace_getsetevrregs)
@@ -1965,8 +1963,8 @@ ppc_linux_nat_target::read_description ()
 
   features.wordsize = ppc_linux_target_wordsize (tid);
 
-  CORE_ADDR hwcap = linux_get_hwcap (current_inferior ()->top_target ());
-  CORE_ADDR hwcap2 = linux_get_hwcap2 (current_inferior ()->top_target ());
+  CORE_ADDR hwcap = linux_get_hwcap ();
+  CORE_ADDR hwcap2 = linux_get_hwcap2 ();
 
   if (have_ptrace_getsetvsxregs
       && (hwcap & PPC_FEATURE_HAS_VSX))
@@ -2123,8 +2121,7 @@ ppc_linux_nat_target::region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
         takes two hardware watchpoints though.  */
       if (len > 1
          && hwdebug_info.features & PPC_DEBUG_FEATURE_DATA_BP_RANGE
-         && (linux_get_hwcap (current_inferior ()->top_target ())
-             & PPC_FEATURE_BOOKE))
+         && (linux_get_hwcap () & PPC_FEATURE_BOOKE))
        return 2;
       /* Check if the processor provides DAWR interface.  */
       if (hwdebug_info.features & PPC_DEBUG_FEATURE_DATA_BP_DAWR)
@@ -2132,7 +2129,7 @@ ppc_linux_nat_target::region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
          /* DAWR interface allows to watch up to 512 byte wide ranges.  */
          region_size = 512;
          /* DAWR interface allows to watch up to 512 byte wide ranges which
-            can't cross a 512 byte bondary on machines that doesn't have a
+            can't cross a 512 byte boundary on machines that don't have a
             second DAWR (P9 or less).  */
          if (!(hwdebug_info.features & PPC_DEBUG_FEATURE_DATA_BP_ARCH_31))
            region_align = 512;
@@ -2152,8 +2149,7 @@ ppc_linux_nat_target::region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
     {
       gdb_assert (m_dreg_interface.debugreg_p ());
 
-      if (((linux_get_hwcap (current_inferior ()->top_target ())
-           & PPC_FEATURE_BOOKE)
+      if (((linux_get_hwcap () & PPC_FEATURE_BOOKE)
           && (addr + len) > (addr & ~3) + 4)
          || (addr + len) > (addr & ~7) + 8)
        return 0;
@@ -2458,14 +2454,14 @@ ppc_linux_nat_target::num_memory_accesses (const std::vector<value_ref_ptr>
       struct value *v = iter.get ();
 
       /* Constants and values from the history are fine.  */
-      if (VALUE_LVAL (v) == not_lval || deprecated_value_modifiable (v) == 0)
+      if (v->lval () == not_lval || !v->deprecated_modifiable ())
        continue;
-      else if (VALUE_LVAL (v) == lval_memory)
+      else if (v->lval () == lval_memory)
        {
          /* A lazy memory lvalue is one that GDB never needed to fetch;
             we either just used its address (e.g., `a' in `a.b') or
             we never needed it at all (e.g., `a' in `a,b').  */
-         if (!value_lazy (v))
+         if (!v->lazy ())
            found_memory_cnt++;
        }
       /* Other kinds of values are not fine.  */
@@ -2512,24 +2508,24 @@ ppc_linux_nat_target::check_condition (CORE_ADDR watch_addr,
     return 0;
 
   if (num_accesses_left == 1 && num_accesses_right == 0
-      && VALUE_LVAL (left_val) == lval_memory
-      && value_address (left_val) == watch_addr)
+      && left_val->lval () == lval_memory
+      && left_val->address () == watch_addr)
     {
       *data_value = value_as_long (right_val);
 
       /* DATA_VALUE is the constant in RIGHT_VAL, but actually has
         the same type as the memory region referenced by LEFT_VAL.  */
-      *len = check_typedef (value_type (left_val))->length ();
+      *len = check_typedef (left_val->type ())->length ();
     }
   else if (num_accesses_left == 0 && num_accesses_right == 1
-          && VALUE_LVAL (right_val) == lval_memory
-          && value_address (right_val) == watch_addr)
+          && right_val->lval () == lval_memory
+          && right_val->address () == watch_addr)
     {
       *data_value = value_as_long (left_val);
 
       /* DATA_VALUE is the constant in LEFT_VAL, but actually has
         the same type as the memory region referenced by RIGHT_VAL.  */
-      *len = check_typedef (value_type (right_val))->length ();
+      *len = check_typedef (right_val->type ())->length ();
     }
   else
     return 0;
@@ -2640,8 +2636,7 @@ ppc_linux_nat_target::insert_watchpoint (CORE_ADDR addr, int len,
       long wp_value;
       long read_mode, write_mode;
 
-      if (linux_get_hwcap (current_inferior ()->top_target ())
-         & PPC_FEATURE_BOOKE)
+      if (linux_get_hwcap () & PPC_FEATURE_BOOKE)
        {
          /* PowerPC 440 requires only the read/write flags to be passed
             to the kernel.  */
@@ -2741,7 +2736,7 @@ ppc_linux_nat_target::low_forget_process (pid_t pid)
 }
 
 /* Copy the per-process state associated with the pid of PARENT to the
-   sate of CHILD_PID.  GDB expects that a forked process will have the
+   state of CHILD_PID.  GDB expects that a forked process will have the
    same hardware breakpoints and watchpoints as the parent.
 
    If we're using the HWDEBUG interface, also copy the thread debug
@@ -2888,7 +2883,7 @@ ppc_linux_nat_target::low_prepare_to_resume (struct lwp_info *lp)
                  perror_with_name (_("Error deleting hardware "
                                      "breakpoint or watchpoint"));
 
-             /* We erase the entries one at a time after successfuly
+             /* We erase the entries one at a time after successfully
                 removing the corresponding slot form the thread so that
                 if we throw an exception above in a future iteration the
                 map remains consistent.  */
@@ -3014,11 +3009,9 @@ ppc_linux_nat_target::watchpoint_addr_within_range (CORE_ADDR addr,
   int mask;
 
   if (m_dreg_interface.hwdebug_p ()
-      && (linux_get_hwcap (current_inferior ()->top_target ())
-         & PPC_FEATURE_BOOKE))
+      && (linux_get_hwcap () & PPC_FEATURE_BOOKE))
     return start <= addr && start + length >= addr;
-  else if (linux_get_hwcap (current_inferior ()->top_target ())
-          & PPC_FEATURE_BOOKE)
+  else if (linux_get_hwcap () & PPC_FEATURE_BOOKE)
     mask = 3;
   else
     mask = 7;