1 //===-- OptionValueArch.cpp ---------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lldb/Interpreter/OptionValueArch.h"
14 // Other libraries and framework 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"
23 using namespace lldb_private;
25 void OptionValueArch::DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
27 if (dump_mask & eDumpOptionType)
28 strm.Printf("(%s)", GetTypeAsCString());
29 if (dump_mask & eDumpOptionValue) {
30 if (dump_mask & eDumpOptionType)
31 strm.PutCString(" = ");
33 if (m_current_value.IsValid()) {
34 const char *arch_name = m_current_value.GetArchitectureName();
36 strm.PutCString(arch_name);
41 Status OptionValueArch::SetValueFromString(llvm::StringRef value,
42 VarSetOperationType op) {
45 case eVarSetOperationClear:
50 case eVarSetOperationReplace:
51 case eVarSetOperationAssign: {
52 std::string value_str = value.trim().str();
53 if (m_current_value.SetTriple(value_str.c_str())) {
54 m_value_was_set = true;
57 error.SetErrorStringWithFormat("unsupported architecture '%s'",
61 case eVarSetOperationInsertBefore:
62 case eVarSetOperationInsertAfter:
63 case eVarSetOperationRemove:
64 case eVarSetOperationAppend:
65 case eVarSetOperationInvalid:
66 error = OptionValue::SetValueFromString(value, op);
72 lldb::OptionValueSP OptionValueArch::DeepCopy() const {
73 return OptionValueSP(new OptionValueArch(*this));
76 size_t OptionValueArch::AutoComplete(CommandInterpreter &interpreter,
77 llvm::StringRef s, int match_start_point,
78 int max_return_elements,
79 bool &word_complete, StringList &matches) {
80 word_complete = false;
82 CommandCompletions::InvokeCommonCompletionCallbacks(
83 interpreter, CommandCompletions::eArchitectureCompletion, s,
84 match_start_point, max_return_elements, nullptr, word_complete, matches);
85 return matches.GetSize();