This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[pushed] gdbserver: decouple x86 watchpoint / hw breakpoint routines from Z packet numbers.


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        | 19 +++++++++++++++++++
 gdb/gdbserver/i386-low.c       | 15 ++++++---------
 gdb/gdbserver/i386-low.h       | 15 +++++++++++----
 gdb/gdbserver/linux-x86-low.c  | 18 ++++++++++++++----
 gdb/gdbserver/win32-i386-low.c | 16 ++++++++++++----
 5 files changed, 62 insertions(+), 21 deletions(-)

diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index ad2b1ae..c419e43 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,5 +1,24 @@
 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.
 
 2014-04-10  Pedro Alves  <palves@redhat.com>
diff --git a/gdb/gdbserver/i386-low.c b/gdb/gdbserver/i386-low.c
index 33ef0a4..03eebd1 100644
--- a/gdb/gdbserver/i386-low.c
+++ b/gdb/gdbserver/i386-low.c
@@ -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;
diff --git a/gdb/gdbserver/i386-low.h b/gdb/gdbserver/i386-low.h
index 1a4e3cc..d91c90a 100644
--- a/gdb/gdbserver/i386-low.h
+++ b/gdb/gdbserver/i386-low.h
@@ -29,6 +29,11 @@
    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
diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c
index 33b5f26..2f518b1 100644
--- a/gdb/gdbserver/linux-x86-low.c
+++ b/gdb/gdbserver/linux-x86-low.c
@@ -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;
diff --git a/gdb/gdbserver/win32-i386-low.c b/gdb/gdbserver/win32-i386-low.c
index 1cb0c5f..ce9b303 100644
--- a/gdb/gdbserver/win32-i386-low.c
+++ b/gdb/gdbserver/win32-i386-low.c
@@ -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;
-- 
1.7.11.7


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]