Add command support for Guile.
[deliverable/binutils-gdb.git] / gdb / mem-break.c
index 1a057df8a7a1b1810af0c76aae56bfe784c120a6..ad7296b9fe3d61e89a52bcfcb27f61e2925976f6 100644 (file)
@@ -89,3 +89,35 @@ memory_remove_breakpoint (struct target_ops *ops, struct gdbarch *gdbarch,
 {
   return gdbarch_memory_remove_breakpoint (gdbarch, bp_tgt);
 }
+
+int
+memory_validate_breakpoint (struct gdbarch *gdbarch,
+                           struct bp_target_info *bp_tgt)
+{
+  CORE_ADDR addr = bp_tgt->placed_address;
+  const gdb_byte *bp;
+  int val;
+  int bplen;
+  gdb_byte cur_contents[BREAKPOINT_MAX];
+  struct cleanup *cleanup;
+  int ret;
+
+  /* Determine appropriate breakpoint contents and size for this
+     address.  */
+  bp = gdbarch_breakpoint_from_pc (gdbarch, &addr, &bplen);
+
+  if (bp == NULL || bp_tgt->placed_size != bplen)
+    return 0;
+
+  /* Make sure we see the memory breakpoints.  */
+  cleanup = make_show_memory_breakpoints_cleanup (1);
+  val = target_read_memory (addr, cur_contents, bplen);
+
+  /* If our breakpoint is no longer at the address, this means that
+     the program modified the code on us, so it is wrong to put back
+     the old value.  */
+  ret = (val == 0 && memcmp (bp, cur_contents, bplen) == 0);
+
+  do_cleanups (cleanup);
+  return ret;
+}
This page took 0.024195 seconds and 4 git commands to generate.