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.