+2014-04-23  Pedro Alves  <palves@redhat.com>
+
+       * i386-low.c: Don't include break-common.h here.
+       (i386_low_insert_watchpoint, i386_low_remove_watchpoint): Change
+       prototype to take target_hw_bp_type as argument instead of a Z
+       packet char.
+       * i386-low.h: Include break-common.h here.
+       (Z_packet_to_hw_type): Declare.
+       (i386_low_insert_watchpoint, i386_low_remove_watchpoint): Change
+       prototypes.
+       * linux-x86-low.c (x86_insert_point): Convert the packet number to
+       a target_hw_bp_type before calling i386_low_insert_watchpoint.
+       (x86_remove_point): Convert the packet number to a
+       target_hw_bp_type before calling i386_low_remove_watchpoint.
+       * win32-i386-low.c (i386_insert_point): Convert the packet number
+       to a target_hw_bp_type before calling i386_low_insert_watchpoint.
+       (i386_remove_point): Convert the packet number to a
+       target_hw_bp_type before calling i386_low_remove_watchpoint.
+
 2014-04-23  Pedro Alves  <palves@redhat.com>
 
        * utils.h (perror_with_name): Add ATTRIBUTE_NORETURN.
 
 #include "server.h"
 #include "target.h"
 #include "i386-low.h"
-#include "break-common.h"
 
 /* Support for 8-byte wide hw watchpoints.  */
 #ifndef TARGET_HAS_DR_LEN_8
 #define Z_PACKET_READ_WP '3'
 #define Z_PACKET_ACCESS_WP '4'
 
-/* Map the protocol watchpoint type TYPE to enum target_hw_bp_type.  */
-
-static enum target_hw_bp_type
+enum target_hw_bp_type
 Z_packet_to_hw_type (char type)
 {
   switch (type)
 
 int
 i386_low_insert_watchpoint (struct i386_debug_reg_state *state,
-                           char type_from_packet, CORE_ADDR addr, int len)
+                           enum target_hw_bp_type type,
+                           CORE_ADDR addr, int len)
 {
   int retval;
-  enum target_hw_bp_type type = Z_packet_to_hw_type (type_from_packet);
   /* Work on a local copy of the debug registers, and on success,
      commit the change back to the inferior.  */
   struct i386_debug_reg_state local_state = *state;
 
 /* Remove a watchpoint that watched the memory region which starts at
    address ADDR, whose length is LEN bytes, and for accesses of the
-   type TYPE_FROM_PACKET.  Return 0 on success, -1 on failure.  */
+   type TYPE.  Return 0 on success, -1 on failure.  */
 
 int
 i386_low_remove_watchpoint (struct i386_debug_reg_state *state,
-                           char type_from_packet, CORE_ADDR addr, int len)
+                           enum target_hw_bp_type type,
+                           CORE_ADDR addr, int len)
 {
   int retval;
-  enum target_hw_bp_type type = Z_packet_to_hw_type (type_from_packet);
   /* Work on a local copy of the debug registers, and on success,
      commit the change back to the inferior.  */
   struct i386_debug_reg_state local_state = *state;
 
    counts, and allow to watch regions up to 16 bytes long
    (32 bytes on 64 bit hosts).  */
 
+#include "break-common.h"
+
+/* Map the protocol watchpoint type TYPE to enum target_hw_bp_type.  */
+
+enum target_hw_bp_type Z_packet_to_hw_type (char type);
 
 /* Debug registers' indices.  */
 #define DR_FIRSTADDR 0
 
 /* Insert a watchpoint to watch a memory region which starts at
    address ADDR and whose length is LEN bytes.  Watch memory accesses
-   of the type TYPE_FROM_PACKET.  Return 0 on success, -1 on failure.  */
+   of the type TYPE.  Return 0 on success, -1 on failure.  */
 extern int i386_low_insert_watchpoint (struct i386_debug_reg_state *state,
-                                      char type_from_packet, CORE_ADDR addr,
+                                      enum target_hw_bp_type type,
+                                      CORE_ADDR addr,
                                       int len);
 
 /* Remove a watchpoint that watched the memory region which starts at
    address ADDR, whose length is LEN bytes, and for accesses of the
-   type TYPE_FROM_PACKET.  Return 0 on success, -1 on failure.  */
+   type TYPE.  Return 0 on success, -1 on failure.  */
 extern int i386_low_remove_watchpoint (struct i386_debug_reg_state *state,
-                                      char type_from_packet, CORE_ADDR addr,
+                                      enum target_hw_bp_type type,
+                                      CORE_ADDR addr,
                                       int len);
 
 /* Return non-zero if we can watch a memory region that starts at
 
     case '2': /* write watchpoint */
     case '3': /* read watchpoint */
     case '4': /* access watchpoint */
-      return i386_low_insert_watchpoint (&proc->private->arch_private->debug_reg_state,
-                                        type, addr, len);
+      {
+       enum target_hw_bp_type hw_type = Z_packet_to_hw_type (type);
+       struct i386_debug_reg_state *state
+         = &proc->private->arch_private->debug_reg_state;
+
+       return i386_low_insert_watchpoint (state, hw_type, addr, len);
+      }
 
     default:
       /* Unsupported.  */
     case '2': /* write watchpoint */
     case '3': /* read watchpoint */
     case '4': /* access watchpoint */
-      return i386_low_remove_watchpoint (&proc->private->arch_private->debug_reg_state,
-                                        type, addr, len);
+      {
+       enum target_hw_bp_type hw_type = Z_packet_to_hw_type (type);
+       struct i386_debug_reg_state *state
+         = &proc->private->arch_private->debug_reg_state;
+
+       return i386_low_remove_watchpoint (state, hw_type, addr, len);
+      }
     default:
       /* Unsupported.  */
       return 1;
 
     case '2':
     case '3':
     case '4':
-      return i386_low_insert_watchpoint (&debug_reg_state,
-                                        type, addr, len);
+      {
+       enum target_hw_bp_type hw_type = Z_packet_to_hw_type (type);
+
+       return i386_low_insert_watchpoint (&debug_reg_state,
+                                          hw_type, addr, len);
+      }
     default:
       /* Unsupported.  */
       return 1;
     case '2':
     case '3':
     case '4':
-      return i386_low_remove_watchpoint (&debug_reg_state,
-                                        type, addr, len);
+      {
+       enum target_hw_bp_type hw_type = Z_packet_to_hw_type (type);
+
+       return i386_low_remove_watchpoint (&debug_reg_state,
+                                          hw_type, addr, len);
+      }
     default:
       /* Unsupported.  */
       return 1;