143000Simp//===-- OptionValueArch.cpp ---------------------------------*- C++ -*-===// 243000Simp// 350477Speter// The LLVM Compiler Infrastructure 443000Simp// 577980Sache// This file is distributed under the University of Illinois Open Source 643000Simp// License. See LICENSE.TXT for details. 743000Simp// 843000Simp//===----------------------------------------------------------------------===// 943000Simp 1043000Simp#include "lldb/lldb-python.h" 1143000Simp 1243000Simp#include "lldb/Interpreter/OptionValueArch.h" 1343000Simp 1443000Simp// C Includes 1543000Simp// C++ Includes 1643000Simp// Other libraries and framework includes 1743000Simp// Project includes 1843000Simp#include "lldb/Core/State.h" 1943000Simp#include "lldb/DataFormatters/FormatManager.h" 2043000Simp#include "lldb/Interpreter/Args.h" 2143000Simp#include "lldb/Interpreter/CommandCompletions.h" 2243000Simp 2343000Simpusing namespace lldb; 2443000Simpusing namespace lldb_private; 2543000Simp 2643000Simpvoid 2743000SimpOptionValueArch::DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) 2843000Simp{ 2943000Simp if (dump_mask & eDumpOptionType) 3043000Simp strm.Printf ("(%s)", GetTypeAsCString ()); 3143000Simp if (dump_mask & eDumpOptionValue) 3243000Simp { 3343000Simp if (dump_mask & eDumpOptionType) 3443000Simp strm.PutCString (" = "); 3543000Simp 3643000Simp if (m_current_value.IsValid()) 3743000Simp { 3843000Simp const char *arch_name = m_current_value.GetArchitectureName(); 39 if (arch_name) 40 strm.PutCString (arch_name); 41 } 42 } 43} 44 45Error 46OptionValueArch::SetValueFromCString (const char *value_cstr, VarSetOperationType op) 47{ 48 Error error; 49 switch (op) 50 { 51 case eVarSetOperationClear: 52 Clear(); 53 break; 54 55 case eVarSetOperationReplace: 56 case eVarSetOperationAssign: 57 if (value_cstr && value_cstr[0]) 58 { 59 if (m_current_value.SetTriple (value_cstr)) 60 m_value_was_set = true; 61 else 62 error.SetErrorStringWithFormat("unsupported architecture '%s'", value_cstr); 63 } 64 else 65 { 66 error.SetErrorString("invalid value string"); 67 } 68 break; 69 70 case eVarSetOperationInsertBefore: 71 case eVarSetOperationInsertAfter: 72 case eVarSetOperationRemove: 73 case eVarSetOperationAppend: 74 case eVarSetOperationInvalid: 75 error = OptionValue::SetValueFromCString (value_cstr, op); 76 break; 77 } 78 return error; 79} 80 81lldb::OptionValueSP 82OptionValueArch::DeepCopy () const 83{ 84 return OptionValueSP(new OptionValueArch(*this)); 85} 86 87 88size_t 89OptionValueArch::AutoComplete (CommandInterpreter &interpreter, 90 const char *s, 91 int match_start_point, 92 int max_return_elements, 93 bool &word_complete, 94 StringList &matches) 95{ 96 word_complete = false; 97 matches.Clear(); 98 CommandCompletions::InvokeCommonCompletionCallbacks (interpreter, 99 CommandCompletions::eArchitectureCompletion, 100 s, 101 match_start_point, 102 max_return_elements, 103 NULL, 104 word_complete, 105 matches); 106 return matches.GetSize(); 107} 108 109 110 111 112