]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/Interpreter/OptionValueArch.cpp
Merge latest version of blacklist sources from NetBSD (@ 20170503)
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / source / Interpreter / OptionValueArch.cpp
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/Interpreter/OptionValueArch.h"
11
12 // C Includes
13 // C++ Includes
14 // Other libraries and framework includes
15 // Project 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"
21
22 using namespace lldb;
23 using namespace lldb_private;
24
25 void OptionValueArch::DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
26                                 uint32_t dump_mask) {
27   if (dump_mask & eDumpOptionType)
28     strm.Printf("(%s)", GetTypeAsCString());
29   if (dump_mask & eDumpOptionValue) {
30     if (dump_mask & eDumpOptionType)
31       strm.PutCString(" = ");
32
33     if (m_current_value.IsValid()) {
34       const char *arch_name = m_current_value.GetArchitectureName();
35       if (arch_name)
36         strm.PutCString(arch_name);
37     }
38   }
39 }
40
41 Error OptionValueArch::SetValueFromString(llvm::StringRef value,
42                                           VarSetOperationType op) {
43   Error error;
44   switch (op) {
45   case eVarSetOperationClear:
46     Clear();
47     NotifyValueChanged();
48     break;
49
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;
55       NotifyValueChanged();
56     } else
57       error.SetErrorStringWithFormat("unsupported architecture '%s'",
58                                      value_str.c_str());
59     break;
60   }
61   case eVarSetOperationInsertBefore:
62   case eVarSetOperationInsertAfter:
63   case eVarSetOperationRemove:
64   case eVarSetOperationAppend:
65   case eVarSetOperationInvalid:
66     error = OptionValue::SetValueFromString(value, op);
67     break;
68   }
69   return error;
70 }
71
72 lldb::OptionValueSP OptionValueArch::DeepCopy() const {
73   return OptionValueSP(new OptionValueArch(*this));
74 }
75
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;
81   matches.Clear();
82   CommandCompletions::InvokeCommonCompletionCallbacks(
83       interpreter, CommandCompletions::eArchitectureCompletion, s,
84       match_start_point, max_return_elements, nullptr, word_complete, matches);
85   return matches.GetSize();
86 }