180814287SRaphael Isemann //===-- OptionGroupArchitecture.cpp ---------------------------------------===//
27260f620SGreg 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
67260f620SGreg Clayton //
77260f620SGreg Clayton //===----------------------------------------------------------------------===//
87260f620SGreg Clayton
94bee32e5SJohnny Chen #include "lldb/Interpreter/OptionGroupArchitecture.h"
103eb2b44dSZachary Turner #include "lldb/Host/OptionParser.h"
117263f1bdSPavel Labath #include "lldb/Target/Platform.h"
127260f620SGreg Clayton
137260f620SGreg Clayton using namespace lldb;
147260f620SGreg Clayton using namespace lldb_private;
157260f620SGreg Clayton
168fe53c49STatyana Krasnukha static constexpr OptionDefinition g_option_table[] = {
17b9c1b51eSKate Stone {LLDB_OPT_SET_1, false, "arch", 'a', OptionParser::eRequiredArgument,
188fe53c49STatyana Krasnukha nullptr, {}, 0, eArgTypeArchitecture,
19b9c1b51eSKate Stone "Specify the architecture for the target."},
207260f620SGreg Clayton };
2184c39663SGreg Clayton
GetDefinitions()221f0f5b5bSZachary Turner llvm::ArrayRef<OptionDefinition> OptionGroupArchitecture::GetDefinitions() {
2370602439SZachary Turner return llvm::makeArrayRef(g_option_table);
247260f620SGreg Clayton }
257260f620SGreg Clayton
GetArchitecture(Platform * platform,ArchSpec & arch)26b9c1b51eSKate Stone bool OptionGroupArchitecture::GetArchitecture(Platform *platform,
27b9c1b51eSKate Stone ArchSpec &arch) {
287263f1bdSPavel Labath arch = Platform::GetAugmentedArchSpec(platform, m_arch_str);
297260f620SGreg Clayton return arch.IsValid();
307260f620SGreg Clayton }
317260f620SGreg Clayton
3297206d57SZachary Turner Status
SetOptionValue(uint32_t option_idx,llvm::StringRef option_arg,ExecutionContext * execution_context)3397206d57SZachary Turner OptionGroupArchitecture::SetOptionValue(uint32_t option_idx,
3497206d57SZachary Turner llvm::StringRef option_arg,
35b9c1b51eSKate Stone ExecutionContext *execution_context) {
3697206d57SZachary Turner Status error;
373bcdfc0eSGreg Clayton const int short_option = g_option_table[option_idx].short_option;
387260f620SGreg Clayton
39b9c1b51eSKate Stone switch (short_option) {
407260f620SGreg Clayton case 'a':
41*adcd0268SBenjamin Kramer m_arch_str.assign(std::string(option_arg));
427260f620SGreg Clayton break;
437260f620SGreg Clayton
447260f620SGreg Clayton default:
4536162014SRaphael Isemann llvm_unreachable("Unimplemented option");
467260f620SGreg Clayton }
477260f620SGreg Clayton
487260f620SGreg Clayton return error;
497260f620SGreg Clayton }
507260f620SGreg Clayton
OptionParsingStarting(ExecutionContext * execution_context)51b9c1b51eSKate Stone void OptionGroupArchitecture::OptionParsingStarting(
52b9c1b51eSKate Stone ExecutionContext *execution_context) {
537260f620SGreg Clayton m_arch_str.clear();
547260f620SGreg Clayton }
55