gdb/
[deliverable/binutils-gdb.git] / gdb / ppc-linux-nat.c
index 9bd11fd8bbbe2ce3c4323b014280ca0c060bb78d..edb16c0b7a6b945c21ddbe2e2489bd855c6fa15a 100644 (file)
@@ -1,7 +1,6 @@
 /* PPC GNU/Linux native support.
 
-   Copyright (C) 1988-1989, 1991-1992, 1994, 1996, 2000-2012 Free
-   Software Foundation, Inc.
+   Copyright (C) 1988-2013 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -548,7 +547,7 @@ fetch_register (struct regcache *regcache, int tid, int regno)
   CORE_ADDR regaddr = ppc_register_u_addr (gdbarch, regno);
   int bytes_transferred;
   unsigned int offset;         /* Offset of registers within the u area.  */
-  char buf[MAX_REGISTER_SIZE];
+  gdb_byte buf[MAX_REGISTER_SIZE];
 
   if (altivec_register_p (gdbarch, regno))
     {
@@ -601,8 +600,8 @@ fetch_register (struct regcache *regcache, int tid, int regno)
       if (errno != 0)
        {
           char message[128];
-         sprintf (message, "reading register %s (#%d)", 
-                  gdbarch_register_name (gdbarch, regno), regno);
+         xsnprintf (message, sizeof (message), "reading register %s (#%d)",
+                    gdbarch_register_name (gdbarch, regno), regno);
          perror_with_name (message);
        }
       memcpy (&buf[bytes_transferred], &l, sizeof (l));
@@ -1035,7 +1034,7 @@ store_register (const struct regcache *regcache, int tid, int regno)
   CORE_ADDR regaddr = ppc_register_u_addr (gdbarch, regno);
   int i;
   size_t bytes_to_transfer;
-  char buf[MAX_REGISTER_SIZE];
+  gdb_byte buf[MAX_REGISTER_SIZE];
 
   if (altivec_register_p (gdbarch, regno))
     {
@@ -1095,8 +1094,8 @@ store_register (const struct regcache *regcache, int tid, int regno)
       if (errno != 0)
        {
           char message[128];
-         sprintf (message, "writing register %s (#%d)", 
-                  gdbarch_register_name (gdbarch, regno), regno);
+         xsnprintf (message, sizeof (message), "writing register %s (#%d)",
+                    gdbarch_register_name (gdbarch, regno), regno);
          perror_with_name (message);
        }
     }
@@ -1421,17 +1420,20 @@ have_ptrace_booke_interface (void)
       /* Check for kernel support for BOOKE debug registers.  */
       if (ptrace (PPC_PTRACE_GETHWDBGINFO, tid, 0, &booke_debug_info) >= 0)
        {
-         have_ptrace_booke_interface = 1;
-         max_slots_number = booke_debug_info.num_instruction_bps
-           + booke_debug_info.num_data_bps
-           + booke_debug_info.num_condition_regs;
-       }
-      else
-       {
-         /* Old school interface and no BOOKE debug registers support.  */
-         have_ptrace_booke_interface = 0;
-         memset (&booke_debug_info, 0, sizeof (struct ppc_debug_info));
+         /* Check whether ptrace BOOKE interface is functional and
+            provides any supported feature.  */
+         if (booke_debug_info.features != 0)
+           {
+             have_ptrace_booke_interface = 1;
+             max_slots_number = booke_debug_info.num_instruction_bps
+               + booke_debug_info.num_data_bps
+               + booke_debug_info.num_condition_regs;
+             return have_ptrace_booke_interface;
+           }
        }
+      /* Old school interface and no BOOKE debug registers support.  */
+      have_ptrace_booke_interface = 0;
+      memset (&booke_debug_info, 0, sizeof (struct ppc_debug_info));
     }
 
   return have_ptrace_booke_interface;
@@ -1461,7 +1463,7 @@ ppc_linux_can_use_hw_breakpoint (int type, int cnt, int ot)
   if (type == bp_hardware_watchpoint || type == bp_read_watchpoint
       || type == bp_access_watchpoint || type == bp_watchpoint)
     {
-      if (cnt > total_hw_wp)
+      if (cnt + ot > total_hw_wp)
        return -1;
     }
   else if (type == bp_hardware_breakpoint)
@@ -2218,12 +2220,13 @@ ppc_linux_thread_exit (struct thread_info *tp, int silent)
 static int
 ppc_linux_stopped_data_address (struct target_ops *target, CORE_ADDR *addr_p)
 {
-  siginfo_t *siginfo_p;
+  siginfo_t siginfo;
 
-  siginfo_p = linux_nat_get_siginfo (inferior_ptid);
+  if (!linux_nat_get_siginfo (inferior_ptid, &siginfo))
+    return 0;
 
-  if (siginfo_p->si_signo != SIGTRAP
-      || (siginfo_p->si_code & 0xffff) != 0x0004 /* TRAP_HWBKPT */)
+  if (siginfo.si_signo != SIGTRAP
+      || (siginfo.si_code & 0xffff) != 0x0004 /* TRAP_HWBKPT */)
     return 0;
 
   if (have_ptrace_booke_interface ())
@@ -2232,7 +2235,7 @@ ppc_linux_stopped_data_address (struct target_ops *target, CORE_ADDR *addr_p)
       struct thread_points *t;
       struct hw_break_tuple *hw_breaks;
       /* The index (or slot) of the *point is passed in the si_errno field.  */
-      int slot = siginfo_p->si_errno;
+      int slot = siginfo.si_errno;
 
       t = booke_find_thread_points_by_tid (TIDGET (inferior_ptid), 0);
 
@@ -2249,7 +2252,7 @@ ppc_linux_stopped_data_address (struct target_ops *target, CORE_ADDR *addr_p)
        }
     }
 
-  *addr_p = (CORE_ADDR) (uintptr_t) siginfo_p->si_addr;
+  *addr_p = (CORE_ADDR) (uintptr_t) siginfo.si_addr;
   return 1;
 }
 
@@ -2390,7 +2393,7 @@ ppc_linux_auxv_parse (struct target_ops *ops, gdb_byte **readptr,
                       gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
 {
   int sizeof_auxv_field = ppc_linux_target_wordsize ();
-  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
+  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
   gdb_byte *ptr = *readptr;
 
   if (endptr == ptr)
This page took 0.053239 seconds and 4 git commands to generate.