void re_set () override;
void check_status (struct bpstat *bs) override;
enum print_stop_action print_it (const bpstat *bs) const override;
- bool print_one (bp_location **) const override;
+ bool print_one (bp_location **, bool) const override;
void print_mention () const override;
void print_recreate (struct ui_file *fp) const override;
catchpoint kinds. */
bool
-ada_catchpoint::print_one (bp_location **last_loc) const
+ada_catchpoint::print_one (bp_location **last_loc, bool print_address_col) const
{
struct ui_out *uiout = current_uiout;
- struct value_print_options opts;
- get_user_print_options (&opts);
-
- if (opts.addressprint)
+ if (print_address_col)
uiout->field_skip ("addr");
annotate_field (5);
CORE_ADDR bp_addr,
const target_waitstatus &ws) override;
enum print_stop_action print_it (const bpstat *bs) const override;
- bool print_one (bp_location **) const override;
+ bool print_one (bp_location **, bool) const override;
void print_mention () const override;
void print_recreate (struct ui_file *fp) const override;
}
bool
-exec_catchpoint::print_one (bp_location **last_loc) const
+exec_catchpoint::print_one (bp_location **last_loc,
+ bool print_address_col) const
{
- struct value_print_options opts;
struct ui_out *uiout = current_uiout;
- get_user_print_options (&opts);
-
/* Field 4, the address, is omitted (which makes the columns
not line up too nicely with the headers, but the effect
is relatively readable). */
- if (opts.addressprint)
+ if (print_address_col)
uiout->field_skip ("addr");
annotate_field (5);
uiout->text ("exec");
CORE_ADDR bp_addr,
const target_waitstatus &ws) override;
enum print_stop_action print_it (const bpstat *bs) const override;
- bool print_one (bp_location **) const override;
+ bool print_one (bp_location **, bool print_address_col) const override;
void print_mention () const override;
void print_recreate (struct ui_file *fp) const override;
/* Implement the "print_one" method for fork catchpoints. */
bool
-fork_catchpoint::print_one (bp_location **last_loc) const
+fork_catchpoint::print_one (bp_location **last_loc,
+ bool print_address_col) const
{
- struct value_print_options opts;
struct ui_out *uiout = current_uiout;
- get_user_print_options (&opts);
-
/* Field 4, the address, is omitted (which makes the columns not
line up too nicely with the headers, but the effect is relatively
readable). */
- if (opts.addressprint)
+ if (print_address_col)
uiout->field_skip ("addr");
annotate_field (5);
const char *name = is_vfork ? "vfork" : "fork";
const target_waitstatus &ws) override;
void check_status (struct bpstat *bs) override;
enum print_stop_action print_it (const bpstat *bs) const override;
- bool print_one (bp_location **) const override;
+ bool print_one (bp_location **, bool) const override;
void print_mention () const override;
void print_recreate (struct ui_file *fp) const override;
}
bool
-solib_catchpoint::print_one (bp_location **locs) const
+solib_catchpoint::print_one (bp_location **locs, bool print_address_col) const
{
- struct value_print_options opts;
struct ui_out *uiout = current_uiout;
- get_user_print_options (&opts);
/* Field 4, the address, is omitted (which makes the columns not
line up too nicely with the headers, but the effect is relatively
readable). */
- if (opts.addressprint)
+ if (print_address_col)
{
annotate_field (4);
uiout->field_skip ("addr");
CORE_ADDR bp_addr,
const target_waitstatus &ws) override;
enum print_stop_action print_it (const bpstat *bs) const override;
- bool print_one (bp_location **) const override;
+ bool print_one (bp_location **, bool) const override;
void print_mention () const override;
void print_recreate (struct ui_file *fp) const override;
bool explains_signal (enum gdb_signal) override;
/* Implement the "print_one" method for signal catchpoints. */
bool
-signal_catchpoint::print_one (bp_location **last_loc) const
+signal_catchpoint::print_one (bp_location **last_loc,
+ bool print_address_col) const
{
- struct value_print_options opts;
struct ui_out *uiout = current_uiout;
- get_user_print_options (&opts);
-
/* Field 4, the address, is omitted (which makes the columns
not line up too nicely with the headers, but the effect
is relatively readable). */
- if (opts.addressprint)
+ if (print_address_col)
uiout->field_skip ("addr");
annotate_field (5);
CORE_ADDR bp_addr,
const target_waitstatus &ws) override;
enum print_stop_action print_it (const bpstat *bs) const override;
- bool print_one (bp_location **) const override;
+ bool print_one (bp_location **, bool) const override;
void print_mention () const override;
void print_recreate (struct ui_file *fp) const override;
/* Implement the "print_one" method for syscall catchpoints. */
bool
-syscall_catchpoint::print_one (bp_location **last_loc) const
+syscall_catchpoint::print_one (bp_location **last_loc,
+ bool print_address_col) const
{
- struct value_print_options opts;
struct ui_out *uiout = current_uiout;
struct gdbarch *gdbarch = loc->owner->gdbarch;
- get_user_print_options (&opts);
/* Field 4, the address, is omitted (which makes the columns not
line up too nicely with the headers, but the effect is relatively
readable). */
- if (opts.addressprint)
+ if (print_address_col)
uiout->field_skip ("addr");
annotate_field (5);
void re_set () override;
enum print_stop_action print_it (const bpstat *bs) const override;
- bool print_one (bp_location **) const override;
+ bool print_one (bp_location **, bool) const override;
void print_mention () const override;
void print_recreate (struct ui_file *fp) const override;
void print_one_detail (struct ui_out *) const override;
}
bool
-exception_catchpoint::print_one (bp_location **last_loc) const
+exception_catchpoint::print_one (bp_location **last_loc,
+ bool print_address_col) const
{
- struct value_print_options opts;
struct ui_out *uiout = current_uiout;
- get_user_print_options (&opts);
-
- if (opts.addressprint)
+ if (print_address_col)
uiout->field_skip ("addr");
annotate_field (5);
const target_waitstatus &ws) override;
int resources_needed (const struct bp_location *) override;
enum print_stop_action print_it (const bpstat *bs) const override;
- bool print_one (bp_location **) const override;
+ bool print_one (bp_location **, bool) const override;
void print_one_detail (struct ui_out *) const override;
void print_mention () const override;
void print_recreate (struct ui_file *fp) const override;
}
}
+/* The options for the "info breakpoints" command. */
+
+struct info_breakpoints_opts
+{
+ /* For "-hide-locations". */
+ bool hide_locations = 0;
+};
+
+static const gdb::option::option_def info_breakpoints_option_defs[] = {
+
+ gdb::option::flag_option_def<info_breakpoints_opts> {
+ "hide-locations",
+ [] (info_breakpoints_opts *opts) { return &opts->hide_locations; },
+ N_("Hide breakpoint locations."),
+ },
+
+};
+
+/* Create an option_def_group for the "info breakpoints" options, with
+ OPTS as context. */
+
+static inline gdb::option::option_def_group
+make_info_breakpoints_options_def_group (info_breakpoints_opts *opts)
+{
+ return {{info_breakpoints_option_defs}, opts};
+}
+
+
/* Print B to gdb_stdout. If RAW_LOC, print raw breakpoint locations
instead of going via breakpoint_ops::print_one. This makes "maint
info breakpoints" show the software breakpoint locations of
struct bp_location *loc,
int loc_number,
struct bp_location **last_loc,
- int allflag, bool raw_loc)
+ int allflag, bool raw_loc,
+ bool print_address_col)
{
struct command_line *l;
static char bpenables[] = "nynny";
struct ui_out *uiout = current_uiout;
- struct value_print_options opts;
-
- get_user_print_options (&opts);
gdb_assert (!loc || loc_number != 0);
/* 5 and 6 */
bool result = false;
- if (!raw_loc && b->print_one (last_loc))
+ if (!raw_loc && b->print_one (last_loc, print_address_col))
result = true;
else
{
/* Field 4, the address, is omitted (which makes the columns
not line up too nicely with the headers, but the effect
is relatively readable). */
- if (opts.addressprint)
+ if (print_address_col)
uiout->field_skip ("addr");
annotate_field (5);
uiout->field_string ("what", w->exp_string.get ());
else if (!is_catchpoint (b) || is_exception_catchpoint (b)
|| is_ada_exception_catchpoint (b))
{
- if (opts.addressprint)
+ if (print_address_col)
{
annotate_field (4);
if (loc == nullptr)
return result;
}
+/* Return whether to print the "Address" column. The "Address" column
+ is suppressed with either "set print address off", or "info
+ breakpoints -hide-locations". */
+
+static bool
+should_print_address_col (const info_breakpoints_opts &ib_opts)
+{
+ struct value_print_options opts;
+ get_user_print_options (&opts);
+ return opts.addressprint && !ib_opts.hide_locations;
+}
+
/* See breakpoint.h. */
bool fix_multi_location_breakpoint_output_globally = false;
static void
print_one_breakpoint (struct breakpoint *b,
struct bp_location **last_loc,
- int allflag)
+ int allflag,
+ const info_breakpoints_opts &ib_opts)
{
struct ui_out *uiout = current_uiout;
bool use_fixed_output
= (uiout->test_flags (fix_multi_location_breakpoint_output)
|| fix_multi_location_breakpoint_output_globally);
+ bool print_address_col = should_print_address_col (ib_opts);
+
gdb::optional<ui_out_emit_tuple> bkpt_tuple_emitter (gdb::in_place, uiout, "bkpt");
bool printed = print_one_breakpoint_location (b, NULL, 0, last_loc,
- allflag, false);
+ allflag, false, print_address_col);
/* The mi2 broken format: the main breakpoint tuple ends here, the locations
are outside. */
if (!use_fixed_output)
bkpt_tuple_emitter.reset ();
- /* If this breakpoint has custom print function,
- it's already printed. Otherwise, print individual
- locations, if any. */
- if (!printed || allflag)
+ /* If this breakpoint has a custom print function, it's already
+ printed. Otherwise, print individual locations, if any, and if
+ not explicitly disabled by the user. */
+ if (!ib_opts.hide_locations && (!printed || allflag))
{
/* Note that while hardware watchpoints have several locations
internally, that's not a property exposed to users.
{
ui_out_emit_tuple loc_tuple_emitter (uiout, NULL);
print_one_breakpoint_location (b, loc, n, last_loc,
- allflag, allflag);
+ allflag, allflag,
+ print_address_col);
n++;
}
}
void
print_breakpoint (breakpoint *b)
{
+ info_breakpoints_opts ib_opts;
struct bp_location *dummy_loc = NULL;
- print_one_breakpoint (b, &dummy_loc, 0);
+ print_one_breakpoint (b, &dummy_loc, 0, ib_opts);
}
/* Return true if this breakpoint was set by the user, false if it is
/* Print information on breakpoints (including watchpoints and tracepoints).
- If non-NULL, BP_NUM_LIST is a list of numbers and number ranges as
- understood by number_or_range_parser. Only breakpoints included in this
- list are then printed.
+ If non-NULL, ARGS possibly contains options, followed by a list of
+ numbers and number ranges as understood by number_or_range_parser.
+ Only breakpoints included in this list are then printed.
If SHOW_INTERNAL is true, print internal breakpoints.
Return the total number of breakpoints listed. */
static int
-breakpoint_1 (const char *bp_num_list, bool show_internal,
+breakpoint_1 (const char *args, bool show_internal,
bool (*filter) (const struct breakpoint *))
{
struct bp_location *last_loc = NULL;
int nr_printable_breakpoints;
- struct value_print_options opts;
int print_address_bits = 0;
int print_type_col_width = 14;
struct ui_out *uiout = current_uiout;
bool has_disabled_by_cond_location = false;
- get_user_print_options (&opts);
+ info_breakpoints_opts ib_opts;
+
+ auto grp = make_info_breakpoints_options_def_group (&ib_opts);
+
+ gdb::option::process_options
+ (&args, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_OPERAND, grp);
+
+ if (args != nullptr
+ && args[0] == '-' && (!show_internal || !isdigit (args[1])))
+ gdb::option::error_unrecognized_option_at (args);
+
+ const char *bp_num_list = args;
+
+ bool print_address_col = should_print_address_col (ib_opts);
/* Compute the number of rows in the table, as well as the size
required for address fields. */
{
ui_out_emit_table table_emitter (uiout,
- opts.addressprint ? 6 : 5,
+ print_address_col ? 6 : 5,
nr_printable_breakpoints,
"BreakpointTable");
if (nr_printable_breakpoints > 0)
annotate_field (3);
uiout->table_header (3, ui_left, "enabled", "Enb"); /* 4 */
- if (opts.addressprint)
+ if (print_address_col)
{
if (nr_printable_breakpoints > 0)
annotate_field (4);
show_internal is set. */
if (show_internal || user_breakpoint_p (b))
{
- print_one_breakpoint (b, &last_loc, show_internal);
+ print_one_breakpoint (b, &last_loc, show_internal, ib_opts);
for (bp_location *loc : b->locations ())
if (loc->disabled_by_cond)
has_disabled_by_cond_location = true;
return nr_printable_breakpoints;
}
+/* Completer for the "info breakpoints" command. */
+
+static void
+info_breakpoints_command_completer (struct cmd_list_element *ignore,
+ completion_tracker &tracker,
+ const char *text, const char *word_ignored)
+{
+ const auto grp = make_info_breakpoints_options_def_group (nullptr);
+
+ if (gdb::option::complete_options
+ (tracker, &text, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_OPERAND, grp))
+ return;
+
+ /* Convenience to let the user know what the command can accept. */
+ if (*text == '\0')
+ {
+ gdb::option::complete_on_all_options (tracker, grp);
+ /* Keep this "ID" in sync with what "help info breakpoints"
+ says. */
+ tracker.add_completion (make_unique_xstrdup ("ID"));
+ }
+}
+
/* Display the value of default-collect in a way that is generally
compatible with the breakpoint list. */
/* Implement the "print_one" method for ranged breakpoints. */
bool
-ranged_breakpoint::print_one (bp_location **last_loc) const
+ranged_breakpoint::print_one (bp_location **last_loc, bool print_address_col) const
{
struct bp_location *bl = loc;
struct value_print_options opts;
get_user_print_options (&opts);
- if (opts.addressprint)
+ if (print_address_col)
/* We don't print the address range here, it will be printed later
by print_one_detail_ranged_breakpoint. */
uiout->field_skip ("addr");
is prefixed with \"server \".\n\n\
Convenience variable \"$bpnum\" contains the number of the last\n\
breakpoint set."));
+ set_cmd_completer_handle_brkchars (info_breakpoints_cmd,
+ info_breakpoints_command_completer);
add_info_alias ("b", info_breakpoints_cmd, 1);
- add_cmd ("breakpoints", class_maintenance, maintenance_info_breakpoints, _("\
+ cmd_list_element *breakpoints_cmd
+ = add_cmd ("breakpoints", class_maintenance, maintenance_info_breakpoints, _("\
Status of all breakpoints, or breakpoint number NUMBER.\n\
The \"Type\" column indicates one of:\n\
\tbreakpoint - normal breakpoint\n\
Convenience variable \"$bpnum\" contains the number of the last\n\
breakpoint set."),
&maintenanceinfolist);
+ set_cmd_completer_handle_brkchars (breakpoints_cmd,
+ info_breakpoints_command_completer);
add_basic_prefix_cmd ("catch", class_breakpoint, _("\
Set catchpoints to catch events."),
/* Display information about this breakpoint, for "info
breakpoints". Returns false if this method should use the
- default behavior. */
- virtual bool print_one (bp_location **) const
+ default behavior. PRINT_ADDRESS_COL specifies whether the "addr"
+ column should be printed. */
+ virtual bool print_one (bp_location **, bool print_address_col) const
{
return false;
}
complete_on_options (options_group, tracker, opt + 1, opt);
}
+/* See cli-option.h. */
+
+void
+error_unrecognized_option_at (const char *at)
+{
+ error (_("Unrecognized option at: %s"), at);
+}
+
/* Parse ARGS, guided by OPTIONS_GROUP. HAVE_DELIMITER is true if the
whole ARGS line included the "--" options-terminator delimiter. */
else if (**args != '-')
{
if (have_delimiter)
- error (_("Unrecognized option at: %s"), *args);
+ error_unrecognized_option_at (*args);
return {};
}
else if (check_for_argument (args, "--"))
if (match == nullptr)
{
if (have_delimiter || mode != PROCESS_OPTIONS_UNKNOWN_IS_OPERAND)
- error (_("Unrecognized option at: %s"), *args);
+ error_unrecognized_option_at (*args);
return {};
}
complete_on_all_options (completion_tracker &tracker,
gdb::array_view<const option_def_group> options_group);
+/* Throw an error indicating an unrecognized option was detected at
+ AT. Use this in conjunction with UNKNOWN_IS_OPERAND instead of
+ UNKNOWN_IS_ERROR when the operand may or may not begin with '-'
+ depending on some condition determined at run time. */
+extern void error_unrecognized_option_at (const char *at);
+
/* Return a string with the result of replacing %OPTIONS% in HELP_TMLP
with an auto-generated "help" string fragment for all the options
in OPTIONS_GROUP. */
@kindex info breakpoints
@cindex @code{$_} and @code{info breakpoints}
-@item info breakpoints @r{[}@var{list}@dots{}@r{]}
-@itemx info break @r{[}@var{list}@dots{}@r{]}
+@item info breakpoints [-hide-locations] @r{[}@var{list}@dots{}@r{]}
+@itemx info break [-hide-locations] @r{[}@var{list}@dots{}@r{]}
Print a table of all breakpoints, watchpoints, tracepoints, and
catchpoints set and not deleted. The optional argument @var{n} means
print information only about the specified breakpoint(s) (or
watchpoint(s) or tracepoint(s) or catchpoint(s)).
-For each code breakpoint and tracepoint (i.e., not for watchpoints,
-nor catchpoints), after printing a row for the breakpoint itself,
+Unless the @code{-hide-locations} option is specified, for each code
+breakpoint and tracepoint (i.e., not for watchpoints, nor
+catchpoints), after printing a row for the breakpoint itself,
@value{GDBN} prints one row for each of the breakpoint's locations.
More on this further below.
@item Address
Where the breakpoint location is in your program, as a memory address.
For a breakpoint with no locations, this field will contain
-@samp{<PENDING>}.
+@samp{<PENDING>}. This column is not printed if you specify the
+@code{-hide-locations} option, nor if you disable printing of
+addresses with @code{set print address off} (@pxref{set print
+address}).
@item What
For a breakpoint header row, this shows the breakpoint's location
specification, derived from the string passed to the breakpoint
instantiation of that template, a new location is added to the list of
locations for the breakpoint. More on this further below.
-As mentioned above, regular code breakpoints and tracepoints are
+As mentioned above, regular code breakpoints and tracepoints are normally
displayed in the breakpoint table using several rows---one header row
per breakpoint, followed by one row for each of the breakpoint's
locations. The header row has an empty address column, and the
For example:
@smallexample
+(@value{GDBP}) info breakpoints
Num Type Disp Enb Address What
1 breakpoint keep y foo
stop only if i==1
breakpoint already hit 1 time
1.1 y 0x080486a2 in void foo<int>() at t.cc:8
1.2 y 0x080486ca in void foo<double>() at t.cc:8
+2 breakpoint keep y bar
+ 2.1 y 0x080646a8 in void bar() at t.cc:20
@end smallexample
Above you can tell from the what column that the breakpoint had been
locations that matched that location specification, each of them a
different instanciation of the foo function template.
+When the @code{-hide-locations} flag is used, @value{GDBN} doesn't
+print breakpoint locations, and doesn't print the address column
+either, since only breakpoint locations have addresses. With the same
+breakpoints as the previous example, you'd get:
+
+@smallexample
+(@value{GDBP}) info breakpoints -hide-locations
+Num Type Disp Enb What
+1 breakpoint keep y foo
+ stop only if i==1
+ breakpoint already hit 1 time
+2 breakpoint keep y bar
+@end smallexample
+
Breakpoints created with the @code{-qualified} option show that fact
in the breakpoint row's what column, as part of the breakpoint's
location specification. For example: