--- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -5296,13 +5296,7 @@ bpstat_stop_status (struct address_space b->enable_state = bp_disabled; removed_any = 1; } - if (b->silent) - bs->print = 0; - bs->commands = b->commands; - incref_counted_command_line (bs->commands); - if (command_line_is_silent (bs->commands - ? bs->commands->commands : NULL)) - bs->print = 0; + b->ops->after_cond (bs); } } @@ -8960,25 +8954,16 @@ update_dprintf_command_list (struct brea _("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); @@ -12764,6 +12749,22 @@ base_breakpoint_explains_signal (struct return BPSTAT_SIGNAL_HIDE; } +/* The default 'after_cond' method. */ + +static void +base_breakpoint_after_cond (struct bpstats *bs) +{ + struct breakpoint *b = bs->breakpoint_at; + + if (b->silent) + bs->print = 0; + bs->commands = b->commands; + incref_counted_command_line (bs->commands); + if (command_line_is_silent (bs->commands + ? bs->commands->commands : NULL)) + bs->print = 0; +} + struct breakpoint_ops base_breakpoint_ops = { base_breakpoint_dtor, @@ -12783,7 +12784,8 @@ struct breakpoint_ops base_breakpoint_op 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_cond, }; /* Default breakpoint_ops methods. */ @@ -13377,6 +13379,24 @@ dprintf_print_recreate (struct breakpoin print_recreate_thread (tp, fp); } +/* Implement the "after_cond" breakpoint_ops method for dprintf. */ + +static void +dprintf_after_cond (struct bpstats *bs) +{ + bpstat tmp; + struct breakpoint *b = bs->breakpoint_at; + + bs->stop = 0; + bs->print = 0; + bs->commands = b->commands; + tmp = bs->next; + bs->next = tmp; + incref_counted_command_line (bs->commands); + bpstat_do_actions_1 (&bs); + bs->next = tmp; +} + /* The breakpoint_ops structure to be used on static tracepoints with markers (`-m'). */ @@ -15873,6 +15893,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_cond = dprintf_after_cond; } /* Chain containing all defined "enable breakpoint" subcommands. */ --- a/gdb/breakpoint.h +++ b/gdb/breakpoint.h @@ -614,6 +614,9 @@ struct breakpoint_ops 'catch signal' interact properly with 'handle'; see bpstat_explains_signal. */ enum bpstat_signal_value (*explains_signal) (struct breakpoint *); + + /* Do some setup after check condition is true. */ + void (*after_cond) (struct bpstats *bs); }; /* Helper for breakpoint_ops->print_recreate implementations. Prints