This is an archive of the discontinued LLVM Phabricator instance.

Remove the "help" subcommand - its undocumented, undiscoverable and doesn't work....
ClosedPublic

Authored by jingham on Jan 18 2023, 5:56 PM.

Details

Summary

For some reason (lost in the mists of time) CommandObjectMultiword will check to see if you've passed it an argument with the text value "help" and if it sees that, it will print help.

That's not how the lldb help system works, and this is nowhere documented. It's not terribly discoverable, and doesn't behave like the rest of the lldb command system - doesn't auto-complete, doesn't do shortest unique match, etc... It also doesn't work for anything but the first level in the hierarchy:

(lldb) break help 
Commands for operating on breakpoints (see 'help b' for shorthand.)

Syntax: breakpoint <subcommand> [<command-options>]
...

But:

(lldb) break set help
error: invalid combination of options for the given command

It is also confusing if you happen across it because then you think that's the way the help system works which it isn't.

Diff Detail

Event Timeline

jingham created this revision.Jan 18 2023, 5:56 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 18 2023, 5:56 PM
jingham requested review of this revision.Jan 18 2023, 5:56 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 18 2023, 5:56 PM
JDevlieghere accepted this revision.Jan 19 2023, 8:31 AM

+1 to everything Jim said in the commit message. LGTM.

This revision is now accepted and ready to land.Jan 19 2023, 8:31 AM

Yeah this is a good cleanup, but fwiw maybe because using git, but I sometimes expect break set --help etc to work, forgetting which style lldb uses. just throwing it out there as something I get tripped up by once in a while, not really related to this change, but I can appreciate where the original author thought they were going with it.

jingham added a comment.EditedJan 19 2023, 11:43 AM

I wouldn't be opposed to adding a --help option (with no short option) that every command would inherit. Implementing help through a command option/argument alone can't suffice for lldb, since that offers no way to list all the commands. git gets around this because you can say git on the command line to get all the available commands. If we're doing the command help through an option, there isn't a really natural way to do "show me all commands". For pedantic consistency, you could have:

(lldb) --help

do that, but that's pretty gross.

Otherwise you really have to have a help command and once you have that it's a little weird to use help to get the list of commands but then not to get help on individual commands. So --help as an option becomes a little redundant. OTOH, you could do some fun stuff with it like:

(lldb) break set --help

would give help on break set, but

(lldb) break set --help -f

would just show the help string for the -f option... So as an add-on I don't mind that, and being an option would keep if from messing with the parsing of everything. Using the bare word help more widely is bound to cause collisions...

This revision was automatically updated to reflect the committed changes.