llvm-project/lldb/source/Commands
Pavel Labath 5f56fca4e1 Move option parsing out of the Args class
Summary:
The args class is used in plenty of places (a lot of them in the lower lldb
layers) for representing a list of arguments, and most of these places don't
care about option parsing. Moving the option parsing out of the class removes
the largest external dependency (there are a couple more, but these are in
static functions), and brings us closer to being able to move it to the
Utility module).

The new home for these functions is the Options class, which was already used
as an argument to the parse calls, so this just inverts the dependency between
the two.

The functions are themselves are mainly just copied -- the biggest functional
change I've made to them is to avoid modifying the input Args argument (getopt
likes to permute the argument vector), as it was weird to have another class
reorder the entries in Args class. So now the functions don't modify the input
arguments, and (for those where it makes sense) return a new Args vector
instead. I've also made the addition of a "fake arg0" (required for getopt
compatibility) an implementation detail rather than a part of interface.

While doing that I noticed that ParseForCompletion function was recording the
option indexes in the shuffled vector, but then the consumer was looking up the
entries in the unshuffled one. This manifested itself as us not being able to
complete "watchpoint set variable foo --" (because getopt would move "foo" to
the end). Surprisingly all other completions (e.g. "watchpoint set variable foo
--w") were not affected by this. However, I couldn't find a comprehensive test
for command argument completion, so I consolidated the existing tests and added
a bunch of new ones.

Reviewers: davide, jingham, zturner

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D43837

llvm-svn: 327110
2018-03-09 10:39:40 +00:00
..
CMakeLists.txt [cmake] add missing dependency lldbCommands->lldbBase 2017-02-09 01:17:34 +00:00
CommandCompletions.cpp Delete some unused #includes of CleanUp.h, NFC 2018-02-23 00:29:40 +00:00
CommandObjectApropos.cpp Add methods to enable using formatv syntax in LLDB. 2016-12-16 04:27:00 +00:00
CommandObjectApropos.h *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
CommandObjectArgs.cpp Rename Error -> Status. 2017-05-12 04:51:55 +00:00
CommandObjectArgs.h Rename Error -> Status. 2017-05-12 04:51:55 +00:00
CommandObjectBreakpoint.cpp Wire up the breakpoint name help string. 2017-09-15 00:52:35 +00:00
CommandObjectBreakpoint.h Make breakpoint names real entities. 2017-09-14 20:22:49 +00:00
CommandObjectBreakpointCommand.cpp Make breakpoint names real entities. 2017-09-14 20:22:49 +00:00
CommandObjectBreakpointCommand.h *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
CommandObjectBugreport.cpp Rename Error -> Status. 2017-05-12 04:51:55 +00:00
CommandObjectBugreport.h *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
CommandObjectCommands.cpp Rename Error -> Status. 2017-05-12 04:51:55 +00:00
CommandObjectCommands.h *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
CommandObjectDisassemble.cpp Invert ArchSpec<->Platform dependency 2017-10-31 10:56:03 +00:00
CommandObjectDisassemble.h Move ArchSpec to the Utility module 2017-11-13 16:16:33 +00:00
CommandObjectExpression.cpp Add help text for "expression" telling how to enter multi-line mode. 2017-07-19 23:25:42 +00:00
CommandObjectExpression.h Rename Error -> Status. 2017-05-12 04:51:55 +00:00
CommandObjectFrame.cpp Move Timer and TraceOptions from Core to Utility 2017-06-29 14:32:17 +00:00
CommandObjectFrame.h Move ArchSpec to the Utility module 2017-11-13 16:16:33 +00:00
CommandObjectGUI.cpp *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
CommandObjectGUI.h *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
CommandObjectHelp.cpp Modernize the Args access pattern in a few more commands. 2016-12-09 01:08:29 +00:00
CommandObjectHelp.h Rename Error -> Status. 2017-05-12 04:51:55 +00:00
CommandObjectLanguage.cpp *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
CommandObjectLanguage.h *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
CommandObjectLog.cpp Move Timer and TraceOptions from Core to Utility 2017-06-29 14:32:17 +00:00
CommandObjectLog.h *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
CommandObjectMemory.cpp Rename Error -> Status. 2017-05-12 04:51:55 +00:00
CommandObjectMemory.h *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
CommandObjectMultiword.cpp Remove some more uses of Args::GetArgumentAtIndex. 2016-12-09 05:46:41 +00:00
CommandObjectPlatform.cpp Invert ArchSpec<->Platform dependency 2017-10-31 10:56:03 +00:00
CommandObjectPlatform.h *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
CommandObjectPlugin.cpp Rename Error -> Status. 2017-05-12 04:51:55 +00:00
CommandObjectPlugin.h *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
CommandObjectProcess.cpp Add Utility/Environment class for handling... environments 2018-01-10 11:57:31 +00:00
CommandObjectProcess.h *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
CommandObjectQuit.cpp Don't allow direct access to StreamString's internal buffer. 2016-11-16 21:15:24 +00:00
CommandObjectQuit.h *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
CommandObjectRegister.cpp replace uses of strerror with llvm::sys::StrError 2017-06-06 14:06:17 +00:00
CommandObjectRegister.h *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
CommandObjectSettings.cpp Move option parsing out of the Args class 2018-03-09 10:39:40 +00:00
CommandObjectSettings.h *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
CommandObjectSource.cpp "source list -a" was calling DisplaySourceLinesWithNumbers incorrectly. 2017-11-17 01:19:59 +00:00
CommandObjectSource.h *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
CommandObjectSyntax.cpp Remove some more uses of Args::GetArgumentAtIndex. 2016-12-09 05:46:41 +00:00
CommandObjectSyntax.h *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
CommandObjectTarget.cpp Remove custom TimePoint-formatting code 2017-11-27 17:06:42 +00:00
CommandObjectTarget.h Move ArchSpec to the Utility module 2017-11-13 16:16:33 +00:00
CommandObjectThread.cpp Re-land r313210 - Fix for bug 34532 - A few rough corners related to post-mortem debugging (core/minidump) 2017-09-19 18:07:33 +00:00
CommandObjectThread.h *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
CommandObjectType.cpp Rename Error -> Status. 2017-05-12 04:51:55 +00:00
CommandObjectType.h *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
CommandObjectVersion.cpp *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
CommandObjectVersion.h *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
CommandObjectWatchpoint.cpp Rename Error -> Status. 2017-05-12 04:51:55 +00:00
CommandObjectWatchpoint.h *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
CommandObjectWatchpointCommand.cpp Rename Error -> Status. 2017-05-12 04:51:55 +00:00
CommandObjectWatchpointCommand.h *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00