summaryrefslogtreecommitdiff
path: root/source/Interpreter/OptionValueUUID.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2018-07-28 11:09:23 +0000
committerDimitry Andric <dim@FreeBSD.org>2018-07-28 11:09:23 +0000
commitf73363f1dd94996356cefbf24388f561891acf0b (patch)
treee3c31248bdb36eaec5fd833490d4278162dba2a0 /source/Interpreter/OptionValueUUID.cpp
parent160ee69dd7ae18978f4068116777639ea98dc951 (diff)
Notes
Diffstat (limited to 'source/Interpreter/OptionValueUUID.cpp')
-rw-r--r--source/Interpreter/OptionValueUUID.cpp36
1 files changed, 13 insertions, 23 deletions
diff --git a/source/Interpreter/OptionValueUUID.cpp b/source/Interpreter/OptionValueUUID.cpp
index bec04cba8c376..7fa155277cecb 100644
--- a/source/Interpreter/OptionValueUUID.cpp
+++ b/source/Interpreter/OptionValueUUID.cpp
@@ -43,7 +43,7 @@ Status OptionValueUUID::SetValueFromString(llvm::StringRef value,
case eVarSetOperationReplace:
case eVarSetOperationAssign: {
- if (m_uuid.SetFromCString(value.str().c_str()) == 0)
+ if (m_uuid.SetFromStringRef(value) == 0)
error.SetErrorStringWithFormat("invalid uuid string value '%s'",
value.str().c_str());
else {
@@ -68,40 +68,30 @@ lldb::OptionValueSP OptionValueUUID::DeepCopy() const {
}
size_t OptionValueUUID::AutoComplete(CommandInterpreter &interpreter,
- llvm::StringRef s, int match_start_point,
- int max_return_elements,
- bool &word_complete, StringList &matches) {
- word_complete = false;
- matches.Clear();
+ CompletionRequest &request) {
+ request.SetWordComplete(false);
+ request.GetMatches().Clear();
ExecutionContext exe_ctx(interpreter.GetExecutionContext());
Target *target = exe_ctx.GetTargetPtr();
if (target) {
- const size_t num_modules = target->GetImages().GetSize();
- if (num_modules > 0) {
- UUID::ValueType uuid_bytes;
- uint32_t num_bytes_decoded = 0;
- UUID::DecodeUUIDBytesFromString(s, uuid_bytes, num_bytes_decoded);
+ auto prefix = request.GetCursorArgumentPrefix();
+ llvm::SmallVector<uint8_t, 20> uuid_bytes;
+ if (UUID::DecodeUUIDBytesFromString(prefix, uuid_bytes).empty()) {
+ const size_t num_modules = target->GetImages().GetSize();
for (size_t i = 0; i < num_modules; ++i) {
ModuleSP module_sp(target->GetImages().GetModuleAtIndex(i));
if (module_sp) {
const UUID &module_uuid = module_sp->GetUUID();
if (module_uuid.IsValid()) {
- bool add_uuid = false;
- if (num_bytes_decoded == 0)
- add_uuid = true;
- else
- add_uuid = ::memcmp(module_uuid.GetBytes(), uuid_bytes,
- num_bytes_decoded) == 0;
- if (add_uuid) {
- std::string uuid_str;
- uuid_str = module_uuid.GetAsString();
- if (!uuid_str.empty())
- matches.AppendString(uuid_str.c_str());
+ llvm::ArrayRef<uint8_t> module_bytes = module_uuid.GetBytes();
+ if (module_bytes.size() >= uuid_bytes.size() &&
+ module_bytes.take_front(uuid_bytes.size()).equals(uuid_bytes)) {
+ request.GetMatches().AppendString(module_uuid.GetAsString());
}
}
}
}
}
}
- return matches.GetSize();
+ return request.GetMatches().GetSize();
}