Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] Unify target header macros
@ 2009-05-10 16:15 Pierre Muller
  2009-05-11  9:17 ` Joel Brobecker
  0 siblings, 1 reply; 3+ messages in thread
From: Pierre Muller @ 2009-05-10 16:15 UTC (permalink / raw)
  To: gdb-patches

This RFA is to answer Joel's request formulated in
http://sourceware.org/ml/gdb-patches/2009-05/msg00178.html

It was done by using a sed script, which means that it is
quite mechanical.

  In particular, I suspect that some of the comments
that are changed by that patch are obsolete...

Is OK nevertheless? 



Pierre Muller
Pascal language support maintainer for GDB



2009-05-10  Pierre Muller  <muller.u-strasbg.fr>

	Unify target macros.

	* target.h (STOPPED_BY_WATCHPOINT): Delete, replaced by ...
	(target_stoppped_by_watchpoint): New macro.
	(HAVE_STEPPABLE_WATCHPOINT): Delete, replaced by ...
	(target_have_steppable_watchpoint): New macro.
	(HAVE_CONTINUABLE_WATCHPOINT): Delete, replace by ...
	(target_have_continuable_watchpoint): New macro.
	(TARGET_CAN_USE_HARDWARE_WATCHPOINT):Delete, replaced by ...
	(target_can_use_hardware_watchpoint): New macro.
	(TARGET_REGION_OK_FOR_HW_WATCHPOINT):Delete, replaced by ...
	(target_region_ok_for_hw_watchpoint): New macro.

	* breakpoint.c (update_watchpoint): Use new macros.
	(bpstat_alloc): Likewise.
	(create_breakpoint): Likewise.
	(watch_command_1): Likewise.
	(can_use_hardware_watchpoint): Likewise.
	(do_enable_breakpoint): Likewise.
	* infrun.c (handle_inferior_event): Adapt to new macros.
	* mips-tdep.c (mips_gdbarch_init): Update comments.
	* procfs.c (procfs_set_watchpoint): Update comment.
	(procfs_insert_watchpoint): Adapt to new macros.
	* remote-m32r-sdi.c (m32r_stop):
	* remote-mips.c (mips_remove_breakpoint):
	* target.c (debug_to_region_ok_for_hw_watchpoint): Update to new
macros.
	(debug_to_stopped_by_watchpoint): Likewise.


Index: target.h
===================================================================
RCS file: /cvs/src/src/gdb/target.h,v
retrieving revision 1.151
diff -u -p -r1.151 target.h
--- target.h	10 May 2009 13:30:53 -0000	1.151
+++ target.h	10 May 2009 14:05:23 -0000
@@ -1053,17 +1053,17 @@ extern char *normal_pid_to_str (ptid_t p
 /* Returns non-zero if we were stopped by a hardware watchpoint (memory
read or
    write).  */
 
-#define STOPPED_BY_WATCHPOINT(w) \
-   (*current_target.to_stopped_by_watchpoint) ()
+#define target_stopped_by_watchpoint \
+   (*current_target.to_stopped_by_watchpoint)
 
 /* Non-zero if we have steppable watchpoints  */
 
-#define HAVE_STEPPABLE_WATCHPOINT \
+#define target_have_steppable_watchpoint \
    (current_target.to_have_steppable_watchpoint)
 
 /* Non-zero if we have continuable watchpoints  */
 
-#define HAVE_CONTINUABLE_WATCHPOINT \
+#define target_have_continuable_watchpoint \
    (current_target.to_have_continuable_watchpoint)
 
 /* Provide defaults for hardware watchpoint functions.  */
@@ -1076,10 +1076,10 @@ extern char *normal_pid_to_str (ptid_t p
    bp_hardware_breakpoint.  CNT is the number of such watchpoints used so
far
    (including this one?).  OTHERTYPE is who knows what...  */
 
-#define TARGET_CAN_USE_HARDWARE_WATCHPOINT(TYPE,CNT,OTHERTYPE) \
+#define target_can_use_hardware_watchpoint(TYPE,CNT,OTHERTYPE) \
  (*current_target.to_can_use_hw_breakpoint) (TYPE, CNT, OTHERTYPE);
 
-#define TARGET_REGION_OK_FOR_HW_WATCHPOINT(addr, len) \
+#define target_region_ok_for_hw_watchpoint(addr, len) \
     (*current_target.to_region_ok_for_hw_watchpoint) (addr, len)
 
 
Index: breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.393
diff -u -p -r1.393 breakpoint.c
--- breakpoint.c	5 May 2009 13:24:48 -0000	1.393
+++ breakpoint.c	10 May 2009 14:03:34 -0000
@@ -961,7 +961,7 @@ update_watchpoint (struct breakpoint *b,
 	      b->type = bp_watchpoint;
 	    else
 	      {
-		int target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT
+		int target_resources_ok = target_can_use_hardware_watchpoint
 		  (bp_hardware_watchpoint, i + mem_cnt, other_type_used);
 		if (target_resources_ok <= 0)
 		  b->type = bp_watchpoint;
@@ -2602,7 +2602,7 @@ bpstat_alloc (const struct bp_location *
 int
 watchpoints_triggered (struct target_waitstatus *ws)
 {
-  int stopped_by_watchpoint = STOPPED_BY_WATCHPOINT (*ws);
+  int stopped_by_watchpoint = target_stopped_by_watchpoint ();
   CORE_ADDR addr;
   struct breakpoint *b;
 
@@ -5249,7 +5249,7 @@ create_breakpoint (struct symtabs_and_li
     {
       int i = hw_breakpoint_used_count ();
       int target_resources_ok = 
-	TARGET_CAN_USE_HARDWARE_WATCHPOINT (bp_hardware_breakpoint, 
+	target_can_use_hardware_watchpoint (bp_hardware_breakpoint, 
 					    i + 1, 0);
       if (target_resources_ok == 0)
 	error (_("No hardware breakpoint support in the target."));
@@ -6170,7 +6170,7 @@ watch_command_1 (char *arg, int accessfl
     {
       i = hw_watchpoint_used_count (bp_type, &other_type_used);
       target_resources_ok = 
-	TARGET_CAN_USE_HARDWARE_WATCHPOINT (bp_type, i + mem_cnt, 
+	target_can_use_hardware_watchpoint (bp_type, i + mem_cnt, 
 					    other_type_used);
       if (target_resources_ok == 0 && bp_type != bp_hardware_watchpoint)
 	error (_("Target does not support this type of hardware
watchpoint."));
@@ -6308,7 +6308,7 @@ can_use_hardware_watchpoint (struct valu
 		  CORE_ADDR vaddr = VALUE_ADDRESS (v) + value_offset (v);
 		  int       len   = TYPE_LENGTH (value_type (v));
 
-		  if (!TARGET_REGION_OK_FOR_HW_WATCHPOINT (vaddr, len))
+		  if (!target_region_ok_for_hw_watchpoint (vaddr, len))
 		    return 0;
 		  else
 		    found_memory_cnt++;
@@ -7977,7 +7977,7 @@ do_enable_breakpoint (struct breakpoint 
       int i;
       i = hw_breakpoint_used_count ();
       target_resources_ok = 
-	TARGET_CAN_USE_HARDWARE_WATCHPOINT (bp_hardware_breakpoint, 
+	target_can_use_hardware_watchpoint (bp_hardware_breakpoint, 
 					    i + 1, 0);
       if (target_resources_ok == 0)
 	error (_("No hardware breakpoint support in the target."));
Index: infrun.c
===================================================================
RCS file: /cvs/src/src/gdb/infrun.c,v
retrieving revision 1.371
diff -u -p -r1.371 infrun.c
--- infrun.c	5 May 2009 13:24:48 -0000	1.371
+++ infrun.c	10 May 2009 14:04:21 -0000
@@ -2568,7 +2568,7 @@ targets should add new threads to the th
     {
       fprintf_unfiltered (gdb_stdlog, "infrun: stop_pc = 0x%s\n",
                           paddr_nz (stop_pc));
-      if (STOPPED_BY_WATCHPOINT (&ecs->ws))
+      if (target_stopped_by_watchpoint ())
 	{
           CORE_ADDR addr;
 	  fprintf_unfiltered (gdb_stdlog, "infrun: stopped by
watchpoint\n");
@@ -2824,7 +2824,7 @@ targets should add new threads to the th
   /* If necessary, step over this watchpoint.  We'll be back to display
      it in a moment.  */
   if (stopped_by_watchpoint
-      && (HAVE_STEPPABLE_WATCHPOINT
+      && (target_have_steppable_watchpoint
 	  || gdbarch_have_nonsteppable_watchpoint (current_gdbarch)))
     {
       /* At this point, we are stopped at an instruction which has
@@ -2849,14 +2849,14 @@ targets should add new threads to the th
 	 disable all watchpoints and breakpoints.  */
       int hw_step = 1;
 
-      if (!HAVE_STEPPABLE_WATCHPOINT)
+      if (!target_have_steppable_watchpoint)
 	remove_breakpoints ();
 	/* Single step */
       hw_step = maybe_software_singlestep (current_gdbarch, stop_pc);
       target_resume (ecs->ptid, hw_step, TARGET_SIGNAL_0);
       registers_changed ();
       waiton_ptid = ecs->ptid;
-      if (HAVE_STEPPABLE_WATCHPOINT)
+      if (target_have_steppable_watchpoint)
 	infwait_state = infwait_step_watch_state;
       else
 	infwait_state = infwait_nonstep_watch_state;
Index: mips-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mips-tdep.c,v
retrieving revision 1.492
diff -u -p -r1.492 mips-tdep.c
--- mips-tdep.c	5 May 2009 13:24:49 -0000	1.492
+++ mips-tdep.c	10 May 2009 14:04:40 -0000
@@ -6005,11 +6005,11 @@ mips_gdbarch_init (struct gdbarch_info i
   else
     set_gdbarch_print_insn (gdbarch, gdb_print_insn_mips);
 
-  /* FIXME: cagney/2003-08-29: The macros HAVE_STEPPABLE_WATCHPOINT,
-     HAVE_NONSTEPPABLE_WATCHPOINT, and HAVE_CONTINUABLE_WATCHPOINT
+  /* FIXME: cagney/2003-08-29: The macros target_have_steppable_watchpoint,
+     HAVE_NONSTEPPABLE_WATCHPOINT, and target_have_continuable_watchpoint
      need to all be folded into the target vector.  Since they are
-     being used as guards for STOPPED_BY_WATCHPOINT, why not have
-     STOPPED_BY_WATCHPOINT return the type of watchpoint that the code
+     being used as guards for target_stopped_by_watchpoint, why not have
+     target_stopped_by_watchpoint return the type of watchpoint that the
code
      is sitting on?  */
   set_gdbarch_have_nonsteppable_watchpoint (gdbarch, 1);
 
Index: procfs.c
===================================================================
RCS file: /cvs/src/src/gdb/procfs.c,v
retrieving revision 1.106
diff -u -p -r1.106 procfs.c
--- procfs.c	6 May 2009 17:18:52 -0000	1.106
+++ procfs.c	10 May 2009 14:04:52 -0000
@@ -5289,7 +5289,7 @@ procfs_set_watchpoint (ptid_t ptid, CORE
 
    Note:  procfs_can_use_hw_breakpoint() is not yet used by all
    procfs.c targets due to the fact that some of them still define
-   TARGET_CAN_USE_HARDWARE_WATCHPOINT.  */
+   target_can_use_hardware_watchpoint.  */
 
 static int
 procfs_can_use_hw_breakpoint (int type, int cnt, int othertype)
@@ -5352,7 +5352,7 @@ procfs_stopped_by_watchpoint (void)
 static int
 procfs_insert_watchpoint (CORE_ADDR addr, int len, int type)
 {
-  if (!HAVE_STEPPABLE_WATCHPOINT
+  if (!target_have_steppable_watchpoint
       && !gdbarch_have_nonsteppable_watchpoint (current_gdbarch))
     {
       /* When a hardware watchpoint fires off the PC will be left at
Index: remote-m32r-sdi.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-m32r-sdi.c,v
retrieving revision 1.41
diff -u -p -r1.41 remote-m32r-sdi.c
--- remote-m32r-sdi.c	5 May 2009 13:24:49 -0000	1.41
+++ remote-m32r-sdi.c	10 May 2009 14:04:54 -0000
@@ -1398,7 +1398,7 @@ m32r_stop (ptid_t ptid)
 
 /* Tell whether this target can support a hardware breakpoint.  CNT
    is the number of hardware breakpoints already installed.  This
-   implements the TARGET_CAN_USE_HARDWARE_WATCHPOINT macro.  */
+   implements the target_can_use_hardware_watchpoint macro.  */
 
 static int
 m32r_can_use_hw_watchpoint (int type, int cnt, int othertype)
Index: remote-mips.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-mips.c,v
retrieving revision 1.100
diff -u -p -r1.100 remote-mips.c
--- remote-mips.c	5 May 2009 13:24:49 -0000	1.100
+++ remote-mips.c	10 May 2009 14:04:55 -0000
@@ -2249,7 +2249,7 @@ mips_remove_breakpoint (struct bp_target
 
 /* Tell whether this target can support a hardware breakpoint.  CNT
    is the number of hardware breakpoints already installed.  This
-   implements the TARGET_CAN_USE_HARDWARE_WATCHPOINT macro.  */
+   implements the target_can_use_hardware_watchpoint macro.  */
 
 int
 mips_can_use_watchpoint (int type, int cnt, int othertype)
Index: target.c
===================================================================
RCS file: /cvs/src/src/gdb/target.c,v
retrieving revision 1.206
diff -u -p -r1.206 target.c
--- target.c	14 Apr 2009 16:48:07 -0000	1.206
+++ target.c	10 May 2009 14:05:23 -0000
@@ -2889,7 +2889,7 @@ debug_to_region_ok_for_hw_watchpoint (CO
   retval = debug_target.to_region_ok_for_hw_watchpoint (addr, len);
 
   fprintf_unfiltered (gdb_stdlog,
-		      "TARGET_REGION_OK_FOR_HW_WATCHPOINT (%ld, %ld) =
0x%lx\n",
+		      "target_region_ok_for_hw_watchpoint (%ld, %ld) =
0x%lx\n",
 		      (unsigned long) addr,
 		      (unsigned long) len,
 		      (unsigned long) retval);
@@ -2904,7 +2904,7 @@ debug_to_stopped_by_watchpoint (void)
   retval = debug_target.to_stopped_by_watchpoint ();
 
   fprintf_unfiltered (gdb_stdlog,
-		      "STOPPED_BY_WATCHPOINT () = %ld\n",
+		      "target_stopped_by_watchpoint () = %ld\n",
 		      (unsigned long) retval);
   return retval;
 }



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFA] Unify target header macros
  2009-05-10 16:15 [RFA] Unify target header macros Pierre Muller
@ 2009-05-11  9:17 ` Joel Brobecker
  2009-05-11 11:17   ` Pierre Muller
  0 siblings, 1 reply; 3+ messages in thread
From: Joel Brobecker @ 2009-05-11  9:17 UTC (permalink / raw)
  To: Pierre Muller; +Cc: gdb-patches

> In particular, I suspect that some of the comments
> that are changed by that patch are obsolete...

It would be nice to revisit these comments in the future, but in the
meantime, it's sufficient to keep their content in sync with the code.
So this is OK for now.

> 2009-05-10  Pierre Muller  <muller.u-strasbg.fr>
> 
> 	Unify target macros.
> 
> 	* target.h (STOPPED_BY_WATCHPOINT): Delete, replaced by ...
> 	(target_stoppped_by_watchpoint): New macro.
> 	(HAVE_STEPPABLE_WATCHPOINT): Delete, replaced by ...
> 	(target_have_steppable_watchpoint): New macro.
> 	(HAVE_CONTINUABLE_WATCHPOINT): Delete, replace by ...
> 	(target_have_continuable_watchpoint): New macro.
> 	(TARGET_CAN_USE_HARDWARE_WATCHPOINT):Delete, replaced by ...
> 	(target_can_use_hardware_watchpoint): New macro.
> 	(TARGET_REGION_OK_FOR_HW_WATCHPOINT):Delete, replaced by ...
> 	(target_region_ok_for_hw_watchpoint): New macro.
> 
> 	* breakpoint.c (update_watchpoint): Use new macros.
> 	(bpstat_alloc): Likewise.
> 	(create_breakpoint): Likewise.
> 	(watch_command_1): Likewise.
> 	(can_use_hardware_watchpoint): Likewise.
> 	(do_enable_breakpoint): Likewise.
> 	* infrun.c (handle_inferior_event): Adapt to new macros.
> 	* mips-tdep.c (mips_gdbarch_init): Update comments.
> 	* procfs.c (procfs_set_watchpoint): Update comment.
> 	(procfs_insert_watchpoint): Adapt to new macros.
> 	* remote-m32r-sdi.c (m32r_stop):
> 	* remote-mips.c (mips_remove_breakpoint):
> 	* target.c (debug_to_region_ok_for_hw_watchpoint): Update to new
> macros.
> 	(debug_to_stopped_by_watchpoint): Likewise.

Looks good to me.

Thanks for doing this.
-- 
Joel


^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [RFA] Unify target header macros
  2009-05-11  9:17 ` Joel Brobecker
@ 2009-05-11 11:17   ` Pierre Muller
  0 siblings, 0 replies; 3+ messages in thread
From: Pierre Muller @ 2009-05-11 11:17 UTC (permalink / raw)
  To: 'Joel Brobecker'; +Cc: gdb-patches



> -----Message d'origine-----
> De : Joel Brobecker [mailto:brobecker@adacore.com]
> Envoyé : Monday, May 11, 2009 11:18 AM
> À : Pierre Muller
> Cc : gdb-patches@sourceware.org
> Objet : Re: [RFA] Unify target header macros
> 
> > In particular, I suspect that some of the comments
> > that are changed by that patch are obsolete...
> 
> It would be nice to revisit these comments in the future, but in the
> meantime, it's sufficient to keep their content in sync with the code.
> So this is OK for now.
Thanks, Joel.

Patch committed.

Pierre


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-05-11 11:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-10 16:15 [RFA] Unify target header macros Pierre Muller
2009-05-11  9:17 ` Joel Brobecker
2009-05-11 11:17   ` Pierre Muller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox