2012-08-23 01:17:09 +08:00
|
|
|
//===-- OptionValueArch.cpp ---------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "lldb/Interpreter/OptionValueArch.h"
|
|
|
|
|
|
|
|
// C Includes
|
|
|
|
// C++ Includes
|
|
|
|
// Other libraries and framework includes
|
|
|
|
// Project includes
|
|
|
|
#include "lldb/Core/State.h"
|
2013-01-29 07:47:25 +08:00
|
|
|
#include "lldb/DataFormatters/FormatManager.h"
|
2012-08-23 01:17:09 +08:00
|
|
|
#include "lldb/Interpreter/CommandCompletions.h"
|
2016-08-12 07:51:28 +08:00
|
|
|
#include "lldb/Interpreter/CommandInterpreter.h"
|
2018-04-18 02:53:35 +08:00
|
|
|
#include "lldb/Utility/Args.h"
|
2012-08-23 01:17:09 +08:00
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
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) {
|
2012-08-23 01:17:09 +08:00
|
|
|
if (dump_mask & eDumpOptionType)
|
2016-09-07 04:57:50 +08:00
|
|
|
strm.PutCString(" = ");
|
2012-08-23 01:17:09 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (m_current_value.IsValid()) {
|
|
|
|
const char *arch_name = m_current_value.GetArchitectureName();
|
|
|
|
if (arch_name)
|
|
|
|
strm.PutCString(arch_name);
|
2012-08-23 01:17:09 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2012-08-23 01:17:09 +08:00
|
|
|
}
|
|
|
|
|
2017-05-12 12:51:55 +08:00
|
|
|
Status OptionValueArch::SetValueFromString(llvm::StringRef value,
|
|
|
|
VarSetOperationType op) {
|
|
|
|
Status error;
|
2016-09-07 04:57:50 +08:00
|
|
|
switch (op) {
|
|
|
|
case eVarSetOperationClear:
|
|
|
|
Clear();
|
|
|
|
NotifyValueChanged();
|
|
|
|
break;
|
2012-08-23 01:17:09 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
case eVarSetOperationReplace:
|
|
|
|
case eVarSetOperationAssign: {
|
|
|
|
std::string value_str = value.trim().str();
|
|
|
|
if (m_current_value.SetTriple(value_str.c_str())) {
|
|
|
|
m_value_was_set = true;
|
|
|
|
NotifyValueChanged();
|
|
|
|
} else
|
|
|
|
error.SetErrorStringWithFormat("unsupported architecture '%s'",
|
|
|
|
value_str.c_str());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case eVarSetOperationInsertBefore:
|
|
|
|
case eVarSetOperationInsertAfter:
|
|
|
|
case eVarSetOperationRemove:
|
|
|
|
case eVarSetOperationAppend:
|
|
|
|
case eVarSetOperationInvalid:
|
|
|
|
error = OptionValue::SetValueFromString(value, op);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return error;
|
2012-08-23 01:17:09 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
lldb::OptionValueSP OptionValueArch::DeepCopy() const {
|
|
|
|
return OptionValueSP(new OptionValueArch(*this));
|
2012-08-23 01:17:09 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
size_t OptionValueArch::AutoComplete(CommandInterpreter &interpreter,
|
2018-07-14 02:28:14 +08:00
|
|
|
CompletionRequest &request) {
|
|
|
|
request.SetWordComplete(false);
|
2016-09-07 04:57:50 +08:00
|
|
|
CommandCompletions::InvokeCommonCompletionCallbacks(
|
2018-07-14 02:28:14 +08:00
|
|
|
interpreter, CommandCompletions::eArchitectureCompletion, request,
|
|
|
|
nullptr);
|
2018-07-28 02:42:46 +08:00
|
|
|
return request.GetNumberOfMatches();
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|