OptionValueArch.cpp revision 321369
1254721Semaste//===-- OptionValueArch.cpp ---------------------------------*- C++ -*-===// 2254721Semaste// 3254721Semaste// The LLVM Compiler Infrastructure 4254721Semaste// 5254721Semaste// This file is distributed under the University of Illinois Open Source 6254721Semaste// License. See LICENSE.TXT for details. 7254721Semaste// 8254721Semaste//===----------------------------------------------------------------------===// 9254721Semaste 10254721Semaste#include "lldb/Interpreter/OptionValueArch.h" 11254721Semaste 12254721Semaste// C Includes 13254721Semaste// C++ Includes 14254721Semaste// Other libraries and framework includes 15254721Semaste// Project includes 16254721Semaste#include "lldb/Core/State.h" 17254721Semaste#include "lldb/DataFormatters/FormatManager.h" 18254721Semaste#include "lldb/Interpreter/Args.h" 19254721Semaste#include "lldb/Interpreter/CommandCompletions.h" 20314564Sdim#include "lldb/Interpreter/CommandInterpreter.h" 21254721Semaste 22254721Semasteusing namespace lldb; 23254721Semasteusing namespace lldb_private; 24254721Semaste 25314564Sdimvoid OptionValueArch::DumpValue(const ExecutionContext *exe_ctx, Stream &strm, 26314564Sdim uint32_t dump_mask) { 27314564Sdim if (dump_mask & eDumpOptionType) 28314564Sdim strm.Printf("(%s)", GetTypeAsCString()); 29314564Sdim if (dump_mask & eDumpOptionValue) { 30254721Semaste if (dump_mask & eDumpOptionType) 31314564Sdim strm.PutCString(" = "); 32254721Semaste 33314564Sdim if (m_current_value.IsValid()) { 34314564Sdim const char *arch_name = m_current_value.GetArchitectureName(); 35314564Sdim if (arch_name) 36314564Sdim strm.PutCString(arch_name); 37254721Semaste } 38314564Sdim } 39254721Semaste} 40254721Semaste 41321369SdimStatus OptionValueArch::SetValueFromString(llvm::StringRef value, 42321369Sdim VarSetOperationType op) { 43321369Sdim Status error; 44314564Sdim switch (op) { 45314564Sdim case eVarSetOperationClear: 46314564Sdim Clear(); 47314564Sdim NotifyValueChanged(); 48314564Sdim break; 49314564Sdim 50314564Sdim case eVarSetOperationReplace: 51314564Sdim case eVarSetOperationAssign: { 52314564Sdim std::string value_str = value.trim().str(); 53314564Sdim if (m_current_value.SetTriple(value_str.c_str())) { 54314564Sdim m_value_was_set = true; 55314564Sdim NotifyValueChanged(); 56314564Sdim } else 57314564Sdim error.SetErrorStringWithFormat("unsupported architecture '%s'", 58314564Sdim value_str.c_str()); 59314564Sdim break; 60314564Sdim } 61314564Sdim case eVarSetOperationInsertBefore: 62314564Sdim case eVarSetOperationInsertAfter: 63314564Sdim case eVarSetOperationRemove: 64314564Sdim case eVarSetOperationAppend: 65314564Sdim case eVarSetOperationInvalid: 66314564Sdim error = OptionValue::SetValueFromString(value, op); 67314564Sdim break; 68314564Sdim } 69314564Sdim return error; 70254721Semaste} 71254721Semaste 72314564Sdimlldb::OptionValueSP OptionValueArch::DeepCopy() const { 73314564Sdim return OptionValueSP(new OptionValueArch(*this)); 74254721Semaste} 75254721Semaste 76314564Sdimsize_t OptionValueArch::AutoComplete(CommandInterpreter &interpreter, 77314564Sdim llvm::StringRef s, int match_start_point, 78314564Sdim int max_return_elements, 79314564Sdim bool &word_complete, StringList &matches) { 80314564Sdim word_complete = false; 81314564Sdim matches.Clear(); 82314564Sdim CommandCompletions::InvokeCommonCompletionCallbacks( 83314564Sdim interpreter, CommandCompletions::eArchitectureCompletion, s, 84314564Sdim match_start_point, max_return_elements, nullptr, word_complete, matches); 85314564Sdim return matches.GetSize(); 86254721Semaste} 87