[PATCH 00/24] gdb::option framework, "print -OPT", other cmd options
Pedro Alves
palves@redhat.com
Wed May 22 20:53:00 GMT 2019
This all started a couple years ago with the idea that one reason
people sometimes complain about gdb's defaults, such as "set print
object" or "set print static-members" is that we don't have an easy
way to override the global print settings.
I.e., how if we had options support in the print command, so you could
do this:
(gdb) print -pretty obj
instead of:
(gdb) set print pretty on
(gdb) print obj
(gdb) set print pretty off
then the defaults, while they'd still matter, wouldn't matter so much.
Back then, I experimented with that, and got a prototype up and
running. Other priorities were put in front of it so I never managed
to finish it... until now. The reason I picked it up again, is that
this addresses part of the same motivation that led to Philippe's "/"
command. I don't necessarily think that the solutions are orthogonal,
but I do think that having this feature in might affect how we look at
the "/"-command idea. Particularly, I'm not sold on the way the
feature's user interface is designed.
I'm a strong believer of TAB-completion driving the CLI, and that is
one of the reasons why I like this patchset. If you're like me,
you're pressing TAB all the time. It allows dynamic discovery of
options/features, and makes it not a problem to have longer option
names:
(gdb) p -[TAB]
-address -elements -pretty -symbol
-array -null-stop -repeats -union
-array-indexes -object -static-members -vtbl
The approach I took is that command options have a similar syntax and
names to the global set settings. The above should be familiar, if
you're familiar with the "set print" settings:
(gdb) set print[TAB]
address max-symbolic-offset symbol
array null-stop symbol-filename
array-indexes object symbol-loading
asm-demangle pascal_static-members thread-events
demangle pretty type
elements raw union
entry-values repeats vtbl
frame-arguments sevenbit-strings
inferior-events static-members
So we have boolean, integer and enum options, just like we have the
"set" command counterpart types. In fact, the data structures used to
describe a command's options can (and are) used to install the
corresponding "set" commands.
This results in options like:
(gdb) print -elements 100 -object off -- *myobj
(gdb) backtrace -frame-arguments scalars
(gdb) frame apply all -past-main
Also, command options are abbreviatable, boolean arguments are
optional (on is assumed), and you can write 0/1 instead of on/off too,
so you could replace the above with
(gdb) print -e 100 -o 0 -- *myobj
(gdb) backtrace -fr s
(gdb) f ap a -past-m
BTW, you'll notice that the framework doesn't split arguments in an
array of arguments, getopt-/buildargv- style. The reason for that is
that many commands in gdb accept raw, unformatted arguments,
expressions, and we can't split those up around whitespace.
So the series adds fixes a number of latent bugs exposed while writing
this, the options infrastructure proper along with its testsuite
(patch #12), and converts a number of commands to use the
infrastructure: "print"/"compile print", "compile code/file",
"backtrace", and "thread/frame apply" & friends.
Patch #9 adds testing of the "set"/"show" commands' parsing/completion
mechanics.
For print in particular, I settled on requiring "--" if you specify
any option. I'm open to opinions otherwise, but please read through
the series, and particularly patch #13 for more details around that
choice.
Documentation is most in the last patch of the series, except there's
another bit in patch #09, which could be a standalone patch.
Pedro Alves (24):
Fix latent bug in custom word point completion handling
Fix latent bug with custom word point completers
Fix TID parser bug
Make check_for_argument skip whitespace after arg itself
Allow "unlimited" abbreviations
Fix "set enum-command value garbage"
Remove "show" command completers
gdb.base/settings.exp: Fix comment typo
New set/show testing framework (gdb.base/settings.exp)
boolean/auto-boolean commands, make "o" ambiguous
number_or_range_parser::get_number, don't treat "1 -" as a range
Introduce generic command options framework
Make "print" and "compile print" support -OPT options
Migrate rest of compile commands to new options framework
Introduce rename_cmd
Make "backtrace" support -OPT options
"backtrace full/no-filters/hide" completer
lib/completion-support.exp: Add test_gdb_completion_offers_commands
Introduce complete_command
Make "frame apply" support -OPT options
"thread apply 1 -- -" vs "frame apply level 0 -- -"
Make "thread apply" use the gdb::option framework
Delete parse_flags/parse_flags_qcs
NEWS and manual changes for command options changes
gdb/doc/gdb.texinfo | 338 +++++++++--
gdb/NEWS | 97 ++++
gdb/Makefile.in | 3 +
gdb/ax-gdb.c | 2 -
gdb/breakpoint.c | 5 +-
gdb/cli/cli-decode.c | 183 ++++--
gdb/cli/cli-decode.h | 4 +
gdb/cli/cli-option.c | 732 ++++++++++++++++++++++++
gdb/cli/cli-option.h | 335 +++++++++++
gdb/cli/cli-setshow.c | 287 ++++++----
gdb/cli/cli-setshow.h | 27 +
gdb/cli/cli-utils.c | 124 +++--
gdb/cli/cli-utils.h | 62 +--
gdb/command.h | 5 +
gdb/compile/compile.c | 215 ++++---
gdb/completer.c | 84 ++-
gdb/completer.h | 20 +-
gdb/cp-valprint.c | 57 --
gdb/frame.c | 84 +--
gdb/frame.h | 55 +-
gdb/maint-test-options.c | 460 +++++++++++++++
gdb/maint-test-settings.c | 257 +++++++++
gdb/mi/mi-cmd-stack.c | 23 +-
gdb/printcmd.c | 94 +++-
gdb/python/py-framefilter.c | 3 +-
gdb/stack.c | 627 ++++++++++++++++-----
gdb/stack.h | 5 +
gdb/testsuite/gdb.base/completion.exp | 2 +-
gdb/testsuite/gdb.base/options.c | 33 ++
gdb/testsuite/gdb.base/options.exp | 923 +++++++++++++++++++++++++++++++
gdb/testsuite/gdb.base/settings.c | 23 +
gdb/testsuite/gdb.base/settings.exp | 536 ++++++++++++++++++
gdb/testsuite/gdb.compile/compile.exp | 15 +-
gdb/testsuite/gdb.multi/tids.exp | 16 +-
gdb/testsuite/lib/completion-support.exp | 66 ++-
gdb/thread.c | 285 +++++++---
gdb/tid-parse.c | 16 +-
gdb/tid-parse.h | 3 +
gdb/unittests/cli-utils-selftests.c | 133 -----
gdb/valprint.c | 259 ++++++---
gdb/valprint.h | 20 +-
41 files changed, 5563 insertions(+), 955 deletions(-)
create mode 100644 gdb/cli/cli-option.c
create mode 100644 gdb/cli/cli-option.h
create mode 100644 gdb/maint-test-options.c
create mode 100644 gdb/maint-test-settings.c
create mode 100644 gdb/testsuite/gdb.base/options.c
create mode 100644 gdb/testsuite/gdb.base/options.exp
create mode 100644 gdb/testsuite/gdb.base/settings.c
create mode 100644 gdb/testsuite/gdb.base/settings.exp
--
2.14.5
More information about the Gdb-patches
mailing list