aboutsummaryrefslogtreecommitdiff
path: root/gdb/stack.c
diff options
context:
space:
mode:
authorAndrew Burgess <andrew.burgess@embecosm.com>2019-07-22 16:53:06 +0100
committerAndrew Burgess <andrew.burgess@embecosm.com>2019-08-27 16:21:42 +0100
commit4acfdd20c9ef3c0368868b4221554f0abef04196 (patch)
tree09e8ed00b4bc0dfdbe8bb12f22a8822d20caeed4 /gdb/stack.c
parentc4a23bf878f2e9a64034006c91596401faf6db3e (diff)
downloadgdb-4acfdd20c9ef3c0368868b4221554f0abef04196.zip
gdb-4acfdd20c9ef3c0368868b4221554f0abef04196.tar.gz
gdb-4acfdd20c9ef3c0368868b4221554f0abef04196.tar.bz2
gdb: Add new -n flag to some info commands
The 'info variables', its alias 'whereis', and 'info functions' all include non-debug symbols in the output by default. The list of non-debug symbols can sometimes be quite long, resulting in the debug symbol based results being scrolled off the screen. This commit adds a '-n' flag to all of the commands listed above that excludes the non-debug symbols from the results, leaving just the debug symbol based results. gdb/ChangeLog: * cli/cli-utils.c (info_print_options_defs): Delete. (make_info_print_options_def_group): Delete. (extract_info_print_options): Delete. (info_print_command_completer): Delete. (info_print_args_help): Add extra parameter, and optionally include text about -n flag. * cli/cli-utils.h (struct info_print_options): Delete. (extract_info_print_options): Delete declaration. (info_print_command_completer): Delete declaration. (info_print_args_help): Add extra parameter, extend header comment. * python/python.c (gdbpy_rbreak): Pass additional parameter to search_symbols. * stack.c (struct info_print_options): New type. (info_print_options_defs): New file scoped variable. (make_info_print_options_def_group): New static function. (info_print_command_completer): New static function. (info_locals_command): Update to use new local functions. (info_args_command): Likewise. (_initialize_stack): Add extra parameter to calls to info_print_args_help. * symtab.c (search_symbols): Add extra parameter, use this to possibly excluse non-debug symbols. (symtab_symbol_info): Add extra parameter, which is passed on to search_symbols. (struct info_print_options): New type. (info_print_options_defs): New file scoped variable. (make_info_print_options_def_group): New static function. (info_print_command_completer): New static function. (info_variables_command): Update to use local functions, and pass extra parameter through to symtab_symbol_info. (info_functions_command): Likewise. (info_types_command): Pass additional argument through to symtab_symbol_info. (rbreak_command): Pass extra argument to search_symbols. (_initialize_symtab): Add extra arguments for calls to info_print_args_help, and update help text for 'info variables', 'whereis', and 'info functions' commands. * symtab.h (search_symbols): Add extra argument to declaration. * NEWS: Mention new flags. gdb/doc/ChangeLog: * gdb.texinfo (Symbols): Add information about the -n flag to "info variables" and "info functions". gdb/testsuite/ChangeLog: * gdb.base/info-fun.exp: Extend to test the -n flag for 'info functions'. Reindent as needed. * gdb.base/info-var-f1.c: New file. * gdb.base/info-var-f2.c: New file. * gdb.base/info-var.exp: New file. * gdb.base/info-var.h: New file.
Diffstat (limited to 'gdb/stack.c')
-rw-r--r--gdb/stack.c77
1 files changed, 73 insertions, 4 deletions
diff --git a/gdb/stack.c b/gdb/stack.c
index 06431ea..10a88e9 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -2417,13 +2417,76 @@ print_frame_local_vars (struct frame_info *frame,
}
}
+/* 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
+{
+ int 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,
@@ -2530,7 +2593,11 @@ void
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);
@@ -3487,14 +3554,16 @@ Usage: info frame level LEVEL"),
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)