Add comment describing continuable/steppable/non-steppable watchpoints
authorPedro Alves <palves@redhat.com>
Fri, 31 Aug 2018 13:24:13 +0000 (14:24 +0100)
committerPedro Alves <palves@redhat.com>
Fri, 31 Aug 2018 17:47:36 +0000 (18:47 +0100)
These weren't described anywhere in the sources.

gdb/ChangeLog:
2018-08-31  Pedro Alves  <palves@redhat.com>

* gdbarch.sh (have_nonsteppable_watchpoint): Add comment.
* target.h (Hardware watchpoint interfaces): Describe
continuable/steppable/non-steppable watchpoints.
* gdbarch.h, gdbarch.c: Regenerate.

gdb/ChangeLog
gdb/gdbarch.h
gdb/gdbarch.sh
gdb/target.h

index 30c0c6f31cdcc0595cf344a60997d42a6ce80714..0b8ed316e0c28760b2b1ad2e7d6ca696484321f8 100644 (file)
@@ -1,3 +1,10 @@
+2018-08-31  Pedro Alves  <palves@redhat.com>
+
+       * gdbarch.sh (have_nonsteppable_watchpoint): Add comment.
+       * target.h (Hardware watchpoint interfaces): Describe
+       continuable/steppable/non-steppable watchpoints.
+       * gdbarch.h, gdbarch.c: Regenerate.
+
 2018-08-31  Pedro Alves  <palves@redhat.com>
 
        * nto-procfs.c (nto_procfs_target::have_continuable_watchpoint):
index b563f8d165aafcaa6e1a011c7107e1ccf15884b5..83408812b2a09050e3169a4bfb553beedfa95563 100644 (file)
@@ -818,6 +818,8 @@ extern void set_gdbarch_adjust_dwarf2_line (struct gdbarch *gdbarch, gdbarch_adj
 extern int gdbarch_cannot_step_breakpoint (struct gdbarch *gdbarch);
 extern void set_gdbarch_cannot_step_breakpoint (struct gdbarch *gdbarch, int cannot_step_breakpoint);
 
+/* See comment in target.h about continue, steppable and non-steppable watchpoints. */
+
 extern int gdbarch_have_nonsteppable_watchpoint (struct gdbarch *gdbarch);
 extern void set_gdbarch_have_nonsteppable_watchpoint (struct gdbarch *gdbarch, int have_nonsteppable_watchpoint);
 
index 24a553b73c3737c1da82b247877b91f66c6db1f0..670ac30c030346592fe1f310669644281b49bc75 100755 (executable)
@@ -707,6 +707,8 @@ f;CORE_ADDR;adjust_dwarf2_addr;CORE_ADDR pc;pc;;default_adjust_dwarf2_addr;;0
 # stop PC.
 f;CORE_ADDR;adjust_dwarf2_line;CORE_ADDR addr, int rel;addr, rel;;default_adjust_dwarf2_line;;0
 v;int;cannot_step_breakpoint;;;0;0;;0
+# See comment in target.h about continuable, steppable and
+# non-steppable watchpoints.
 v;int;have_nonsteppable_watchpoint;;;0;0;;0
 F;int;address_class_type_flags;int byte_size, int dwarf2_addr_class;byte_size, dwarf2_addr_class
 M;const char *;address_class_type_flags_to_name;int type_flags;type_flags
index b29d34b8a65ced5690a560a7c45ef2228d204c97..229b5d0551a077a951036ace2226edb193a7690f 100644 (file)
@@ -1905,6 +1905,40 @@ extern struct thread_info *target_thread_handle_to_thread_info
 
 /* Hardware watchpoint interfaces.  */
 
+/* GDB's current model is that there are three "kinds" of watchpoints,
+   with respect to when they trigger and how you can move past them.
+
+   Those are: continuable, steppable, and non-steppable.
+
+   Continuable watchpoints are like x86's -- those trigger after the
+   memory access's side effects are fully committed to memory.  I.e.,
+   they trap with the PC pointing at the next instruction already.
+   Continuing past such a watchpoint is doable by just normally
+   continuing, hence the name.
+
+   Both steppable and non-steppable watchpoints trap before the memory
+   access.  I.e, the PC points at the instruction that is accessing
+   the memory.  So GDB needs to single-step once past the current
+   instruction in order to make the access effective and check whether
+   the instruction's side effects change the watched expression.
+
+   Now, in order to step past that instruction, depending on
+   architecture and target, you can have two situations:
+
+   - steppable watchpoints: you can single-step with the watchpoint
+     still armed, and the watchpoint won't trigger again.
+
+   - non-steppable watchpoints: if you try to single-step with the
+     watchpoint still armed, you'd trap the watchpoint again and the
+     thread wouldn't make any progress.  So GDB needs to temporarily
+     remove the watchpoint in order to step past it.
+
+   If your target/architecture does not signal that it has either
+   steppable or non-steppable watchpoints via either
+   target_have_steppable_watchpoint or
+   gdbarch_have_nonsteppable_watchpoint, GDB assumes continuable
+   watchpoints.  */
+
 /* Returns non-zero if we were stopped by a hardware watchpoint (memory read or
    write).  Only the INFERIOR_PTID task is being queried.  */