2020-01-24 08:23:27 +01:00
|
|
|
//===-- OptionValueArch.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/OptionValueArch.h"
|
|
|
|
|
|
2013-01-28 23:47:25 +00:00
|
|
|
#include "lldb/DataFormatters/FormatManager.h"
|
2012-08-22 17:17:09 +00:00
|
|
|
#include "lldb/Interpreter/CommandCompletions.h"
|
2016-08-11 23:51:28 +00:00
|
|
|
#include "lldb/Interpreter/CommandInterpreter.h"
|
2018-04-17 18:53:35 +00:00
|
|
|
#include "lldb/Utility/Args.h"
|
2018-08-07 11:07:21 +00:00
|
|
|
#include "lldb/Utility/State.h"
|
2012-08-22 17:17:09 +00:00
|
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
|
|
void OptionValueArch::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(" = ");
|
|
|
|
|
|
|
|
|
|
if (m_current_value.IsValid()) {
|
|
|
|
|
const char *arch_name = m_current_value.GetArchitectureName();
|
|
|
|
|
if (arch_name)
|
|
|
|
|
strm.PutCString(arch_name);
|
|
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2012-08-22 17:17:09 +00:00
|
|
|
}
|
|
|
|
|
|
2017-05-12 04:51:55 +00:00
|
|
|
Status OptionValueArch::SetValueFromString(llvm::StringRef value,
|
|
|
|
|
VarSetOperationType op) {
|
|
|
|
|
Status error;
|
2012-08-22 17:17:09 +00:00
|
|
|
switch (op) {
|
|
|
|
|
case eVarSetOperationClear:
|
|
|
|
|
Clear();
|
2015-01-13 21:13:08 +00:00
|
|
|
NotifyValueChanged();
|
2012-08-22 17:17:09 +00:00
|
|
|
break;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2012-08-22 17:17:09 +00:00
|
|
|
case eVarSetOperationReplace:
|
|
|
|
|
case eVarSetOperationAssign: {
|
2015-02-20 11:14:59 +00:00
|
|
|
std::string value_str = value.trim().str();
|
|
|
|
|
if (m_current_value.SetTriple(value_str.c_str())) {
|
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
|
|
|
} else
|
2015-02-20 11:14:59 +00:00
|
|
|
error.SetErrorStringWithFormat("unsupported architecture '%s'",
|
|
|
|
|
value_str.c_str());
|
|
|
|
|
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);
|
2012-08-22 17:17:09 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lldb::OptionValueSP OptionValueArch::DeepCopy() const {
|
|
|
|
|
return OptionValueSP(new OptionValueArch(*this));
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-22 07:41:23 +00:00
|
|
|
void OptionValueArch::AutoComplete(CommandInterpreter &interpreter,
|
|
|
|
|
CompletionRequest &request) {
|
2012-08-22 17:17:09 +00:00
|
|
|
CommandCompletions::InvokeCommonCompletionCallbacks(
|
2018-07-13 18:28:14 +00:00
|
|
|
interpreter, CommandCompletions::eArchitectureCompletion, request,
|
|
|
|
|
nullptr);
|
2012-08-22 17:17:09 +00:00
|
|
|
}
|