[Lldb-commits] [PATCH] D83309: [lldb] tab completion for `target modules search-paths insert`
Raphael Isemann via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Tue Aug 11 02:58:36 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG24bc8afd4baf: [lldb] tab completion for `target modules search-paths insert` (authored by MrHate, committed by teemperor).
Herald added a subscriber: lldb-commits.
Changed prior to commit:
https://reviews.llvm.org/D83309?vs=276069&id=284627#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D83309/new/
https://reviews.llvm.org/D83309
Files:
lldb/source/Commands/CommandObjectTarget.cpp
lldb/test/API/functionalities/completion/TestCompletion.py
Index: lldb/test/API/functionalities/completion/TestCompletion.py
===================================================================
--- lldb/test/API/functionalities/completion/TestCompletion.py
+++ lldb/test/API/functionalities/completion/TestCompletion.py
@@ -368,6 +368,18 @@
self.complete_from_to('target modules load a.ou',
['a.out'])
+ def test_target_modules_search_paths_insert(self):
+ # Completion won't work without a valid target.
+ self.complete_from_to("target modules search-paths insert ", "target modules search-paths insert ")
+ self.build()
+ target = self.dbg.CreateTarget(self.getBuildArtifact('a.out'))
+ self.assertTrue(target, VALID_TARGET)
+ self.complete_from_to("target modules search-paths insert ", "target modules search-paths insert ")
+ self.runCmd("target modules search-paths add a b")
+ self.complete_from_to("target modules search-paths insert ", "target modules search-paths insert 0")
+ # Completion only works for the first arg.
+ self.complete_from_to("target modules search-paths insert 0 ", "target modules search-paths insert 0 ")
+
def test_target_create_dash_co(self):
"""Test that 'target create --co' completes to 'target variable --core '."""
self.complete_from_to('target create --co', 'target create --core ')
Index: lldb/source/Commands/CommandObjectTarget.cpp
===================================================================
--- lldb/source/Commands/CommandObjectTarget.cpp
+++ lldb/source/Commands/CommandObjectTarget.cpp
@@ -1157,6 +1157,25 @@
~CommandObjectTargetModulesSearchPathsInsert() override = default;
+ void
+ HandleArgumentCompletion(CompletionRequest &request,
+ OptionElementVector &opt_element_vector) override {
+ if (!m_exe_ctx.HasTargetScope() || request.GetCursorIndex() != 0)
+ return;
+
+ Target *target = m_exe_ctx.GetTargetPtr();
+ const PathMappingList &list = target->GetImageSearchPathList();
+ const size_t num = list.GetSize();
+ ConstString old_path, new_path;
+ for (size_t i = 0; i < num; ++i) {
+ if (!list.GetPathsAtIndex(i, old_path, new_path))
+ break;
+ StreamString strm;
+ strm << old_path << " -> " << new_path;
+ request.TryCompleteCurrentArg(std::to_string(i), strm.GetString());
+ }
+ }
+
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
Target *target = &GetSelectedTarget();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83309.284627.patch
Type: text/x-patch
Size: 2545 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200811/7e8cd411/attachment.bin>
More information about the lldb-commits
mailing list