[Lldb-commits] [PATCH] D128453: Automate checking for "command that takes no arguments" being passed arguments in CommandObjectParsed

Jim Ingham via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Jun 23 10:08:43 PDT 2022


jingham created this revision.
jingham added reviewers: JDevlieghere, clayborg, kastiglione, ADodds.
Herald added a project: All.
jingham requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

At present, if a command takes no arguments, it's required to check by hand that it hasn't been passed an argument.  That's  error-prone and unnecessary, since CommandObject has a way for sub-classes to register what arguments it takes, and that could be checked directly after the command line parse.  I only do this for CommandObjectParsed.  There isn't enough information to do a generic check for CommandObjectRaw, since these are explicitly unstructured commands.

This patch has four parts:

1. The tiny bit of code in CommandObjectParsed::Execute that does the check
2. Fixing up the handful of commands that hadn't registered their arguments (up to now this was not required)

These were pretty straightforward.  I did have to fix up a bunch of the RenderScript commands.  I don't know
who's responsible for the Renderscript plugin these days, so I picked one of the more recent contributors to
that file at random...

3. Removing all the ad hoc checks for arguments passed to commands that don't take them
4. Fixing up the tests that relied on the exact wording of the ad hoc errors

We can do a lot more with the argument info - automating completions and validation of arguments for commands that do take them.  But here I'm only dealing with the automatic error generation for commands that take no arguments.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128453

Files:
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/API/SBCommandInterpreter.cpp
  lldb/source/Commands/CommandObjectCommands.cpp
  lldb/source/Commands/CommandObjectFrame.cpp
  lldb/source/Commands/CommandObjectGUI.cpp
  lldb/source/Commands/CommandObjectPlatform.cpp
  lldb/source/Commands/CommandObjectProcess.cpp
  lldb/source/Commands/CommandObjectQuit.cpp
  lldb/source/Commands/CommandObjectReproducer.cpp
  lldb/source/Commands/CommandObjectSource.cpp
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/source/Commands/CommandObjectThreadUtil.cpp
  lldb/source/Commands/CommandObjectTrace.cpp
  lldb/source/Commands/CommandObjectType.cpp
  lldb/source/Commands/CommandObjectVersion.cpp
  lldb/source/Interpreter/CommandObject.cpp
  lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
  lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptScriptGroup.cpp
  lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/test/API/commands/gui/invalid-args/TestInvalidArgsGui.py
  lldb/test/API/commands/reproducer/invalid-args/TestInvalidArgsReproducer.py
  lldb/test/API/commands/target/basic/TestTargetCommand.py
  lldb/test/API/commands/target/dump/TestTargetDumpTypeSystem.py
  lldb/test/API/commands/version/TestVersion.py
  lldb/test/API/commands/watchpoints/multi_watchpoint_slots/TestWatchpointMultipleSlots.py
  lldb/test/API/functionalities/completion/TestCompletion.py

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128453.439443.patch
Type: text/x-patch
Size: 56165 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220623/b38e29e5/attachment-0001.bin>


More information about the lldb-commits mailing list