[lldb] Fix that `process signal` completion always returns all signals
authorRaphael Isemann <teemperor@gmail.com>
Thu, 22 Jul 2021 11:37:34 +0000 (13:37 +0200)
committerRaphael Isemann <teemperor@gmail.com>
Thu, 22 Jul 2021 11:51:21 +0000 (13:51 +0200)
commit078003482e90ff5c7ba047a3d3152f0b0c392b31
treeac760eba38ab26c75190e268750628655c390a67
parent5a4de84d55faa5502de38b4f7ec6c6ed43d90043
[lldb] Fix that `process signal` completion always returns all signals

`CompletionRequest::AddCompletion` adds the given string as completion of the
current command token. `CompletionRequest::TryCompleteCurrentArg` only adds it
if the current token is a prefix of the given string. We're using
`AddCompletion` for the `process signal` handler which means that `process
signal SIGIN` doesn't get uniquely completed to `process signal SIGINT` as we
unconditionally add all other signals (such as `SIGABRT`) as possible
completions.

By using `TryCompleteCurrentArg` we actually do the proper filtering which will
only add `SIGINT` (as that's the only signal with the prefix 'SIGIN' in the
example above).

Reviewed By: mib

Differential Revision: https://reviews.llvm.org/D105028
lldb/source/Commands/CommandObjectProcess.cpp
lldb/test/API/functionalities/completion/TestCompletion.py