forked from OSchip/llvm-project
[lldb] move the frame index completion into a common completion and apply it to `thread backtrace -s`
Commands frame select and thread backtrace -s can be completed in the same way. Moved the dedicated completion of frame select into a common completion and apply it to the both commands, along with the test modified.
This commit is contained in:
parent
ef0c0844fe
commit
66fa73fa27
|
@ -39,10 +39,11 @@ public:
|
|||
eProcessPluginCompletion = (1u << 11),
|
||||
eDisassemblyFlavorCompletion = (1u << 12),
|
||||
eTypeLanguageCompletion = (1u << 13),
|
||||
eFrameIndexCompletion = (1u << 14),
|
||||
// This item serves two purposes. It is the last element in the enum, so
|
||||
// you can add custom enums starting from here in your Option class. Also
|
||||
// if you & in this bit the base code will not process the option.
|
||||
eCustomCompletion = (1u << 14)
|
||||
eCustomCompletion = (1u << 15)
|
||||
};
|
||||
|
||||
static bool InvokeCommonCompletionCallbacks(
|
||||
|
@ -103,6 +104,9 @@ public:
|
|||
|
||||
static void TypeLanguages(CommandInterpreter &interpreter,
|
||||
CompletionRequest &request, SearchFilter *searcher);
|
||||
|
||||
static void FrameIndexes(CommandInterpreter &interpreter,
|
||||
CompletionRequest &request, SearchFilter *searcher);
|
||||
};
|
||||
|
||||
} // namespace lldb_private
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "lldb/Symbol/Variable.h"
|
||||
#include "lldb/Target/Language.h"
|
||||
#include "lldb/Target/RegisterContext.h"
|
||||
#include "lldb/Target/Thread.h"
|
||||
#include "lldb/Utility/FileSpec.h"
|
||||
#include "lldb/Utility/StreamString.h"
|
||||
#include "lldb/Utility/TildeExpressionResolver.h"
|
||||
|
@ -62,6 +63,7 @@ bool CommandCompletions::InvokeCommonCompletionCallbacks(
|
|||
{eProcessPluginCompletion, CommandCompletions::ProcessPluginNames},
|
||||
{eDisassemblyFlavorCompletion, CommandCompletions::DisassemblyFlavors},
|
||||
{eTypeLanguageCompletion, CommandCompletions::TypeLanguages},
|
||||
{eFrameIndexCompletion, CommandCompletions::FrameIndexes},
|
||||
{eNoCompletion, nullptr} // This one has to be last in the list.
|
||||
};
|
||||
|
||||
|
@ -618,3 +620,20 @@ void CommandCompletions::TypeLanguages(CommandInterpreter &interpreter,
|
|||
Language::GetNameForLanguageType(static_cast<lldb::LanguageType>(bit)));
|
||||
}
|
||||
}
|
||||
|
||||
void CommandCompletions::FrameIndexes(CommandInterpreter &interpreter,
|
||||
CompletionRequest &request,
|
||||
SearchFilter *searcher) {
|
||||
const ExecutionContext &exe_ctx = interpreter.GetExecutionContext();
|
||||
if (!exe_ctx.HasProcessScope())
|
||||
return;
|
||||
|
||||
lldb::ThreadSP thread_sp = exe_ctx.GetThreadSP();
|
||||
const uint32_t frame_num = thread_sp->GetStackFrameCount();
|
||||
for (uint32_t i = 0; i < frame_num; ++i) {
|
||||
lldb::StackFrameSP frame_sp = thread_sp->GetStackFrameAtIndex(i);
|
||||
StreamString strm;
|
||||
frame_sp->Dump(&strm, false, true);
|
||||
request.TryCompleteCurrentArg(std::to_string(i), strm.GetString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -291,17 +291,12 @@ public:
|
|||
void
|
||||
HandleArgumentCompletion(CompletionRequest &request,
|
||||
OptionElementVector &opt_element_vector) override {
|
||||
if (!m_exe_ctx.HasProcessScope() || request.GetCursorIndex() != 0)
|
||||
if (request.GetCursorIndex() != 0)
|
||||
return;
|
||||
|
||||
lldb::ThreadSP thread_sp = m_exe_ctx.GetThreadSP();
|
||||
const uint32_t frame_num = thread_sp->GetStackFrameCount();
|
||||
for (uint32_t i = 0; i < frame_num; ++i) {
|
||||
lldb::StackFrameSP frame_sp = thread_sp->GetStackFrameAtIndex(i);
|
||||
StreamString strm;
|
||||
frame_sp->Dump(&strm, false, true);
|
||||
request.TryCompleteCurrentArg(std::to_string(i), strm.GetString());
|
||||
}
|
||||
CommandCompletions::InvokeCommonCompletionCallbacks(
|
||||
GetCommandInterpreter(), CommandCompletions::eFrameIndexCompletion,
|
||||
request, nullptr);
|
||||
}
|
||||
|
||||
Options *GetOptions() override { return &m_options; }
|
||||
|
|
|
@ -1055,7 +1055,7 @@ CommandObject::ArgumentTableEntry CommandObject::g_arguments_data[] = {
|
|||
{ eArgTypeExprFormat, "expression-format", CommandCompletions::eNoCompletion, { nullptr, false }, "[ [bool|b] | [bin] | [char|c] | [oct|o] | [dec|i|d|u] | [hex|x] | [float|f] | [cstr|s] ]" },
|
||||
{ eArgTypeFilename, "filename", CommandCompletions::eDiskFileCompletion, { nullptr, false }, "The name of a file (can include path)." },
|
||||
{ eArgTypeFormat, "format", CommandCompletions::eNoCompletion, { FormatHelpTextCallback, true }, nullptr },
|
||||
{ eArgTypeFrameIndex, "frame-index", CommandCompletions::eNoCompletion, { nullptr, false }, "Index into a thread's list of frames." },
|
||||
{ eArgTypeFrameIndex, "frame-index", CommandCompletions::eFrameIndexCompletion, { nullptr, false }, "Index into a thread's list of frames." },
|
||||
{ eArgTypeFullName, "fullname", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." },
|
||||
{ eArgTypeFunctionName, "function-name", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a function." },
|
||||
{ eArgTypeFunctionOrSymbol, "function-or-symbol", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a function or symbol." },
|
||||
|
|
|
@ -460,12 +460,12 @@ class CommandLineCompletionTestCase(TestBase):
|
|||
self.check_completion_with_desc("breakpoint set --Z", [
|
||||
])
|
||||
|
||||
def test_frame_select(self):
|
||||
def test_common_completion_frame_index(self):
|
||||
self.build()
|
||||
self.main_source_spec = lldb.SBFileSpec("main.cpp")
|
||||
lldbutil.run_to_source_breakpoint(self, '// Break here', self.main_source_spec)
|
||||
lldbutil.run_to_source_breakpoint(self, '// Break here', lldb.SBFileSpec("main.cpp"))
|
||||
|
||||
self.complete_from_to('frame select ', ['0'])
|
||||
self.complete_from_to('thread backtrace -s ', ['0'])
|
||||
|
||||
def test_frame_recognizer_delete(self):
|
||||
self.runCmd("frame recognizer add -l py_class -s module_name -n recognizer_name")
|
||||
|
|
Loading…
Reference in New Issue