blob: 7df149234bda60138f94aab79597444d46b9daed [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
46OptionValueArch::SetValueFromCString (const char *value_cstr, VarSetOperationType op)
47{
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:
58 if (value_cstr && value_cstr[0])
59 {
60 if (m_current_value.SetTriple (value_cstr))
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
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
85lldb::OptionValueSP
86OptionValueArch::DeepCopy () const
87{
88 return OptionValueSP(new OptionValueArch(*this));
89}
90
91
92size_t
93OptionValueArch::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,
Ed Masted78c9572014-04-20 00:31:37 +0000107 nullptr,
Greg Clayton67cc0632012-08-22 17:17:09 +0000108 word_complete,
109 matches);
110 return matches.GetSize();
111}
112
113
114
115