This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH v3 00/24] gdb::option framework, "print -OPT", other cmd options
- From: Pedro Alves <palves at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Tue, 4 Jun 2019 23:34:20 +0100
- Subject: [PATCH v3 00/24] gdb::option framework, "print -OPT", other cmd options
Here's v3 of this patch series, which I believe addresses all comments
against v2 so far. This is mostly a consolidation of an assortment of
fixes.
- rebased on current master.
- make_unique_xstrdup was split to a separate patch, and merged.
- the check_for_argument patch (#2) removes a new instance of
skip_spaces that went into the tree meanwhile.
- patch #6 (previously 'Fix "set enum-command value garbage"')
says "junk" instead of "garbage" now.
- the settings.exp testcase got a couple new tests.
- indentation in commit log of patch #13 fixed.
- complete_command in patch #19 was renamed to
complete_nested_command_line.
- fixed a number of typos throughout.
Documentation-wise, nothing changed.
I've pushed this to users/palves/cli-options-v3.
~~~~~~
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.
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" command 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 fixes a number of latent bugs exposed while writing
this, adds 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 mostly in the last patch of the series, though there
are bits in patch #09 and patch #15 too.
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 junk"
Remove "show" command completers, "set" command completers for string
commands
gdb.base/completion.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
"set print raw frame-arguments" -> "set print raw-frame-arguments"
Make "backtrace" support -OPT options
"backtrace full/no-filters/hide" completer
lib/completion-support.exp: Add test_gdb_completion_offers_commands
Introduce complete_nested_command_line
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 | 344 +++++++++--
gdb/NEWS | 102 ++++
gdb/Makefile.in | 3 +
gdb/ax-gdb.c | 2 -
gdb/breakpoint.c | 5 +-
gdb/cli/cli-cmds.c | 3 -
gdb/cli/cli-decode.c | 27 +-
gdb/cli/cli-decode.h | 4 +
gdb/cli/cli-option.c | 724 ++++++++++++++++++++++
gdb/cli/cli-option.h | 335 +++++++++++
gdb/cli/cli-setshow.c | 289 +++++----
gdb/cli/cli-setshow.h | 27 +
gdb/cli/cli-utils.c | 124 ++--
gdb/cli/cli-utils.h | 62 +-
gdb/command.h | 19 +-
gdb/compile/compile.c | 215 ++++---
gdb/completer.c | 84 ++-
gdb/completer.h | 21 +-
gdb/cp-valprint.c | 57 --
gdb/frame.c | 84 +--
gdb/frame.h | 55 +-
gdb/maint-test-options.c | 461 ++++++++++++++
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 | 620 ++++++++++++++-----
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 | 545 +++++++++++++++++
gdb/testsuite/gdb.compile/compile.exp | 15 +-
gdb/testsuite/gdb.guile/scm-frame-args.exp | 4 +-
gdb/testsuite/gdb.multi/tids.exp | 16 +-
gdb/testsuite/gdb.python/py-frame-args.exp | 4 +-
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 | 280 ++++++---
gdb/valprint.h | 20 +-
44 files changed, 5492 insertions(+), 925 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