gdbserver: decouple x86 watchpoint / hw breakpoint routines from Z packet numbers.
authorPedro Alves <palves@redhat.com>
Tue, 22 Apr 2014 18:47:04 +0000 (19:47 +0100)
committerPedro Alves <palves@redhat.com>
Wed, 23 Apr 2014 17:33:52 +0000 (18:33 +0100)
My main motivation here is moving in the direction of decoupling
insert_point/remove_point from packet numbers, though this bit alone
should make it a little bit easier to merge gdb/gdbserver/i386-low.c
and gdb/i386-nat.c (which are largely the same).

Tested on x86_64 Fedora 17, and cross built for i686-mingw32 too.

gdb/gdbserver/
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.

gdb/gdbserver/ChangeLog
gdb/gdbserver/i386-low.c
gdb/gdbserver/i386-low.h
gdb/gdbserver/linux-x86-low.c
gdb/gdbserver/win32-i386-low.c

index ad2b1ae2a3de80ddb5293f736c1e0d63330da2a3..c419e43c9f2e4251e4f2a6fc4617b15dfef10a0e 100644 (file)
@@ -1,3 +1,22 @@
+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.
index 33ef0a4d60ffac8eb8515e59cf163ac97d47467b..03eebd1b761f69f7f5eb1d534cc4a2e72def2778 100644 (file)
@@ -20,7 +20,6 @@
 #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
@@ -408,9 +407,7 @@ Invalid value %d of operation in i386_handle_nonaligned_watchpoint.\n",
 #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)
@@ -457,10 +454,10 @@ i386_update_inferior_debug_regs (struct i386_debug_reg_state *inf_state,
 
 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;
@@ -493,14 +490,14 @@ i386_low_insert_watchpoint (struct i386_debug_reg_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;
index 1a4e3cc68d7139ea906b4c3090c318c91938c688..d91c90ac776bb1fb91a79b76f3132c5335d90643 100644 (file)
    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
@@ -58,16 +63,18 @@ extern void i386_low_init_dregs (struct i386_debug_reg_state *state);
 
 /* 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
index 33b5f265f773091d283f1b761466f784e86e3110..2f518b19b015f681ebf8632b48de4aa0b6ac8217 100644 (file)
@@ -641,8 +641,13 @@ x86_insert_point (char type, CORE_ADDR addr, int len)
     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.  */
@@ -671,8 +676,13 @@ x86_remove_point (char type, CORE_ADDR addr, int len)
     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;
index 1cb0c5fb66c4a32335d0fdca53964a05fcbec511..ce9b3032f46510efdea15fa007e723b180996d65 100644 (file)
@@ -105,8 +105,12 @@ i386_insert_point (char type, CORE_ADDR addr, int len)
     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;
@@ -121,8 +125,12 @@ i386_remove_point (char type, CORE_ADDR addr, int len)
     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;
This page took 0.036453 seconds and 4 git commands to generate.