From e1cd7cac8a36608616d515b64d12f2e86643970d Mon Sep 17 00:00:00 2001 From: Gongyu Deng Date: Fri, 21 Aug 2020 09:57:18 +0200 Subject: [lldb] Tab completion for process load/unload 1. Complete `process load` with the common disk file completion, so there is not test provided for it; 2. Complete `process unload` with the tokens of valid loaded images. Thanks for Raphael's help on the test for `process unload`. Reviewed By: teemperor Differential Revision: https://reviews.llvm.org/D79887 --- lldb/source/Commands/CommandObjectProcess.cpp | 29 +++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'lldb/source/Commands/CommandObjectProcess.cpp') diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp index a5df62f23345..25fe2e4b8b1a 100644 --- a/lldb/source/Commands/CommandObjectProcess.cpp +++ b/lldb/source/Commands/CommandObjectProcess.cpp @@ -923,6 +923,17 @@ public: ~CommandObjectProcessLoad() override = default; + void + HandleArgumentCompletion(CompletionRequest &request, + OptionElementVector &opt_element_vector) override { + if (!m_exe_ctx.HasProcessScope()) + return; + + CommandCompletions::InvokeCommonCompletionCallbacks( + GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion, + request, nullptr); + } + Options *GetOptions() override { return &m_options; } protected: @@ -988,6 +999,24 @@ public: ~CommandObjectProcessUnload() override = default; + void + HandleArgumentCompletion(CompletionRequest &request, + OptionElementVector &opt_element_vector) override { + + if (request.GetCursorIndex() || !m_exe_ctx.HasProcessScope()) + return; + + Process *process = m_exe_ctx.GetProcessPtr(); + + const std::vector &tokens = process->GetImageTokens(); + const size_t token_num = tokens.size(); + for (size_t i = 0; i < token_num; ++i) { + if (tokens[i] == LLDB_INVALID_IMAGE_TOKEN) + continue; + request.TryCompleteCurrentArg(std::to_string(i)); + } + } + protected: bool DoExecute(Args &command, CommandReturnObject &result) override { Process *process = m_exe_ctx.GetProcessPtr(); -- cgit v1.2.3