error (_("The 'while-stepping' command can "
"only be used for tracepoints"));
- for (i = 0; i < c->body_count; ++i)
- check_no_tracepoint_commands ((c->body_list)[i]);
+ check_no_tracepoint_commands (c->body_list_0.get ());
+ check_no_tracepoint_commands (c->body_list_1.get ());
/* Not that command parsing removes leading whitespace and comment
lines and also empty lines. So, we only need to check for
{
struct command_line *c2;
- gdb_assert (while_stepping->body_count == 1);
- c2 = while_stepping->body_list[0];
+ gdb_assert (while_stepping->body_list_1 == nullptr);
+ c2 = while_stepping->body_list_0.get ();
for (; c2; c2 = c2->next)
{
if (c2->control_type == while_stepping_control)
void
breakpoint_set_commands (struct breakpoint *b,
- command_line_up &&commands)
+ counted_command_line &&commands)
{
validate_commands_for_breakpoint (b, commands.get ());
gdb::observers::breakpoint_modified.notify (b);
}
-void
-check_tracepoint_command (char *line, void *closure)
-{
- struct breakpoint *b = (struct breakpoint *) closure;
-
- validate_actionline (line, b);
-}
-
static void
commands_command_1 (const char *arg, int from_tty,
struct command_line *control)
if (cmd == NULL)
{
if (control != NULL)
- cmd = copy_command_lines (control->body_list[0]);
+ cmd = control->body_list_0;
else
{
std::string str
"%s, one per line."),
arg);
- cmd = read_command_lines (&str[0],
- from_tty, 1,
- (is_tracepoint (b)
- ? check_tracepoint_command : 0),
- b);
+ auto do_validate = [=] (const char *line)
+ {
+ validate_actionline (line, b);
+ };
+ gdb::function_view<void (const char *)> validator;
+ if (is_tracepoint (b))
+ validator = do_validate;
+
+ cmd = read_command_lines (str.c_str (), from_tty, 1, validator);
}
}
}
addr = BMSYMBOL_VALUE_ADDRESS (bp_objfile_data->exception_msym);
- addr = gdbarch_convert_from_func_ptr_addr (gdbarch, addr,
- ¤t_target);
+ addr = gdbarch_convert_from_func_ptr_addr (gdbarch, addr, target_stack);
b = create_internal_breakpoint (gdbarch, addr, bp_exception_master,
&internal_breakpoint_ops);
initialize_explicit_location (&explicit_loc);
print_solib_event (int is_catchpoint)
{
bool any_deleted = !current_program_space->deleted_solibs.empty ();
- int any_added
- = !VEC_empty (so_list_ptr, current_program_space->added_solibs);
+ bool any_added = !current_program_space->added_solibs.empty ();
if (!is_catchpoint)
{
if (any_added)
{
- struct so_list *iter;
- int ix;
-
current_uiout->text (_(" Inferior loaded "));
ui_out_emit_list list_emitter (current_uiout, "added");
- for (ix = 0;
- VEC_iterate (so_list_ptr, current_program_space->added_solibs,
- ix, iter);
- ++ix)
+ bool first = true;
+ for (so_list *iter : current_program_space->added_solibs)
{
- if (ix > 0)
+ if (!first)
current_uiout->text (" ");
+ first = false;
current_uiout->field_string ("library", iter->so_name);
current_uiout->text ("\n");
}
int
watchpoints_triggered (struct target_waitstatus *ws)
{
- int stopped_by_watchpoint = target_stopped_by_watchpoint ();
+ bool stopped_by_watchpoint = target_stopped_by_watchpoint ();
CORE_ADDR addr;
struct breakpoint *b;
return 0;
}
- if (!target_stopped_data_address (¤t_target, &addr))
+ if (!target_stopped_data_address (target_stack, &addr))
{
/* We were stopped by a watchpoint, but we don't know where.
Mark all watchpoints as unknown. */
}
}
/* Exact match not required. Within range is sufficient. */
- else if (target_watchpoint_addr_within_range (¤t_target,
+ else if (target_watchpoint_addr_within_range (target_stack,
addr, loc->address,
loc->length))
{
&& !target_supports_stopped_by_hw_breakpoint ()));
}
-
-/* Get a bpstat associated with having just stopped at address
- BP_ADDR in thread PTID.
-
- Determine whether we stopped at a breakpoint, etc, or whether we
- don't understand this stop. Result is a chain of bpstat's such
- that:
-
- if we don't understand the stop, the result is a null pointer.
-
- if we understand why we stopped, the result is not null.
-
- Each element of the chain refers to a particular breakpoint or
- watchpoint at which we have stopped. (We may have stopped for
- several reasons concurrently.)
-
- Each element of the chain has valid next, breakpoint_at,
- commands, FIXME??? fields. */
+/* See breakpoint.h. */
bpstat
-bpstat_stop_status (const address_space *aspace,
- CORE_ADDR bp_addr, ptid_t ptid,
+build_bpstat_chain (const address_space *aspace, CORE_ADDR bp_addr,
const struct target_waitstatus *ws)
{
- struct breakpoint *b = NULL;
- struct bp_location *bl;
- struct bp_location *loc;
- /* First item of allocated bpstat's. */
+ struct breakpoint *b;
bpstat bs_head = NULL, *bs_link = &bs_head;
- /* Pointer to the last thing in the chain currently. */
- bpstat bs;
- int ix;
- int need_remove_insert;
- int removed_any;
-
- /* First, build the bpstat chain with locations that explain a
- target stop, while being careful to not set the target running,
- as that may invalidate locations (in particular watchpoint
- locations are recreated). Resuming will happen here with
- breakpoint conditions or watchpoint expressions that include
- inferior function calls. */
ALL_BREAKPOINTS (b)
{
if (!breakpoint_enabled (b))
continue;
- for (bl = b->loc; bl != NULL; bl = bl->next)
+ for (bp_location *bl = b->loc; bl != NULL; bl = bl->next)
{
/* For hardware watchpoints, we look only at the first
location. The watchpoint_check function will work on the
/* Come here if it's a watchpoint, or if the break address
matches. */
- bs = new bpstats (bl, &bs_link); /* Alloc a bpstat to
- explain stop. */
+ bpstat bs = new bpstats (bl, &bs_link); /* Alloc a bpstat to
+ explain stop. */
/* Assume we stop. Should we find a watchpoint that is not
actually triggered, or if the condition of the breakpoint
if (!target_supports_stopped_by_sw_breakpoint ()
|| !target_supports_stopped_by_hw_breakpoint ())
{
- for (ix = 0; VEC_iterate (bp_location_p, moribund_locations, ix, loc); ++ix)
+ bp_location *loc;
+
+ for (int ix = 0;
+ VEC_iterate (bp_location_p, moribund_locations, ix, loc); ++ix)
{
if (breakpoint_location_address_match (loc, aspace, bp_addr)
&& need_moribund_for_location_type (loc))
{
- bs = new bpstats (loc, &bs_link);
+ bpstat bs = new bpstats (loc, &bs_link);
/* For hits of moribund locations, we should just proceed. */
bs->stop = 0;
bs->print = 0;
}
}
+ return bs_head;
+}
+
+/* See breakpoint.h. */
+
+bpstat
+bpstat_stop_status (const address_space *aspace,
+ CORE_ADDR bp_addr, ptid_t ptid,
+ const struct target_waitstatus *ws,
+ bpstat stop_chain)
+{
+ struct breakpoint *b = NULL;
+ /* First item of allocated bpstat's. */
+ bpstat bs_head = stop_chain;
+ bpstat bs;
+ int need_remove_insert;
+ int removed_any;
+
+ /* First, build the bpstat chain with locations that explain a
+ target stop, while being careful to not set the target running,
+ as that may invalidate locations (in particular watchpoint
+ locations are recreated). Resuming will happen here with
+ breakpoint conditions or watchpoint expressions that include
+ inferior function calls. */
+ if (bs_head == NULL)
+ bs_head = build_bpstat_chain (aspace, bp_addr, ws);
+
/* A bit of special processing for shlib breakpoints. We need to
process solib loading here, so that the lists of loaded and
unloaded libraries are correct before we handle "catch load" and
const char *function_name;
if (loc->msymbol != NULL
- && MSYMBOL_TYPE (loc->msymbol) == mst_text_gnu_ifunc
+ && (MSYMBOL_TYPE (loc->msymbol) == mst_text_gnu_ifunc
+ || MSYMBOL_TYPE (loc->msymbol) == mst_data_gnu_ifunc)
&& !explicit_loc)
{
struct breakpoint *b = loc->owner;
if (self->is_load)
{
- struct so_list *iter;
-
- for (int ix = 0;
- VEC_iterate (so_list_ptr, current_program_space->added_solibs,
- ix, iter);
- ++ix)
+ for (so_list *iter : current_program_space->added_solibs)
{
if (!self->regex
|| self->compiled->exec (iter->so_name, 0, NULL, 0) == 0)
mention (struct breakpoint *b)
{
b->ops->print_mention (b);
- if (current_uiout->is_mi_like_p ())
- return;
- printf_filtered ("\n");
+ current_uiout->text ("\n");
}
\f
_("Invalid dprintf style."));
gdb_assert (printf_line != NULL);
- /* Manufacture a printf sequence. */
- {
- struct command_line *printf_cmd_line = XNEW (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 = NULL;
- printf_cmd_line->line = printf_line;
- breakpoint_set_commands (b, command_line_up (printf_cmd_line));
- }
+ /* Manufacture a printf sequence. */
+ struct command_line *printf_cmd_line
+ = new struct command_line (simple_control, printf_line);
+ breakpoint_set_commands (b, counted_command_line (printf_cmd_line,
+ command_lines_deleter ()));
}
/* Update all dprintf commands, making their command lists reflect
gdb_assert (bl);
gdb_assert (b->type == bp_hardware_breakpoint);
- if (uiout->is_mi_like_p ())
- return;
-
- printf_filtered (_("Hardware assisted ranged breakpoint %d from %s to %s."),
- b->number, paddress (bl->gdbarch, bl->address),
- paddress (bl->gdbarch, bl->address + bl->length - 1));
+ uiout->message (_("Hardware assisted ranged breakpoint %d from %s to %s."),
+ b->number, paddress (bl->gdbarch, bl->address),
+ paddress (bl->gdbarch, bl->address + bl->length - 1));
}
/* Implement the "print_recreate" breakpoint_ops method for
scoped_restore save_input_radix = make_scoped_restore (&input_radix);
scoped_restore_current_pspace_and_thread restore_pspace_thread;
+ /* breakpoint_re_set_one sets the current_language to the language
+ of the breakpoint it is resetting (see prepare_re_set_context)
+ before re-evaluating the breakpoint's location. This change can
+ unfortunately get undone by accident if the language_mode is set
+ to auto, and we either switch frames, or more likely in this context,
+ we select the current frame.
+
+ We prevent this by temporarily turning the language_mode to
+ language_mode_manual. We restore it once all breakpoints
+ have been reset. */
+ scoped_restore save_language_mode = make_scoped_restore (&language_mode);
+ language_mode = language_mode_manual;
+
/* Note: we must not try to insert locations until after all
breakpoints have been re-set. Otherwise, e.g., when re-setting
breakpoint 1, we'd insert the locations of breakpoint 2, which
function. */
if (!utp->cmd_strings.empty ())
{
- command_line_up cmd_list;
+ counted_command_line cmd_list;
this_utp = utp;
next_cmd = 0;
- cmd_list = read_command_lines_1 (read_uploaded_action, 1, NULL, NULL);
+ cmd_list = read_command_lines_1 (read_uploaded_action, 1, NULL);
breakpoint_set_commands (tp, std::move (cmd_list));
}