1 //===-- OptionValueArch.cpp ---------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #include "lldb/Interpreter/OptionValueArch.h" 11 12 #include "lldb/DataFormatters/FormatManager.h" 13 #include "lldb/Interpreter/CommandCompletions.h" 14 #include "lldb/Interpreter/CommandInterpreter.h" 15 #include "lldb/Utility/Args.h" 16 #include "lldb/Utility/State.h" 17 18 using namespace lldb; 19 using namespace lldb_private; 20 21 void OptionValueArch::DumpValue(const ExecutionContext *exe_ctx, Stream &strm, 22 uint32_t dump_mask) { 23 if (dump_mask & eDumpOptionType) 24 strm.Printf("(%s)", GetTypeAsCString()); 25 if (dump_mask & eDumpOptionValue) { 26 if (dump_mask & eDumpOptionType) 27 strm.PutCString(" = "); 28 29 if (m_current_value.IsValid()) { 30 const char *arch_name = m_current_value.GetArchitectureName(); 31 if (arch_name) 32 strm.PutCString(arch_name); 33 } 34 } 35 } 36 37 Status OptionValueArch::SetValueFromString(llvm::StringRef value, 38 VarSetOperationType op) { 39 Status error; 40 switch (op) { 41 case eVarSetOperationClear: 42 Clear(); 43 NotifyValueChanged(); 44 break; 45 46 case eVarSetOperationReplace: 47 case eVarSetOperationAssign: { 48 std::string value_str = value.trim().str(); 49 if (m_current_value.SetTriple(value_str.c_str())) { 50 m_value_was_set = true; 51 NotifyValueChanged(); 52 } else 53 error.SetErrorStringWithFormat("unsupported architecture '%s'", 54 value_str.c_str()); 55 break; 56 } 57 case eVarSetOperationInsertBefore: 58 case eVarSetOperationInsertAfter: 59 case eVarSetOperationRemove: 60 case eVarSetOperationAppend: 61 case eVarSetOperationInvalid: 62 error = OptionValue::SetValueFromString(value, op); 63 break; 64 } 65 return error; 66 } 67 68 lldb::OptionValueSP OptionValueArch::DeepCopy() const { 69 return OptionValueSP(new OptionValueArch(*this)); 70 } 71 72 size_t OptionValueArch::AutoComplete(CommandInterpreter &interpreter, 73 CompletionRequest &request) { 74 request.SetWordComplete(false); 75 CommandCompletions::InvokeCommonCompletionCallbacks( 76 interpreter, CommandCompletions::eArchitectureCompletion, request, 77 nullptr); 78 return request.GetNumberOfMatches(); 79 } 80