dprintf-style agent can't explain a trap.
authorPedro Alves <palves@redhat.com>
Mon, 2 Jun 2014 21:27:32 +0000 (22:27 +0100)
committerPedro Alves <palves@redhat.com>
Mon, 2 Jun 2014 22:28:54 +0000 (23:28 +0100)
If some event happens to trigger at the same address as a dprintf-style
agent dprintf is installed, GDB will complain, like:

 (gdb) continue
 Continuing.
 May only run agent-printf on the target
 (gdb)

Such dprintfs are completely handled on the target side, so they can't
explain a stop, but GDB is currently putting then on the bpstat chain
anyway, because they currently unconditionally use bkpt_breakpoint_hit
as breakpoint_hit method.

gdb/
2014-06-02  Pedro Alves  <palves@redhat.com>

* breakpoint.c (dprintf_breakpoint_hit): New function.
(initialize_breakpoint_ops): Install it as dprintf's
breakpoint_hit method.

gdb/ChangeLog
gdb/breakpoint.c

index 6faa689b48c73c6b8209894c734532618e2f48fc..1d37c567ddfda2b3b6783091e4d5033825b07121 100644 (file)
@@ -1,3 +1,9 @@
+2014-06-02  Pedro Alves  <palves@redhat.com>
+
+       * breakpoint.c (dprintf_breakpoint_hit): New function.
+       (initialize_breakpoint_ops): Install it as dprintf's
+       breakpoint_hit method.
+
 2014-06-02  Joel Brobecker  <brobecker@adacore.com>
 
        * source.c (substitute_path_rule_matches): Simplify using
index 676c7b888cbb8bc887619634a615b17dd9410685..a966ba2bee14133b1a1a00aad39a0e4a46fdaa95 100644 (file)
@@ -13141,6 +13141,23 @@ bkpt_breakpoint_hit (const struct bp_location *bl,
   return 1;
 }
 
+static int
+dprintf_breakpoint_hit (const struct bp_location *bl,
+                       struct address_space *aspace, CORE_ADDR bp_addr,
+                       const struct target_waitstatus *ws)
+{
+  if (dprintf_style == dprintf_style_agent
+      && target_can_run_breakpoint_commands ())
+    {
+      /* An agent-style dprintf never causes a stop.  If we see a trap
+        for this address it must be for a breakpoint that happens to
+        be set at the same address.  */
+      return 0;
+    }
+
+  return bkpt_breakpoint_hit (bl, aspace, bp_addr, ws);
+}
+
 static int
 bkpt_resources_needed (const struct bp_location *bl)
 {
@@ -16220,6 +16237,7 @@ initialize_breakpoint_ops (void)
   ops->print_mention = bkpt_print_mention;
   ops->print_recreate = dprintf_print_recreate;
   ops->after_condition_true = dprintf_after_condition_true;
+  ops->breakpoint_hit = dprintf_breakpoint_hit;
 }
 
 /* Chain containing all defined "enable breakpoint" subcommands.  */