[Lldb-commits] [lldb] 0780034 - [lldb] Fix that `process signal` completion always returns all signals

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Thu Jul 22 04:51:46 PDT 2021


Author: Raphael Isemann
Date: 2021-07-22T13:51:21+02:00
New Revision: 078003482e90ff5c7ba047a3d3152f0b0c392b31

URL: https://github.com/llvm/llvm-project/commit/078003482e90ff5c7ba047a3d3152f0b0c392b31
DIFF: https://github.com/llvm/llvm-project/commit/078003482e90ff5c7ba047a3d3152f0b0c392b31.diff

LOG: [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

Added: 
    

Modified: 
    lldb/source/Commands/CommandObjectProcess.cpp
    lldb/test/API/functionalities/completion/TestCompletion.py

Removed: 
    


################################################################################
diff  --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp
index 00fb4d669f499..7aaba37315000 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -1043,7 +1043,7 @@ class CommandObjectProcessSignal : public CommandObjectParsed {
     UnixSignalsSP signals = m_exe_ctx.GetProcessPtr()->GetUnixSignals();
     int signo = signals->GetFirstSignalNumber();
     while (signo != LLDB_INVALID_SIGNAL_NUMBER) {
-      request.AddCompletion(signals->GetSignalAsCString(signo), "");
+      request.TryCompleteCurrentArg(signals->GetSignalAsCString(signo));
       signo = signals->GetNextSignalNumber(signo);
     }
   }

diff  --git a/lldb/test/API/functionalities/completion/TestCompletion.py b/lldb/test/API/functionalities/completion/TestCompletion.py
index 7e4612ec41e6e..6a52d540184be 100644
--- a/lldb/test/API/functionalities/completion/TestCompletion.py
+++ b/lldb/test/API/functionalities/completion/TestCompletion.py
@@ -164,6 +164,8 @@ def test_process_signal(self):
 
         self.complete_from_to('process signal ',
                               'process signal SIG')
+        self.complete_from_to('process signal SIGIN',
+                              'process signal SIGINT')
         self.complete_from_to('process signal SIGA',
                               ['SIGABRT',
                                'SIGALRM'])


        


More information about the lldb-commits mailing list