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]

[RFC] Remove last occurences of target_{insert/remove}_watchpoint


The two macros target_insert_watchpoint and target_remove_watchpoint
and only still defined inn three config files.

  These macros are really bad, because that
forbid remote target to work properly on the targets
that define them.

  The patch below tries to get rid of them,
by defining appropriate target functions.

  I needed to insert another new macros that I called
STOP_AFTER_WATCHPOINT because out of three, two of these targets
call procfs_set_watchpoint with after_trap set to one,
and the third (mips/nm-irix5.h) set to zero.


I tried a similar patch on an i386 open solaris and it seems to
give almost unchanged results for the testsuite.
(Beware that the patch below is not exactly the one I tested, because I
couldn't
retrieve it...)


Who are the maintainers of
 - i386 solaris
 - sparc solaris
and
 - mips irix?

 
Comments most welcome,



Pierre Muller
Pascal language support maintainer for GDB



2009-04-23  Pierre Muller  <muller.u-strasbg.fr>

	Remove target_insert_watchpoint and target_remove_watchpoint.
	* procfs.c (procfs_insert_watchpoint, procfs_remove_watchpoint)
	(procfs_insert_hw_breakpoint, procfs_remove_hw_breakpoint)
	(procfs_use_watchpoints):
	New functions.
	(procfs_stopped_by_watchpoint): Made static, ptid type
	argument removed.
	(_initialize_procfs): Register new watchpoint related
	target functions.
	* config/i386/nm-i386sol2.h (STOP_AFTER_WATCHPOINT): New macro.
	(target_insert_watchpoint, target_remove_watchpoint): Delete.
	* config/mips/nm-irix5.h: Idem.
	* config/sparc/nm-sol2.h: Idem.

Index: procfs.c
===================================================================
RCS file: /cvs/src/src/gdb/procfs.c,v
retrieving revision 1.104
diff -u -p -r1.104 procfs.c
--- procfs.c	16 Apr 2009 18:41:40 -0000	1.104
+++ procfs.c	22 Apr 2009 22:54:05 -0000
@@ -223,6 +223,56 @@ procfs_target (void)
   return t;
 }
 
+#ifdef TARGET_HAS_HARDWARE_WATCHPOINTS
+
+static int procfs_stopped_by_watchpoint ();
+
+static int
+procfs_insert_watchpoint (CORE_ADDR addr, int len, int type)
+{
+  return procfs_set_watchpoint (inferior_ptid, addr, len, type, 
+				STOP_AFTER_WATCHPOINT);
+}
+
+static int
+procfs_remove_watchpoint (CORE_ADDR addr, int len, int type)
+{
+  procfs_set_watchpoint (inferior_ptid, addr, 0, 0, 0);
+}
+
+static int
+procfs_insert_hw_breakpoint (struct bp_target_info *bp_tgt)
+{
+  CORE_ADDR addr = bp_tgt->placed_address;
+  return procfs_set_watchpoint (inferior_ptid, addr, 1, hw_execute, 0);
+}
+
+static int
+procfs_remove_hw_breakpoint (struct bp_target_info *bp_tgt)
+{
+  CORE_ADDR addr = bp_tgt->placed_address;
+  procfs_set_watchpoint (inferior_ptid, addr, 0, 0, 0);
+}
+
+
+void
+procfs_use_watchpoints (struct target_ops *t)
+{
+  // region_ok_for_hw_watchpoint has a default function
+  // t->to_region_ok_for_hw_watchpoint = procfs_region_ok_for_watchpoint;
+  t->to_stopped_by_watchpoint = procfs_stopped_by_watchpoint;
+  /* FIXME: Is it possible in procfs to know the address of the triggered
+     watchpoint?  */
+  /* t->to_stopped_data_address = procfs_stopped_data_address;
+     this function does not exist yet.  */
+  t->to_insert_watchpoint = procfs_insert_watchpoint;
+  t->to_remove_watchpoint = procfs_remove_watchpoint;
+  t->to_insert_hw_breakpoint = procfs_insert_hw_breakpoint;
+  t->to_remove_hw_breakpoint = procfs_remove_hw_breakpoint;
+}
+
+#endif /* TARGET_HAS_HARDWARE_WATCHPOINTS */
+
 /* =================== END, TARGET_OPS "MODULE" =================== */
 
 /*
@@ -5321,13 +5371,12 @@ procfs_can_use_hw_breakpoint (int type, 
  * else returns zero.
  */
 
-int
-procfs_stopped_by_watchpoint (ptid_t ptid)
+static int
+procfs_stopped_by_watchpoint ()
 {
   procinfo *pi;
 
-  pi = find_procinfo_or_die (PIDGET (ptid) == -1 ?
-			     PIDGET (inferior_ptid) : PIDGET (ptid), 0);
+  pi = find_procinfo_or_die (PIDGET (inferior_ptid));
 
   if (!pi)	/* If no process, then not stopped by watchpoint!  */
     return 0;
@@ -5970,6 +6019,10 @@ _initialize_procfs (void)
 
   t = procfs_target ();
 
+#ifdef TARGET_HAS_HARDWARE_WATCHPOINTS 
+  procfs_use_watchpoints (t);
+#endif /* TARGET_HAS_HARDWARE_WATCHPOINTS */
+
   add_target (t);
 
   add_info ("proc", info_proc_cmd, _("\
Index: config/i386/nm-i386sol2.h
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/nm-i386sol2.h,v
retrieving revision 1.16
diff -u -p -r1.16 nm-i386sol2.h
--- config/i386/nm-i386sol2.h	3 Jan 2009 05:57:54 -0000	1.16
+++ config/i386/nm-i386sol2.h	22 Apr 2009 22:52:44 -0000
@@ -19,6 +19,7 @@
 #ifdef NEW_PROC_API	/* Solaris 6 and above can do HW watchpoints */
 
 #define TARGET_HAS_HARDWARE_WATCHPOINTS
+#define STOP_AFTER_WATCHPOINT 1
 
 /* The man page for proc4 on solaris 6 and 7 says that the system
    can support "thousands" of hardware watchpoints, but gives no
@@ -41,17 +42,4 @@
    step anyway.  */
 #define CANNOT_STEP_HW_WATCHPOINTS
 
-extern int procfs_stopped_by_watchpoint (ptid_t);
-#define STOPPED_BY_WATCHPOINT(W) \
-  procfs_stopped_by_watchpoint(inferior_ptid)
-
-/* Use these macros for watchpoint insertion/deletion.  */
-/* type can be 0: write watch, 1: read watch, 2: access watch (read/write)
*/
-
-extern int procfs_set_watchpoint (ptid_t, CORE_ADDR, int, int, int);
-#define target_insert_watchpoint(ADDR, LEN, TYPE) \
-        procfs_set_watchpoint (inferior_ptid, ADDR, LEN, TYPE, 1)
-#define target_remove_watchpoint(ADDR, LEN, TYPE) \
-        procfs_set_watchpoint (inferior_ptid, ADDR, 0, 0, 0)
-
 #endif /* NEW_PROC_API */
Index: config/mips/nm-irix5.h
===================================================================
RCS file: /cvs/src/src/gdb/config/mips/nm-irix5.h,v
retrieving revision 1.18
diff -u -p -r1.18 nm-irix5.h
--- config/mips/nm-irix5.h	3 Jan 2009 05:57:55 -0000	1.18
+++ config/mips/nm-irix5.h	22 Apr 2009 22:52:44 -0000
@@ -19,6 +19,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
 
 #define TARGET_HAS_HARDWARE_WATCHPOINTS
+#define STOP_AFTER_WATCHPOINT 0
 
 /* TARGET_CAN_USE_HARDWARE_WATCHPOINT is now defined to go through
    the target vector.  For Irix5, procfs_can_use_hw_watchpoint()
@@ -28,17 +29,5 @@
    instruction which caused the watchpoint.  It will be necessary for
    GDB to step over the watchpoint. */
 
-#define STOPPED_BY_WATCHPOINT(W) \
-     procfs_stopped_by_watchpoint(inferior_ptid)
-extern int procfs_stopped_by_watchpoint (ptid_t);
-
-/* Use these macros for watchpoint insertion/deletion.  */
-/* type can be 0: write watch, 1: read watch, 2: access watch (read/write)
*/
-#define target_insert_watchpoint(ADDR, LEN, TYPE) \
-     procfs_set_watchpoint (inferior_ptid, ADDR, LEN, TYPE, 0)
-#define target_remove_watchpoint(ADDR, LEN, TYPE) \
-     procfs_set_watchpoint (inferior_ptid, ADDR, 0, 0, 0)
-extern int procfs_set_watchpoint (ptid_t, CORE_ADDR, int, int, int);
-
 #define TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT(SIZE) 1
 
Index: config/sparc/nm-sol2.h
===================================================================
RCS file: /cvs/src/src/gdb/config/sparc/nm-sol2.h,v
retrieving revision 1.7
diff -u -p -r1.7 nm-sol2.h
--- config/sparc/nm-sol2.h	3 Jan 2009 05:57:56 -0000	1.7
+++ config/sparc/nm-sol2.h	22 Apr 2009 22:52:45 -0000
@@ -29,6 +29,7 @@
 #ifdef NEW_PROC_API
 
 #define TARGET_HAS_HARDWARE_WATCHPOINTS
+#define STOP_AFTER_WATCHPOINT 1
 
 /* The man page for proc(4) on Solaris 2.6 and up says that the system
    can support "thousands" of hardware watchpoints, but gives no
@@ -42,19 +43,6 @@
    *NOT* be necessary for GDB to step over the watchpoint.  */
 #define HAVE_CONTINUABLE_WATCHPOINT 1
 
-extern int procfs_stopped_by_watchpoint (ptid_t);
-#define STOPPED_BY_WATCHPOINT(W) \
-  procfs_stopped_by_watchpoint(inferior_ptid)
-
-/* Use these macros for watchpoint insertion/deletion.  TYPE can be 0
-   (write watch), 1 (read watch), 2 (access watch (read/write).  */
-
-extern int procfs_set_watchpoint (ptid_t, CORE_ADDR, int, int, int);
-#define target_insert_watchpoint(ADDR, LEN, TYPE) \
-        procfs_set_watchpoint (inferior_ptid, ADDR, LEN, TYPE, 1)
-#define target_remove_watchpoint(ADDR, LEN, TYPE) \
-        procfs_set_watchpoint (inferior_ptid, ADDR, 0, 0, 0)
-
 #endif /* NEW_PROC_API */
 
 #endif /* nm-sol2.h */


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