1*80814287SRaphael Isemann //===-- OptionValueArch.cpp -----------------------------------------------===//
267cc0636SGreg Clayton //
32946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
42946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
52946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
667cc0636SGreg Clayton //
767cc0636SGreg Clayton //===----------------------------------------------------------------------===//
867cc0636SGreg Clayton
967cc0636SGreg Clayton #include "lldb/Interpreter/OptionValueArch.h"
1067cc0636SGreg Clayton
115548cb50SEnrico Granata #include "lldb/DataFormatters/FormatManager.h"
1267cc0636SGreg Clayton #include "lldb/Interpreter/CommandCompletions.h"
13e1cfbc79STodd Fiala #include "lldb/Interpreter/CommandInterpreter.h"
14145d95c9SPavel Labath #include "lldb/Utility/Args.h"
15d821c997SPavel Labath #include "lldb/Utility/State.h"
1667cc0636SGreg Clayton
1767cc0636SGreg Clayton using namespace lldb;
1867cc0636SGreg Clayton using namespace lldb_private;
1967cc0636SGreg Clayton
DumpValue(const ExecutionContext * exe_ctx,Stream & strm,uint32_t dump_mask)20b9c1b51eSKate Stone void OptionValueArch::DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
21b9c1b51eSKate Stone uint32_t dump_mask) {
2267cc0636SGreg Clayton if (dump_mask & eDumpOptionType)
2367cc0636SGreg Clayton strm.Printf("(%s)", GetTypeAsCString());
24b9c1b51eSKate Stone if (dump_mask & eDumpOptionValue) {
2567cc0636SGreg Clayton if (dump_mask & eDumpOptionType)
2667cc0636SGreg Clayton strm.PutCString(" = ");
2767cc0636SGreg Clayton
28b9c1b51eSKate Stone if (m_current_value.IsValid()) {
2967cc0636SGreg Clayton const char *arch_name = m_current_value.GetArchitectureName();
3067cc0636SGreg Clayton if (arch_name)
3167cc0636SGreg Clayton strm.PutCString(arch_name);
3267cc0636SGreg Clayton }
3367cc0636SGreg Clayton }
3467cc0636SGreg Clayton }
3567cc0636SGreg Clayton
SetValueFromString(llvm::StringRef value,VarSetOperationType op)3697206d57SZachary Turner Status OptionValueArch::SetValueFromString(llvm::StringRef value,
37b9c1b51eSKate Stone VarSetOperationType op) {
3897206d57SZachary Turner Status error;
39b9c1b51eSKate Stone switch (op) {
4067cc0636SGreg Clayton case eVarSetOperationClear:
4167cc0636SGreg Clayton Clear();
42332e8b1cSGreg Clayton NotifyValueChanged();
4367cc0636SGreg Clayton break;
4467cc0636SGreg Clayton
4567cc0636SGreg Clayton case eVarSetOperationReplace:
46b9c1b51eSKate Stone case eVarSetOperationAssign: {
47c95f7e2aSPavel Labath std::string value_str = value.trim().str();
48b9c1b51eSKate Stone if (m_current_value.SetTriple(value_str.c_str())) {
4967cc0636SGreg Clayton m_value_was_set = true;
50332e8b1cSGreg Clayton NotifyValueChanged();
51b9c1b51eSKate Stone } else
52b9c1b51eSKate Stone error.SetErrorStringWithFormat("unsupported architecture '%s'",
53b9c1b51eSKate Stone value_str.c_str());
5467cc0636SGreg Clayton break;
55c95f7e2aSPavel Labath }
5667cc0636SGreg Clayton case eVarSetOperationInsertBefore:
5767cc0636SGreg Clayton case eVarSetOperationInsertAfter:
5867cc0636SGreg Clayton case eVarSetOperationRemove:
5967cc0636SGreg Clayton case eVarSetOperationAppend:
6067cc0636SGreg Clayton case eVarSetOperationInvalid:
61c95f7e2aSPavel Labath error = OptionValue::SetValueFromString(value, op);
6267cc0636SGreg Clayton break;
6367cc0636SGreg Clayton }
6467cc0636SGreg Clayton return error;
6567cc0636SGreg Clayton }
6667cc0636SGreg Clayton
AutoComplete(CommandInterpreter & interpreter,CompletionRequest & request)67ae34ed2cSRaphael Isemann void OptionValueArch::AutoComplete(CommandInterpreter &interpreter,
68a2e76c0bSRaphael Isemann CompletionRequest &request) {
69b9c1b51eSKate Stone CommandCompletions::InvokeCommonCompletionCallbacks(
70a2e76c0bSRaphael Isemann interpreter, CommandCompletions::eArchitectureCompletion, request,
71a2e76c0bSRaphael Isemann nullptr);
7267cc0636SGreg Clayton }
73