aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandCompletions.cpp
diff options
context:
space:
mode:
authorGongyu Deng <gy_deng@icloud.com>2020-08-11 13:19:27 +0200
committerRaphael Isemann <teemperor@gmail.com>2020-08-11 13:27:13 +0200
commita952fe236f993b531eceb89e0a18d25bba048185 (patch)
tree6e4a5841a1939f4663bc360a65d72fd2af35122b /lldb/source/Commands/CommandCompletions.cpp
parentbd1013a4825bf2cf58b3c75320f64b24b244f343 (diff)
downloadllvm-a952fe236f993b531eceb89e0a18d25bba048185.zip
llvm-a952fe236f993b531eceb89e0a18d25bba048185.tar.gz
llvm-a952fe236f993b531eceb89e0a18d25bba048185.tar.bz2
[lldb] thread index common completion for commands like `thread select/step-over`
1. Added a common completion completing with a list of the threads of the current process; 2. Apply the common completion above to these commands: thread continue/info/exception/select/step-in/step-inst/step-inst-over/step-out/step-over/step-script​ 3. Correlated test case test_common_completion_thread_index. Reviewed By: teemperor Differential Revision: https://reviews.llvm.org/D84088
Diffstat (limited to 'lldb/source/Commands/CommandCompletions.cpp')
-rw-r--r--lldb/source/Commands/CommandCompletions.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/lldb/source/Commands/CommandCompletions.cpp b/lldb/source/Commands/CommandCompletions.cpp
index de0e07e..526efe3 100644
--- a/lldb/source/Commands/CommandCompletions.cpp
+++ b/lldb/source/Commands/CommandCompletions.cpp
@@ -19,6 +19,7 @@
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/Variable.h"
#include "lldb/Target/Language.h"
+#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/Thread.h"
#include "lldb/Utility/FileSpec.h"
@@ -66,6 +67,7 @@ bool CommandCompletions::InvokeCommonCompletionCallbacks(
{eTypeLanguageCompletion, CommandCompletions::TypeLanguages},
{eFrameIndexCompletion, CommandCompletions::FrameIndexes},
{eStopHookIDCompletion, CommandCompletions::StopHookIDs},
+ {eThreadIndexCompletion, CommandCompletions::ThreadIndexes},
{eNoCompletion, nullptr} // This one has to be last in the list.
};
@@ -678,3 +680,20 @@ void CommandCompletions::StopHookIDs(CommandInterpreter &interpreter,
strm.GetString());
}
}
+
+void CommandCompletions::ThreadIndexes(CommandInterpreter &interpreter,
+ CompletionRequest &request,
+ SearchFilter *searcher) {
+ const ExecutionContext &exe_ctx = interpreter.GetExecutionContext();
+ if (!exe_ctx.HasProcessScope())
+ return;
+
+ ThreadList &threads = exe_ctx.GetProcessPtr()->GetThreadList();
+ lldb::ThreadSP thread_sp;
+ for (uint32_t idx = 0; (thread_sp = threads.GetThreadAtIndex(idx)); ++idx) {
+ StreamString strm;
+ thread_sp->GetStatus(strm, 0, 1, 1, true);
+ request.TryCompleteCurrentArg(std::to_string(thread_sp->GetIndexID()),
+ strm.GetString());
+ }
+}