aboutsummaryrefslogtreecommitdiff
path: root/gdb/cli
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2019-06-13 00:06:53 +0100
committerPedro Alves <palves@redhat.com>2019-06-13 00:22:07 +0100
commit5d7071341dd3c01d38fc01398ef8b23b1bd3783c (patch)
tree62f105b390f2950fe27f33439a9b0cbee921b5b8 /gdb/cli
parent272d4594343349a713f7d8967d90ae2413ecbc30 (diff)
downloadgdb-5d7071341dd3c01d38fc01398ef8b23b1bd3783c.zip
gdb-5d7071341dd3c01d38fc01398ef8b23b1bd3783c.tar.gz
gdb-5d7071341dd3c01d38fc01398ef8b23b1bd3783c.tar.bz2
Make "frame apply" support -OPT options
This adds support for '-'-style options to the "frame apply" family of commands -- "frame apply COUNT", "frame apply level", "frame apply all", "faas" and "tfaas". The -q/-c/-s flags were already supported, -past-main/-past-entry is new: ~~~ (gdb) help frame apply all Apply a command to all frames. Usage: frame apply all [OPTION]... COMMAND Prints the frame location information followed by COMMAND output. By default, an error raised during the execution of COMMAND aborts "frame apply". Options: -q Disables printing the frame location information. -c Print any error raised by COMMAND and continue. -s Silently ignore any errors or empty output produced by COMMAND. -past-main [on|off] Set whether backtraces should continue past "main". Normally the caller of "main" is not of interest, so GDB will terminate the backtrace at "main". Set this if you need to see the rest of the stack trace. -past-entry [on|off] Set whether backtraces should continue past the entry point of a program. Normally there are no callers beyond the entry point of a program, so GDB will terminate the backtrace there. Set this if you need to see the rest of the stack trace. ~~~ TAB completion of options is now supported. Also, TAB completion of COMMAND in "frame apply all COMMAND" does the right thing now, making use of complete_command, added by the previous patch. E.g.: (gdb) thread apply all -ascending frame apply all -past-main print -[TAB] -address -elements -pretty -symbol -array -null-stop -repeats -union -array-indexes -object -static-members -vtbl (gdb) thread apply all -ascending frame apply all -past-main print glo[TAB] global1 global2 The change to tfaas_command is necessary because otherwise you get this: (gdb) tfaas -- Unrecognized option at: frame apply all -s -- That's because the above is equivalent to: (gdb) thread apply all -s frame apply all -s -- and the "--" instructs "thread apply" to consider everything up to "--" as its command options. And from that view, "frame" is an invalid option. The change makes tfaas be equivalent to: (gdb) thread apply all -s -- frame apply all -s -- gdb/ChangeLog: 2019-06-13 Pedro Alves <palves@redhat.com> * cli/cli-utils.c (parse_flags_qcs): Use validate_flags_qcs. (validate_flags_qcs): New. * cli/cli-utils.h (struct qcs_flags): Change field types to int. (validate_flags_qcs): Declare. * stack.c (qcs_flag_option_def, fr_qcs_flags_option_defs): New. (make_frame_apply_options_def_group): New. (frame_apply_command_count): Process options with gdb::option::process_options. (frame_apply_completer): New. (frame_apply_level_completer, frame_apply_all_completer) (frame_apply_completer): New. (_initialize_stack): Update help of "frame apply", "frame apply level", "frame apply all" and "faas" to mention supported options and install command completers. * stack.h (frame_apply_all_completer): Declare. * thread.c: Include "stack.h". (tfaas_command): Add "--". (_initialize_thread): Update help "tfaas" to mention supported options and install command completer. gdb/testsuite/ChangeLog: 2019-06-13 Pedro Alves <palves@redhat.com> * gdb.base/options.exp (test-frame-apply): New. (top level): Test print commands with different "frame apply" prefixes.
Diffstat (limited to 'gdb/cli')
-rw-r--r--gdb/cli/cli-utils.c14
-rw-r--r--gdb/cli/cli-utils.h14
2 files changed, 22 insertions, 6 deletions
diff --git a/gdb/cli/cli-utils.c b/gdb/cli/cli-utils.c
index 306b69e..30d4091 100644
--- a/gdb/cli/cli-utils.c
+++ b/gdb/cli/cli-utils.c
@@ -573,8 +573,18 @@ parse_flags_qcs (const char *which_command, const char **str,
gdb_assert_not_reached ("int qcs flag out of bound");
}
- if (flags->cont && flags->silent)
- error (_("%s: -c and -s are mutually exclusive"), which_command);
+ validate_flags_qcs (which_command, flags);
return true;
}
+
+/* See documentation in cli-utils.h. */
+
+void
+validate_flags_qcs (const char *which_command, qcs_flags *flags)
+{
+ if (flags->cont && flags->silent)
+ error (_("%s: -c and -s are mutually exclusive"), which_command);
+}
+
+/* See documentation in cli-utils.h. */
diff --git a/gdb/cli/cli-utils.h b/gdb/cli/cli-utils.h
index 41c2356..e6b877d 100644
--- a/gdb/cli/cli-utils.h
+++ b/gdb/cli/cli-utils.h
@@ -229,13 +229,14 @@ check_for_argument (char **str, const char *arg)
such that FLAGS [N - 1] is the valid found flag. */
extern int parse_flags (const char **str, const char *flags);
-/* qcs_flags struct regroups the flags parsed by parse_flags_qcs. */
+/* qcs_flags struct groups the -q, -c, and -s flags parsed by "thread
+ apply" and "frame apply" commands */
struct qcs_flags
{
- bool quiet = false;
- bool cont = false;
- bool silent = false;
+ int quiet = false;
+ int cont = false;
+ int silent = false;
};
/* A helper function that uses parse_flags to handle the flags qcs :
@@ -259,4 +260,9 @@ struct qcs_flags
extern bool parse_flags_qcs (const char *which_command, const char **str,
qcs_flags *flags);
+/* Validate FLAGS. Throws an error if both FLAGS->CONT and
+ FLAGS->SILENT are true. WHICH_COMMAND is included in the error
+ message. */
+extern void validate_flags_qcs (const char *which_command, qcs_flags *flags);
+
#endif /* CLI_CLI_UTILS_H */