public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2 00/24] gdb::option framework, "print -OPT", other cmd options
@ 2019-05-30 19:53 Pedro Alves
  2019-05-30 19:53 ` [PATCH v2 06/24] Fix "set enum-command value garbage" Pedro Alves
                   ` (24 more replies)
  0 siblings, 25 replies; 43+ messages in thread
From: Pedro Alves @ 2019-05-30 19:53 UTC (permalink / raw)
  To: gdb-patches

Here's v2 of this patch series, which I believe addresses all comments
against v1 so far.  The main change in v2 is that patch #15 is
completely different, hence the repost.  In v1, I was adding a way to
rename a command.  In v2, after discussion with Philippe, I'm adding
new "set/show print raw-frame-arguments" (dash) commands and
deprecating "set/show print raw frame-arguments" (space).
Documentation for that change is in that same patch.  Eli,
documentation-wise, nothing else changed in the series other than
addressing your comments in the previous iteration.

~~~~~~

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 garbage"
  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_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                        | 344 +++++++++--
 gdb/NEWS                                   | 103 ++++
 gdb/Makefile.in                            |   3 +
 gdb/ax-gdb.c                               |   2 -
 gdb/breakpoint.c                           |   5 +-
 gdb/cli/cli-decode.c                       |  27 +-
 gdb/cli/cli-decode.h                       |   4 +
 gdb/cli/cli-option.c                       | 732 +++++++++++++++++++++++
 gdb/cli/cli-option.h                       | 335 +++++++++++
 gdb/cli/cli-setshow.c                      | 290 +++++----
 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                            |  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                                | 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        | 542 +++++++++++++++++
 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 +-
 43 files changed, 5497 insertions(+), 922 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

^ permalink raw reply	[flat|nested] 43+ messages in thread

end of thread, other threads:[~2019-06-05  1:53 UTC | newest]

Thread overview: 43+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-30 19:53 [PATCH v2 00/24] gdb::option framework, "print -OPT", other cmd options Pedro Alves
2019-05-30 19:53 ` [PATCH v2 06/24] Fix "set enum-command value garbage" Pedro Alves
2019-06-03 18:51   ` Tom Tromey
2019-06-04 21:52     ` Pedro Alves
2019-05-30 19:53 ` [PATCH v2 15/24] "set print raw frame-arguments" -> "set print raw-frame-arguments" Pedro Alves
2019-05-31  5:48   ` Eli Zaretskii
2019-05-30 19:53 ` [PATCH v2 02/24] Fix latent bug with custom word point completers Pedro Alves
2019-05-30 19:53 ` [PATCH v2 11/24] number_or_range_parser::get_number, don't treat "1 -" as a range Pedro Alves
2019-05-30 19:53 ` [PATCH v2 01/24] Fix latent bug in custom word point completion handling Pedro Alves
2019-05-30 19:54 ` [PATCH v2 24/24] NEWS and manual changes for command options changes Pedro Alves
2019-05-30 19:54 ` [PATCH v2 05/24] Allow "unlimited" abbreviations Pedro Alves
2019-05-30 19:54 ` [PATCH v2 16/24] Make "backtrace" support -OPT options Pedro Alves
2019-05-30 19:54 ` [PATCH v2 07/24] Remove "show" command completers, "set" command completers for string commands Pedro Alves
2019-06-03 18:55   ` Tom Tromey
2019-06-04 21:54     ` Pedro Alves
2019-05-30 19:54 ` [PATCH v2 12/24] Introduce generic command options framework Pedro Alves
2019-06-03 19:25   ` Tom Tromey
2019-06-04 18:46     ` [PATCH] Introduce and use make_unique_xstrdup (was: Re: [PATCH v2 12/24] Introduce generic command options framework) Pedro Alves
2019-06-04 18:59       ` [PATCH] Introduce and use make_unique_xstrdup Tom Tromey
2019-06-04 21:51         ` Pedro Alves
2019-06-04 21:37     ` [PATCH v2 12/24] Introduce generic command options framework Pedro Alves
2019-05-30 19:54 ` [PATCH v2 21/24] "thread apply 1 -- -" vs "frame apply level 0 -- -" Pedro Alves
2019-05-30 19:54 ` [PATCH v2 13/24] Make "print" and "compile print" support -OPT options Pedro Alves
2019-06-03 19:20   ` Tom Tromey
2019-06-04 21:59     ` Pedro Alves
2019-05-30 19:54 ` [PATCH v2 10/24] boolean/auto-boolean commands, make "o" ambiguous Pedro Alves
2019-05-30 19:54 ` [PATCH v2 08/24] gdb.base/completion.exp: Fix comment typo Pedro Alves
2019-05-30 19:54 ` [PATCH v2 03/24] Fix TID parser bug Pedro Alves
2019-05-30 19:59 ` [PATCH v2 19/24] Introduce complete_command Pedro Alves
2019-06-03 19:28   ` Tom Tromey
2019-06-04 22:10     ` Pedro Alves
2019-06-05  1:53       ` Tom Tromey
2019-05-30 19:59 ` [PATCH v2 22/24] Make "thread apply" use the gdb::option framework Pedro Alves
2019-05-30 20:01 ` [PATCH v2 14/24] Migrate rest of compile commands to new options framework Pedro Alves
2019-05-30 20:01 ` [PATCH v2 20/24] Make "frame apply" support -OPT options Pedro Alves
2019-05-30 20:02 ` [PATCH v2 23/24] Delete parse_flags/parse_flags_qcs Pedro Alves
2019-05-30 20:02 ` [PATCH v2 09/24] New set/show testing framework (gdb.base/settings.exp) Pedro Alves
2019-05-30 20:03 ` [PATCH v2 04/24] Make check_for_argument skip whitespace after arg itself Pedro Alves
2019-06-03 18:49   ` Tom Tromey
2019-06-04 22:21     ` Pedro Alves
2019-05-30 20:03 ` [PATCH v2 18/24] lib/completion-support.exp: Add test_gdb_completion_offers_commands Pedro Alves
2019-05-30 20:03 ` [PATCH v2 17/24] "backtrace full/no-filters/hide" completer Pedro Alves
2019-06-03 19:33 ` [PATCH v2 00/24] gdb::option framework, "print -OPT", other cmd options Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).