Path: blob/main/contrib/llvm-project/lldb/source/Interpreter/OptionValueArch.cpp
39587 views
//===-- OptionValueArch.cpp -----------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "lldb/Interpreter/OptionValueArch.h"910#include "lldb/DataFormatters/FormatManager.h"11#include "lldb/Interpreter/CommandCompletions.h"12#include "lldb/Interpreter/CommandInterpreter.h"13#include "lldb/Utility/Args.h"14#include "lldb/Utility/State.h"1516using namespace lldb;17using namespace lldb_private;1819void OptionValueArch::DumpValue(const ExecutionContext *exe_ctx, Stream &strm,20uint32_t dump_mask) {21if (dump_mask & eDumpOptionType)22strm.Printf("(%s)", GetTypeAsCString());23if (dump_mask & eDumpOptionValue) {24if (dump_mask & eDumpOptionType)25strm.PutCString(" = ");2627if (m_current_value.IsValid()) {28const char *arch_name = m_current_value.GetArchitectureName();29if (arch_name)30strm.PutCString(arch_name);31}32}33}3435Status OptionValueArch::SetValueFromString(llvm::StringRef value,36VarSetOperationType op) {37Status error;38switch (op) {39case eVarSetOperationClear:40Clear();41NotifyValueChanged();42break;4344case eVarSetOperationReplace:45case eVarSetOperationAssign: {46std::string value_str = value.trim().str();47if (m_current_value.SetTriple(value_str.c_str())) {48m_value_was_set = true;49NotifyValueChanged();50} else51error.SetErrorStringWithFormat("unsupported architecture '%s'",52value_str.c_str());53break;54}55case eVarSetOperationInsertBefore:56case eVarSetOperationInsertAfter:57case eVarSetOperationRemove:58case eVarSetOperationAppend:59case eVarSetOperationInvalid:60error = OptionValue::SetValueFromString(value, op);61break;62}63return error;64}6566void OptionValueArch::AutoComplete(CommandInterpreter &interpreter,67CompletionRequest &request) {68lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(69interpreter, lldb::eArchitectureCompletion, request, nullptr);70}717273