Patchwork RISC-V: enable have_nonsteppable_watchpoint by default

mail settings
Submitter Craig Blackmore
Date Oct. 4, 2018, 4:25 p.m.
Message ID <>
Download mbox | patch
Permalink /patch/29646/
State New
Headers show


Craig Blackmore - Oct. 4, 2018, 4:25 p.m.
On 03/10/18 23:37, Joel Brobecker wrote:
> I assume this patch is waiting for review from Andrew?
> I took a look, since I am interested in it as well. Here are my
> comments.
> You forgot to document the introduction of riscv_have_nonsteppable_watchpoint
> in your ChangeLog above; eg:
>         * riscv-tdep.c (riscv_have_nonsteppable_watchpoint): New static
>         global.
> You also forgot to document that you're adding new subcommands.
> The rest looks good to me.
Hi Joel,

Thanks for the review. I have updated the ChangeLog in the patch below.



The RISC-V debug spec 0.13 recommends that write triggers fire before the
write is committed. If the target follows this behaviour, then
have_nonsteppable_watchpoint needs to be set to 'on' so that GDB will step
over the watchpoint before checking if the value has changed.

This patch adds a setshow for have_nonsteppable_watchpoint which defaults
to 'on' to match the recommended behaviour. If a target does not follow
this timing, then 'set riscv have_nonsteppable_watchpoint off' will need
to be issued on the command line.

	* riscv-tdep.c (riscv_have_nonsteppable_watchpoint): New static
	(set_have_nonsteppable_watchpoint): Add callback for
	'set riscv have_nonsteppable_watchpoint'.
	(show_have_nonsteppable_watchpoint): Add callback for
	'show riscv have_nonsteppable_watchpoint'.
	(riscv_gdbarch_init): Initialise gdbarch setting for
	(_initialize_riscv_tdep): Add 'set/show riscv
	have_nonsteppable_watchpoint' subcommands.



diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c
index 254914c..857c5d1 100644
--- a/gdb/riscv-tdep.c
+++ b/gdb/riscv-tdep.c
@@ -226,6 +226,36 @@  show_use_compressed_breakpoints (struct ui_file *file, int from_tty,
 		      "to %s%s.\n"), value, additional_info);
+/* Controls whether the debugger should step over hardware watchpoints before
+   checking if the watched variable has changed.  If true, then the debugger
+   will step over the watchpoint.  */
+static int riscv_have_nonsteppable_watchpoint = 1;
+/* The set callback for 'set riscv have-nonsteppable-watchpoint'.  */
+static void
+set_have_nonsteppable_watchpoint (const char *args, int from_tty,
+				  struct cmd_list_element *c)
+  struct gdbarch *gdbarch = target_gdbarch ();
+  set_gdbarch_have_nonsteppable_watchpoint (gdbarch,
+					    riscv_have_nonsteppable_watchpoint);
+/* The show callback for 'show riscv have-nonsteppable-watchpoint'.  */
+static void
+show_have_nonsteppable_watchpoint (struct ui_file *file, int from_tty,
+				   struct cmd_list_element *c,
+				   const char *value)
+  fprintf_filtered (file,
+		    _("Debugger must step over hardware watchpoints is set to "
+		      "%s.\n"), value);
 /* The set and show lists for 'set riscv' and 'show riscv' prefixes.  */
 static struct cmd_list_element *setriscvcmdlist = NULL;
@@ -2736,6 +2766,8 @@  riscv_gdbarch_init (struct gdbarch_info info,
   set_gdbarch_return_value (gdbarch, riscv_return_value);
   set_gdbarch_breakpoint_kind_from_pc (gdbarch, riscv_breakpoint_kind_from_pc);
   set_gdbarch_sw_breakpoint_from_kind (gdbarch, riscv_sw_breakpoint_from_kind);
+  set_gdbarch_have_nonsteppable_watchpoint (gdbarch,
+					    riscv_have_nonsteppable_watchpoint);
   /* Register architecture.  */
   set_gdbarch_num_regs (gdbarch, RISCV_LAST_REGNUM + 1);
@@ -2980,4 +3012,20 @@  can be used."),
+  add_setshow_boolean_cmd ("have-nonsteppable-watchpoint", no_class,
+			   &riscv_have_nonsteppable_watchpoint,
+			   _("\
+Set whether debugger must step over hardware watchpoints"),
+			   _("\
+Show whether debugger must step over hardware watchpoints"),
+			   _("\
+The RISC-V debug spec recommends that hardware write watchpoints fire before\n\
+the write is committed, in which case, GDB must step over the watchpoint\n\
+before checking the old and new values.  Set this option to 'on' (default)\n\
+for targets that follow this behaviour, otherwise set to 'off'."),
+			   set_have_nonsteppable_watchpoint,
+			   show_have_nonsteppable_watchpoint,
+			   &setriscvcmdlist,
+			   &showriscvcmdlist);