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 // C Includes 13 // C++ Includes 14 // Other libraries and framework includes 15 // Project includes 16 #include "lldb/Core/State.h" 17 #include "lldb/DataFormatters/FormatManager.h" 18 #include "lldb/Interpreter/Args.h" 19 #include "lldb/Interpreter/CommandCompletions.h" 20 21 using namespace lldb; 22 using namespace lldb_private; 23 24 void 25 OptionValueArch::DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) 26 { 27 if (dump_mask & eDumpOptionType) 28 strm.Printf ("(%s)", GetTypeAsCString ()); 29 if (dump_mask & eDumpOptionValue) 30 { 31 if (dump_mask & eDumpOptionType) 32 strm.PutCString (" = "); 33 34 if (m_current_value.IsValid()) 35 { 36 const char *arch_name = m_current_value.GetArchitectureName(); 37 if (arch_name) 38 strm.PutCString (arch_name); 39 } 40 } 41 } 42 43 Error 44 OptionValueArch::SetValueFromString (llvm::StringRef value, VarSetOperationType op) 45 { 46 Error error; 47 switch (op) 48 { 49 case eVarSetOperationClear: 50 Clear(); 51 NotifyValueChanged(); 52 break; 53 54 case eVarSetOperationReplace: 55 case eVarSetOperationAssign: 56 { 57 std::string value_str = value.trim().str(); 58 if (m_current_value.SetTriple (value_str.c_str())) 59 { 60 m_value_was_set = true; 61 NotifyValueChanged(); 62 } 63 else 64 error.SetErrorStringWithFormat("unsupported architecture '%s'", value_str.c_str()); 65 break; 66 } 67 case eVarSetOperationInsertBefore: 68 case eVarSetOperationInsertAfter: 69 case eVarSetOperationRemove: 70 case eVarSetOperationAppend: 71 case eVarSetOperationInvalid: 72 error = OptionValue::SetValueFromString (value, op); 73 break; 74 } 75 return error; 76 } 77 78 lldb::OptionValueSP 79 OptionValueArch::DeepCopy () const 80 { 81 return OptionValueSP(new OptionValueArch(*this)); 82 } 83 84 85 size_t 86 OptionValueArch::AutoComplete (CommandInterpreter &interpreter, 87 const char *s, 88 int match_start_point, 89 int max_return_elements, 90 bool &word_complete, 91 StringList &matches) 92 { 93 word_complete = false; 94 matches.Clear(); 95 CommandCompletions::InvokeCommonCompletionCallbacks (interpreter, 96 CommandCompletions::eArchitectureCompletion, 97 s, 98 match_start_point, 99 max_return_elements, 100 nullptr, 101 word_complete, 102 matches); 103 return matches.GetSize(); 104 } 105 106 107 108 109