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