aboutsummaryrefslogtreecommitdiff
path: root/gdb/breakpoint.c
diff options
context:
space:
mode:
authorHui Zhu <teawater@gmail.com>2013-06-25 11:37:48 +0000
committerHui Zhu <teawater@gmail.com>2013-06-25 11:37:48 +0000
commit9d6e6e84f73ef7c5410c097a23d5952a99684f5b (patch)
tree6fb90992e7e7f929c15dff6d1cad38e3ee40f6a7 /gdb/breakpoint.c
parentd1706f383db8e648486e0bda24e182d7233d6674 (diff)
downloadgdb-9d6e6e84f73ef7c5410c097a23d5952a99684f5b.zip
gdb-9d6e6e84f73ef7c5410c097a23d5952a99684f5b.tar.gz
gdb-9d6e6e84f73ef7c5410c097a23d5952a99684f5b.tar.bz2
2013-06-25 Yao Qi <yao@codesourcery.com>
Hui Zhu <hui@codesourcery.com> Pedro Alves <palves@redhat.com> PR breakpoints/15075 PR breakpoints/15434 * breakpoint.c (bpstat_stop_status): Call b->ops->after_condition_true. (update_dprintf_command_list): Don't append "continue" command to the command list of dprintf breakpoint. (base_breakpoint_after_condition_true): New function. (base_breakpoint_ops): Add base_breakpoint_after_condition_true. (dprintf_after_condition_true): New function. (initialize_breakpoint_ops): Set dprintf_after_condition_true. * breakpoint.h (breakpoint_ops): Add after_condition_true. 2013-06-25 Yao Qi <yao@codesourcery.com> Hui Zhu <hui@codesourcery.com> Pedro Alves <palves@redhat.com> PR breakpoints/15075 PR breakpoints/15434 * gdb.base/dprintf-next.c: New file. * gdb.base/dprintf-next.exp: New file. * gdb.base/dprintf-non-stop.c: New file. * gdb.base/dprintf-non-stop.exp: New file. * gdb.base/dprintf.exp: Don't check "continue" in the output of "info breakpoints". * gdb.mi/mi-breakpoint-changed.exp (test_insert_delete_modify): Don't check "continue" in script field.
Diffstat (limited to 'gdb/breakpoint.c')
-rw-r--r--gdb/breakpoint.c69
1 files changed, 55 insertions, 14 deletions
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 0ff5a4e..ccd05d9 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -5308,6 +5308,8 @@ bpstat_stop_status (struct address_space *aspace,
if (command_line_is_silent (bs->commands
? bs->commands->commands : NULL))
bs->print = 0;
+
+ b->ops->after_condition_true (bs);
}
}
@@ -8943,25 +8945,16 @@ update_dprintf_command_list (struct breakpoint *b)
_("Invalid dprintf style."));
gdb_assert (printf_line != NULL);
- /* Manufacture a printf/continue sequence. */
+ /* Manufacture a printf sequence. */
{
- struct command_line *printf_cmd_line, *cont_cmd_line = NULL;
-
- if (strcmp (dprintf_style, dprintf_style_agent) != 0)
- {
- cont_cmd_line = xmalloc (sizeof (struct command_line));
- cont_cmd_line->control_type = simple_control;
- cont_cmd_line->body_count = 0;
- cont_cmd_line->body_list = NULL;
- cont_cmd_line->next = NULL;
- cont_cmd_line->line = xstrdup ("continue");
- }
+ struct command_line *printf_cmd_line
+ = xmalloc (sizeof (struct command_line));
printf_cmd_line = xmalloc (sizeof (struct command_line));
printf_cmd_line->control_type = simple_control;
printf_cmd_line->body_count = 0;
printf_cmd_line->body_list = NULL;
- printf_cmd_line->next = cont_cmd_line;
+ printf_cmd_line->next = NULL;
printf_cmd_line->line = printf_line;
breakpoint_set_commands (b, printf_cmd_line);
@@ -12761,6 +12754,14 @@ base_breakpoint_explains_signal (struct breakpoint *b, enum gdb_signal sig)
return BPSTAT_SIGNAL_HIDE;
}
+/* The default "after_condition_true" method. */
+
+static void
+base_breakpoint_after_condition_true (struct bpstats *bs)
+{
+ /* Nothing to do. */
+}
+
struct breakpoint_ops base_breakpoint_ops =
{
base_breakpoint_dtor,
@@ -12780,7 +12781,8 @@ struct breakpoint_ops base_breakpoint_ops =
base_breakpoint_create_sals_from_address,
base_breakpoint_create_breakpoints_sal,
base_breakpoint_decode_linespec,
- base_breakpoint_explains_signal
+ base_breakpoint_explains_signal,
+ base_breakpoint_after_condition_true,
};
/* Default breakpoint_ops methods. */
@@ -13374,6 +13376,44 @@ dprintf_print_recreate (struct breakpoint *tp, struct ui_file *fp)
print_recreate_thread (tp, fp);
}
+/* Implement the "after_condition_true" breakpoint_ops method for
+ dprintf.
+
+ dprintf's are implemented with regular commands in their command
+ list, but we run the commands here instead of before presenting the
+ stop to the user, as dprintf's don't actually cause a stop. This
+ also makes it so that the commands of multiple dprintfs at the same
+ address are all handled. */
+
+static void
+dprintf_after_condition_true (struct bpstats *bs)
+{
+ struct cleanup *old_chain;
+ struct bpstats tmp_bs = { NULL };
+ struct bpstats *tmp_bs_p = &tmp_bs;
+
+ /* dprintf's never cause a stop. This wasn't set in the
+ check_status hook instead because that would make the dprintf's
+ condition not be evaluated. */
+ bs->stop = 0;
+
+ /* Run the command list here. Take ownership of it instead of
+ copying. We never want these commands to run later in
+ bpstat_do_actions, if a breakpoint that causes a stop happens to
+ be set at same address as this dprintf, or even if running the
+ commands here throws. */
+ tmp_bs.commands = bs->commands;
+ bs->commands = NULL;
+ old_chain = make_cleanup_decref_counted_command_line (&tmp_bs.commands);
+
+ bpstat_do_actions_1 (&tmp_bs_p);
+
+ /* 'tmp_bs.commands' will usually be NULL by now, but
+ bpstat_do_actions_1 may return early without processing the whole
+ list. */
+ do_cleanups (old_chain);
+}
+
/* The breakpoint_ops structure to be used on static tracepoints with
markers (`-m'). */
@@ -15870,6 +15910,7 @@ initialize_breakpoint_ops (void)
ops->print_it = bkpt_print_it;
ops->print_mention = bkpt_print_mention;
ops->print_recreate = dprintf_print_recreate;
+ ops->after_condition_true = dprintf_after_condition_true;
}
/* Chain containing all defined "enable breakpoint" subcommands. */