blob: 45b9a9e07d9e0f7f1e4fc6b61f9f459325a4550a [file] [log] [blame]
Greg Clayton67cc0632012-08-22 17:17:09 +00001//===-- 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
Daniel Malea93a64302012-12-05 00:20:57 +000010#include "lldb/lldb-python.h"
11
Greg Clayton67cc0632012-08-22 17:17:09 +000012#include "lldb/Interpreter/OptionValueArch.h"
13
14// C Includes
15// C++ Includes
16// Other libraries and framework includes
17// Project includes
Greg Clayton67cc0632012-08-22 17:17:09 +000018#include "lldb/Core/State.h"
Enrico Granata5548cb52013-01-28 23:47:25 +000019#include "lldb/DataFormatters/FormatManager.h"
Greg Clayton67cc0632012-08-22 17:17:09 +000020#include "lldb/Interpreter/Args.h"
21#include "lldb/Interpreter/CommandCompletions.h"
22
23using namespace lldb;
24using namespace lldb_private;
25
26void
27OptionValueArch::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
45Error
Pavel Labathc95f7e22015-02-20 11:14:59 +000046OptionValueArch::SetValueFromString (llvm::StringRef value, VarSetOperationType op)
Greg Clayton67cc0632012-08-22 17:17:09 +000047{
48 Error error;
49 switch (op)
50 {
51 case eVarSetOperationClear:
52 Clear();
Greg Clayton332e8b12015-01-13 21:13:08 +000053 NotifyValueChanged();
Greg Clayton67cc0632012-08-22 17:17:09 +000054 break;
55
56 case eVarSetOperationReplace:
57 case eVarSetOperationAssign:
Greg Clayton67cc0632012-08-22 17:17:09 +000058 {
Pavel Labathc95f7e22015-02-20 11:14:59 +000059 std::string value_str = value.trim().str();
60 if (m_current_value.SetTriple (value_str.c_str()))
Greg Clayton332e8b12015-01-13 21:13:08 +000061 {
Greg Clayton67cc0632012-08-22 17:17:09 +000062 m_value_was_set = true;
Greg Clayton332e8b12015-01-13 21:13:08 +000063 NotifyValueChanged();
64 }
Greg Clayton67cc0632012-08-22 17:17:09 +000065 else
Pavel Labathc95f7e22015-02-20 11:14:59 +000066 error.SetErrorStringWithFormat("unsupported architecture '%s'", value_str.c_str());
67 break;
Greg Clayton67cc0632012-08-22 17:17:09 +000068 }
Greg Clayton67cc0632012-08-22 17:17:09 +000069 case eVarSetOperationInsertBefore:
70 case eVarSetOperationInsertAfter:
71 case eVarSetOperationRemove:
72 case eVarSetOperationAppend:
73 case eVarSetOperationInvalid:
Pavel Labathc95f7e22015-02-20 11:14:59 +000074 error = OptionValue::SetValueFromString (value, op);
Greg Clayton67cc0632012-08-22 17:17:09 +000075 break;
76 }
77 return error;
78}
79
80lldb::OptionValueSP
81OptionValueArch::DeepCopy () const
82{
83 return OptionValueSP(new OptionValueArch(*this));
84}
85
86
87size_t
88OptionValueArch::AutoComplete (CommandInterpreter &interpreter,
89 const char *s,
90 int match_start_point,
91 int max_return_elements,
92 bool &word_complete,
93 StringList &matches)
94{
95 word_complete = false;
96 matches.Clear();
97 CommandCompletions::InvokeCommonCompletionCallbacks (interpreter,
98 CommandCompletions::eArchitectureCompletion,
99 s,
100 match_start_point,
101 max_return_elements,
Ed Masted78c9572014-04-20 00:31:37 +0000102 nullptr,
Greg Clayton67cc0632012-08-22 17:17:09 +0000103 word_complete,
104 matches);
105 return matches.GetSize();
106}
107
108
109
110