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