Update years in copyright notice for the GDB files.
[deliverable/binutils-gdb.git] / gdb / gdbserver / linux-arm-low.c
index bf1792bf9e08d1f6fd0a47ddfebfaebb9bffe884..8ddd90af3a9bbef21de1151c848baa2ef1ee1209 100644 (file)
@@ -1,5 +1,5 @@
 /* GNU/Linux/ARM specific low level interface, for the remote server for GDB.
-   Copyright (C) 1995-1996, 1998-2012 Free Software Foundation, Inc.
+   Copyright (C) 1995-2013 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -432,8 +432,9 @@ arm_linux_hw_breakpoint_equal (const struct arm_linux_hw_breakpoint *p1,
 
 /* Initialize the hardware breakpoint structure P for a breakpoint or
    watchpoint at ADDR to LEN.  The type of watchpoint is given in TYPE.
-   Returns -1 if TYPE is unsupported, 0 if TYPE represents a breakpoint,
-   and 1 if type represents a watchpoint.  */
+   Returns -1 if TYPE is unsupported, or -2 if the particular combination
+   of ADDR and LEN cannot be implemented.  Otherwise, returns 0 if TYPE
+   represents a breakpoint and 1 if type represents a watchpoint.  */
 static int
 arm_linux_hw_point_initialize (char type, CORE_ADDR addr, int len,
                               struct arm_linux_hw_breakpoint *p)
@@ -474,17 +475,17 @@ arm_linux_hw_point_initialize (char type, CORE_ADDR addr, int len,
        {
        case 2:  /* 16-bit Thumb mode breakpoint */
        case 3:  /* 32-bit Thumb mode breakpoint */
-         mask = 0x3 << (addr & 2);
+         mask = 0x3;
+         addr &= ~1;
          break;
        case 4:  /* 32-bit ARM mode breakpoint */
          mask = 0xf;
+         addr &= ~3;
          break;
        default:
          /* Unsupported. */
-         return -1;
+         return -2;
        }
-
-      addr &= ~3;
     }
   else
     {
@@ -493,17 +494,17 @@ arm_linux_hw_point_initialize (char type, CORE_ADDR addr, int len,
 
       /* Can not set watchpoints for zero or negative lengths.  */
       if (len <= 0)
-       return -1;
+       return -2;
       /* The current ptrace interface can only handle watchpoints that are a
         power of 2.  */
       if ((len & (len - 1)) != 0)
-       return -1;
+       return -2;
 
       /* Test that the range [ADDR, ADDR + LEN) fits into the largest address
         range covered by a watchpoint.  */
       aligned_addr = addr & ~(max_wp_length - 1);
       if (aligned_addr + max_wp_length < addr + len)
-       return -1;
+       return -2;
 
       mask = (1 << len) - 1;
     }
@@ -560,7 +561,7 @@ arm_insert_point (char type, CORE_ADDR addr, int len)
   if (watch < 0)
     {
       /* Unsupported.  */
-      return 1;
+      return watch == -1 ? 1 : -1;
     }
 
   if (watch)
@@ -709,13 +710,15 @@ arm_prepare_to_resume (struct lwp_info *lwp)
        errno = 0;
 
        if (arm_hwbp_control_is_enabled (proc_info->bpts[i].control))
-         if (ptrace (PTRACE_SETHBPREGS, pid, ((i << 1) + 1),
-             &proc_info->bpts[i].address) < 0)
+         if (ptrace (PTRACE_SETHBPREGS, pid,
+                     (PTRACE_ARG3_TYPE) ((i << 1) + 1),
+                     &proc_info->bpts[i].address) < 0)
            perror_with_name ("Unexpected error setting breakpoint address");
 
        if (arm_hwbp_control_is_initialized (proc_info->bpts[i].control))
-         if (ptrace (PTRACE_SETHBPREGS, pid, ((i << 1) + 2),
-             &proc_info->bpts[i].control) < 0)
+         if (ptrace (PTRACE_SETHBPREGS, pid,
+                     (PTRACE_ARG3_TYPE) ((i << 1) + 2),
+                     &proc_info->bpts[i].control) < 0)
            perror_with_name ("Unexpected error setting breakpoint");
 
        lwp_info->bpts_changed[i] = 0;
@@ -727,13 +730,15 @@ arm_prepare_to_resume (struct lwp_info *lwp)
        errno = 0;
 
        if (arm_hwbp_control_is_enabled (proc_info->wpts[i].control))
-         if (ptrace (PTRACE_SETHBPREGS, pid, -((i << 1) + 1),
-             &proc_info->wpts[i].address) < 0)
+         if (ptrace (PTRACE_SETHBPREGS, pid,
+                     (PTRACE_ARG3_TYPE) -((i << 1) + 1),
+                     &proc_info->wpts[i].address) < 0)
            perror_with_name ("Unexpected error setting watchpoint address");
 
        if (arm_hwbp_control_is_initialized (proc_info->wpts[i].control))
-         if (ptrace (PTRACE_SETHBPREGS, pid, -((i << 1) + 2),
-             &proc_info->wpts[i].control) < 0)
+         if (ptrace (PTRACE_SETHBPREGS, pid,
+                     (PTRACE_ARG3_TYPE) -((i << 1) + 2),
+                     &proc_info->wpts[i].control) < 0)
            perror_with_name ("Unexpected error setting watchpoint");
 
        lwp_info->wpts_changed[i] = 0;
This page took 0.027415 seconds and 4 git commands to generate.