2020-01-24 08:23:27 +01:00
|
|
|
//===-- OptionValueUUID.cpp -----------------------------------------------===//
|
2012-08-22 17:17:09 +00:00
|
|
|
//
|
2019-01-19 08:50:56 +00: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
|
2012-08-22 17:17:09 +00:00
|
|
|
//
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
|
|
#include "lldb/Interpreter/OptionValueUUID.h"
|
|
|
|
|
|
2012-09-27 22:26:11 +00:00
|
|
|
#include "lldb/Core/Module.h"
|
|
|
|
|
#include "lldb/Interpreter/CommandInterpreter.h"
|
2017-02-02 21:39:50 +00:00
|
|
|
#include "lldb/Utility/Stream.h"
|
2017-03-21 18:25:04 +00:00
|
|
|
#include "lldb/Utility/StringList.h"
|
2012-08-22 17:17:09 +00:00
|
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
|
|
void OptionValueUUID::DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
|
|
|
|
|
uint32_t dump_mask) {
|
|
|
|
|
if (dump_mask & eDumpOptionType)
|
|
|
|
|
strm.Printf("(%s)", GetTypeAsCString());
|
|
|
|
|
if (dump_mask & eDumpOptionValue) {
|
|
|
|
|
if (dump_mask & eDumpOptionType)
|
|
|
|
|
strm.PutCString(" = ");
|
|
|
|
|
m_uuid.Dump(&strm);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-12 04:51:55 +00:00
|
|
|
Status OptionValueUUID::SetValueFromString(llvm::StringRef value,
|
|
|
|
|
VarSetOperationType op) {
|
|
|
|
|
Status error;
|
2012-08-22 17:17:09 +00:00
|
|
|
switch (op) {
|
|
|
|
|
case eVarSetOperationClear:
|
2016-09-06 20:57:50 +00:00
|
|
|
Clear();
|
2015-01-13 21:13:08 +00:00
|
|
|
NotifyValueChanged();
|
2016-09-06 20:57:50 +00:00
|
|
|
break;
|
|
|
|
|
|
2012-08-22 17:17:09 +00:00
|
|
|
case eVarSetOperationReplace:
|
|
|
|
|
case eVarSetOperationAssign: {
|
2020-06-01 20:43:18 +00:00
|
|
|
if (!m_uuid.SetFromStringRef(value))
|
2015-02-20 11:14:59 +00:00
|
|
|
error.SetErrorStringWithFormat("invalid uuid string value '%s'",
|
|
|
|
|
value.str().c_str());
|
2016-09-06 20:57:50 +00:00
|
|
|
else {
|
2012-08-22 17:17:09 +00:00
|
|
|
m_value_was_set = true;
|
2015-01-13 21:13:08 +00:00
|
|
|
NotifyValueChanged();
|
2012-08-22 17:17:09 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
} break;
|
|
|
|
|
|
2012-08-22 17:17:09 +00:00
|
|
|
case eVarSetOperationInsertBefore:
|
|
|
|
|
case eVarSetOperationInsertAfter:
|
|
|
|
|
case eVarSetOperationRemove:
|
|
|
|
|
case eVarSetOperationAppend:
|
|
|
|
|
case eVarSetOperationInvalid:
|
2015-02-20 11:14:59 +00:00
|
|
|
error = OptionValue::SetValueFromString(value, op);
|
2016-09-06 20:57:50 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2012-08-22 17:17:09 +00:00
|
|
|
return error;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-20 11:14:59 +00:00
|
|
|
lldb::OptionValueSP OptionValueUUID::DeepCopy() const {
|
|
|
|
|
return OptionValueSP(new OptionValueUUID(*this));
|
2012-08-22 17:17:09 +00:00
|
|
|
}
|
|
|
|
|
|
2019-08-22 07:41:23 +00:00
|
|
|
void OptionValueUUID::AutoComplete(CommandInterpreter &interpreter,
|
|
|
|
|
CompletionRequest &request) {
|
2012-09-27 22:26:11 +00:00
|
|
|
ExecutionContext exe_ctx(interpreter.GetExecutionContext());
|
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
2019-08-22 09:02:54 +00:00
|
|
|
if (!target)
|
|
|
|
|
return;
|
|
|
|
|
auto prefix = request.GetCursorArgumentPrefix();
|
|
|
|
|
llvm::SmallVector<uint8_t, 20> uuid_bytes;
|
|
|
|
|
if (!UUID::DecodeUUIDBytesFromString(prefix, uuid_bytes).empty())
|
|
|
|
|
return;
|
|
|
|
|
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)
|
|
|
|
|
continue;
|
|
|
|
|
const UUID &module_uuid = module_sp->GetUUID();
|
|
|
|
|
if (!module_uuid.IsValid())
|
|
|
|
|
continue;
|
2019-09-23 08:59:21 +00:00
|
|
|
request.TryCompleteCurrentArg(module_uuid.GetAsString());
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2012-09-27 22:26:11 +00:00
|
|
|
}
|