print_entry_values_choices,
[] (frame_print_options *opt) { return &opt->print_entry_values; },
NULL, /* show_cmd_cb */
- N_("Set printing of function arguments at function entry"),
- N_("Show printing of function arguments at function entry"),
+ N_("Set printing of function arguments at function entry."),
+ N_("Show printing of function arguments at function entry."),
N_("GDB can sometimes determine the values of function arguments at entry,\n\
in addition to their current values. This option tells GDB whether\n\
to print the current value, the value at entry (marked as val@entry),\n\
print_frame_arguments_choices,
[] (frame_print_options *opt) { return &opt->print_frame_arguments; },
NULL, /* show_cmd_cb */
- N_("Set printing of non-scalar frame arguments"),
- N_("Show printing of non-scalar frame arguments"),
+ N_("Set printing of non-scalar frame arguments."),
+ N_("Show printing of non-scalar frame arguments."),
NULL /* help_doc */
},
struct backtrace_cmd_options
{
- int full = 0;
- int no_filters = 0;
- int hide = 0;
+ bool full = false;
+ bool no_filters = false;
+ bool hide = false;
};
using bt_flag_option_def
else
{
if (arg->error)
- stb.printf (_("<error reading variable: %s>"), arg->error);
+ stb.printf (_("<error reading variable: %s>"), arg->error.get ());
else
{
try
}
catch (const gdb_exception_error &except)
{
- argp->error = xstrdup (except.what ());
+ argp->error.reset (xstrdup (except.what ()));
}
}
-/* Read in inferior function parameter SYM at FRAME into ARGP. Caller is
- responsible for xfree of ARGP->ERROR. This function never throws an
- exception. */
+/* Read in inferior function parameter SYM at FRAME into ARGP. This
+ function never throws an exception. */
void
read_frame_arg (const frame_print_options &fp_opts,
argp->sym = sym;
argp->val = val;
- argp->error = val_error ? xstrdup (val_error) : NULL;
+ argp->error.reset (val_error ? xstrdup (val_error) : NULL);
if (!val && !val_error)
argp->entry_kind = print_entry_values_only;
else if ((fp_opts.print_entry_values == print_entry_values_compact
entryargp->sym = sym;
entryargp->val = entryval;
- entryargp->error = entryval_error ? xstrdup (entryval_error) : NULL;
+ entryargp->error.reset (entryval_error ? xstrdup (entryval_error) : NULL);
if (!entryval && !entryval_error)
entryargp->entry_kind = print_entry_values_no;
else
if (!print_args)
{
- memset (&arg, 0, sizeof (arg));
arg.sym = sym;
arg.entry_kind = print_entry_values_no;
- memset (&entryarg, 0, sizeof (entryarg));
entryarg.sym = sym;
entryarg.entry_kind = print_entry_values_no;
}
print_frame_arg (fp_opts, &entryarg);
}
- xfree (arg.error);
- xfree (entryarg.error);
-
first = 0;
}
}
print_frame_info);
}
+/* Print the PC from FRAME, plus any flags, to UIOUT. */
+
+static void
+print_pc (struct ui_out *uiout, struct gdbarch *gdbarch, frame_info *frame,
+ CORE_ADDR pc)
+{
+ uiout->field_core_addr ("addr", gdbarch, pc);
+
+ std::string flags = gdbarch_get_pc_address_flags (gdbarch, frame, pc);
+ if (!flags.empty ())
+ {
+ uiout->text (" [");
+ uiout->field_string ("addr_flags", flags);
+ uiout->text ("]");
+ }
+}
+
/* See stack.h. */
void
if (uiout->is_mi_like_p ())
{
annotate_frame_address ();
- uiout->field_core_addr ("addr",
- gdbarch, get_frame_pc (frame));
+ print_pc (uiout, gdbarch, frame, get_frame_pc (frame));
annotate_frame_address_end ();
}
ability to decide for themselves if it is desired. */
if (opts.addressprint && mid_statement)
{
- uiout->field_core_addr ("addr",
- gdbarch, get_frame_pc (frame));
+ print_pc (uiout, gdbarch, frame, get_frame_pc (frame));
uiout->text ("\t");
}
{
annotate_frame_address ();
if (pc_p)
- uiout->field_core_addr ("addr", gdbarch, pc);
+ print_pc (uiout, gdbarch, frame, pc);
else
uiout->field_string ("addr", "<unavailable>",
ui_out_style_kind::ADDRESS);
}
}
+/* Structure to hold the values of the options used by the 'info
+ variables' command and other similar commands. These correspond to the
+ -q and -t options. */
+
+struct info_print_options
+{
+ bool quiet = false;
+ char *type_regexp = nullptr;
+
+ ~info_print_options ()
+ {
+ xfree (type_regexp);
+ }
+};
+
+/* The options used by the 'info locals' and 'info args' commands. */
+
+static const gdb::option::option_def info_print_options_defs[] = {
+ gdb::option::boolean_option_def<info_print_options> {
+ "q",
+ [] (info_print_options *opt) { return &opt->quiet; },
+ nullptr, /* show_cmd_cb */
+ nullptr /* set_doc */
+ },
+
+ gdb::option::string_option_def<info_print_options> {
+ "t",
+ [] (info_print_options *opt) { return &opt->type_regexp; },
+ nullptr, /* show_cmd_cb */
+ nullptr /* set_doc */
+ }
+};
+
+/* Returns the option group used by 'info locals' and 'info args'
+ commands. */
+
+static gdb::option::option_def_group
+make_info_print_options_def_group (info_print_options *opts)
+{
+ return {{info_print_options_defs}, opts};
+}
+
+/* Command completer for 'info locals' and 'info args'. */
+
+static void
+info_print_command_completer (struct cmd_list_element *ignore,
+ completion_tracker &tracker,
+ const char *text, const char * /* word */)
+{
+ const auto group
+ = make_info_print_options_def_group (nullptr);
+ if (gdb::option::complete_options
+ (tracker, &text, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_OPERAND, group))
+ return;
+
+ const char *word = advance_to_expression_complete_word_point (tracker, text);
+ symbol_completer (ignore, tracker, text, word);
+}
+
/* Implement the 'info locals' command. */
void
info_locals_command (const char *args, int from_tty)
{
info_print_options opts;
- extract_info_print_options (&opts, &args);
+ auto grp = make_info_print_options_def_group (&opts);
+ gdb::option::process_options
+ (&args, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_OPERAND, grp);
+ if (args != nullptr && *args == '\0')
+ args = nullptr;
print_frame_local_vars (get_selected_frame (_("No frame selected.")),
opts.quiet, args, opts.type_regexp,
info_args_command (const char *args, int from_tty)
{
info_print_options opts;
- extract_info_print_options (&opts, &args);
+ auto grp = make_info_print_options_def_group (&opts);
+ gdb::option::process_options
+ (&args, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_OPERAND, grp);
+ if (args != nullptr && *args == '\0')
+ args = nullptr;
print_frame_arg_vars (get_selected_frame (_("No frame selected.")),
opts.quiet, args, opts.type_regexp, gdb_stdout);
add_cmd ("address", class_stack, &frame_cmd.address,
_("\
-Select and print a stack frame by stack address\n\
+Select and print a stack frame by stack address.\n\
\n\
Usage: frame address STACK-ADDRESS"),
&frame_cmd_list);
Usage: backtrace [OPTION]... [QUALIFIER]... [COUNT | -COUNT]\n\
\n\
Options:\n\
-%OPTIONS%\
+%OPTIONS%\n\
+\n\
For backward compatibility, the following qualifiers are supported:\n\
\n\
full - same as -full option.\n\
All local variables of current stack frame or those matching REGEXPs.\n\
Usage: info locals [-q] [-t TYPEREGEXP] [NAMEREGEXP]\n\
Prints the local variables of the current stack frame.\n"),
- _("local variables")));
+ _("local variables"),
+ false));
set_cmd_completer_handle_brkchars (cmd, info_print_command_completer);
cmd = add_info ("args", info_args_command,
info_print_args_help (_("\
All argument variables of current stack frame or those matching REGEXPs.\n\
Usage: info args [-q] [-t TYPEREGEXP] [NAMEREGEXP]\n\
Prints the argument variables of the current stack frame.\n"),
- _("argument variables")));
+ _("argument variables"),
+ false));
set_cmd_completer_handle_brkchars (cmd, info_print_command_completer);
if (dbx_commands)