1//===-- OptionValueArch.cpp -----------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "lldb/Interpreter/OptionValueArch.h"
10
11#include "lldb/DataFormatters/FormatManager.h"
12#include "lldb/Interpreter/CommandCompletions.h"
13#include "lldb/Interpreter/CommandInterpreter.h"
14#include "lldb/Utility/Args.h"
15#include "lldb/Utility/State.h"
16
17using namespace lldb;
18using namespace lldb_private;
19
20void OptionValueArch::DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
21 uint32_t dump_mask) {
22 if (dump_mask & eDumpOptionType)
23 strm.Printf(format: "(%s)", GetTypeAsCString());
24 if (dump_mask & eDumpOptionValue) {
25 if (dump_mask & eDumpOptionType)
26 strm.PutCString(cstr: " = ");
27
28 if (m_current_value.IsValid()) {
29 const char *arch_name = m_current_value.GetArchitectureName();
30 if (arch_name)
31 strm.PutCString(cstr: arch_name);
32 }
33 }
34}
35
36llvm::json::Value
37OptionValueArch::ToJSON(const ExecutionContext *exe_ctx) const {
38 if (m_current_value.IsValid())
39 return llvm::json::Value(m_current_value.GetArchitectureName());
40
41 return {};
42}
43
44Status OptionValueArch::SetValueFromString(llvm::StringRef value,
45 VarSetOperationType op) {
46 Status error;
47 switch (op) {
48 case eVarSetOperationClear:
49 Clear();
50 NotifyValueChanged();
51 break;
52
53 case eVarSetOperationReplace:
54 case eVarSetOperationAssign: {
55 std::string value_str = value.trim().str();
56 if (m_current_value.SetTriple(value_str.c_str())) {
57 m_value_was_set = true;
58 NotifyValueChanged();
59 } else
60 error = Status::FromErrorStringWithFormat(format: "unsupported architecture '%s'",
61 value_str.c_str());
62 break;
63 }
64 case eVarSetOperationInsertBefore:
65 case eVarSetOperationInsertAfter:
66 case eVarSetOperationRemove:
67 case eVarSetOperationAppend:
68 case eVarSetOperationInvalid:
69 error = OptionValue::SetValueFromString(value, op);
70 break;
71 }
72 return error;
73}
74
75void OptionValueArch::AutoComplete(CommandInterpreter &interpreter,
76 CompletionRequest &request) {
77 lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
78 interpreter, completion_mask: lldb::eArchitectureCompletion, request, searcher: nullptr);
79}
80

Provided by KDAB

Privacy Policy
Improve your Profiling and Debugging skills
Find out more

source code of lldb/source/Interpreter/OptionValueArch.cpp