[Lldb-commits] [PATCH] D137000: [lldb] Make callback-based formatter matching available from the CLI.
Jorge Gorbe Moya via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Mon Oct 31 15:58:34 PDT 2022
jgorbe added a comment.
I'm looking at the option of using a non-printable character for the short flag, and at the same time make `--regex` and `--recognizer-function` mutually exclusive using option groups. One problem I see is that the command help gets pretty confusing. Using a non-printable character as the short option name makes the option completely disappear from the "Command Options Usage" summary part of the help.
For example, for `disassemble` the `--force` option is defined with `Groups[2,3,4,5,7]` but there's no indication in the usage summary that `--force` is only usable in some of the groups:
Command Options Usage:
disassemble [-bkmr] -s <address-expression> [-A <arch>] [-C <num-lines>] [-e <address-expression>] [-F <disassembly-flavor>] [-P <plugin>]
disassemble [-bkmr] -s <address-expression> [-A <arch>] [-C <num-lines>] [-c <num-lines>] [-F <disassembly-flavor>] [-P <plugin>]
disassemble [-bkmr] [-A <arch>] [-C <num-lines>] [-c <num-lines>] [-F <disassembly-flavor>] [-n <function-name>] [-P <plugin>]
disassemble [-bfkmr] [-A <arch>] [-C <num-lines>] [-c <num-lines>] [-F <disassembly-flavor>] [-P <plugin>]
disassemble [-bkmpr] [-A <arch>] [-C <num-lines>] [-c <num-lines>] [-F <disassembly-flavor>] [-P <plugin>]
disassemble [-bklmr] [-A <arch>] [-C <num-lines>] [-F <disassembly-flavor>] [-P <plugin>]
disassemble [-bkmr] [-a <address-expression>] [-A <arch>] [-C <num-lines>] [-c <num-lines>] [-F <disassembly-flavor>] [-P <plugin>]
------
In the `type summary add` and `type synth add` class it would be even worse IMO, because we're now using the groups to enforce two mutually exclusive flags. `--regex` (`-x`) is currently accepted everywhere:
type summary add -c [-Oprvx] [-C <boolean>] [-w <name>] <name> [<name> [...]]
type summary add [-ehprvx] -s <summary-string> [-C <boolean>] [-w <name>] [-n <name>] <name> [<name> [...]]
type summary add [-Pehprvx] [-C <boolean>] [-w <name>] [-n <name>] [-F <python-function>] [-o <python-script>] <name> [<name> [...]]
so we need to double the number of groups. Half would have `-x` and the other half would have `-R`. But if we don't have a short flag, then we end up with something like this:
type summary add -c [-Oprvx] [-C <boolean>] [-w <name>] <name> [<name> [...]]
type summary add [-ehprvx] -s <summary-string> [-C <boolean>] [-w <name>] [-n <name>] <name> [<name> [...]]
type summary add [-Pehprvx] [-C <boolean>] [-w <name>] [-n <name>] [-F <python-function>] [-o <python-script>] <name> [<name> [...]]
type summary add -c [-Oprv] [-C <boolean>] [-w <name>] <name> [<name> [...]]
type summary add [-ehprv] -s <summary-string> [-C <boolean>] [-w <name>] [-n <name>] <name> [<name> [...]]
type summary add [-Pehprv] [-C <boolean>] [-w <name>] [-n <name>] [-F <python-function>] [-o <python-script>] <name> [<name> [...]]
... where the only visible difference between groups 1-3 and 4-6 is that they don't have the optional `-x`.
I think a reasonable compromise would be to remove the short `-R` flag, not use groups to enforce the mutual exclusion with `-x`, and have some ad-hoc error logic to alert the user if they specify both options at the same time. This way we don't have to duplicate the number of groups just for the sake of an option that will presumably be only very rarely used. I'll give that a try.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D137000/new/
https://reviews.llvm.org/D137000
More information about the lldb-commits
mailing list