[lldb][NFC] Fix all formatting errors in .cpp file headers
Summary:
A *.cpp file header in LLDB (and in LLDB) should like this:
```
//===-- TestUtilities.cpp -------------------------------------------------===//
```
However in LLDB most of our source files have arbitrary changes to this format and
these changes are spreading through LLDB as folks usually just use the existing
source files as templates for their new files (most notably the unnecessary
editor language indicator `-*- C++ -*-` is spreading and in every review
someone is pointing out that this is wrong, resulting in people pointing out that this
is done in the same way in other files).
This patch removes most of these inconsistencies including the editor language indicators,
all the different missing/additional '-' characters, files that center the file name, missing
trailing `===//` (mostly caused by clang-format breaking the line).
Reviewers: aprantl, espindola, jfb, shafik, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: dexonsmith, wuzish, emaste, sdardis, nemanjai, kbarton, MaskRay, atanasyan, arphaman, jfb, abidh, jsji, JDevlieghere, usaxena95, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D73258
2020-01-24 15:23:27 +08:00
|
|
|
//===-- CommandCompletions.cpp --------------------------------------------===//
|
2010-06-09 00:52:24 +08:00
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2010-06-09 00:52:24 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2016-02-20 03:33:46 +08:00
|
|
|
#include "llvm/ADT/SmallString.h"
|
2017-03-13 08:41:01 +08:00
|
|
|
#include "llvm/ADT/StringSet.h"
|
2016-02-20 03:33:46 +08:00
|
|
|
|
2011-02-01 13:15:22 +08:00
|
|
|
#include "lldb/Core/FileSpecList.h"
|
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-30 05:13:06 +08:00
|
|
|
#include "lldb/Core/Module.h"
|
2016-03-23 01:58:09 +08:00
|
|
|
#include "lldb/Core/PluginManager.h"
|
|
|
|
#include "lldb/Host/FileSystem.h"
|
2011-02-01 13:15:22 +08:00
|
|
|
#include "lldb/Interpreter/CommandCompletions.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Interpreter/CommandInterpreter.h"
|
2015-03-04 09:58:01 +08:00
|
|
|
#include "lldb/Interpreter/OptionValueProperties.h"
|
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-30 05:13:06 +08:00
|
|
|
#include "lldb/Symbol/CompileUnit.h"
|
2013-05-15 07:43:18 +08:00
|
|
|
#include "lldb/Symbol/Variable.h"
|
2020-08-11 16:32:55 +08:00
|
|
|
#include "lldb/Target/Language.h"
|
2020-05-08 00:12:39 +08:00
|
|
|
#include "lldb/Target/RegisterContext.h"
|
2020-08-11 18:20:43 +08:00
|
|
|
#include "lldb/Target/Thread.h"
|
2017-03-23 02:40:07 +08:00
|
|
|
#include "lldb/Utility/FileSpec.h"
|
2017-04-07 05:28:29 +08:00
|
|
|
#include "lldb/Utility/StreamString.h"
|
2017-03-13 08:41:01 +08:00
|
|
|
#include "lldb/Utility/TildeExpressionResolver.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2017-03-09 01:56:08 +08:00
|
|
|
#include "llvm/Support/FileSystem.h"
|
2017-03-13 08:41:01 +08:00
|
|
|
#include "llvm/Support/Path.h"
|
2016-03-23 01:58:09 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
using namespace lldb_private;
|
|
|
|
|
2020-02-12 16:22:59 +08:00
|
|
|
// This is the command completion callback that is used to complete the
|
|
|
|
// argument of the option it is bound to (in the OptionDefinition table
|
|
|
|
// below).
|
|
|
|
typedef void (*CompletionCallback)(CommandInterpreter &interpreter,
|
|
|
|
CompletionRequest &request,
|
|
|
|
// A search filter to limit the search...
|
|
|
|
lldb_private::SearchFilter *searcher);
|
|
|
|
|
|
|
|
struct CommonCompletionElement {
|
|
|
|
uint32_t type;
|
|
|
|
CompletionCallback callback;
|
2010-06-09 00:52:24 +08:00
|
|
|
};
|
|
|
|
|
2016-02-20 03:33:46 +08:00
|
|
|
bool CommandCompletions::InvokeCommonCompletionCallbacks(
|
|
|
|
CommandInterpreter &interpreter, uint32_t completion_mask,
|
2018-07-14 02:28:14 +08:00
|
|
|
CompletionRequest &request, SearchFilter *searcher) {
|
2010-06-09 00:52:24 +08:00
|
|
|
bool handled = false;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2020-02-12 16:22:59 +08:00
|
|
|
const CommonCompletionElement common_completions[] = {
|
|
|
|
{eSourceFileCompletion, CommandCompletions::SourceFiles},
|
|
|
|
{eDiskFileCompletion, CommandCompletions::DiskFiles},
|
|
|
|
{eDiskDirectoryCompletion, CommandCompletions::DiskDirectories},
|
|
|
|
{eSymbolCompletion, CommandCompletions::Symbols},
|
|
|
|
{eModuleCompletion, CommandCompletions::Modules},
|
2020-08-11 18:29:25 +08:00
|
|
|
{eModuleUUIDCompletion, CommandCompletions::ModuleUUIDs},
|
2020-02-12 16:22:59 +08:00
|
|
|
{eSettingsNameCompletion, CommandCompletions::SettingsNames},
|
|
|
|
{ePlatformPluginCompletion, CommandCompletions::PlatformPluginNames},
|
|
|
|
{eArchitectureCompletion, CommandCompletions::ArchitectureNames},
|
|
|
|
{eVariablePathCompletion, CommandCompletions::VariablePath},
|
2020-05-08 00:12:39 +08:00
|
|
|
{eRegisterCompletion, CommandCompletions::Registers},
|
2020-05-11 21:21:37 +08:00
|
|
|
{eBreakpointCompletion, CommandCompletions::Breakpoints},
|
2020-05-27 20:06:28 +08:00
|
|
|
{eProcessPluginCompletion, CommandCompletions::ProcessPluginNames},
|
2020-08-11 15:59:30 +08:00
|
|
|
{eDisassemblyFlavorCompletion, CommandCompletions::DisassemblyFlavors},
|
2020-08-11 16:32:55 +08:00
|
|
|
{eTypeLanguageCompletion, CommandCompletions::TypeLanguages},
|
2020-08-11 18:20:43 +08:00
|
|
|
{eFrameIndexCompletion, CommandCompletions::FrameIndexes},
|
2020-08-11 19:13:49 +08:00
|
|
|
{eStopHookIDCompletion, CommandCompletions::StopHookIDs},
|
2020-02-12 16:22:59 +08:00
|
|
|
{eNoCompletion, nullptr} // This one has to be last in the list.
|
|
|
|
};
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
for (int i = 0;; i++) {
|
2020-02-12 16:22:59 +08:00
|
|
|
if (common_completions[i].type == eNoCompletion)
|
2010-06-09 00:52:24 +08:00
|
|
|
break;
|
2020-02-12 16:22:59 +08:00
|
|
|
else if ((common_completions[i].type & completion_mask) ==
|
|
|
|
common_completions[i].type &&
|
|
|
|
common_completions[i].callback != nullptr) {
|
2010-06-09 00:52:24 +08:00
|
|
|
handled = true;
|
2020-02-12 16:22:59 +08:00
|
|
|
common_completions[i].callback(interpreter, request, searcher);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
return handled;
|
|
|
|
}
|
|
|
|
|
2020-02-12 15:56:03 +08:00
|
|
|
namespace {
|
|
|
|
// The Completer class is a convenient base class for building searchers that
|
|
|
|
// go along with the SearchFilter passed to the standard Completer functions.
|
|
|
|
class Completer : public Searcher {
|
|
|
|
public:
|
|
|
|
Completer(CommandInterpreter &interpreter, CompletionRequest &request)
|
|
|
|
: m_interpreter(interpreter), m_request(request) {}
|
|
|
|
|
|
|
|
~Completer() override = default;
|
|
|
|
|
|
|
|
CallbackReturn SearchCallback(SearchFilter &filter, SymbolContext &context,
|
|
|
|
Address *addr) override = 0;
|
|
|
|
|
|
|
|
lldb::SearchDepth GetDepth() override = 0;
|
|
|
|
|
|
|
|
virtual void DoCompletion(SearchFilter *filter) = 0;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
CommandInterpreter &m_interpreter;
|
|
|
|
CompletionRequest &m_request;
|
|
|
|
|
|
|
|
private:
|
[lldb] NFC remove DISALLOW_COPY_AND_ASSIGN
Summary:
This is how I applied my clang-tidy check (see
https://reviews.llvm.org/D80531) in order to remove
`DISALLOW_COPY_AND_ASSIGN` and have deleted copy ctors and deleted
assignment operators instead.
```
lang=bash
grep DISALLOW_COPY_AND_ASSIGN /opt/notnfs/kkleine/llvm/lldb -r -l | sort | uniq > files
for i in $(cat files);
do
clang-tidy \
--checks="-*,modernize-replace-disallow-copy-and-assign-macro" \
--format-style=LLVM \
--header-filter=.* \
--fix \
-fix-errors \
$i;
done
```
Reviewers: espindola, labath, aprantl, teemperor
Reviewed By: labath, aprantl, teemperor
Subscribers: teemperor, aprantl, labath, emaste, sbc100, aheejin, MaskRay, arphaman, usaxena95, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D80543
2020-06-03 00:19:55 +08:00
|
|
|
Completer(const Completer &) = delete;
|
|
|
|
const Completer &operator=(const Completer &) = delete;
|
2020-02-12 15:56:03 +08:00
|
|
|
};
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
// SourceFileCompleter implements the source file completer
|
|
|
|
namespace {
|
|
|
|
class SourceFileCompleter : public Completer {
|
|
|
|
public:
|
|
|
|
SourceFileCompleter(CommandInterpreter &interpreter,
|
|
|
|
CompletionRequest &request)
|
|
|
|
: Completer(interpreter, request), m_matching_files() {
|
|
|
|
FileSpec partial_spec(m_request.GetCursorArgumentPrefix());
|
|
|
|
m_file_name = partial_spec.GetFilename().GetCString();
|
|
|
|
m_dir_name = partial_spec.GetDirectory().GetCString();
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::SearchDepth GetDepth() override { return lldb::eSearchDepthCompUnit; }
|
|
|
|
|
|
|
|
Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
|
|
|
|
SymbolContext &context,
|
|
|
|
Address *addr) override {
|
|
|
|
if (context.comp_unit != nullptr) {
|
|
|
|
const char *cur_file_name =
|
|
|
|
context.comp_unit->GetPrimaryFile().GetFilename().GetCString();
|
|
|
|
const char *cur_dir_name =
|
|
|
|
context.comp_unit->GetPrimaryFile().GetDirectory().GetCString();
|
|
|
|
|
|
|
|
bool match = false;
|
|
|
|
if (m_file_name && cur_file_name &&
|
|
|
|
strstr(cur_file_name, m_file_name) == cur_file_name)
|
|
|
|
match = true;
|
|
|
|
|
|
|
|
if (match && m_dir_name && cur_dir_name &&
|
|
|
|
strstr(cur_dir_name, m_dir_name) != cur_dir_name)
|
|
|
|
match = false;
|
|
|
|
|
|
|
|
if (match) {
|
|
|
|
m_matching_files.AppendIfUnique(context.comp_unit->GetPrimaryFile());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Searcher::eCallbackReturnContinue;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DoCompletion(SearchFilter *filter) override {
|
|
|
|
filter->Search(*this);
|
|
|
|
// Now convert the filelist to completions:
|
|
|
|
for (size_t i = 0; i < m_matching_files.GetSize(); i++) {
|
|
|
|
m_request.AddCompletion(
|
|
|
|
m_matching_files.GetFileSpecAtIndex(i).GetFilename().GetCString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
FileSpecList m_matching_files;
|
|
|
|
const char *m_file_name;
|
|
|
|
const char *m_dir_name;
|
|
|
|
|
[lldb] NFC remove DISALLOW_COPY_AND_ASSIGN
Summary:
This is how I applied my clang-tidy check (see
https://reviews.llvm.org/D80531) in order to remove
`DISALLOW_COPY_AND_ASSIGN` and have deleted copy ctors and deleted
assignment operators instead.
```
lang=bash
grep DISALLOW_COPY_AND_ASSIGN /opt/notnfs/kkleine/llvm/lldb -r -l | sort | uniq > files
for i in $(cat files);
do
clang-tidy \
--checks="-*,modernize-replace-disallow-copy-and-assign-macro" \
--format-style=LLVM \
--header-filter=.* \
--fix \
-fix-errors \
$i;
done
```
Reviewers: espindola, labath, aprantl, teemperor
Reviewed By: labath, aprantl, teemperor
Subscribers: teemperor, aprantl, labath, emaste, sbc100, aheejin, MaskRay, arphaman, usaxena95, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D80543
2020-06-03 00:19:55 +08:00
|
|
|
SourceFileCompleter(const SourceFileCompleter &) = delete;
|
|
|
|
const SourceFileCompleter &operator=(const SourceFileCompleter &) = delete;
|
2020-02-12 15:56:03 +08:00
|
|
|
};
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
static bool regex_chars(const char comp) {
|
|
|
|
return llvm::StringRef("[](){}+.*|^$\\?").contains(comp);
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
class SymbolCompleter : public Completer {
|
|
|
|
|
|
|
|
public:
|
|
|
|
SymbolCompleter(CommandInterpreter &interpreter, CompletionRequest &request)
|
|
|
|
: Completer(interpreter, request) {
|
|
|
|
std::string regex_str;
|
|
|
|
if (!m_request.GetCursorArgumentPrefix().empty()) {
|
|
|
|
regex_str.append("^");
|
|
|
|
regex_str.append(std::string(m_request.GetCursorArgumentPrefix()));
|
|
|
|
} else {
|
|
|
|
// Match anything since the completion string is empty
|
|
|
|
regex_str.append(".");
|
|
|
|
}
|
|
|
|
std::string::iterator pos =
|
|
|
|
find_if(regex_str.begin() + 1, regex_str.end(), regex_chars);
|
|
|
|
while (pos < regex_str.end()) {
|
|
|
|
pos = regex_str.insert(pos, '\\');
|
|
|
|
pos = find_if(pos + 2, regex_str.end(), regex_chars);
|
|
|
|
}
|
|
|
|
m_regex = RegularExpression(regex_str);
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::SearchDepth GetDepth() override { return lldb::eSearchDepthModule; }
|
|
|
|
|
|
|
|
Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
|
|
|
|
SymbolContext &context,
|
|
|
|
Address *addr) override {
|
|
|
|
if (context.module_sp) {
|
|
|
|
SymbolContextList sc_list;
|
|
|
|
const bool include_symbols = true;
|
|
|
|
const bool include_inlines = true;
|
|
|
|
context.module_sp->FindFunctions(m_regex, include_symbols,
|
|
|
|
include_inlines, sc_list);
|
|
|
|
|
|
|
|
SymbolContext sc;
|
|
|
|
// Now add the functions & symbols to the list - only add if unique:
|
|
|
|
for (uint32_t i = 0; i < sc_list.GetSize(); i++) {
|
|
|
|
if (sc_list.GetContextAtIndex(i, sc)) {
|
|
|
|
ConstString func_name = sc.GetFunctionName(Mangled::ePreferDemangled);
|
|
|
|
// Ensure that the function name matches the regex. This is more than
|
|
|
|
// a sanity check. It is possible that the demangled function name
|
|
|
|
// does not start with the prefix, for example when it's in an
|
|
|
|
// anonymous namespace.
|
|
|
|
if (!func_name.IsEmpty() && m_regex.Execute(func_name.GetStringRef()))
|
|
|
|
m_match_set.insert(func_name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Searcher::eCallbackReturnContinue;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DoCompletion(SearchFilter *filter) override {
|
|
|
|
filter->Search(*this);
|
|
|
|
collection::iterator pos = m_match_set.begin(), end = m_match_set.end();
|
|
|
|
for (pos = m_match_set.begin(); pos != end; pos++)
|
|
|
|
m_request.AddCompletion((*pos).GetCString());
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
RegularExpression m_regex;
|
|
|
|
typedef std::set<ConstString> collection;
|
|
|
|
collection m_match_set;
|
|
|
|
|
[lldb] NFC remove DISALLOW_COPY_AND_ASSIGN
Summary:
This is how I applied my clang-tidy check (see
https://reviews.llvm.org/D80531) in order to remove
`DISALLOW_COPY_AND_ASSIGN` and have deleted copy ctors and deleted
assignment operators instead.
```
lang=bash
grep DISALLOW_COPY_AND_ASSIGN /opt/notnfs/kkleine/llvm/lldb -r -l | sort | uniq > files
for i in $(cat files);
do
clang-tidy \
--checks="-*,modernize-replace-disallow-copy-and-assign-macro" \
--format-style=LLVM \
--header-filter=.* \
--fix \
-fix-errors \
$i;
done
```
Reviewers: espindola, labath, aprantl, teemperor
Reviewed By: labath, aprantl, teemperor
Subscribers: teemperor, aprantl, labath, emaste, sbc100, aheejin, MaskRay, arphaman, usaxena95, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D80543
2020-06-03 00:19:55 +08:00
|
|
|
SymbolCompleter(const SymbolCompleter &) = delete;
|
|
|
|
const SymbolCompleter &operator=(const SymbolCompleter &) = delete;
|
2020-02-12 15:56:03 +08:00
|
|
|
};
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
class ModuleCompleter : public Completer {
|
|
|
|
public:
|
|
|
|
ModuleCompleter(CommandInterpreter &interpreter, CompletionRequest &request)
|
|
|
|
: Completer(interpreter, request) {
|
|
|
|
FileSpec partial_spec(m_request.GetCursorArgumentPrefix());
|
|
|
|
m_file_name = partial_spec.GetFilename().GetCString();
|
|
|
|
m_dir_name = partial_spec.GetDirectory().GetCString();
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::SearchDepth GetDepth() override { return lldb::eSearchDepthModule; }
|
|
|
|
|
|
|
|
Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
|
|
|
|
SymbolContext &context,
|
|
|
|
Address *addr) override {
|
|
|
|
if (context.module_sp) {
|
|
|
|
const char *cur_file_name =
|
|
|
|
context.module_sp->GetFileSpec().GetFilename().GetCString();
|
|
|
|
const char *cur_dir_name =
|
|
|
|
context.module_sp->GetFileSpec().GetDirectory().GetCString();
|
|
|
|
|
|
|
|
bool match = false;
|
|
|
|
if (m_file_name && cur_file_name &&
|
|
|
|
strstr(cur_file_name, m_file_name) == cur_file_name)
|
|
|
|
match = true;
|
|
|
|
|
|
|
|
if (match && m_dir_name && cur_dir_name &&
|
|
|
|
strstr(cur_dir_name, m_dir_name) != cur_dir_name)
|
|
|
|
match = false;
|
|
|
|
|
|
|
|
if (match) {
|
|
|
|
m_request.AddCompletion(cur_file_name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Searcher::eCallbackReturnContinue;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DoCompletion(SearchFilter *filter) override { filter->Search(*this); }
|
|
|
|
|
|
|
|
private:
|
|
|
|
const char *m_file_name;
|
|
|
|
const char *m_dir_name;
|
|
|
|
|
[lldb] NFC remove DISALLOW_COPY_AND_ASSIGN
Summary:
This is how I applied my clang-tidy check (see
https://reviews.llvm.org/D80531) in order to remove
`DISALLOW_COPY_AND_ASSIGN` and have deleted copy ctors and deleted
assignment operators instead.
```
lang=bash
grep DISALLOW_COPY_AND_ASSIGN /opt/notnfs/kkleine/llvm/lldb -r -l | sort | uniq > files
for i in $(cat files);
do
clang-tidy \
--checks="-*,modernize-replace-disallow-copy-and-assign-macro" \
--format-style=LLVM \
--header-filter=.* \
--fix \
-fix-errors \
$i;
done
```
Reviewers: espindola, labath, aprantl, teemperor
Reviewed By: labath, aprantl, teemperor
Subscribers: teemperor, aprantl, labath, emaste, sbc100, aheejin, MaskRay, arphaman, usaxena95, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D80543
2020-06-03 00:19:55 +08:00
|
|
|
ModuleCompleter(const ModuleCompleter &) = delete;
|
|
|
|
const ModuleCompleter &operator=(const ModuleCompleter &) = delete;
|
2020-02-12 15:56:03 +08:00
|
|
|
};
|
|
|
|
} // namespace
|
|
|
|
|
[lldb][NFC] Remove WordComplete mode, make result array indexed from 0 and remove any undocumented/redundant return values
Summary:
We still have some leftovers of the old completion API in the internals of
LLDB that haven't been replaced by the new CompletionRequest. These leftovers
are:
* The return values (int/size_t) in all completion functions.
* Our result array that starts indexing at 1.
* `WordComplete` mode.
I didn't replace them back then because it's tricky to figure out what exactly they
are used for and the completion code is relatively untested. I finally got around
to writing more tests for the API and understanding the semantics, so I think it's
a good time to get rid of them.
A few words why those things should be removed/replaced:
* The return values are really cryptic, partly redundant and rarely documented.
They are also completely ignored by Xcode, so whatever information they contain will end up
breaking Xcode's completion mechanism. They are also partly impossible to even implement
as we assign negative values special meaning and our completion API sometimes returns size_t.
Completion functions are supposed to return -2 to rewrite the current line. We seem to use this
in some untested code path to expand the history repeat character to the full command, but
I haven't figured out why that doesn't work at the moment.
Completion functions return -1 to 'insert the completion character', but that isn't implemented
(even though we seem to activate this feature in LLDB sometimes).
All positive values have to match the number of results. This is obviously just redundant information
as the user can just look at the result list to get that information (which is what Xcode does).
* The result array that starts indexing at 1 is obviously unexpected. The first element of the array is
reserved for the common prefix of all completions (e.g. "foobar" and "footar" -> "foo"). The idea is
that we calculate this to make the life of the API caller easier, but obviously forcing people to have
1-based indices is not helpful (or even worse, forces them to manually copy the results to make it
0-based like Xcode has to do).
* The `WordComplete` mode indicates that LLDB should enter a space behind the completion. The
idea is that we let the top-level API know that we just provided a full completion. Interestingly we
`WordComplete` is just a single bool that somehow represents all N completions. And we always
provide full completions in LLDB, so in theory it should always be true.
The only use it currently serves is providing redundant information about whether we have a single
definitive completion or not (which we already know from the number of results we get).
This patch essentially removes `WordComplete` mode and makes the result array indexed from 0.
It also removes all return values from all internal completion functions. The only non-redundant information
they contain is about rewriting the current line (which is broken), so that functionality was moved
to the CompletionRequest API. So you can now do `addCompletion("blub", "description", CompletionMode::RewriteLine)`
to do the same.
For the SB API we emulate the old behaviour by making the array indexed from 1 again with the common
prefix at index 0. I didn't keep the special negative return codes as we either never sent them before (e.g. -2) or we
didn't even implement them in the Editline handler (e.g. -1).
I tried to keep this patch minimal and I'm aware we can probably now even further simplify a bunch of related code,
but I would prefer doing this in follow-up NFC commits
Reviewers: JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arphaman, abidh, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D66536
llvm-svn: 369624
2019-08-22 15:41:23 +08:00
|
|
|
void CommandCompletions::SourceFiles(CommandInterpreter &interpreter,
|
|
|
|
CompletionRequest &request,
|
|
|
|
SearchFilter *searcher) {
|
2020-02-12 01:44:02 +08:00
|
|
|
SourceFileCompleter completer(interpreter, request);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2016-02-20 03:33:46 +08:00
|
|
|
if (searcher == nullptr) {
|
2010-08-27 05:32:51 +08:00
|
|
|
lldb::TargetSP target_sp = interpreter.GetDebugger().GetSelectedTarget();
|
2014-12-06 09:28:03 +08:00
|
|
|
SearchFilterForUnconstrainedSearches null_searcher(target_sp);
|
2010-06-09 00:52:24 +08:00
|
|
|
completer.DoCompletion(&null_searcher);
|
|
|
|
} else {
|
|
|
|
completer.DoCompletion(searcher);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
[lldb][NFC] Remove WordComplete mode, make result array indexed from 0 and remove any undocumented/redundant return values
Summary:
We still have some leftovers of the old completion API in the internals of
LLDB that haven't been replaced by the new CompletionRequest. These leftovers
are:
* The return values (int/size_t) in all completion functions.
* Our result array that starts indexing at 1.
* `WordComplete` mode.
I didn't replace them back then because it's tricky to figure out what exactly they
are used for and the completion code is relatively untested. I finally got around
to writing more tests for the API and understanding the semantics, so I think it's
a good time to get rid of them.
A few words why those things should be removed/replaced:
* The return values are really cryptic, partly redundant and rarely documented.
They are also completely ignored by Xcode, so whatever information they contain will end up
breaking Xcode's completion mechanism. They are also partly impossible to even implement
as we assign negative values special meaning and our completion API sometimes returns size_t.
Completion functions are supposed to return -2 to rewrite the current line. We seem to use this
in some untested code path to expand the history repeat character to the full command, but
I haven't figured out why that doesn't work at the moment.
Completion functions return -1 to 'insert the completion character', but that isn't implemented
(even though we seem to activate this feature in LLDB sometimes).
All positive values have to match the number of results. This is obviously just redundant information
as the user can just look at the result list to get that information (which is what Xcode does).
* The result array that starts indexing at 1 is obviously unexpected. The first element of the array is
reserved for the common prefix of all completions (e.g. "foobar" and "footar" -> "foo"). The idea is
that we calculate this to make the life of the API caller easier, but obviously forcing people to have
1-based indices is not helpful (or even worse, forces them to manually copy the results to make it
0-based like Xcode has to do).
* The `WordComplete` mode indicates that LLDB should enter a space behind the completion. The
idea is that we let the top-level API know that we just provided a full completion. Interestingly we
`WordComplete` is just a single bool that somehow represents all N completions. And we always
provide full completions in LLDB, so in theory it should always be true.
The only use it currently serves is providing redundant information about whether we have a single
definitive completion or not (which we already know from the number of results we get).
This patch essentially removes `WordComplete` mode and makes the result array indexed from 0.
It also removes all return values from all internal completion functions. The only non-redundant information
they contain is about rewriting the current line (which is broken), so that functionality was moved
to the CompletionRequest API. So you can now do `addCompletion("blub", "description", CompletionMode::RewriteLine)`
to do the same.
For the SB API we emulate the old behaviour by making the array indexed from 1 again with the common
prefix at index 0. I didn't keep the special negative return codes as we either never sent them before (e.g. -2) or we
didn't even implement them in the Editline handler (e.g. -1).
I tried to keep this patch minimal and I'm aware we can probably now even further simplify a bunch of related code,
but I would prefer doing this in follow-up NFC commits
Reviewers: JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arphaman, abidh, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D66536
llvm-svn: 369624
2019-08-22 15:41:23 +08:00
|
|
|
static void DiskFilesOrDirectories(const llvm::Twine &partial_name,
|
2019-08-27 19:32:22 +08:00
|
|
|
bool only_directories,
|
|
|
|
CompletionRequest &request,
|
[lldb][NFC] Remove WordComplete mode, make result array indexed from 0 and remove any undocumented/redundant return values
Summary:
We still have some leftovers of the old completion API in the internals of
LLDB that haven't been replaced by the new CompletionRequest. These leftovers
are:
* The return values (int/size_t) in all completion functions.
* Our result array that starts indexing at 1.
* `WordComplete` mode.
I didn't replace them back then because it's tricky to figure out what exactly they
are used for and the completion code is relatively untested. I finally got around
to writing more tests for the API and understanding the semantics, so I think it's
a good time to get rid of them.
A few words why those things should be removed/replaced:
* The return values are really cryptic, partly redundant and rarely documented.
They are also completely ignored by Xcode, so whatever information they contain will end up
breaking Xcode's completion mechanism. They are also partly impossible to even implement
as we assign negative values special meaning and our completion API sometimes returns size_t.
Completion functions are supposed to return -2 to rewrite the current line. We seem to use this
in some untested code path to expand the history repeat character to the full command, but
I haven't figured out why that doesn't work at the moment.
Completion functions return -1 to 'insert the completion character', but that isn't implemented
(even though we seem to activate this feature in LLDB sometimes).
All positive values have to match the number of results. This is obviously just redundant information
as the user can just look at the result list to get that information (which is what Xcode does).
* The result array that starts indexing at 1 is obviously unexpected. The first element of the array is
reserved for the common prefix of all completions (e.g. "foobar" and "footar" -> "foo"). The idea is
that we calculate this to make the life of the API caller easier, but obviously forcing people to have
1-based indices is not helpful (or even worse, forces them to manually copy the results to make it
0-based like Xcode has to do).
* The `WordComplete` mode indicates that LLDB should enter a space behind the completion. The
idea is that we let the top-level API know that we just provided a full completion. Interestingly we
`WordComplete` is just a single bool that somehow represents all N completions. And we always
provide full completions in LLDB, so in theory it should always be true.
The only use it currently serves is providing redundant information about whether we have a single
definitive completion or not (which we already know from the number of results we get).
This patch essentially removes `WordComplete` mode and makes the result array indexed from 0.
It also removes all return values from all internal completion functions. The only non-redundant information
they contain is about rewriting the current line (which is broken), so that functionality was moved
to the CompletionRequest API. So you can now do `addCompletion("blub", "description", CompletionMode::RewriteLine)`
to do the same.
For the SB API we emulate the old behaviour by making the array indexed from 1 again with the common
prefix at index 0. I didn't keep the special negative return codes as we either never sent them before (e.g. -2) or we
didn't even implement them in the Editline handler (e.g. -1).
I tried to keep this patch minimal and I'm aware we can probably now even further simplify a bunch of related code,
but I would prefer doing this in follow-up NFC commits
Reviewers: JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arphaman, abidh, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D66536
llvm-svn: 369624
2019-08-22 15:41:23 +08:00
|
|
|
TildeExpressionResolver &Resolver) {
|
2017-03-13 08:41:01 +08:00
|
|
|
llvm::SmallString<256> CompletionBuffer;
|
|
|
|
llvm::SmallString<256> Storage;
|
|
|
|
partial_name.toVector(CompletionBuffer);
|
|
|
|
|
|
|
|
if (CompletionBuffer.size() >= PATH_MAX)
|
[lldb][NFC] Remove WordComplete mode, make result array indexed from 0 and remove any undocumented/redundant return values
Summary:
We still have some leftovers of the old completion API in the internals of
LLDB that haven't been replaced by the new CompletionRequest. These leftovers
are:
* The return values (int/size_t) in all completion functions.
* Our result array that starts indexing at 1.
* `WordComplete` mode.
I didn't replace them back then because it's tricky to figure out what exactly they
are used for and the completion code is relatively untested. I finally got around
to writing more tests for the API and understanding the semantics, so I think it's
a good time to get rid of them.
A few words why those things should be removed/replaced:
* The return values are really cryptic, partly redundant and rarely documented.
They are also completely ignored by Xcode, so whatever information they contain will end up
breaking Xcode's completion mechanism. They are also partly impossible to even implement
as we assign negative values special meaning and our completion API sometimes returns size_t.
Completion functions are supposed to return -2 to rewrite the current line. We seem to use this
in some untested code path to expand the history repeat character to the full command, but
I haven't figured out why that doesn't work at the moment.
Completion functions return -1 to 'insert the completion character', but that isn't implemented
(even though we seem to activate this feature in LLDB sometimes).
All positive values have to match the number of results. This is obviously just redundant information
as the user can just look at the result list to get that information (which is what Xcode does).
* The result array that starts indexing at 1 is obviously unexpected. The first element of the array is
reserved for the common prefix of all completions (e.g. "foobar" and "footar" -> "foo"). The idea is
that we calculate this to make the life of the API caller easier, but obviously forcing people to have
1-based indices is not helpful (or even worse, forces them to manually copy the results to make it
0-based like Xcode has to do).
* The `WordComplete` mode indicates that LLDB should enter a space behind the completion. The
idea is that we let the top-level API know that we just provided a full completion. Interestingly we
`WordComplete` is just a single bool that somehow represents all N completions. And we always
provide full completions in LLDB, so in theory it should always be true.
The only use it currently serves is providing redundant information about whether we have a single
definitive completion or not (which we already know from the number of results we get).
This patch essentially removes `WordComplete` mode and makes the result array indexed from 0.
It also removes all return values from all internal completion functions. The only non-redundant information
they contain is about rewriting the current line (which is broken), so that functionality was moved
to the CompletionRequest API. So you can now do `addCompletion("blub", "description", CompletionMode::RewriteLine)`
to do the same.
For the SB API we emulate the old behaviour by making the array indexed from 1 again with the common
prefix at index 0. I didn't keep the special negative return codes as we either never sent them before (e.g. -2) or we
didn't even implement them in the Editline handler (e.g. -1).
I tried to keep this patch minimal and I'm aware we can probably now even further simplify a bunch of related code,
but I would prefer doing this in follow-up NFC commits
Reviewers: JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arphaman, abidh, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D66536
llvm-svn: 369624
2019-08-22 15:41:23 +08:00
|
|
|
return;
|
2017-03-13 08:41:01 +08:00
|
|
|
|
|
|
|
namespace path = llvm::sys::path;
|
|
|
|
|
|
|
|
llvm::StringRef SearchDir;
|
|
|
|
llvm::StringRef PartialItem;
|
|
|
|
|
|
|
|
if (CompletionBuffer.startswith("~")) {
|
|
|
|
llvm::StringRef Buffer(CompletionBuffer);
|
2017-03-17 06:28:04 +08:00
|
|
|
size_t FirstSep =
|
|
|
|
Buffer.find_if([](char c) { return path::is_separator(c); });
|
2017-03-13 08:41:01 +08:00
|
|
|
|
|
|
|
llvm::StringRef Username = Buffer.take_front(FirstSep);
|
|
|
|
llvm::StringRef Remainder;
|
|
|
|
if (FirstSep != llvm::StringRef::npos)
|
|
|
|
Remainder = Buffer.drop_front(FirstSep + 1);
|
|
|
|
|
2018-12-11 01:23:28 +08:00
|
|
|
llvm::SmallString<256> Resolved;
|
2017-03-13 08:41:01 +08:00
|
|
|
if (!Resolver.ResolveExact(Username, Resolved)) {
|
|
|
|
// We couldn't resolve it as a full username. If there were no slashes
|
|
|
|
// then this might be a partial username. We try to resolve it as such
|
|
|
|
// but after that, we're done regardless of any matches.
|
|
|
|
if (FirstSep == llvm::StringRef::npos) {
|
|
|
|
llvm::StringSet<> MatchSet;
|
2018-07-14 02:28:14 +08:00
|
|
|
Resolver.ResolvePartial(Username, MatchSet);
|
2017-03-13 08:41:01 +08:00
|
|
|
for (const auto &S : MatchSet) {
|
|
|
|
Resolved = S.getKey();
|
|
|
|
path::append(Resolved, path::get_separator());
|
2019-08-27 19:32:22 +08:00
|
|
|
request.AddCompletion(Resolved, "", CompletionMode::Partial);
|
2017-03-13 08:41:01 +08:00
|
|
|
}
|
|
|
|
}
|
[lldb][NFC] Remove WordComplete mode, make result array indexed from 0 and remove any undocumented/redundant return values
Summary:
We still have some leftovers of the old completion API in the internals of
LLDB that haven't been replaced by the new CompletionRequest. These leftovers
are:
* The return values (int/size_t) in all completion functions.
* Our result array that starts indexing at 1.
* `WordComplete` mode.
I didn't replace them back then because it's tricky to figure out what exactly they
are used for and the completion code is relatively untested. I finally got around
to writing more tests for the API and understanding the semantics, so I think it's
a good time to get rid of them.
A few words why those things should be removed/replaced:
* The return values are really cryptic, partly redundant and rarely documented.
They are also completely ignored by Xcode, so whatever information they contain will end up
breaking Xcode's completion mechanism. They are also partly impossible to even implement
as we assign negative values special meaning and our completion API sometimes returns size_t.
Completion functions are supposed to return -2 to rewrite the current line. We seem to use this
in some untested code path to expand the history repeat character to the full command, but
I haven't figured out why that doesn't work at the moment.
Completion functions return -1 to 'insert the completion character', but that isn't implemented
(even though we seem to activate this feature in LLDB sometimes).
All positive values have to match the number of results. This is obviously just redundant information
as the user can just look at the result list to get that information (which is what Xcode does).
* The result array that starts indexing at 1 is obviously unexpected. The first element of the array is
reserved for the common prefix of all completions (e.g. "foobar" and "footar" -> "foo"). The idea is
that we calculate this to make the life of the API caller easier, but obviously forcing people to have
1-based indices is not helpful (or even worse, forces them to manually copy the results to make it
0-based like Xcode has to do).
* The `WordComplete` mode indicates that LLDB should enter a space behind the completion. The
idea is that we let the top-level API know that we just provided a full completion. Interestingly we
`WordComplete` is just a single bool that somehow represents all N completions. And we always
provide full completions in LLDB, so in theory it should always be true.
The only use it currently serves is providing redundant information about whether we have a single
definitive completion or not (which we already know from the number of results we get).
This patch essentially removes `WordComplete` mode and makes the result array indexed from 0.
It also removes all return values from all internal completion functions. The only non-redundant information
they contain is about rewriting the current line (which is broken), so that functionality was moved
to the CompletionRequest API. So you can now do `addCompletion("blub", "description", CompletionMode::RewriteLine)`
to do the same.
For the SB API we emulate the old behaviour by making the array indexed from 1 again with the common
prefix at index 0. I didn't keep the special negative return codes as we either never sent them before (e.g. -2) or we
didn't even implement them in the Editline handler (e.g. -1).
I tried to keep this patch minimal and I'm aware we can probably now even further simplify a bunch of related code,
but I would prefer doing this in follow-up NFC commits
Reviewers: JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arphaman, abidh, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D66536
llvm-svn: 369624
2019-08-22 15:41:23 +08:00
|
|
|
return;
|
2017-03-13 08:41:01 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2018-05-01 00:49:04 +08:00
|
|
|
// If there was no trailing slash, then we're done as soon as we resolve
|
|
|
|
// the expression to the correct directory. Otherwise we need to continue
|
2017-03-13 08:41:01 +08:00
|
|
|
// looking for matches within that directory.
|
|
|
|
if (FirstSep == llvm::StringRef::npos) {
|
|
|
|
// Make sure it ends with a separator.
|
|
|
|
path::append(CompletionBuffer, path::get_separator());
|
2019-08-27 19:32:22 +08:00
|
|
|
request.AddCompletion(CompletionBuffer, "", CompletionMode::Partial);
|
[lldb][NFC] Remove WordComplete mode, make result array indexed from 0 and remove any undocumented/redundant return values
Summary:
We still have some leftovers of the old completion API in the internals of
LLDB that haven't been replaced by the new CompletionRequest. These leftovers
are:
* The return values (int/size_t) in all completion functions.
* Our result array that starts indexing at 1.
* `WordComplete` mode.
I didn't replace them back then because it's tricky to figure out what exactly they
are used for and the completion code is relatively untested. I finally got around
to writing more tests for the API and understanding the semantics, so I think it's
a good time to get rid of them.
A few words why those things should be removed/replaced:
* The return values are really cryptic, partly redundant and rarely documented.
They are also completely ignored by Xcode, so whatever information they contain will end up
breaking Xcode's completion mechanism. They are also partly impossible to even implement
as we assign negative values special meaning and our completion API sometimes returns size_t.
Completion functions are supposed to return -2 to rewrite the current line. We seem to use this
in some untested code path to expand the history repeat character to the full command, but
I haven't figured out why that doesn't work at the moment.
Completion functions return -1 to 'insert the completion character', but that isn't implemented
(even though we seem to activate this feature in LLDB sometimes).
All positive values have to match the number of results. This is obviously just redundant information
as the user can just look at the result list to get that information (which is what Xcode does).
* The result array that starts indexing at 1 is obviously unexpected. The first element of the array is
reserved for the common prefix of all completions (e.g. "foobar" and "footar" -> "foo"). The idea is
that we calculate this to make the life of the API caller easier, but obviously forcing people to have
1-based indices is not helpful (or even worse, forces them to manually copy the results to make it
0-based like Xcode has to do).
* The `WordComplete` mode indicates that LLDB should enter a space behind the completion. The
idea is that we let the top-level API know that we just provided a full completion. Interestingly we
`WordComplete` is just a single bool that somehow represents all N completions. And we always
provide full completions in LLDB, so in theory it should always be true.
The only use it currently serves is providing redundant information about whether we have a single
definitive completion or not (which we already know from the number of results we get).
This patch essentially removes `WordComplete` mode and makes the result array indexed from 0.
It also removes all return values from all internal completion functions. The only non-redundant information
they contain is about rewriting the current line (which is broken), so that functionality was moved
to the CompletionRequest API. So you can now do `addCompletion("blub", "description", CompletionMode::RewriteLine)`
to do the same.
For the SB API we emulate the old behaviour by making the array indexed from 1 again with the common
prefix at index 0. I didn't keep the special negative return codes as we either never sent them before (e.g. -2) or we
didn't even implement them in the Editline handler (e.g. -1).
I tried to keep this patch minimal and I'm aware we can probably now even further simplify a bunch of related code,
but I would prefer doing this in follow-up NFC commits
Reviewers: JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arphaman, abidh, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D66536
llvm-svn: 369624
2019-08-22 15:41:23 +08:00
|
|
|
return;
|
2017-03-13 08:41:01 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2017-03-13 08:41:01 +08:00
|
|
|
// We want to keep the form the user typed, so we special case this to
|
|
|
|
// search in the fully resolved directory, but CompletionBuffer keeps the
|
|
|
|
// unmodified form that the user typed.
|
|
|
|
Storage = Resolved;
|
2018-06-29 18:27:18 +08:00
|
|
|
llvm::StringRef RemainderDir = path::parent_path(Remainder);
|
2018-06-19 04:11:38 +08:00
|
|
|
if (!RemainderDir.empty()) {
|
|
|
|
// Append the remaining path to the resolved directory.
|
|
|
|
Storage.append(path::get_separator());
|
|
|
|
Storage.append(RemainderDir);
|
|
|
|
}
|
2018-01-22 17:17:16 +08:00
|
|
|
SearchDir = Storage;
|
2017-03-13 08:41:01 +08:00
|
|
|
} else {
|
|
|
|
SearchDir = path::parent_path(CompletionBuffer);
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2017-03-13 08:41:01 +08:00
|
|
|
size_t FullPrefixLen = CompletionBuffer.size();
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2017-03-13 08:41:01 +08:00
|
|
|
PartialItem = path::filename(CompletionBuffer);
|
2018-09-01 07:03:28 +08:00
|
|
|
|
|
|
|
// path::filename() will return "." when the passed path ends with a
|
|
|
|
// directory separator. We have to filter those out, but only when the
|
|
|
|
// "." doesn't come from the completion request itself.
|
|
|
|
if (PartialItem == "." && path::is_separator(CompletionBuffer.back()))
|
2017-03-13 08:41:01 +08:00
|
|
|
PartialItem = llvm::StringRef();
|
2013-08-23 20:44:05 +08:00
|
|
|
|
2017-04-15 10:44:53 +08:00
|
|
|
if (SearchDir.empty()) {
|
|
|
|
llvm::sys::fs::current_path(Storage);
|
|
|
|
SearchDir = Storage;
|
|
|
|
}
|
2017-03-13 08:41:01 +08:00
|
|
|
assert(!PartialItem.contains(path::get_separator()));
|
2013-08-23 20:44:05 +08:00
|
|
|
|
2017-03-13 08:41:01 +08:00
|
|
|
// SearchDir now contains the directory to search in, and Prefix contains the
|
|
|
|
// text we want to match against items in that directory.
|
2013-08-23 20:44:05 +08:00
|
|
|
|
2018-12-05 01:58:21 +08:00
|
|
|
FileSystem &fs = FileSystem::Instance();
|
2017-03-13 08:41:01 +08:00
|
|
|
std::error_code EC;
|
2018-12-05 01:58:21 +08:00
|
|
|
llvm::vfs::directory_iterator Iter = fs.DirBegin(SearchDir, EC);
|
|
|
|
llvm::vfs::directory_iterator End;
|
2017-03-13 08:41:01 +08:00
|
|
|
for (; Iter != End && !EC; Iter.increment(EC)) {
|
|
|
|
auto &Entry = *Iter;
|
2018-12-05 01:58:21 +08:00
|
|
|
llvm::ErrorOr<llvm::vfs::Status> Status = fs.GetStatus(Entry.path());
|
|
|
|
|
|
|
|
if (!Status)
|
|
|
|
continue;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2017-03-13 08:41:01 +08:00
|
|
|
auto Name = path::filename(Entry.path());
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2017-03-13 08:41:01 +08:00
|
|
|
// Omit ".", ".."
|
|
|
|
if (Name == "." || Name == ".." || !Name.startswith(PartialItem))
|
|
|
|
continue;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2018-12-05 01:58:21 +08:00
|
|
|
bool is_dir = Status->isDirectory();
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2017-03-13 08:41:01 +08:00
|
|
|
// If it's a symlink, then we treat it as a directory as long as the target
|
|
|
|
// is a directory.
|
2018-12-05 01:58:21 +08:00
|
|
|
if (Status->isSymlink()) {
|
|
|
|
FileSpec symlink_filespec(Entry.path());
|
|
|
|
FileSpec resolved_filespec;
|
|
|
|
auto error = fs.ResolveSymbolicLink(symlink_filespec, resolved_filespec);
|
|
|
|
if (error.Success())
|
|
|
|
is_dir = fs.IsDirectory(symlink_filespec);
|
2017-03-13 08:41:01 +08:00
|
|
|
}
|
2018-12-05 01:58:21 +08:00
|
|
|
|
2017-03-13 08:41:01 +08:00
|
|
|
if (only_directories && !is_dir)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// Shrink it back down so that it just has the original prefix the user
|
|
|
|
// typed and remove the part of the name which is common to the located
|
|
|
|
// item and what the user typed.
|
|
|
|
CompletionBuffer.resize(FullPrefixLen);
|
|
|
|
Name = Name.drop_front(PartialItem.size());
|
|
|
|
CompletionBuffer.append(Name);
|
|
|
|
|
|
|
|
if (is_dir) {
|
|
|
|
path::append(CompletionBuffer, path::get_separator());
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2019-08-27 19:32:22 +08:00
|
|
|
CompletionMode mode =
|
|
|
|
is_dir ? CompletionMode::Partial : CompletionMode::Normal;
|
|
|
|
request.AddCompletion(CompletionBuffer, "", mode);
|
2017-03-13 08:41:01 +08:00
|
|
|
}
|
2010-06-30 13:02:46 +08:00
|
|
|
}
|
|
|
|
|
2019-08-27 19:32:22 +08:00
|
|
|
static void DiskFilesOrDirectories(const llvm::Twine &partial_name,
|
|
|
|
bool only_directories, StringList &matches,
|
|
|
|
TildeExpressionResolver &Resolver) {
|
|
|
|
CompletionResult result;
|
|
|
|
std::string partial_name_str = partial_name.str();
|
|
|
|
CompletionRequest request(partial_name_str, partial_name_str.size(), result);
|
|
|
|
DiskFilesOrDirectories(partial_name, only_directories, request, Resolver);
|
|
|
|
result.GetMatches(matches);
|
|
|
|
}
|
|
|
|
|
[lldb][NFC] Remove WordComplete mode, make result array indexed from 0 and remove any undocumented/redundant return values
Summary:
We still have some leftovers of the old completion API in the internals of
LLDB that haven't been replaced by the new CompletionRequest. These leftovers
are:
* The return values (int/size_t) in all completion functions.
* Our result array that starts indexing at 1.
* `WordComplete` mode.
I didn't replace them back then because it's tricky to figure out what exactly they
are used for and the completion code is relatively untested. I finally got around
to writing more tests for the API and understanding the semantics, so I think it's
a good time to get rid of them.
A few words why those things should be removed/replaced:
* The return values are really cryptic, partly redundant and rarely documented.
They are also completely ignored by Xcode, so whatever information they contain will end up
breaking Xcode's completion mechanism. They are also partly impossible to even implement
as we assign negative values special meaning and our completion API sometimes returns size_t.
Completion functions are supposed to return -2 to rewrite the current line. We seem to use this
in some untested code path to expand the history repeat character to the full command, but
I haven't figured out why that doesn't work at the moment.
Completion functions return -1 to 'insert the completion character', but that isn't implemented
(even though we seem to activate this feature in LLDB sometimes).
All positive values have to match the number of results. This is obviously just redundant information
as the user can just look at the result list to get that information (which is what Xcode does).
* The result array that starts indexing at 1 is obviously unexpected. The first element of the array is
reserved for the common prefix of all completions (e.g. "foobar" and "footar" -> "foo"). The idea is
that we calculate this to make the life of the API caller easier, but obviously forcing people to have
1-based indices is not helpful (or even worse, forces them to manually copy the results to make it
0-based like Xcode has to do).
* The `WordComplete` mode indicates that LLDB should enter a space behind the completion. The
idea is that we let the top-level API know that we just provided a full completion. Interestingly we
`WordComplete` is just a single bool that somehow represents all N completions. And we always
provide full completions in LLDB, so in theory it should always be true.
The only use it currently serves is providing redundant information about whether we have a single
definitive completion or not (which we already know from the number of results we get).
This patch essentially removes `WordComplete` mode and makes the result array indexed from 0.
It also removes all return values from all internal completion functions. The only non-redundant information
they contain is about rewriting the current line (which is broken), so that functionality was moved
to the CompletionRequest API. So you can now do `addCompletion("blub", "description", CompletionMode::RewriteLine)`
to do the same.
For the SB API we emulate the old behaviour by making the array indexed from 1 again with the common
prefix at index 0. I didn't keep the special negative return codes as we either never sent them before (e.g. -2) or we
didn't even implement them in the Editline handler (e.g. -1).
I tried to keep this patch minimal and I'm aware we can probably now even further simplify a bunch of related code,
but I would prefer doing this in follow-up NFC commits
Reviewers: JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arphaman, abidh, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D66536
llvm-svn: 369624
2019-08-22 15:41:23 +08:00
|
|
|
static void DiskFilesOrDirectories(CompletionRequest &request,
|
|
|
|
bool only_directories) {
|
2018-11-09 09:59:28 +08:00
|
|
|
StandardTildeExpressionResolver resolver;
|
2018-07-28 02:42:46 +08:00
|
|
|
DiskFilesOrDirectories(request.GetCursorArgumentPrefix(), only_directories,
|
2019-08-27 19:32:22 +08:00
|
|
|
request, resolver);
|
2018-07-28 02:42:46 +08:00
|
|
|
}
|
|
|
|
|
[lldb][NFC] Remove WordComplete mode, make result array indexed from 0 and remove any undocumented/redundant return values
Summary:
We still have some leftovers of the old completion API in the internals of
LLDB that haven't been replaced by the new CompletionRequest. These leftovers
are:
* The return values (int/size_t) in all completion functions.
* Our result array that starts indexing at 1.
* `WordComplete` mode.
I didn't replace them back then because it's tricky to figure out what exactly they
are used for and the completion code is relatively untested. I finally got around
to writing more tests for the API and understanding the semantics, so I think it's
a good time to get rid of them.
A few words why those things should be removed/replaced:
* The return values are really cryptic, partly redundant and rarely documented.
They are also completely ignored by Xcode, so whatever information they contain will end up
breaking Xcode's completion mechanism. They are also partly impossible to even implement
as we assign negative values special meaning and our completion API sometimes returns size_t.
Completion functions are supposed to return -2 to rewrite the current line. We seem to use this
in some untested code path to expand the history repeat character to the full command, but
I haven't figured out why that doesn't work at the moment.
Completion functions return -1 to 'insert the completion character', but that isn't implemented
(even though we seem to activate this feature in LLDB sometimes).
All positive values have to match the number of results. This is obviously just redundant information
as the user can just look at the result list to get that information (which is what Xcode does).
* The result array that starts indexing at 1 is obviously unexpected. The first element of the array is
reserved for the common prefix of all completions (e.g. "foobar" and "footar" -> "foo"). The idea is
that we calculate this to make the life of the API caller easier, but obviously forcing people to have
1-based indices is not helpful (or even worse, forces them to manually copy the results to make it
0-based like Xcode has to do).
* The `WordComplete` mode indicates that LLDB should enter a space behind the completion. The
idea is that we let the top-level API know that we just provided a full completion. Interestingly we
`WordComplete` is just a single bool that somehow represents all N completions. And we always
provide full completions in LLDB, so in theory it should always be true.
The only use it currently serves is providing redundant information about whether we have a single
definitive completion or not (which we already know from the number of results we get).
This patch essentially removes `WordComplete` mode and makes the result array indexed from 0.
It also removes all return values from all internal completion functions. The only non-redundant information
they contain is about rewriting the current line (which is broken), so that functionality was moved
to the CompletionRequest API. So you can now do `addCompletion("blub", "description", CompletionMode::RewriteLine)`
to do the same.
For the SB API we emulate the old behaviour by making the array indexed from 1 again with the common
prefix at index 0. I didn't keep the special negative return codes as we either never sent them before (e.g. -2) or we
didn't even implement them in the Editline handler (e.g. -1).
I tried to keep this patch minimal and I'm aware we can probably now even further simplify a bunch of related code,
but I would prefer doing this in follow-up NFC commits
Reviewers: JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arphaman, abidh, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D66536
llvm-svn: 369624
2019-08-22 15:41:23 +08:00
|
|
|
void CommandCompletions::DiskFiles(CommandInterpreter &interpreter,
|
|
|
|
CompletionRequest &request,
|
|
|
|
SearchFilter *searcher) {
|
|
|
|
DiskFilesOrDirectories(request, /*only_dirs*/ false);
|
2017-03-13 08:41:01 +08:00
|
|
|
}
|
|
|
|
|
[lldb][NFC] Remove WordComplete mode, make result array indexed from 0 and remove any undocumented/redundant return values
Summary:
We still have some leftovers of the old completion API in the internals of
LLDB that haven't been replaced by the new CompletionRequest. These leftovers
are:
* The return values (int/size_t) in all completion functions.
* Our result array that starts indexing at 1.
* `WordComplete` mode.
I didn't replace them back then because it's tricky to figure out what exactly they
are used for and the completion code is relatively untested. I finally got around
to writing more tests for the API and understanding the semantics, so I think it's
a good time to get rid of them.
A few words why those things should be removed/replaced:
* The return values are really cryptic, partly redundant and rarely documented.
They are also completely ignored by Xcode, so whatever information they contain will end up
breaking Xcode's completion mechanism. They are also partly impossible to even implement
as we assign negative values special meaning and our completion API sometimes returns size_t.
Completion functions are supposed to return -2 to rewrite the current line. We seem to use this
in some untested code path to expand the history repeat character to the full command, but
I haven't figured out why that doesn't work at the moment.
Completion functions return -1 to 'insert the completion character', but that isn't implemented
(even though we seem to activate this feature in LLDB sometimes).
All positive values have to match the number of results. This is obviously just redundant information
as the user can just look at the result list to get that information (which is what Xcode does).
* The result array that starts indexing at 1 is obviously unexpected. The first element of the array is
reserved for the common prefix of all completions (e.g. "foobar" and "footar" -> "foo"). The idea is
that we calculate this to make the life of the API caller easier, but obviously forcing people to have
1-based indices is not helpful (or even worse, forces them to manually copy the results to make it
0-based like Xcode has to do).
* The `WordComplete` mode indicates that LLDB should enter a space behind the completion. The
idea is that we let the top-level API know that we just provided a full completion. Interestingly we
`WordComplete` is just a single bool that somehow represents all N completions. And we always
provide full completions in LLDB, so in theory it should always be true.
The only use it currently serves is providing redundant information about whether we have a single
definitive completion or not (which we already know from the number of results we get).
This patch essentially removes `WordComplete` mode and makes the result array indexed from 0.
It also removes all return values from all internal completion functions. The only non-redundant information
they contain is about rewriting the current line (which is broken), so that functionality was moved
to the CompletionRequest API. So you can now do `addCompletion("blub", "description", CompletionMode::RewriteLine)`
to do the same.
For the SB API we emulate the old behaviour by making the array indexed from 1 again with the common
prefix at index 0. I didn't keep the special negative return codes as we either never sent them before (e.g. -2) or we
didn't even implement them in the Editline handler (e.g. -1).
I tried to keep this patch minimal and I'm aware we can probably now even further simplify a bunch of related code,
but I would prefer doing this in follow-up NFC commits
Reviewers: JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arphaman, abidh, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D66536
llvm-svn: 369624
2019-08-22 15:41:23 +08:00
|
|
|
void CommandCompletions::DiskFiles(const llvm::Twine &partial_file_name,
|
|
|
|
StringList &matches,
|
|
|
|
TildeExpressionResolver &Resolver) {
|
|
|
|
DiskFilesOrDirectories(partial_file_name, false, matches, Resolver);
|
2010-06-30 13:02:46 +08:00
|
|
|
}
|
|
|
|
|
[lldb][NFC] Remove WordComplete mode, make result array indexed from 0 and remove any undocumented/redundant return values
Summary:
We still have some leftovers of the old completion API in the internals of
LLDB that haven't been replaced by the new CompletionRequest. These leftovers
are:
* The return values (int/size_t) in all completion functions.
* Our result array that starts indexing at 1.
* `WordComplete` mode.
I didn't replace them back then because it's tricky to figure out what exactly they
are used for and the completion code is relatively untested. I finally got around
to writing more tests for the API and understanding the semantics, so I think it's
a good time to get rid of them.
A few words why those things should be removed/replaced:
* The return values are really cryptic, partly redundant and rarely documented.
They are also completely ignored by Xcode, so whatever information they contain will end up
breaking Xcode's completion mechanism. They are also partly impossible to even implement
as we assign negative values special meaning and our completion API sometimes returns size_t.
Completion functions are supposed to return -2 to rewrite the current line. We seem to use this
in some untested code path to expand the history repeat character to the full command, but
I haven't figured out why that doesn't work at the moment.
Completion functions return -1 to 'insert the completion character', but that isn't implemented
(even though we seem to activate this feature in LLDB sometimes).
All positive values have to match the number of results. This is obviously just redundant information
as the user can just look at the result list to get that information (which is what Xcode does).
* The result array that starts indexing at 1 is obviously unexpected. The first element of the array is
reserved for the common prefix of all completions (e.g. "foobar" and "footar" -> "foo"). The idea is
that we calculate this to make the life of the API caller easier, but obviously forcing people to have
1-based indices is not helpful (or even worse, forces them to manually copy the results to make it
0-based like Xcode has to do).
* The `WordComplete` mode indicates that LLDB should enter a space behind the completion. The
idea is that we let the top-level API know that we just provided a full completion. Interestingly we
`WordComplete` is just a single bool that somehow represents all N completions. And we always
provide full completions in LLDB, so in theory it should always be true.
The only use it currently serves is providing redundant information about whether we have a single
definitive completion or not (which we already know from the number of results we get).
This patch essentially removes `WordComplete` mode and makes the result array indexed from 0.
It also removes all return values from all internal completion functions. The only non-redundant information
they contain is about rewriting the current line (which is broken), so that functionality was moved
to the CompletionRequest API. So you can now do `addCompletion("blub", "description", CompletionMode::RewriteLine)`
to do the same.
For the SB API we emulate the old behaviour by making the array indexed from 1 again with the common
prefix at index 0. I didn't keep the special negative return codes as we either never sent them before (e.g. -2) or we
didn't even implement them in the Editline handler (e.g. -1).
I tried to keep this patch minimal and I'm aware we can probably now even further simplify a bunch of related code,
but I would prefer doing this in follow-up NFC commits
Reviewers: JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arphaman, abidh, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D66536
llvm-svn: 369624
2019-08-22 15:41:23 +08:00
|
|
|
void CommandCompletions::DiskDirectories(CommandInterpreter &interpreter,
|
|
|
|
CompletionRequest &request,
|
|
|
|
SearchFilter *searcher) {
|
|
|
|
DiskFilesOrDirectories(request, /*only_dirs*/ true);
|
2017-03-13 08:41:01 +08:00
|
|
|
}
|
|
|
|
|
[lldb][NFC] Remove WordComplete mode, make result array indexed from 0 and remove any undocumented/redundant return values
Summary:
We still have some leftovers of the old completion API in the internals of
LLDB that haven't been replaced by the new CompletionRequest. These leftovers
are:
* The return values (int/size_t) in all completion functions.
* Our result array that starts indexing at 1.
* `WordComplete` mode.
I didn't replace them back then because it's tricky to figure out what exactly they
are used for and the completion code is relatively untested. I finally got around
to writing more tests for the API and understanding the semantics, so I think it's
a good time to get rid of them.
A few words why those things should be removed/replaced:
* The return values are really cryptic, partly redundant and rarely documented.
They are also completely ignored by Xcode, so whatever information they contain will end up
breaking Xcode's completion mechanism. They are also partly impossible to even implement
as we assign negative values special meaning and our completion API sometimes returns size_t.
Completion functions are supposed to return -2 to rewrite the current line. We seem to use this
in some untested code path to expand the history repeat character to the full command, but
I haven't figured out why that doesn't work at the moment.
Completion functions return -1 to 'insert the completion character', but that isn't implemented
(even though we seem to activate this feature in LLDB sometimes).
All positive values have to match the number of results. This is obviously just redundant information
as the user can just look at the result list to get that information (which is what Xcode does).
* The result array that starts indexing at 1 is obviously unexpected. The first element of the array is
reserved for the common prefix of all completions (e.g. "foobar" and "footar" -> "foo"). The idea is
that we calculate this to make the life of the API caller easier, but obviously forcing people to have
1-based indices is not helpful (or even worse, forces them to manually copy the results to make it
0-based like Xcode has to do).
* The `WordComplete` mode indicates that LLDB should enter a space behind the completion. The
idea is that we let the top-level API know that we just provided a full completion. Interestingly we
`WordComplete` is just a single bool that somehow represents all N completions. And we always
provide full completions in LLDB, so in theory it should always be true.
The only use it currently serves is providing redundant information about whether we have a single
definitive completion or not (which we already know from the number of results we get).
This patch essentially removes `WordComplete` mode and makes the result array indexed from 0.
It also removes all return values from all internal completion functions. The only non-redundant information
they contain is about rewriting the current line (which is broken), so that functionality was moved
to the CompletionRequest API. So you can now do `addCompletion("blub", "description", CompletionMode::RewriteLine)`
to do the same.
For the SB API we emulate the old behaviour by making the array indexed from 1 again with the common
prefix at index 0. I didn't keep the special negative return codes as we either never sent them before (e.g. -2) or we
didn't even implement them in the Editline handler (e.g. -1).
I tried to keep this patch minimal and I'm aware we can probably now even further simplify a bunch of related code,
but I would prefer doing this in follow-up NFC commits
Reviewers: JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arphaman, abidh, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D66536
llvm-svn: 369624
2019-08-22 15:41:23 +08:00
|
|
|
void CommandCompletions::DiskDirectories(const llvm::Twine &partial_file_name,
|
|
|
|
StringList &matches,
|
|
|
|
TildeExpressionResolver &Resolver) {
|
|
|
|
DiskFilesOrDirectories(partial_file_name, true, matches, Resolver);
|
2010-06-30 13:02:46 +08:00
|
|
|
}
|
|
|
|
|
[lldb][NFC] Remove WordComplete mode, make result array indexed from 0 and remove any undocumented/redundant return values
Summary:
We still have some leftovers of the old completion API in the internals of
LLDB that haven't been replaced by the new CompletionRequest. These leftovers
are:
* The return values (int/size_t) in all completion functions.
* Our result array that starts indexing at 1.
* `WordComplete` mode.
I didn't replace them back then because it's tricky to figure out what exactly they
are used for and the completion code is relatively untested. I finally got around
to writing more tests for the API and understanding the semantics, so I think it's
a good time to get rid of them.
A few words why those things should be removed/replaced:
* The return values are really cryptic, partly redundant and rarely documented.
They are also completely ignored by Xcode, so whatever information they contain will end up
breaking Xcode's completion mechanism. They are also partly impossible to even implement
as we assign negative values special meaning and our completion API sometimes returns size_t.
Completion functions are supposed to return -2 to rewrite the current line. We seem to use this
in some untested code path to expand the history repeat character to the full command, but
I haven't figured out why that doesn't work at the moment.
Completion functions return -1 to 'insert the completion character', but that isn't implemented
(even though we seem to activate this feature in LLDB sometimes).
All positive values have to match the number of results. This is obviously just redundant information
as the user can just look at the result list to get that information (which is what Xcode does).
* The result array that starts indexing at 1 is obviously unexpected. The first element of the array is
reserved for the common prefix of all completions (e.g. "foobar" and "footar" -> "foo"). The idea is
that we calculate this to make the life of the API caller easier, but obviously forcing people to have
1-based indices is not helpful (or even worse, forces them to manually copy the results to make it
0-based like Xcode has to do).
* The `WordComplete` mode indicates that LLDB should enter a space behind the completion. The
idea is that we let the top-level API know that we just provided a full completion. Interestingly we
`WordComplete` is just a single bool that somehow represents all N completions. And we always
provide full completions in LLDB, so in theory it should always be true.
The only use it currently serves is providing redundant information about whether we have a single
definitive completion or not (which we already know from the number of results we get).
This patch essentially removes `WordComplete` mode and makes the result array indexed from 0.
It also removes all return values from all internal completion functions. The only non-redundant information
they contain is about rewriting the current line (which is broken), so that functionality was moved
to the CompletionRequest API. So you can now do `addCompletion("blub", "description", CompletionMode::RewriteLine)`
to do the same.
For the SB API we emulate the old behaviour by making the array indexed from 1 again with the common
prefix at index 0. I didn't keep the special negative return codes as we either never sent them before (e.g. -2) or we
didn't even implement them in the Editline handler (e.g. -1).
I tried to keep this patch minimal and I'm aware we can probably now even further simplify a bunch of related code,
but I would prefer doing this in follow-up NFC commits
Reviewers: JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arphaman, abidh, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D66536
llvm-svn: 369624
2019-08-22 15:41:23 +08:00
|
|
|
void CommandCompletions::Modules(CommandInterpreter &interpreter,
|
|
|
|
CompletionRequest &request,
|
|
|
|
SearchFilter *searcher) {
|
2018-07-14 02:28:14 +08:00
|
|
|
ModuleCompleter completer(interpreter, request);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2016-02-20 03:33:46 +08:00
|
|
|
if (searcher == nullptr) {
|
2010-08-27 05:32:51 +08:00
|
|
|
lldb::TargetSP target_sp = interpreter.GetDebugger().GetSelectedTarget();
|
2014-12-06 09:28:03 +08:00
|
|
|
SearchFilterForUnconstrainedSearches null_searcher(target_sp);
|
2010-06-09 00:52:24 +08:00
|
|
|
completer.DoCompletion(&null_searcher);
|
|
|
|
} else {
|
|
|
|
completer.DoCompletion(searcher);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-11 18:29:25 +08:00
|
|
|
void CommandCompletions::ModuleUUIDs(CommandInterpreter &interpreter,
|
|
|
|
CompletionRequest &request,
|
|
|
|
SearchFilter *searcher) {
|
|
|
|
const ExecutionContext &exe_ctx = interpreter.GetExecutionContext();
|
|
|
|
if (!exe_ctx.HasTargetScope())
|
|
|
|
return;
|
|
|
|
|
|
|
|
exe_ctx.GetTargetPtr()->GetImages().ForEach(
|
|
|
|
[&request](const lldb::ModuleSP &module) {
|
|
|
|
StreamString strm;
|
|
|
|
module->GetDescription(strm.AsRawOstream(),
|
|
|
|
lldb::eDescriptionLevelInitial);
|
|
|
|
request.TryCompleteCurrentArg(module->GetUUID().GetAsString(),
|
|
|
|
strm.GetString());
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
[lldb][NFC] Remove WordComplete mode, make result array indexed from 0 and remove any undocumented/redundant return values
Summary:
We still have some leftovers of the old completion API in the internals of
LLDB that haven't been replaced by the new CompletionRequest. These leftovers
are:
* The return values (int/size_t) in all completion functions.
* Our result array that starts indexing at 1.
* `WordComplete` mode.
I didn't replace them back then because it's tricky to figure out what exactly they
are used for and the completion code is relatively untested. I finally got around
to writing more tests for the API and understanding the semantics, so I think it's
a good time to get rid of them.
A few words why those things should be removed/replaced:
* The return values are really cryptic, partly redundant and rarely documented.
They are also completely ignored by Xcode, so whatever information they contain will end up
breaking Xcode's completion mechanism. They are also partly impossible to even implement
as we assign negative values special meaning and our completion API sometimes returns size_t.
Completion functions are supposed to return -2 to rewrite the current line. We seem to use this
in some untested code path to expand the history repeat character to the full command, but
I haven't figured out why that doesn't work at the moment.
Completion functions return -1 to 'insert the completion character', but that isn't implemented
(even though we seem to activate this feature in LLDB sometimes).
All positive values have to match the number of results. This is obviously just redundant information
as the user can just look at the result list to get that information (which is what Xcode does).
* The result array that starts indexing at 1 is obviously unexpected. The first element of the array is
reserved for the common prefix of all completions (e.g. "foobar" and "footar" -> "foo"). The idea is
that we calculate this to make the life of the API caller easier, but obviously forcing people to have
1-based indices is not helpful (or even worse, forces them to manually copy the results to make it
0-based like Xcode has to do).
* The `WordComplete` mode indicates that LLDB should enter a space behind the completion. The
idea is that we let the top-level API know that we just provided a full completion. Interestingly we
`WordComplete` is just a single bool that somehow represents all N completions. And we always
provide full completions in LLDB, so in theory it should always be true.
The only use it currently serves is providing redundant information about whether we have a single
definitive completion or not (which we already know from the number of results we get).
This patch essentially removes `WordComplete` mode and makes the result array indexed from 0.
It also removes all return values from all internal completion functions. The only non-redundant information
they contain is about rewriting the current line (which is broken), so that functionality was moved
to the CompletionRequest API. So you can now do `addCompletion("blub", "description", CompletionMode::RewriteLine)`
to do the same.
For the SB API we emulate the old behaviour by making the array indexed from 1 again with the common
prefix at index 0. I didn't keep the special negative return codes as we either never sent them before (e.g. -2) or we
didn't even implement them in the Editline handler (e.g. -1).
I tried to keep this patch minimal and I'm aware we can probably now even further simplify a bunch of related code,
but I would prefer doing this in follow-up NFC commits
Reviewers: JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arphaman, abidh, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D66536
llvm-svn: 369624
2019-08-22 15:41:23 +08:00
|
|
|
void CommandCompletions::Symbols(CommandInterpreter &interpreter,
|
|
|
|
CompletionRequest &request,
|
|
|
|
SearchFilter *searcher) {
|
2018-07-14 02:28:14 +08:00
|
|
|
SymbolCompleter completer(interpreter, request);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2016-02-20 03:33:46 +08:00
|
|
|
if (searcher == nullptr) {
|
2010-08-27 05:32:51 +08:00
|
|
|
lldb::TargetSP target_sp = interpreter.GetDebugger().GetSelectedTarget();
|
2014-12-06 09:28:03 +08:00
|
|
|
SearchFilterForUnconstrainedSearches null_searcher(target_sp);
|
2010-06-09 00:52:24 +08:00
|
|
|
completer.DoCompletion(&null_searcher);
|
|
|
|
} else {
|
|
|
|
completer.DoCompletion(searcher);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
[lldb][NFC] Remove WordComplete mode, make result array indexed from 0 and remove any undocumented/redundant return values
Summary:
We still have some leftovers of the old completion API in the internals of
LLDB that haven't been replaced by the new CompletionRequest. These leftovers
are:
* The return values (int/size_t) in all completion functions.
* Our result array that starts indexing at 1.
* `WordComplete` mode.
I didn't replace them back then because it's tricky to figure out what exactly they
are used for and the completion code is relatively untested. I finally got around
to writing more tests for the API and understanding the semantics, so I think it's
a good time to get rid of them.
A few words why those things should be removed/replaced:
* The return values are really cryptic, partly redundant and rarely documented.
They are also completely ignored by Xcode, so whatever information they contain will end up
breaking Xcode's completion mechanism. They are also partly impossible to even implement
as we assign negative values special meaning and our completion API sometimes returns size_t.
Completion functions are supposed to return -2 to rewrite the current line. We seem to use this
in some untested code path to expand the history repeat character to the full command, but
I haven't figured out why that doesn't work at the moment.
Completion functions return -1 to 'insert the completion character', but that isn't implemented
(even though we seem to activate this feature in LLDB sometimes).
All positive values have to match the number of results. This is obviously just redundant information
as the user can just look at the result list to get that information (which is what Xcode does).
* The result array that starts indexing at 1 is obviously unexpected. The first element of the array is
reserved for the common prefix of all completions (e.g. "foobar" and "footar" -> "foo"). The idea is
that we calculate this to make the life of the API caller easier, but obviously forcing people to have
1-based indices is not helpful (or even worse, forces them to manually copy the results to make it
0-based like Xcode has to do).
* The `WordComplete` mode indicates that LLDB should enter a space behind the completion. The
idea is that we let the top-level API know that we just provided a full completion. Interestingly we
`WordComplete` is just a single bool that somehow represents all N completions. And we always
provide full completions in LLDB, so in theory it should always be true.
The only use it currently serves is providing redundant information about whether we have a single
definitive completion or not (which we already know from the number of results we get).
This patch essentially removes `WordComplete` mode and makes the result array indexed from 0.
It also removes all return values from all internal completion functions. The only non-redundant information
they contain is about rewriting the current line (which is broken), so that functionality was moved
to the CompletionRequest API. So you can now do `addCompletion("blub", "description", CompletionMode::RewriteLine)`
to do the same.
For the SB API we emulate the old behaviour by making the array indexed from 1 again with the common
prefix at index 0. I didn't keep the special negative return codes as we either never sent them before (e.g. -2) or we
didn't even implement them in the Editline handler (e.g. -1).
I tried to keep this patch minimal and I'm aware we can probably now even further simplify a bunch of related code,
but I would prefer doing this in follow-up NFC commits
Reviewers: JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arphaman, abidh, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D66536
llvm-svn: 369624
2019-08-22 15:41:23 +08:00
|
|
|
void CommandCompletions::SettingsNames(CommandInterpreter &interpreter,
|
|
|
|
CompletionRequest &request,
|
|
|
|
SearchFilter *searcher) {
|
2012-08-23 01:17:09 +08:00
|
|
|
// Cache the full setting name list
|
|
|
|
static StringList g_property_names;
|
|
|
|
if (g_property_names.GetSize() == 0) {
|
|
|
|
// Generate the full setting name list on demand
|
|
|
|
lldb::OptionValuePropertiesSP properties_sp(
|
|
|
|
interpreter.GetDebugger().GetValueProperties());
|
|
|
|
if (properties_sp) {
|
|
|
|
StreamString strm;
|
2016-02-20 03:33:46 +08:00
|
|
|
properties_sp->DumpValue(nullptr, strm, OptionValue::eDumpOptionName);
|
2020-01-29 03:23:46 +08:00
|
|
|
const std::string &str = std::string(strm.GetString());
|
2012-08-23 01:17:09 +08:00
|
|
|
g_property_names.SplitIntoLines(str.c_str(), str.size());
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2019-09-23 16:59:21 +08:00
|
|
|
for (const std::string &s : g_property_names)
|
|
|
|
request.TryCompleteCurrentArg(s);
|
2010-09-04 08:03:46 +08:00
|
|
|
}
|
|
|
|
|
[lldb][NFC] Remove WordComplete mode, make result array indexed from 0 and remove any undocumented/redundant return values
Summary:
We still have some leftovers of the old completion API in the internals of
LLDB that haven't been replaced by the new CompletionRequest. These leftovers
are:
* The return values (int/size_t) in all completion functions.
* Our result array that starts indexing at 1.
* `WordComplete` mode.
I didn't replace them back then because it's tricky to figure out what exactly they
are used for and the completion code is relatively untested. I finally got around
to writing more tests for the API and understanding the semantics, so I think it's
a good time to get rid of them.
A few words why those things should be removed/replaced:
* The return values are really cryptic, partly redundant and rarely documented.
They are also completely ignored by Xcode, so whatever information they contain will end up
breaking Xcode's completion mechanism. They are also partly impossible to even implement
as we assign negative values special meaning and our completion API sometimes returns size_t.
Completion functions are supposed to return -2 to rewrite the current line. We seem to use this
in some untested code path to expand the history repeat character to the full command, but
I haven't figured out why that doesn't work at the moment.
Completion functions return -1 to 'insert the completion character', but that isn't implemented
(even though we seem to activate this feature in LLDB sometimes).
All positive values have to match the number of results. This is obviously just redundant information
as the user can just look at the result list to get that information (which is what Xcode does).
* The result array that starts indexing at 1 is obviously unexpected. The first element of the array is
reserved for the common prefix of all completions (e.g. "foobar" and "footar" -> "foo"). The idea is
that we calculate this to make the life of the API caller easier, but obviously forcing people to have
1-based indices is not helpful (or even worse, forces them to manually copy the results to make it
0-based like Xcode has to do).
* The `WordComplete` mode indicates that LLDB should enter a space behind the completion. The
idea is that we let the top-level API know that we just provided a full completion. Interestingly we
`WordComplete` is just a single bool that somehow represents all N completions. And we always
provide full completions in LLDB, so in theory it should always be true.
The only use it currently serves is providing redundant information about whether we have a single
definitive completion or not (which we already know from the number of results we get).
This patch essentially removes `WordComplete` mode and makes the result array indexed from 0.
It also removes all return values from all internal completion functions. The only non-redundant information
they contain is about rewriting the current line (which is broken), so that functionality was moved
to the CompletionRequest API. So you can now do `addCompletion("blub", "description", CompletionMode::RewriteLine)`
to do the same.
For the SB API we emulate the old behaviour by making the array indexed from 1 again with the common
prefix at index 0. I didn't keep the special negative return codes as we either never sent them before (e.g. -2) or we
didn't even implement them in the Editline handler (e.g. -1).
I tried to keep this patch minimal and I'm aware we can probably now even further simplify a bunch of related code,
but I would prefer doing this in follow-up NFC commits
Reviewers: JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arphaman, abidh, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D66536
llvm-svn: 369624
2019-08-22 15:41:23 +08:00
|
|
|
void CommandCompletions::PlatformPluginNames(CommandInterpreter &interpreter,
|
|
|
|
CompletionRequest &request,
|
|
|
|
SearchFilter *searcher) {
|
|
|
|
PluginManager::AutoCompletePlatformName(request.GetCursorArgumentPrefix(),
|
|
|
|
request);
|
2011-04-14 06:47:15 +08:00
|
|
|
}
|
|
|
|
|
[lldb][NFC] Remove WordComplete mode, make result array indexed from 0 and remove any undocumented/redundant return values
Summary:
We still have some leftovers of the old completion API in the internals of
LLDB that haven't been replaced by the new CompletionRequest. These leftovers
are:
* The return values (int/size_t) in all completion functions.
* Our result array that starts indexing at 1.
* `WordComplete` mode.
I didn't replace them back then because it's tricky to figure out what exactly they
are used for and the completion code is relatively untested. I finally got around
to writing more tests for the API and understanding the semantics, so I think it's
a good time to get rid of them.
A few words why those things should be removed/replaced:
* The return values are really cryptic, partly redundant and rarely documented.
They are also completely ignored by Xcode, so whatever information they contain will end up
breaking Xcode's completion mechanism. They are also partly impossible to even implement
as we assign negative values special meaning and our completion API sometimes returns size_t.
Completion functions are supposed to return -2 to rewrite the current line. We seem to use this
in some untested code path to expand the history repeat character to the full command, but
I haven't figured out why that doesn't work at the moment.
Completion functions return -1 to 'insert the completion character', but that isn't implemented
(even though we seem to activate this feature in LLDB sometimes).
All positive values have to match the number of results. This is obviously just redundant information
as the user can just look at the result list to get that information (which is what Xcode does).
* The result array that starts indexing at 1 is obviously unexpected. The first element of the array is
reserved for the common prefix of all completions (e.g. "foobar" and "footar" -> "foo"). The idea is
that we calculate this to make the life of the API caller easier, but obviously forcing people to have
1-based indices is not helpful (or even worse, forces them to manually copy the results to make it
0-based like Xcode has to do).
* The `WordComplete` mode indicates that LLDB should enter a space behind the completion. The
idea is that we let the top-level API know that we just provided a full completion. Interestingly we
`WordComplete` is just a single bool that somehow represents all N completions. And we always
provide full completions in LLDB, so in theory it should always be true.
The only use it currently serves is providing redundant information about whether we have a single
definitive completion or not (which we already know from the number of results we get).
This patch essentially removes `WordComplete` mode and makes the result array indexed from 0.
It also removes all return values from all internal completion functions. The only non-redundant information
they contain is about rewriting the current line (which is broken), so that functionality was moved
to the CompletionRequest API. So you can now do `addCompletion("blub", "description", CompletionMode::RewriteLine)`
to do the same.
For the SB API we emulate the old behaviour by making the array indexed from 1 again with the common
prefix at index 0. I didn't keep the special negative return codes as we either never sent them before (e.g. -2) or we
didn't even implement them in the Editline handler (e.g. -1).
I tried to keep this patch minimal and I'm aware we can probably now even further simplify a bunch of related code,
but I would prefer doing this in follow-up NFC commits
Reviewers: JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arphaman, abidh, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D66536
llvm-svn: 369624
2019-08-22 15:41:23 +08:00
|
|
|
void CommandCompletions::ArchitectureNames(CommandInterpreter &interpreter,
|
|
|
|
CompletionRequest &request,
|
|
|
|
SearchFilter *searcher) {
|
|
|
|
ArchSpec::AutoComplete(request);
|
2011-04-14 06:47:15 +08:00
|
|
|
}
|
|
|
|
|
[lldb][NFC] Remove WordComplete mode, make result array indexed from 0 and remove any undocumented/redundant return values
Summary:
We still have some leftovers of the old completion API in the internals of
LLDB that haven't been replaced by the new CompletionRequest. These leftovers
are:
* The return values (int/size_t) in all completion functions.
* Our result array that starts indexing at 1.
* `WordComplete` mode.
I didn't replace them back then because it's tricky to figure out what exactly they
are used for and the completion code is relatively untested. I finally got around
to writing more tests for the API and understanding the semantics, so I think it's
a good time to get rid of them.
A few words why those things should be removed/replaced:
* The return values are really cryptic, partly redundant and rarely documented.
They are also completely ignored by Xcode, so whatever information they contain will end up
breaking Xcode's completion mechanism. They are also partly impossible to even implement
as we assign negative values special meaning and our completion API sometimes returns size_t.
Completion functions are supposed to return -2 to rewrite the current line. We seem to use this
in some untested code path to expand the history repeat character to the full command, but
I haven't figured out why that doesn't work at the moment.
Completion functions return -1 to 'insert the completion character', but that isn't implemented
(even though we seem to activate this feature in LLDB sometimes).
All positive values have to match the number of results. This is obviously just redundant information
as the user can just look at the result list to get that information (which is what Xcode does).
* The result array that starts indexing at 1 is obviously unexpected. The first element of the array is
reserved for the common prefix of all completions (e.g. "foobar" and "footar" -> "foo"). The idea is
that we calculate this to make the life of the API caller easier, but obviously forcing people to have
1-based indices is not helpful (or even worse, forces them to manually copy the results to make it
0-based like Xcode has to do).
* The `WordComplete` mode indicates that LLDB should enter a space behind the completion. The
idea is that we let the top-level API know that we just provided a full completion. Interestingly we
`WordComplete` is just a single bool that somehow represents all N completions. And we always
provide full completions in LLDB, so in theory it should always be true.
The only use it currently serves is providing redundant information about whether we have a single
definitive completion or not (which we already know from the number of results we get).
This patch essentially removes `WordComplete` mode and makes the result array indexed from 0.
It also removes all return values from all internal completion functions. The only non-redundant information
they contain is about rewriting the current line (which is broken), so that functionality was moved
to the CompletionRequest API. So you can now do `addCompletion("blub", "description", CompletionMode::RewriteLine)`
to do the same.
For the SB API we emulate the old behaviour by making the array indexed from 1 again with the common
prefix at index 0. I didn't keep the special negative return codes as we either never sent them before (e.g. -2) or we
didn't even implement them in the Editline handler (e.g. -1).
I tried to keep this patch minimal and I'm aware we can probably now even further simplify a bunch of related code,
but I would prefer doing this in follow-up NFC commits
Reviewers: JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arphaman, abidh, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D66536
llvm-svn: 369624
2019-08-22 15:41:23 +08:00
|
|
|
void CommandCompletions::VariablePath(CommandInterpreter &interpreter,
|
|
|
|
CompletionRequest &request,
|
|
|
|
SearchFilter *searcher) {
|
|
|
|
Variable::AutoComplete(interpreter.GetExecutionContext(), request);
|
2013-05-15 07:43:18 +08:00
|
|
|
}
|
2020-05-08 00:12:39 +08:00
|
|
|
|
|
|
|
void CommandCompletions::Registers(CommandInterpreter &interpreter,
|
|
|
|
CompletionRequest &request,
|
|
|
|
SearchFilter *searcher) {
|
|
|
|
std::string reg_prefix = "";
|
|
|
|
if (request.GetCursorArgumentPrefix().startswith("$"))
|
|
|
|
reg_prefix = "$";
|
|
|
|
|
|
|
|
RegisterContext *reg_ctx =
|
|
|
|
interpreter.GetExecutionContext().GetRegisterContext();
|
|
|
|
const size_t reg_num = reg_ctx->GetRegisterCount();
|
|
|
|
for (size_t reg_idx = 0; reg_idx < reg_num; ++reg_idx) {
|
|
|
|
const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex(reg_idx);
|
|
|
|
request.TryCompleteCurrentArg(reg_prefix + reg_info->name,
|
|
|
|
reg_info->alt_name);
|
|
|
|
}
|
2020-05-11 21:21:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CommandCompletions::Breakpoints(CommandInterpreter &interpreter,
|
|
|
|
CompletionRequest &request,
|
|
|
|
SearchFilter *searcher) {
|
|
|
|
lldb::TargetSP target = interpreter.GetDebugger().GetSelectedTarget();
|
|
|
|
if (!target)
|
|
|
|
return;
|
|
|
|
|
|
|
|
const BreakpointList &breakpoints = target->GetBreakpointList();
|
|
|
|
|
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
|
|
|
target->GetBreakpointList().GetListMutex(lock);
|
|
|
|
|
|
|
|
size_t num_breakpoints = breakpoints.GetSize();
|
|
|
|
if (num_breakpoints == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (size_t i = 0; i < num_breakpoints; ++i) {
|
|
|
|
lldb::BreakpointSP bp = breakpoints.GetBreakpointAtIndex(i);
|
|
|
|
|
|
|
|
StreamString s;
|
|
|
|
bp->GetDescription(&s, lldb::eDescriptionLevelBrief);
|
|
|
|
llvm::StringRef bp_info = s.GetString();
|
|
|
|
|
|
|
|
const size_t colon_pos = bp_info.find_first_of(':');
|
|
|
|
if (colon_pos != llvm::StringRef::npos)
|
|
|
|
bp_info = bp_info.drop_front(colon_pos + 2);
|
|
|
|
|
|
|
|
request.TryCompleteCurrentArg(std::to_string(bp->GetID()), bp_info);
|
|
|
|
}
|
|
|
|
}
|
2020-05-27 20:06:28 +08:00
|
|
|
|
|
|
|
void CommandCompletions::ProcessPluginNames(CommandInterpreter &interpreter,
|
|
|
|
CompletionRequest &request,
|
|
|
|
SearchFilter *searcher) {
|
|
|
|
PluginManager::AutoCompleteProcessName(request.GetCursorArgumentPrefix(),
|
|
|
|
request);
|
2020-08-11 15:59:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CommandCompletions::DisassemblyFlavors(CommandInterpreter &interpreter,
|
|
|
|
CompletionRequest &request,
|
|
|
|
SearchFilter *searcher) {
|
|
|
|
// Currently the only valid options for disassemble -F are default, and for
|
|
|
|
// Intel architectures, att and intel.
|
|
|
|
static const char *flavors[] = {"default", "att", "intel"};
|
|
|
|
for (const char *flavor : flavors) {
|
|
|
|
request.TryCompleteCurrentArg(flavor);
|
|
|
|
}
|
|
|
|
}
|
2020-08-11 16:32:55 +08:00
|
|
|
|
|
|
|
void CommandCompletions::TypeLanguages(CommandInterpreter &interpreter,
|
|
|
|
CompletionRequest &request,
|
|
|
|
SearchFilter *searcher) {
|
|
|
|
for (int bit :
|
|
|
|
Language::GetLanguagesSupportingTypeSystems().bitvector.set_bits()) {
|
|
|
|
request.TryCompleteCurrentArg(
|
|
|
|
Language::GetNameForLanguageType(static_cast<lldb::LanguageType>(bit)));
|
|
|
|
}
|
|
|
|
}
|
2020-08-11 18:20:43 +08:00
|
|
|
|
|
|
|
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());
|
|
|
|
}
|
|
|
|
}
|
2020-08-11 19:13:49 +08:00
|
|
|
|
|
|
|
void CommandCompletions::StopHookIDs(CommandInterpreter &interpreter,
|
|
|
|
CompletionRequest &request,
|
|
|
|
SearchFilter *searcher) {
|
|
|
|
const lldb::TargetSP target_sp =
|
|
|
|
interpreter.GetExecutionContext().GetTargetSP();
|
|
|
|
if (!target_sp)
|
|
|
|
return;
|
|
|
|
|
|
|
|
const size_t num = target_sp->GetNumStopHooks();
|
|
|
|
for (size_t idx = 0; idx < num; ++idx) {
|
|
|
|
StreamString strm;
|
|
|
|
// The value 11 is an offset to make the completion description looks
|
|
|
|
// neater.
|
|
|
|
strm.SetIndentLevel(11);
|
|
|
|
const Target::StopHookSP stophook_sp = target_sp->GetStopHookAtIndex(idx);
|
|
|
|
stophook_sp->GetDescription(&strm, lldb::eDescriptionLevelInitial);
|
|
|
|
request.TryCompleteCurrentArg(std::to_string(stophook_sp->GetID()),
|
|
|
|
strm.GetString());
|
|
|
|
}
|
|
|
|
}
|